Changeset 88


Ignore:
Timestamp:
04/01/11 18:01:14 (14 years ago)
Author:
Kris Deugau
Message:

/trunk

Checkpoint, web UI miscellaneous cleanup

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dns.cgi

    r87 r88  
    211211
    212212  $page->param(id => $webvar{id});
     213
    213214  # first pass = confirm y/n (sorta)
    214215  if (!defined($webvar{del})) {
     216
    215217    $page->param(del_getconf => 1);
    216218    $page->param(domain => domainName($dbh,$webvar{id}));
    217 # print some neato things?
    218 
    219 #  } else {
    220 #    #whether actually deleting or cancelling we redirect to the domain list, default format
    221219
    222220  } elsif ($webvar{del} eq 'ok') {
     221
    223222    my $pargroup = parentID($webvar{id}, 'dom', 'group');
    224223    my $dom = domainName($dbh, $webvar{id});
     
    232231      changepage(page => "domlist");
    233232    }
     233
    234234  } else {
    235235    # cancelled.  whee!
     
    245245  $page->param(curpage => $webvar{page});
    246246
    247 # select count(*) from (default_)?records where (group|domain)_id=?
    248     my $sth = $dbh->prepare("SELECT count(*) FROM ".
     247  my $sth = $dbh->prepare("SELECT count(*) FROM ".
    249248        ($webvar{defrec} eq 'y' ? 'default_' : '')."records ".
    250249        "WHERE ".($webvar{defrec} eq 'y' ? 'group' : 'domain')."_id=? ".
    251250        "AND NOT type=$reverse_typemap{SOA}");
    252     $sth->execute($webvar{id});
    253     my ($count) = ($sth->fetchrow_array);
     251  $sth->execute($webvar{id});
     252  my ($count) = ($sth->fetchrow_array);
    254253
    255254#  $sortby = 'host';
     
    402401  } else {
    403402    $page->param(parentid => $webvar{parentid});
    404 #    $page->param(id => $webvar{id});
    405403    $page->param(dohere => domainName($dbh,$webvar{parentid}));
    406404  }
     
    431429                "Failed deleting record '$rec{host} $typemap{$rec{type}} $rec{val}', TTL $rec{ttl} ($msg)");
    432430      }
    433 changepage(page => "reclist", id => $webvar{parentid}, defrec => $webvar{defrec}, del_failed => 1, errmsg => $msg);
     431      changepage(page => "reclist", id => $webvar{parentid}, defrec => $webvar{defrec},
     432                del_failed => 1, errmsg => $msg);
    434433      $page->param(del_failed => 1);
    435434      $page->param(errmsg => $msg);
     
    493492  # do.. uhh.. stuff.. if we have no webvar{action}
    494493  if ($webvar{action} && $webvar{action} eq 'add') {
    495         # not gonna provide the 4th param: template-or-clone flag, just yet
    496494    my %newperms;
    497495    foreach (@permtypes) {
     
    499497      $newperms{$_} = 1 if $webvar{$_} eq 'on';
    500498    }
     499    # not gonna provide the 4th param: template-or-clone flag, just yet
    501500    my ($code,$msg) = addGroup($dbh, $webvar{newgroup}, $webvar{pargroup}, \%newperms);
    502501    if ($code eq 'OK') {
     
    511510    fill_grouplist('pargroup',$webvar{pargroup});
    512511  } else {
    513 #    $page->param
    514512    fill_grouplist('pargroup',$curgroup);
    515   # fill default permissions with immediate parent's current ones
     513    # fill default permissions with immediate parent's current ones
    516514    my %parperms;
    517515    getPermissions($dbh, 'group', $curgroup, \%parperms);
     
    540538      $page->param(curpage => $webvar{page});
    541539      listgroups();
     540##fixme: log
    542541    } else {
    543542##fixme: need to clean up log when deleting a major container
     
    603602
    604603  $page->param(is_admin => $permissions{admin});
     604
     605  $webvar{action} = '' if !$webvar{action};
    605606
    606607  if ($webvar{action} eq 'add' or $webvar{action} eq 'update') {
     
    676677    if ($code eq 'OK') {
    677678
     679##fixme:  log doesn't log.  WTF?  O_o
    678680      logaction(0, $session->param("username"), $webvar{group},
    679         ($webvar{action} eq 'add' ? 'Added' : 'Updated')." user $webvar{uname} ($webvar{fname} $webvar{lname})");
     681        ($webvar{action} eq 'add' ? 'Added' : 'Updated')." uid $webvar{uid}, user $webvar{uname} ($webvar{fname} $webvar{lname})");
    680682      if ($alterperms) {
    681683        changepage(page => "useradmin", warnmsg =>
     
    707709      fill_actypelist($webvar{accttype});
    708710      fill_clonemelist();
     711##fixme: log
    709712    }
    710713
     
    760763  $page->param(grpperms => $grppermlist->output);
    761764
    762 } elsif ($webvar{page} eq 'adduser') {
    763 
    764   my ($code,$msg);
    765  
    766   if ($webvar{pass1} ne $webvar{pass2}) {
    767     $code = 'FAIL';
    768     $msg = "Passwords don't match";
    769   } else {
    770 # assemble a permission string - far simpler than trying to pass an
    771 # indeterminate set of permission flags individually
    772 my $permstring;
    773 if ($webvar{perms_type} eq 'custom') {
    774   $permstring = 'C:,g:,u:,d:,r:';
    775   $page->param(perm_custom => 1);
    776 } elsif ($webvar{perms_type} eq 'clone') {
    777   $permstring = 'c:';
    778   $page->param(perm_clone => 1);
    779 } else {
    780   $permstring = 'i';
    781 #  $page->param(perm_inherit => 1);
    782 }
    783     ($code,$msg) = addUser($dbh,$webvar{uname}, $webvar{group}, $webvar{pass1},
    784         ($webvar{makeactive} eq 'on' ? 1 : 0), $webvar{accttype},
    785         $webvar{fname}, $webvar{lname}, $webvar{phone});
    786   }
    787 
    788 # hokay, a bit of magic to decide which page we hit.
    789   if ($code eq 'OK') {
    790 ##log
    791     logaction(0, $session->param("username"), $webvar{group},
    792         "Added user $webvar{uname} ($webvar{fname} $webvar{lname})");
    793     changepage(page => "useradmin");
    794   } else {
    795 # oddity - apparently, xhtml 1.0 strict swallows username as an HTML::Template var.  O_o
    796     $page->param(add_failed => 1);
    797     $page->param(uname => $webvar{uname});
    798     $page->param(fname => $webvar{fname});
    799     $page->param(lname => $webvar{lname});
    800     $page->param(pass1 => $webvar{pass1});
    801     $page->param(pass2 => $webvar{pass2});
    802     $page->param(errmsg => $msg);
    803     fill_actypelist($webvar{accttype});
    804     fill_clonemelist();
    805   }
    806 
    807 #  $page->param(add_failed => 1);
    808 
    809 } elsif ($webvar{page} eq 'deluser') {
    810 
    811   $page->param(id => $webvar{id});
    812   # first pass = confirm y/n (sorta)
    813   if (!defined($webvar{del})) {
    814     $page->param(del_getconf => 1);
    815     $page->param(user => userFullName($dbh,$webvar{id}));
    816   } elsif ($webvar{del} eq 'ok') {
    817 ##fixme: find group id user is in (for logging) *before* we delete the user
    818     my ($code,$msg) = delUser($dbh, $webvar{id});
    819     if ($code ne 'OK') {
    820 # need to find failure mode
    821       $page->param(del_failed => 1);
    822       $page->param(errmsg => $msg);
    823       list_users($curgroup);
    824     } else {
    825       # success.  go back to the user list, do not pass "GO"
    826 ##log
    827       logaction(0, $session->param("username"), $webvar{group}, "Added domain $webvar{domain}");
    828       changepage(page => "useradmin");
    829     }
    830   } else {
    831     # cancelled.  whee!
    832     changepage(page => "useradmin");
    833   }
    834 
    835 } elsif ($webvar{page} eq 'edituser') {
     765#} elsif ($webvar{page} eq 'adduser') {
     766#
     767#  my ($code,$msg);
     768# 
     769#  if ($webvar{pass1} ne $webvar{pass2}) {
     770#    $code = 'FAIL';
     771#    $msg = "Passwords don't match";
     772#  } else {
     773## assemble a permission string - far simpler than trying to pass an
     774## indeterminate set of permission flags individually
     775#my $permstring;
     776#if ($webvar{perms_type} eq 'custom') {
     777#  $permstring = 'C:,g:,u:,d:,r:';
     778#  $page->param(perm_custom => 1);
     779#} elsif ($webvar{perms_type} eq 'clone') {
     780#  $permstring = 'c:';
     781#  $page->param(perm_clone => 1);
     782#} else {
     783#  $permstring = 'i';
     784##  $page->param(perm_inherit => 1);
     785#}
     786#    ($code,$msg) = addUser($dbh,$webvar{uname}, $webvar{group}, $webvar{pass1},
     787#       ($webvar{makeactive} eq 'on' ? 1 : 0), $webvar{accttype},
     788#       $webvar{fname}, $webvar{lname}, $webvar{phone});
     789#  }
     790#
     791## hokay, a bit of magic to decide which page we hit.
     792#  if ($code eq 'OK') {
     793###log
     794#    logaction(0, $session->param("username"), $webvar{group},
     795#       "Added user $webvar{uname} ($webvar{fname} $webvar{lname})");
     796#    changepage(page => "useradmin");
     797#  } else {
     798## oddity - apparently, xhtml 1.0 strict swallows username as an HTML::Template var.  O_o
     799#    $page->param(add_failed => 1);
     800#    $page->param(uname => $webvar{uname});
     801#    $page->param(fname => $webvar{fname});
     802#    $page->param(lname => $webvar{lname});
     803#    $page->param(pass1 => $webvar{pass1});
     804#    $page->param(pass2 => $webvar{pass2});
     805#    $page->param(errmsg => $msg);
     806#    fill_actypelist($webvar{accttype});
     807#    fill_clonemelist();
     808#  }
     809#
     810##  $page->param(add_failed => 1);
     811#
     812#} elsif ($webvar{page} eq 'deluser') {
     813#
     814#  $page->param(id => $webvar{id});
     815#  # first pass = confirm y/n (sorta)
     816#  if (!defined($webvar{del})) {
     817#    $page->param(del_getconf => 1);
     818#    $page->param(user => userFullName($dbh,$webvar{id}));
     819#  } elsif ($webvar{del} eq 'ok') {
     820###fixme: find group id user is in (for logging) *before* we delete the user
     821#    my ($code,$msg) = delUser($dbh, $webvar{id});
     822#    if ($code ne 'OK') {
     823## need to find failure mode
     824#      $page->param(del_failed => 1);
     825#      $page->param(errmsg => $msg);
     826#      list_users($curgroup);
     827#    } else {
     828#      # success.  go back to the user list, do not pass "GO"
     829###log
     830#      logaction(0, $session->param("username"), $webvar{group}, "Added domain $webvar{domain}");
     831#      changepage(page => "useradmin");
     832#    }
     833#  } else {
     834#    # cancelled.  whee!
     835#    changepage(page => "useradmin");
     836#  }
     837#
     838#} elsif ($webvar{page} eq 'edituser') {
    836839
    837840} elsif ($webvar{page} eq 'dnsq') {
     
    925928      my ($code,$msg) = importAXFR($dbh, $webvar{ifrom}, $domain, $webvar{group},
    926929        $webvar{domstatus}, $webvar{rwsoa}, $webvar{rwns});
     930##fixme: log
    927931      $row{domok} = $msg if $code eq 'OK';
    928932      if ($code eq 'WARN') {
Note: See TracChangeset for help on using the changeset viewer.