Changeset 87 for trunk/dns.cgi


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

/trunk

Checkpoint. Permissions manipulation should be complete.
Still need to set up permissions *checking*.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dns.cgi

    r83 r87  
    77# Last update by $Author$
    88###
    9 # Copyright (C) 2008,2009 - Kris Deugau <kdeugau@deepnet.cx>
     9# Copyright (C) 2008-2011 - Kris Deugau <kdeugau@deepnet.cx>
    1010
    1111use strict;
     
    261261  $sortorder = $session->param($webvar{page}.'order');
    262262
    263 ##work
    264263# set up the headers
    265264  my @cols = ('host', 'type', 'val', 'distance', 'weight', 'port', 'ttl');
     
    275274  $page->param(defrec => $webvar{defrec});
    276275  if ($webvar{defrec} eq 'y') {
    277 ##fixme: hardcoded group
    278276    showdomain('y',$curgroup);
    279277  } else {
     
    291289  if ($webvar{recact} eq 'new') {
    292290
    293     $page->param(todo => "Add record to");
     291    $page->param(todo => "Add record");
    294292    $page->param(recact => "add");
    295293    $page->param(parentid => $webvar{parentid});
     
    324322      $page->param(errmsg       => $msg);
    325323      $page->param(wastrying    => "adding");
    326       $page->param(todo         => "Add record to");
     324      $page->param(todo         => "Add record");
    327325      $page->param(recact       => "add");
    328326      $page->param(parentid     => $webvar{parentid});
     
    613611
    614612    my $alterperms = 0; # flag iff we need to force custom permissions due to user's current access limits
    615     my %newperms;
     613
     614    my %newperms;       # we're going to prefill the existing permissions, so we can change them.
     615    getPermissions($dbh, 'user', $webvar{uid}, \%newperms);
    616616
    617617    if ($webvar{pass1} ne $webvar{pass2}) {
     
    642642        $permstring = 'C:';
    643643        foreach (@permtypes) {
    644           $newperms{$_} = 0;
    645           $newperms{$_} = 1 if $webvar{$_} eq 'on';
    646           if ($permissions{admin}) {
     644          if ($permissions{admin} || $permissions{$_}) {
    647645            $permstring .= ",$_" if defined($webvar{$_}) && $webvar{$_} eq 'on';
    648           } else {
    649             $permstring .= ",$_" if $permissions{$_} && defined($webvar{$_}) && $webvar{$_} eq 'on';
     646            $newperms{$_} = (defined($webvar{$_}) && $webvar{$_} eq 'on' ? 1 : 0);
    650647          }
    651648        }
     
    653650      } elsif ($permissions{admin} && $webvar{perms_type} eq 'clone') {
    654651        $permstring = "c:$webvar{clonesrc}";
     652        getPermissions($dbh, 'user', $webvar{clonesrc}, \%newperms);
    655653        $page->param(perm_clone => 1);
    656654      } else {
     
    671669##fixme - need to actually get a correct permission set to pass in here,
    672670# also a flag to revert custom permissions to inherited
    673 ##work
    674           ($code,$msg) = changePermissions($dbh, 'user', $webvar{uid}, \%newperms);
     671          ($code,$msg) = changePermissions($dbh, 'user', $webvar{uid}, \%newperms, ($permstring eq 'i'));
    675672        }
    676673      }
     
    694691      $page->param(action => $webvar{action});
    695692      $page->param(set_permgroup => 1);
     693      if ($webvar{perms_type} eq 'inherit') {   # set permission class radio
     694        $page->param(perm_inherit => 1);
     695      } elsif ($webvar{perms_type} eq 'clone') {
     696        $page->param(perm_clone => 1);
     697      } else {
     698        $page->param(perm_custom => 1);
     699      }
    696700      $page->param(uname => $webvar{uname});
    697701      $page->param(fname => $webvar{fname});
     
    724728    $page->param(fname => $userinfo->{firstname});
    725729    $page->param(lname => $userinfo->{lastname});
     730    $page->param(set_permgroup => 1);
    726731    if ($userinfo->{inherit_perm}) {
    727732      $page->param(perm_inherit => 1);
     
    729734      $page->param(perm_custom => 1);
    730735    }
    731 
     736##work
    732737#  } elsif ($webvar{action} eq 'update') {
    733738  } else {
     
    10431048}
    10441049
     1050print "<pre>\n";
    10451051foreach (@debugbits) { print; }
     1052print "</pre>\n";
    10461053
    10471054# spit it out
     
    12391246  $sth->execute;
    12401247
     1248  # shut up some warnings, but don't stomp on caller's state
     1249  local $webvar{clonesrc} = 0 if !defined($webvar{clonesrc});
     1250
    12411251  my @clonesrc;
    12421252  while (my ($username,$uid) = $sth->fetchrow_array) {
     
    12761286        $page->param(lastoffs => int (($count-1)/$perpage));
    12771287      }
     1288    } else {
     1289      $page->param(onepage => 1);
    12781290    }
    12791291  }
     
    13741386} # end listdomains()
    13751387
     1388
    13761389sub listgroups {
    13771390
Note: See TracChangeset for help on using the changeset viewer.