Changeset 476


Ignore:
Timestamp:
03/13/13 13:20:50 (11 years ago)
Author:
Kris Deugau
Message:

/trunk

Object conversion of DNSDB.pm, 10 of <mumble>. See #11.

  • group manipulation and data-retrieval subs changeGroup(), addGroup(), delGroup(), getChildren(), getGroupCount(), and getGroupList()
Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/DNSDB.pm

    r475 r476  
    17461746# Takes a database handle, entity type, entity ID, and new group ID
    17471747sub changeGroup {
    1748   my $dbh = shift;
     1748  my $self = shift;
     1749  my $dbh = $self->{dbh};
    17491750  my $type = shift;
    17501751  my $id = shift;
     
    23282329sub addGroup {
    23292330  $errstr = '';
    2330   my $dbh = shift;
     2331  my $self = shift;
     2332  my $dbh = $self->{dbh};
    23312333  my $groupname = shift;
    23322334  my $pargroup = shift;
     
    24282430# Returns a status code and message
    24292431sub delGroup {
    2430   my $dbh = shift;
     2432  my $self = shift;
     2433  my $dbh = $self->{dbh};
    24312434  my $groupid = shift;
    24322435
     
    24942497sub getChildren {
    24952498  $errstr = '';
    2496   my $dbh = shift;
     2499  my $self = shift;
     2500  my $dbh = $self->{dbh};
    24972501  my $rootgroup = shift;
    24982502  my $groupdest = shift;
     
    25152519    while (my ($group) = $sth->fetchrow_array) {
    25162520      push @$groupdest, $group;
    2517       getChildren($dbh,$group,$groupdest) if $immed eq 'all';
     2521      $self->getChildren($group, $groupdest) if $immed eq 'all';
    25182522    }
    25192523  }
     
    25462550# Returns an integer count of the resulting group list.
    25472551sub getGroupCount {
    2548   my $dbh = shift;
     2552  my $self = shift;
     2553  my $dbh = $self->{dbh};
    25492554
    25502555  my %args = @_;
     
    25712576# Returns an arrayref containing hashrefs suitable for feeding straight to HTML::Template
    25722577sub getGroupList {
    2573   my $dbh = shift;
     2578  my $self = shift;
     2579  my $dbh = $self->{dbh};
    25742580
    25752581  my %args = @_;
  • trunk/dns-rpc.cgi

    r468 r476  
    200200        };
    201201## optional $inhert arg?
    202   my ($code,$msg) = DNSDB::addGroup($dbh, $args{groupname}, $args{parent_id}, $perms);
     202  my ($code,$msg) = $dnsdb->addGroup($args{groupname}, $args{parent_id}, $perms);
    203203  die $msg if $code eq 'FAIL';
    204204  return $msg;
     
    214214  # Let's be nice;  delete based on groupid OR group name.  Saves an RPC call round-trip, maybe.
    215215  if ($args{group} =~ /^\d+$/) {
    216     ($code,$msg) = DNSDB::delGroup($dbh, $args{group});
     216    ($code,$msg) = $dnsdb->delGroup($args{group});
    217217  } else {
    218218    my $grpid = DNSDB::groupID($dbh, $args{group});
    219219    die "Can't find group\n" if !$grpid;
    220     ($code,$msg) = DNSDB::delGroup($dbh, $grpid);
     220    ($code,$msg) = $dnsdb->delGroup($grpid);
    221221  }
    222222  die $msg if $code eq 'FAIL';
  • trunk/dns.cgi

    r474 r476  
    874874    # https://secure.deepnet.cx/trac/dnsadmin/ticket/8 for the UI enhancement
    875875    # that will make this variable.
    876     my ($code,$msg) = addGroup($dbh, $webvar{newgroup}, $webvar{pargroup}, \%newperms, 1);
     876    my ($code,$msg) = $dnsdb->addGroup($webvar{newgroup}, $webvar{pargroup}, \%newperms, 1);
    877877    if ($code eq 'OK') {
    878878      if ($alterperms) {
     
    917917
    918918  } elsif ($webvar{del} eq 'ok') {
    919     my ($code,$msg) = delGroup($dbh, $webvar{id});
     919    my ($code,$msg) = $dnsdb->delGroup($webvar{id});
    920920    if ($code eq 'OK') {
    921921##fixme: need to clean up log when deleting a major container
     
    10601060    # Do the $webvar{bulkaction}
    10611061    my ($code, $msg);
    1062     ($code, $msg) = changeGroup($dbh, 'domain', $webvar{$_}, $webvar{destgroup})
     1062    ($code, $msg) = $dnsdb->changeGroup('domain', $webvar{$_}, $webvar{destgroup})
    10631063        if $webvar{bulkaction} eq 'move';
    10641064    if ($webvar{bulkaction} eq 'deactivate' || $webvar{bulkaction} eq 'activate') {
     
    17661766
    17671767  my $grptree = HTML::Template->new(filename => 'templates/grptree.tmpl');
    1768   getChildren($dbh,$root,\@childlist,'immediate');
     1768  $dnsdb->getChildren($root, \@childlist, 'immediate');
    17691769  return if $#childlist == -1;
    17701770  my @grouplist;
     
    20322032
    20332033  my @childgroups;
    2034   getChildren($dbh, $curgroup, \@childgroups, 'all') if $searchsubs;
     2034  $dnsdb->getChildren($curgroup, \@childgroups, 'all') if $searchsubs;
    20352035  my $childlist = join(',',@childgroups);
    20362036
     
    20902090
    20912091  my @childgroups;
    2092   getChildren($dbh, $curgroup, \@childgroups, 'all') if $searchsubs;
     2092  $dnsdb->getChildren($curgroup, \@childgroups, 'all') if $searchsubs;
    20932093  my $childlist = join(',',@childgroups);
    20942094
    2095   my ($count) = getGroupCount($dbh, (childlist => $childlist, curgroup => $curgroup,
    2096         filter => ($filter ? $filter : undef), startwith => ($startwith ? $startwith : undef) ) );
     2095  my ($count) = $dnsdb->getGroupCount(childlist => $childlist, curgroup => $curgroup,
     2096        filter => ($filter ? $filter : undef), startwith => ($startwith ? $startwith : undef) );
    20972097
    20982098# fill page count and first-previous-next-last-all bits
     
    21252125  $sortby = 'g2.group_name' if $sortby eq 'parent';
    21262126
    2127   my $glist = getGroupList($dbh, (childlist => $childlist, curgroup => $curgroup,
     2127  my $glist = $dnsdb->getGroupList(childlist => $childlist, curgroup => $curgroup,
    21282128        filter => ($filter ? $filter : undef), startwith => ($startwith ? $startwith : undef),
    2129         offset => $webvar{offset}, sortby => $sortby, sortorder => $sortorder) );
     2129        offset => $webvar{offset}, sortby => $sortby, sortorder => $sortorder);
    21302130
    21312131  $page->param(grouptable => $glist);
     
    21452145
    21462146    my @childlist;
    2147     getChildren($dbh,$root,\@childlist,'immediate');
     2147    $dnsdb->getChildren($root, \@childlist, 'immediate');
    21482148    return if $#childlist == -1;
    21492149    foreach (@childlist) {
     
    21882188
    21892189  my @childgroups;
    2190   getChildren($dbh, $curgroup, \@childgroups, 'all') if $searchsubs;
     2190  $dnsdb->getChildren($curgroup, \@childgroups, 'all') if $searchsubs;
    21912191  my $childlist = join(',',@childgroups);
    21922192
     
    22352235
    22362236  my @childgroups;
    2237   getChildren($dbh, $curgroup, \@childgroups, 'all') if $searchsubs;
     2237  $dnsdb->getChildren($curgroup, \@childgroups, 'all') if $searchsubs;
    22382238  my $childlist = join(',',@childgroups);
    22392239
Note: See TracChangeset for help on using the changeset viewer.