Changeset 78
- Timestamp:
- 02/23/11 14:53:57 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/DNSDB.pm
r72 r78 247 247 my $newperms = shift; 248 248 249 my $failmsg = '';249 my $failmsg = ''; 250 250 251 251 # see if we're switching from inherited to custom … … 258 258 my ($wasinherited,$permid) = $sth->fetchrow_array; 259 259 260 # hack phtoui 261 # group id 1 is "special" in that it's it's own parent (err... possibly.) 262 # may make its parent id 0 which doesn't exist, and as a bonus is Perl-false. 263 $wasinherited = 0 if ($type eq 'group' && $id == 1); 264 260 265 local $dbh->{AutoCommit} = 0; 261 266 local $dbh->{RaiseError} = 1; … … 264 269 eval { 265 270 if ($wasinherited) { 266 $failmsg = "wasinherited: '$wasinherited'";267 die "don't wanna add perms where we don't need to";268 271 ##fixme: need to add semirecursive bit to properly munge inherited permission ID on subgroups and users 269 ## FIXME: need to fiddle permissions table to track back to users or groups table 270 my $sql = "INSERT INTO permissions ($permlist) ". 271 "SELECT $permlist FROM permissions WHERE permission_id=?"; 272 $sth = $dbh->prepare($sql); 273 $sth->execute($permid); 272 $dbh->do("INSERT INTO permissions ($permlist) ". 273 "SELECT $permlist FROM permissions WHERE permission_id=?", undef, ($permid) ); 274 #$sth = $dbh->prepare($sql); 275 #$sth->execute($permid); 274 276 $sth = $dbh->prepare("SELECT permission_id FROM ".($type eq 'user' ? 'users' : 'groups'). 275 277 " WHERE ".($type eq 'user' ? 'user' : 'group')."_id=?"); 276 278 $sth->execute($id); 277 279 ($permid) = $sth->fetchrow_array; 280 $dbh->do("UPDATE permissions SET ".($type eq 'user' ? 'user' : 'group')."_id=? ". 281 "WHERE permission_id=?", undef, ($id,$permid) ); 282 $dbh->do("UPDATE ".($type eq 'user' ? 'users' : 'groups')." SET permission_id=? ". 283 "WHERE ".($type eq 'user' ? 'user' : 'group')."_id=?", undef, ($permid,$id) ); 278 284 } 279 285 foreach (@permtypes) { 280 286 if (defined ($newperms->{$_})) { 281 $ sth = $dbh->prepare("UPDATE permissions SET $_=? WHERE permission_id=?");282 $sth->execute($newperms->{$_},$permid);287 $dbh->do("UPDATE permissions SET $_=? WHERE permission_id=?", undef, ($newperms->{$_},$permid) ); 288 #$sth->execute($newperms->{$_},$permid); 283 289 } 284 290 } 291 285 292 $dbh->commit; 286 293 }; # end eval
Note:
See TracChangeset
for help on using the changeset viewer.