Changeset 326 for trunk


Ignore:
Timestamp:
05/02/12 17:41:48 (13 years ago)
Author:
Kris Deugau
Message:

/trunk

Move SQL for clone-this-user dropdown into DNSDB.pm. See #1

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/DNSDB.pm

    r325 r326  
    4444        &getGroupCount &getGroupList
    4545        &addUser &updateUser &delUser &userFullName &userStatus &getUserData
    46         &getUserCount &getUserList
     46        &getUserCount &getUserList &getUserDropdown
    4747        &getSOA &updateSOA &getRecLine &getDomRecs &getRecCount
    4848        &addRec &updateRec &delRec
     
    6969                &getGroupCount &getGroupList
    7070                &addUser &updateUser &delUser &userFullName &userStatus &getUserData
    71                 &getUserCount &getUserList
     71                &getUserCount &getUserList &getUserDropdown
    7272                &getSOA &updateSOA &getRecLine &getDomRecs &getRecCount
    7373                &addRec &updateRec &delRec
     
    24272427  return $ulist;
    24282428} # end getUserList()
     2429
     2430
     2431## DNSDB::getUserDropdown()
     2432# Get a list of usernames for use in a dropdown menu.
     2433# Takes a database handle, current group, and optional "tag this as selected" flag.
     2434# Returns a reference to a list of hashrefs suitable to feeding to HTML::Template
     2435sub getUserDropdown {
     2436  my $dbh = shift;
     2437  my $grp = shift;
     2438  my $sel = shift || 0;
     2439
     2440  my $sth = $dbh->prepare("SELECT username,user_id FROM users WHERE group_id=?");
     2441  $sth->execute($grp);
     2442
     2443  my @userlist;
     2444  while (my ($username,$uid) = $sth->fetchrow_array) {
     2445    my %row = (
     2446        username => $username,
     2447        uid => $uid,
     2448        selected => ($sel == $uid ? 1 : 0)
     2449        );
     2450    push @userlist, \%row;
     2451  }
     2452  return \@userlist;
     2453} # end getUserDropdown()
    24292454
    24302455
  • trunk/dns.cgi

    r325 r326  
    18281828
    18291829sub fill_clonemelist {
    1830   my $sth = $dbh->prepare("SELECT username,user_id FROM users WHERE group_id=$curgroup");
    1831   $sth->execute;
    1832 
    18331830  # shut up some warnings, but don't stomp on caller's state
    18341831  local $webvar{clonesrc} = 0 if !defined($webvar{clonesrc});
    18351832
    1836   my @clonesrc;
    1837   while (my ($username,$uid) = $sth->fetchrow_array) {
    1838     my %row = (
    1839         username => $username,
    1840         uid => $uid,
    1841         selected => ($webvar{clonesrc} == $uid ? 1 : 0)
    1842         );
    1843     push @clonesrc, \%row;
    1844   }
    1845   $page->param(clonesrc => \@clonesrc);
     1833  my $clones = getUserDropdown($dbh, $curgroup, $webvar{clonesrc});
     1834  $page->param(clonesrc => $clones);
    18461835}
    18471836
Note: See TracChangeset for help on using the changeset viewer.