Changeset 24 for trunk/dns.cgi
- Timestamp:
- 10/30/09 17:52:55 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dns.cgi
r23 r24 198 198 changepage(page => "reclist", id => $webvar{parentid}, defrec => $webvar{defrec}); 199 199 } else { 200 $page->param(failed => 1); 201 $page->param(errmsg => $msg); 200 201 $page->param(failed => 1); 202 $page->param(errmsg => $msg); 203 $page->param(wastrying => "adding"); 204 $page->param(todo => "Add record to"); 205 $page->param(recact => "add"); 206 $page->param(parentid => $webvar{parentid}); 207 $page->param(defrec => $webvar{defrec}); 208 $page->param(id => $webvar{id}); 202 209 fill_recdata(); # populate the form... er, mostly. 203 210 } … … 246 253 $page->param(dohere => "default records in group ".groupName($dbh,$webvar{parentid})); 247 254 } else { 255 $page->param(parentid => $webvar{parentid}); 256 # $page->param(id => $webvar{id}); 248 257 $page->param(dohere => domainName($dbh,$webvar{parentid})); 249 258 } … … 353 362 # redirect to dns.cgi?etc&page=reclist 354 363 changepage(page => "reclist", id => $msg); 355 $page = HTML::Template->new(filename => "$templatedir/reclist.tmpl"); 356 showdomain(0,$msg); 357 ##work 364 # $page = HTML::Template->new(filename => "$templatedir/reclist.tmpl"); 365 # showdomain(0,$msg); 358 366 } else { 359 367 # oooh, yeah, this is supposed to be a redirect. er, maybe. whee. 368 ##fixme: session ID 360 369 $page = HTML::Template->new(filename => "$templatedir/newdomain.tmpl"); 361 370 $page->param(add_failed => 1); … … 416 425 } 417 426 $page->param(delgroupname => groupName($dbh, $webvar{id})); 427 428 } elsif ($webvar{page} eq 'useradmin') { 429 430 list_users(); 431 $page->param(curpage => $webvar{page}); 432 433 } elsif ($webvar{page} eq 'newuser') { 434 435 # foo? 436 fill_actypelist(); 437 438 } elsif ($webvar{page} eq 'adduser') { 439 440 my ($code,$msg); 441 442 if ($webvar{pass1} ne $webvar{pass2}) { 443 $code = 'FAIL'; 444 $msg = "Passwords don't match"; 445 } else { 446 ($code,$msg) = addUser($dbh,$webvar{username}, $webvar{group}, $webvar{pass1}, 447 ($webvar{makeactive} eq 'on' ? 1 : 0), $webvar{fname}, $webvar{lname}); 448 } 449 450 # hokay, a bit of magic to decide which page we hit. 451 if ($code eq 'OK') { 452 # redirect to dns.cgi?etc&page=reclist 453 changepage(page => "useradmin"); 454 # $page = HTML::Template->new(filename => "$templatedir/reclist.tmpl"); 455 # showdomain(0,$msg); 456 ##work 457 } else { 458 # oooh, yeah, this is supposed to be a redirect. er, maybe. whee. 459 # $page = HTML::Template->new(filename => "$templatedir/newuser.tmpl"); 460 $page->param(add_failed => 1); 461 $page->param(username => $webvar{username}); 462 $page->param(fname => $webvar{fname}); 463 $page->param(lname => $webvar{lname}); 464 $page->param(pass1 => $webvar{pass1}); 465 $page->param(pass2 => $webvar{pass2}); 466 $page->param(errmsg => $msg); 467 fill_actypelist(); 468 } 469 470 $page->param(add_failed => 1); 418 471 } 419 472 … … 421 474 # start output here so we can redirect pages. 422 475 print "Content-type: text/html\n\n", $header->output; 423 424 foreach (@debugbits) { print; }425 476 426 477 ##common bits … … 429 480 $page->param(groupname => groupName($dbh,$curgroup)); 430 481 482 # group tree. should go elsewhere, probably 483 my $tmpgrplist = fill_grptree($logingroup,$curgroup); 484 $page->param(grptree => $tmpgrplist); 485 431 486 # stuff for menu group change. nb: this is icky. 432 487 fill_grouplist("grouplist"); 433 488 $page->param(whereami => $ENV{REQUEST_URI}); 434 489 } 490 491 foreach (@debugbits) { print; } 435 492 436 493 # spit it out … … 458 515 459 516 exit 0; 517 518 519 sub fill_grptree { 520 my $root = shift; 521 my $cur = shift; 522 523 my @childlist; 524 525 my $grptree = HTML::Template->new(filename => 'templates/grptree.tmpl'); 526 getChildren($dbh,$root,\@childlist,'immediate'); 527 return if $#childlist == -1; 528 my @grouplist; 529 foreach (@childlist) { 530 my %row; 531 $row{grpname} = groupName($dbh,$_); 532 $row{grpname} = "<b>$row{grpname}</b>" if $_ == $cur; 533 $row{subs} = fill_grptree($_,$cur); 534 push @grouplist, \%row; 535 } 536 $grptree->param(treelvl => \@grouplist); 537 return $grptree->output; 538 } 460 539 461 540 … … 575 654 $page->param(ttl => ($webvar{ttl} ? $webvar{ttl} : $DNSDB::def{minttl})); 576 655 } 656 657 658 sub fill_actypelist { 659 my @actypes; 660 661 my %row1 = (actypeval => 'u', actypename => 'user'); 662 $row1{typesel} = 1 if $webvar{accttype} eq 'u'; 663 push @actypes, \%row1; 664 665 my %row2 = (actypeval => 'S', actypename => 'superuser'); 666 $row2{typesel} = 1 if $webvar{accttype} eq 'S'; 667 push @actypes, \%row2; 668 669 $page->param(actypelist => \@actypes); 670 } 671 577 672 578 673 sub fill_fpnla { … … 713 808 $page->param("$template_var" => \@grouplist); 714 809 715 } 810 } # end fill_grouplist() 811 812 sub list_users { 813 my $sth = $dbh->prepare("select count(*) from users where group_id=?"); 814 $sth->execute($curgroup); 815 my ($count) = ($sth->fetchrow_array); 816 817 # fill page count and first-previous-next-last-all bits 818 ##fixme - hardcoded group bit 819 fill_pgcount($count,"users",''); 820 fill_fpnla($count); 821 822 my @userlist; 823 $sth = $dbh->prepare("SELECT u.user_id, u.email, u.firstname, u.lastname, u.type, g.group_name, u.status ". 824 "FROM users u ". 825 "INNER JOIN groups g ON u.group_id=g.group_id ". 826 "WHERE u.group_id=?". 827 ($offset eq 'all' ? '' : " LIMIT $perpage OFFSET ".$offset*$perpage)); 828 $sth->execute($curgroup); 829 830 my $rownum = 0; 831 while (my @data = $sth->fetchrow_array) { 832 my %row; 833 $row{userid} = $data[0]; 834 $row{username} = $data[1]; 835 $row{userfull} = "$data[2] $data[3]"; 836 $row{usertype} = ($data[4] eq 'S' ? 'superuser' : "user"); 837 $row{usergroup} = $data[5]; 838 $row{mkactive} = $data[6]; 839 $row{bg} = ($rownum++)%2; 840 $row{sid} = $sid; 841 push @userlist, \%row; 842 } 843 $page->param(usertable => \@userlist); 844 }
Note:
See TracChangeset
for help on using the changeset viewer.