- Timestamp:
- 10/09/09 17:49:14 (15 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/DNSDB.pm
r18 r19 23 23 @ISA = qw(Exporter); 24 24 @EXPORT_OK = qw( 25 &initGlobals &connectDB &finish &addDomain &delDomain &domainName &addGroup &g rpName &getSOA25 &initGlobals &connectDB &finish &addDomain &delDomain &domainName &addGroup &getChildren &grpName &getSOA 26 26 &getRecLine &getDomRecs &addRec &updateRec &delRec &domStatus 27 27 %typemap %reverse_typemap … … 30 30 @EXPORT = (); # Export nothing by default. 31 31 %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 33 34 &getRecLine &getDomRecs &addRec &updateRec &delRec &domStatus 34 35 %typemap %reverse_typemap … … 318 319 319 320 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 325 sub 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 320 353 ## DNSDB::grpName() 321 354 # Return the group name based on a group ID -
trunk/dns.cgi
r18 r19 49 49 } 50 50 51 my $logingroup = $session->param('logingroup');52 my $curgroup = ($session->param('curgroup') ? $session->param('curgroup') : $ session->param('logingroup'));51 my $logingroup = ($session->param('logingroup') ? $session->param('logingroup') : 1); 52 my $curgroup = ($session->param('curgroup') ? $session->param('curgroup') : $logingroup); 53 53 my $group = ($webvar{group} ? $webvar{group} : 1); 54 54 … … 403 403 $page->param(errmsg => $msg); 404 404 $page->param(newgroup => $webvar{newgroup}); 405 fill_grplist('pargroup',$webvar{pargroup}); 406 } else { 407 # $page->param 408 fill_grplist('pargroup',$curgroup); 409 405 410 } 406 411 } … … 416 421 $page->param(grp => $group); 417 422 $page->param(grpname => grpName($dbh,$group)); 418 fill_grplist( );423 fill_grplist("grplist"); 419 424 } 420 425 … … 634 639 635 640 sub fill_grplist { 641 my $template_var = shift; 642 my $cur = shift || $curgroup; 636 643 # weesa gonna discard parent_group_id for now 637 644 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";639 645 $sth->execute; 640 646 my @grplist; … … 645 651 ##fixme: need magic 646 652 # $row{defgrp} = ''; 647 $row{grpactive} = 1 if $grpid eq $curgroup;653 $row{grpactive} = 1 if $grpid == $cur; 648 654 push @grplist, \%row; 649 655 } 650 656 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.