Changeset 704 for trunk


Ignore:
Timestamp:
03/04/16 14:10:53 (9 years ago)
Author:
Kris Deugau
Message:

/trunk

Refine a couple of segments of location handling

  • resurrect a missing dropdown on new revzone page
  • update DB structure and code to allow duplicate zone names so long as each is in a different location/view
  • show the location/view in the zone lists
Location:
trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/DNSDB.pm

    r703 r704  
    23162316# Add a domain
    23172317# Takes a database handle, domain name, numeric group, boolean(ish) state (active/inactive),
    2318 # and user info hash (for logging).
     2318# and a default location indicator
    23192319# Returns a status code and message
    23202320sub addDomain {
     
    23412341  return ('FAIL', "Invalid characters in domain") if $domain !~ /^[a-zA-Z0-9_.-]+$/;
    23422342
    2343   my $sth = $dbh->prepare("SELECT domain_id FROM domains WHERE lower(domain) = lower(?)");
     2343  my $sth = $dbh->prepare("SELECT domain_id FROM domains WHERE lower(domain) = lower(?) AND location = ?");
    23442344  my $dom_id;
    23452345
    23462346# quick check to start to see if we've already got one
    2347   $sth->execute($domain);
     2347  $sth->execute($domain, $defloc);
    23482348  ($dom_id) = $sth->fetchrow_array;
    23492349
     
    23622362
    23632363    # get the ID...
    2364     ($dom_id) = $dbh->selectrow_array("SELECT domain_id FROM domains WHERE lower(domain) = lower(?)",
    2365         undef, ($domain));
     2364    ($dom_id) = $dbh->selectrow_array("SELECT domain_id FROM domains WHERE lower(domain) = lower(?) AND location = ?",
     2365        undef, ($domain, $defloc));
    23662366
    23672367    $self->_log(domain_id => $dom_id, group_id => $group,
     
    26022602
    26032603# quick check to start to see if we've already got one
    2604   my ($rdns_id) = $dbh->selectrow_array("SELECT rdns_id FROM revzones WHERE revnet=?", undef, ("$zone"));
     2604  my ($rdns_id) = $dbh->selectrow_array("SELECT rdns_id FROM revzones WHERE revnet = ? AND default_location = ?",
     2605        undef, ("$zone", $defloc));
    26052606
    26062607  return ('FAIL', "Zone already exists") if $rdns_id;
     
    28432844  if ($args{revrec} eq 'n') {
    28442845    $args{sortby} = 'domain' if !$args{sortby} || !grep /^$args{sortby}$/, ('domain','group','status');
    2845     $sql = "SELECT domain_id AS zoneid,domain AS zone,status,groups.group_name AS group FROM domains".
    2846         " INNER JOIN groups ON domains.group_id=groups.group_id".
    2847         " WHERE domains.group_id IN ($args{curgroup}".($args{childlist} ? ",$args{childlist}" : '').")".
     2846    $sql = q(SELECT
     2847                domain_id AS zoneid,
     2848                domain AS zone,
     2849                status,
     2850                groups.group_name AS group,
     2851                l.description AS location
     2852        FROM domains
     2853        LEFT JOIN locations l ON domains.default_location=l.location
     2854        INNER JOIN groups ON domains.group_id=groups.group_id ).
     2855        "WHERE domains.group_id IN ($args{curgroup}".($args{childlist} ? ",$args{childlist}" : '').")".
    28482856        ($args{startwith} ? " AND domain ~* ?" : '').
    28492857        ($args{filter} ? " AND domain ~* ?" : '');
     
    28512859##fixme:  arguably startwith here is irrelevant.  depends on the UI though.
    28522860    $args{sortby} = 'revnet' if !$args{sortby} || !grep /^$args{sortby}$/, ('revnet','group','status');
    2853     $sql = "SELECT rdns_id AS zoneid,revnet AS zone,status,groups.group_name AS group FROM revzones".
    2854         " INNER JOIN groups ON revzones.group_id=groups.group_id".
     2861    $sql = q(SELECT
     2862                rdns_id AS zoneid,
     2863                revnet AS zone,
     2864                status,
     2865                groups.group_name AS group,
     2866                l.description AS location
     2867        FROM revzones
     2868        LEFT JOIN locations l ON revzones.default_location=l.location
     2869        INNER JOIN groups ON revzones.group_id=groups.group_id ).
    28552870        " WHERE revzones.group_id IN ($args{curgroup}".($args{childlist} ? ",$args{childlist}" : '').")".
    28562871        ($args{startwith} ? " AND CAST(revnet AS VARCHAR) ~* ?" : '');
  • trunk/dns.cgi

    r702 r704  
    528528
    529529  fill_grouplist("grouplist");
    530   my $loclist = $dnsdb->getLocDropdown($curgroup);
    531   $page->param(loclist => $loclist);
     530  fill_loclist($curgroup, $webvar{defloc} ? $webvar{defloc} : '');
    532531
    533532  # prepopulate revpatt with the matching default record
  • trunk/templates/domlist.tmpl

    r589 r704  
    4242<TMPL_LOOP name=domtable>
    4343<tr class="row<TMPL_IF __odd__>0<TMPL_ELSE>1</TMPL_IF>">
    44         <td align="left"><a href="<TMPL_VAR NAME=script_self>&amp;page=reclist&amp;id=<TMPL_VAR NAME=zoneid>&amp;defrec=n<TMPL_UNLESS domlist>&amp;revrec=y</TMPL_UNLESS>"><TMPL_VAR NAME=zone></a></td>
     44        <td align="left"><a href="<TMPL_VAR NAME=script_self>&amp;page=reclist&amp;id=<TMPL_VAR NAME=zoneid>&amp;defrec=n<TMPL_UNLESS domlist>&amp;revrec=y</TMPL_UNLESS>"><TMPL_VAR NAME=zone></a><TMPL_IF location> (<TMPL_VAR NAME=location>)</TMPL_IF></td>
    4545        <td><TMPL_IF status>Active<TMPL_ELSE>Inactive</TMPL_IF></td>
    4646        <td><TMPL_VAR name=group></td>
Note: See TracChangeset for help on using the changeset viewer.