Changeset 296
Legend:
- Unmodified
- Added
- Removed
-
trunk/DNSDB.pm
r295 r296 2285 2285 my $dbh = shift; 2286 2286 my $id = shift; 2287 my $newstatus = shift ;2287 my $newstatus = shift || 'mu'; 2288 2288 2289 2289 return undef if $id !~ /^\d+$/; 2290 2290 2291 my $sth; 2292 2293 # ooo, fun! let's see what we were passed for status 2294 if ($newstatus) { 2295 $sth = $dbh->prepare("update users set status=? where user_id=?"); 2296 # ass-u-me caller knows what's going on in full 2297 if ($newstatus =~ /^[01]$/) { # only two valid for now. 2298 $sth->execute($newstatus,$id); 2299 } elsif ($newstatus =~ /^usero(?:n|ff)$/) { 2300 $sth->execute(($newstatus eq 'useron' ? 1 : 0),$id); 2301 } 2302 } 2303 2304 $sth = $dbh->prepare("select status from users where user_id=?"); 2305 $sth->execute($id); 2306 my ($status) = $sth->fetchrow_array; 2291 my $userdata = getUserData($dbh, $id); 2292 2293 # Allow transactions, and raise an exception on errors so we can catch it later. 2294 # Use local to make sure these get "reset" properly on exiting this block 2295 local $dbh->{AutoCommit} = 0; 2296 local $dbh->{RaiseError} = 1; 2297 2298 if ($newstatus ne 'mu') { 2299 # ooo, fun! let's see what we were passed for status 2300 eval { 2301 $newstatus = 0 if $newstatus eq 'useroff'; 2302 $newstatus = 1 if $newstatus eq 'useron'; 2303 $dbh->do("UPDATE users SET status=? WHERE user_id=?", undef, ($newstatus, $id)); 2304 2305 $resultstr = ($newstatus ? 'Enabled' : 'Disabled')." user ".$userdata->{username}; 2306 2307 my %loghash; 2308 $loghash{group_id} = parentID($dbh, (id => $id, type => 'user')); 2309 $loghash{entry} = $resultstr; 2310 _log($dbh, %loghash); 2311 2312 $dbh->commit; 2313 }; 2314 if ($@) { 2315 my $msg = $@; 2316 eval { $dbh->rollback; }; 2317 $resultstr = ''; 2318 $errstr = $msg; 2319 ##fixme: failure logging? 2320 return; 2321 } 2322 } 2323 2324 my ($status) = $dbh->selectrow_array("SELECT status FROM users WHERE user_id=?", undef, ($id)); 2307 2325 return $status; 2308 2326 } # end userStatus() -
trunk/dns.cgi
r295 r296 1159 1159 if ($flag && ($permissions{admin} || $permissions{user_edit})) { 1160 1160 my $stat = userStatus($dbh,$webvar{id},$webvar{userstatus}); 1161 logaction(0, $session->param("username"), parentID($dbh, (id => $webvar{id}, type => 'user')), 1162 ($stat ? 'Enabled' : 'Disabled')." ".userFullName($dbh, $webvar{id}, '%u')); 1163 $page->param(resultmsg => ($stat ? 'Enabled' : 'Disabled')." ".userFullName($dbh, $webvar{id}, '%u')); 1161 $page->param(resultmsg => $DNSDB::resultstr); 1164 1162 } else { 1165 1163 $page->param(errmsg => "You are not permitted to view or change the requested user");
Note:
See TracChangeset
for help on using the changeset viewer.