Changeset 19 for trunk


Ignore:
Timestamp:
10/09/09 17:49:14 (15 years ago)
Author:
Kris Deugau
Message:

/trunk

checkpoint

Location:
trunk
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/DNSDB.pm

    r18 r19  
    2323@ISA            = qw(Exporter);
    2424@EXPORT_OK      = qw(
    25         &initGlobals &connectDB &finish &addDomain &delDomain &domainName &addGroup &grpName &getSOA
     25        &initGlobals &connectDB &finish &addDomain &delDomain &domainName &addGroup &getChildren &grpName &getSOA
    2626        &getRecLine &getDomRecs &addRec &updateRec &delRec &domStatus
    2727        %typemap %reverse_typemap
     
    3030@EXPORT         = (); # Export nothing by default.
    3131%EXPORT_TAGS    = ( ALL => [qw(
    32                 &initGlobals &connectDB &finish &addDomain &delDomain &domainName &addGroup &grpName &getSOA
     32                &initGlobals &connectDB &finish &addDomain &delDomain &domainName &addGroup &getChildren &grpName
     33&getSOA
    3334                &getRecLine &getDomRecs &addRec &updateRec &delRec &domStatus
    3435                %typemap %reverse_typemap
     
    318319
    319320
     321## DNSDB::getChildren()
     322# Get a list of all groups whose parent^n is group <n>
     323# Takes a database handle, group ID, and reference to an array to put the group IDs in
     324# Calls itself
     325sub getChildren {
     326  $errstr = '';
     327  my $dbh = shift;
     328  my $rootgrp = shift;
     329  my $grpdest = shift;
     330
     331  # special break for default group;  otherwise we get stuck.
     332  if ($rootgrp == 1) {
     333    # by definition, group 1 is the Root Of All Groups
     334    my $sth = $dbh->prepare("SELECT group_id FROM groups");
     335    $sth->execute;
     336    my @grplist;
     337    while (my @this = $sth->fetchrow_array) {
     338      push @$grpdest, @this;
     339    }
     340  } else {
     341    my $sth = $dbh->prepare("SELECT group_id FROM groups WHERE parent_group_id=?");
     342    $sth->execute($rootgrp);
     343    return if $sth->rows == 0;
     344    my @grplist;
     345    while (my ($grp) = $sth->fetchrow_array) {
     346      push @$grpdest, $grp;
     347      getChildren($dbh,$grp,$grpdest);
     348    }
     349  }
     350} # end getChildren()
     351
     352
    320353## DNSDB::grpName()
    321354# Return the group name based on a group ID
  • trunk/dns.cgi

    r18 r19  
    4949}
    5050
    51 my $logingroup = $session->param('logingroup');
    52 my $curgroup = ($session->param('curgroup') ? $session->param('curgroup') : $session->param('logingroup'));
     51my $logingroup = ($session->param('logingroup') ? $session->param('logingroup') : 1);
     52my $curgroup = ($session->param('curgroup') ? $session->param('curgroup') : $logingroup);
    5353my $group = ($webvar{group} ? $webvar{group} : 1);
    5454
     
    403403    $page->param(errmsg => $msg);
    404404    $page->param(newgroup => $webvar{newgroup});
     405     fill_grplist('pargroup',$webvar{pargroup});
     406  } else {
     407#    $page->param
     408     fill_grplist('pargroup',$curgroup);
     409
    405410  }
    406411}
     
    416421  $page->param(grp => $group);
    417422  $page->param(grpname => grpName($dbh,$group));
    418   fill_grplist();
     423  fill_grplist("grplist");
    419424}
    420425
     
    634639
    635640sub fill_grplist {
     641  my $template_var = shift;
     642  my $cur = shift || $curgroup;
    636643  # weesa gonna discard parent_group_id for now
    637644  my $sth = $dbh->prepare("SELECT group_id,parent_group_id,group_name FROM groups ORDER BY group_id");
    638 push @debugbits, "grp list sth err: ".$sth->errstr."<br>\n";
    639645  $sth->execute;
    640646  my @grplist;
     
    645651##fixme: need magic
    646652#    $row{defgrp} = '';
    647     $row{grpactive} = 1 if $grpid eq $curgroup;
     653    $row{grpactive} = 1 if $grpid == $cur;
    648654    push @grplist, \%row;
    649655  }
    650656
    651   $page->param(grplist => \@grplist);
    652 
    653 }
     657  $page->param("$template_var" => \@grplist);
     658
     659}
Note: See TracChangeset for help on using the changeset viewer.