Changeset 294 for trunk/dns.cgi


Ignore:
Timestamp:
03/29/12 13:22:59 (13 years ago)
Author:
Kris Deugau
Message:

/trunk

"Move action logging for change group default permissions" mutated
into "Move action logging for (change group default permissions),
(add user), (update user), (update user permissions)". See #35.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dns.cgi

    r293 r294  
    10161016    my ($code,$msg) = changePermissions($dbh, 'group', $webvar{gid}, \%chperms);
    10171017    if ($code eq 'OK') {
    1018       logaction(0, $session->param("username"), $webvar{gid},
    1019         "Updated default permissions in group $webvar{gid} (".groupName($dbh, $webvar{gid}).")");
    10201018      if ($alterperms) {
    10211019        changepage(page => "grpman", warnmsg =>
     
    10231021                groupName($dbh, $webvar{gid})." updated with reduced access");
    10241022      } else {
    1025         changepage(page => "grpman", resultmsg =>
    1026                 "Updated default permissions in group ".groupName($dbh, $webvar{gid}));
     1023        changepage(page => "grpman", resultmsg => $msg);
    10271024      }
    10281025    } # fallthrough else
    1029     logaction(0, $session->param("username"), $webvar{gid}, "Failed to update default permissions in group ".
    1030         groupName($dbh, $webvar{gid}).": $msg")
    1031         if $config{log_failures};
    10321026    # no point in doing extra work
    10331027    fill_permissions($page, \%chperms);
     
    12611255    $page->param(add => 1) if $webvar{useraction} eq 'add';
    12621256
    1263     my ($code,$msg);
     1257    # can't re-use $code and $msg for update if we want to be able to identify separate failure states
     1258    my ($code,$code2,$msg,$msg2) = ('OK','OK','OK','OK');
    12641259
    12651260    my $alterperms = 0; # flag iff we need to force custom permissions due to user's current access limits
     
    13151310                ($webvar{makeactive} eq 'on' ? 1 : 0), $webvar{accttype}, $permstring,
    13161311                $webvar{fname}, $webvar{lname}, $webvar{phone});
    1317         logaction(0, $session->param("username"), $curgroup, "Added user $webvar{uname} (uid $msg)")
    1318                 if $code eq 'OK';
    13191312      } else {
    13201313        changepage(page => "useradmin", errmsg => "You do not have permission to edit users")
     
    13241317          changepage(page => "useradmin", errmsg => "You do not have permission to edit the requested user");
    13251318        }
    1326 # User update is icky.  I'd really like to do this in one atomic
    1327 # operation, but that would duplicate a **lot** of code in DNSDB.pm
     1319# User update is icky.  I'd really like to do this in one atomic operation,
     1320# but that gets hairy by either duplicating a **lot** of code in DNSDB.pm
     1321# or self-torture trying to not commit the transaction until we're really done.
    13281322        # Allowing for changing group, but not coding web support just yet.
    13291323        ($code,$msg) = updateUser($dbh, $webvar{uid}, $webvar{uname}, $webvar{gid}, $webvar{pass1},
     
    13321326        if ($code eq 'OK') {
    13331327          $newperms{admin} = 1 if $webvar{accttype} eq 'S';
    1334           ($code,$msg) = changePermissions($dbh, 'user', $webvar{uid}, \%newperms, ($permstring eq 'i'));
    1335           logaction(0, $session->param("username"), $curgroup,
    1336                 "Updated uid $webvar{uid}, user $webvar{uname} ($webvar{fname} $webvar{lname})");
     1328          ($code2,$msg2) = changePermissions($dbh, 'user', $webvar{uid}, \%newperms, ($permstring eq 'i'));
    13371329        }
    13381330      }
    13391331    }
    13401332
    1341     if ($code eq 'OK') {
    1342 
     1333    if ($code eq 'OK' && $code2 eq 'OK') {
     1334      my %pageparams = (page => "useradmin");
    13431335      if ($alterperms) {
    1344         changepage(page => "useradmin", warnmsg =>
    1345                 "You can only grant permissions you hold.  $webvar{uname} ".
    1346                 ($webvar{useraction} eq 'add' ? 'added' : 'updated')." with reduced access.");
     1336        $pageparams{warnmsg} = "You can only grant permissions you hold.\nUser ".
     1337                ($webvar{useraction} eq 'add' ? "$webvar{uname} added" : "info updated for $webvar{uname}").
     1338                ".\nPermissions ".($webvar{useraction} eq 'add' ? 'added' : 'updated')." with reduced access.";
    13471339      } else {
    1348         changepage(page => "useradmin", resultmsg => "Successfully ".
    1349                 ($webvar{useraction} eq 'add' ? 'added' : 'updated')." user $webvar{uname}");
     1340        $pageparams{resultmsg} = "$msg".($webvar{useraction} eq 'add' ? '' : "\n$msg2");
    13501341      }
     1342      changepage(%pageparams);
    13511343
    13521344    # add/update failed:
     
    13671359      $page->param(pass1 => $webvar{pass1});
    13681360      $page->param(pass2 => $webvar{pass2});
    1369       $page->param(errmsg => $msg);
     1361      $page->param(errmsg => "User info updated but permissions update failed: $msg2") if $code eq 'OK';
     1362      $page->param(errmsg => $msg) if $code ne 'OK';
    13701363      fill_permissions($page, \%newperms);
    13711364      fill_actypelist($webvar{accttype});
    13721365      fill_clonemelist();
    1373       logaction(0, $session->param("username"), $curgroup, "Failed to $webvar{useraction} user ".
    1374         "$webvar{uname}: $msg")
    1375         if $config{log_failures};
    13761366    }
    13771367
     
    13941384    fill_actypelist($userinfo->{type});
    13951385    # not using this yet, but adding it now means we can *much* more easily do so later.
    1396     $page->param(gid => $webvar{group_id});
     1386    $page->param(gid => $userinfo->{group_id});
    13971387
    13981388    my %curperms;
Note: See TracChangeset for help on using the changeset viewer.