Changeset 390 for trunk


Ignore:
Timestamp:
09/21/12 13:41:48 (12 years ago)
Author:
Kris Deugau
Message:

/trunk

Extend handling of setting permissions to keep "chained"
permissions straight. Needed mainly for locations; if the user
can manipulate them (add/edit/delete/change-on-record) then they
should be able to view them. See #10.
Also sets self_edit if user_edit is set.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/DNSDB.pm

    r389 r390  
    5959        &mailNotify
    6060        %typemap %reverse_typemap %config
    61         %permissions @permtypes $permlist
     61        %permissions @permtypes $permlist %permchains
    6262        );
    6363
     
    8686                &mailNotify
    8787                %typemap %reverse_typemap %config
    88                 %permissions @permtypes $permlist
     88                %permissions @permtypes $permlist %permchains
    8989                )]
    9090        );
     
    120120);
    121121our $permlist = join(',',@permtypes);
     122
     123# Some permissions more or less require certain others.
     124our %permchains = (
     125        user_edit       => 'self_edit',
     126        location_edit   => 'location_view',
     127        location_create => 'location_view',
     128        location_delete => 'location_view',
     129        record_locchg   => 'location_view',
     130);
    122131
    123132# DNS record type map and reverse map.
  • trunk/dns.cgi

    r389 r390  
    956956      }
    957957    }
     958    # "Chained" permissions.  Some permissions imply others;  make sure they get set.
     959    foreach (keys %permchains) {
     960      if ($chperms{$_} && !$chperms{$permchains{$_}}) {
     961        $chperms{$permchains{$_}} = 1;
     962      }
     963    }
    958964    my ($code,$msg) = changePermissions($dbh, 'group', $webvar{gid}, \%chperms);
    959965    if ($code eq 'OK') {
     
    11801186      } else {
    11811187        $permstring = 'i';
     1188      }
     1189      # "Chained" permissions.  Some permissions imply others;  make sure they get set.
     1190      foreach (keys %permchains) {
     1191        if ($newperms{$_} && !$newperms{$permchains{$_}}) {
     1192          $newperms{$permchains{$_}} = 1;
     1193          $permstring .= ",$permchains{$_}";
     1194        }
    11821195      }
    11831196      if ($webvar{useraction} eq 'add') {
Note: See TracChangeset for help on using the changeset viewer.