Changeset 383 for trunk/DNSDB.pm


Ignore:
Timestamp:
08/13/12 17:26:35 (12 years ago)
Author:
Kris Deugau
Message:

/trunk

Checkpoint adding location support to UI. See #10.

  • Add location entries to new domain, record list, and record add/edit templates
  • Add UI sub to fill location dropdown on new domain and record add/edit templates
  • Fix thinko in initial setting of location_view permission
  • Handle display properly if user does not have location_view permission
  • Add DB-interfacing subs in DNSDB.pm to get the default location set on a zone, and to return a list of locations suitable for a UI dropdown
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/DNSDB.pm

    r382 r383  
    4242        &loadConfig &connectDB &finish
    4343        &addDomain &delZone &domainName &revName &domainID &revID &addRDNS
    44         &getZoneCount &getZoneList
     44        &getZoneCount &getZoneList &getZoneLocation
    4545        &addGroup &delGroup &getChildren &groupName
    4646        &getGroupCount &getGroupList
     
    6969                &loadConfig &connectDB &finish
    7070                &addDomain &delZone &domainName &revName &domainID &revID &addRDNS
    71                 &getZoneCount &getZoneList
     71                &getZoneCount &getZoneList &getZoneLocation
    7272                &addGroup &delGroup &getChildren &groupName
    7373                &getGroupCount &getGroupList
     
    21822182
    21832183
     2184## DNSDB::getZoneLocation()
     2185# Retrieve the default locatino for a zone.
     2186# Takes a database handle, forward/reverse flag, and zone ID
     2187sub getZoneLocation {
     2188  my $dbh = shift;
     2189  my $revrec = shift;
     2190  my $zoneid = shift;
     2191
     2192  my ($loc) = $dbh->selectrow_array("SELECT default_location FROM ".
     2193        ($revrec eq 'n' ? 'domains WHERE domain_id = ?' : 'revzones WHERE rdns_id = ?'),
     2194        undef, ($zoneid));
     2195  return $loc;
     2196} # end getZoneLocation()
     2197
     2198
    21842199## DNSDB::addGroup()
    21852200# Add a group
     
    31013116
    31023117## DNSDB::getLocDropdown()
     3118# Get a list of location names for use in a dropdown menu.
     3119# Takes a database handle, current group, and optional "tag this as selected" flag.
     3120# Returns a reference to a list of hashrefs suitable to feeding to HTML::Template
     3121sub getLocDropdown {
     3122  my $dbh = shift;
     3123  my $grp = shift;
     3124  my $sel = shift || '';
     3125
     3126  my $sth = $dbh->prepare(qq(
     3127        SELECT description,location FROM locations
     3128        WHERE group_id=?
     3129        ORDER BY description
     3130        ) );
     3131  $sth->execute($grp);
     3132
     3133  my @loclist;
     3134  push @loclist, { locname => "(None/public)", loc => '', selected => ($sel ? 0 : ($sel eq '' ? 1 : 0)) };
     3135  while (my ($locname, $loc) = $sth->fetchrow_array) {
     3136    my %row = (
     3137        locname => $locname,
     3138        loc => $loc,
     3139        selected => ($sel eq $loc ? 1 : 0)
     3140        );
     3141    push @loclist, \%row;
     3142  }
     3143  return \@loclist;
     3144} # end getLocDropdown()
    31033145
    31043146
Note: See TracChangeset for help on using the changeset viewer.