Legend:
- Unmodified
- Added
- Removed
-
trunk/DNSDB.pm
r375 r377 2959 2959 $dbh->do("INSERT INTO locations (location, group_id, iplist, description, comments) VALUES (?,?,?,?,?)", 2960 2960 undef, ($loc, $grp, $iplist, $shdesc, $comments) ); 2961 _log($dbh, entry => "Added location ($shdesc, '$iplist')"); 2962 $dbh->commit; 2961 2963 }; 2962 2964 if ($@) { … … 2972 2974 2973 2975 return ('OK',$loc); 2974 } 2976 } # end addLoc() 2975 2977 2976 2978 2977 2979 ## DNSDB::updateLoc() 2978 sub updateLoc {} 2980 sub updateLoc { 2981 my $dbh = shift; 2982 my $loc = shift; 2983 my $grp = shift; 2984 my $shdesc = shift; 2985 my $comments = shift; 2986 my $iplist = shift; 2987 2988 $shdesc = '' if !$shdesc; 2989 $comments = '' if !$comments; 2990 $iplist = '' if !$iplist; 2991 2992 # Allow transactions, and raise an exception on errors so we can catch it later. 2993 # Use local to make sure these get "reset" properly on exiting this block 2994 local $dbh->{AutoCommit} = 0; 2995 local $dbh->{RaiseError} = 1; 2996 2997 my $oldloc = getLoc($dbh, $loc); 2998 my $okmsg = "Updated location (".$oldloc->{description}.", '".$oldloc->{iplist}."') to ($shdesc, '$iplist')"; 2999 3000 eval { 3001 $dbh->do("UPDATE locations SET group_id=?,iplist=?,description=?,comments=? WHERE location=?", 3002 undef, ($grp, $iplist, $shdesc, $comments, $loc) ); 3003 _log($dbh, entry => $okmsg); 3004 $dbh->commit; 3005 }; 3006 if ($@) { 3007 my $msg = $@; 3008 eval { $dbh->rollback; }; 3009 if ($config{log_failures}) { 3010 $shdesc = $loc if !$shdesc; 3011 _log($dbh, (entry => "Failed updating location ($shdesc, '$iplist'): $msg")); 3012 $dbh->commit; 3013 } 3014 return ('FAIL',$msg); 3015 } 3016 3017 return ('OK',$okmsg); 3018 } # end updateLoc() 3019 2979 3020 2980 3021 ## DNSDB::delLoc() -
trunk/dns.cgi
r376 r377 96 96 $session->param('reclistsortby','host'); 97 97 $session->param('reclistorder','ASC'); 98 $session->param('loclistsortby','description'); 99 $session->param('loclistorder','ASC'); 98 100 $session->param('logsortby','stamp'); 99 101 $session->param('logorder','DESC'); … … 1352 1354 1353 1355 my $loc = getLoc($dbh, $webvar{loc}); 1354 $page->param(wastrying => " adding");1356 $page->param(wastrying => "editing"); 1355 1357 $page->param(todo => "Edit location/view"); 1356 1358 $page->param(locact => "update"); … … 1363 1365 changepage(page => "loclist", errmsg => "You are not permitted to edit locations/views", id => $webvar{parentid}) 1364 1366 unless ($permissions{admin} || $permissions{location_edit}); 1365 ##work 1367 1368 my ($code,$msg) = updateLoc($dbh, $webvar{id}, $curgroup, $webvar{locname}, $webvar{comments}, $webvar{iplist}); 1369 1370 if ($code eq 'OK') { 1371 changepage(page => "loclist", resultmsg => $msg); 1372 } else { 1373 $page->param(failed => 1); 1374 $page->param(errmsg => $msg); 1375 $page->param(wastrying => "editing"); 1376 $page->param(todo => "Edit location/view"); 1377 $page->param(locact => "update"); 1378 $page->param(id => $webvar{loc}); 1379 $page->param(locname => $webvar{locname}); 1380 $page->param(comments => $webvar{comments}); 1381 $page->param(iplist => $webvar{iplist}); 1382 } 1366 1383 } else { 1367 1384 changepage(page => "loclist", errmsg => "You are not permitted to add locations/views", id => $webvar{parentid}) … … 2169 2186 # Some UI things need to be done to the list 2170 2187 foreach my $l (@{$loclist}) { 2188 $l->{iplist} = "(All IPs)" if !$l->{iplist}; 2171 2189 $l->{edloc} = ($permissions{admin} || $permissions{loc_edit}); 2172 2190 $l->{delloc} = ($permissions{admin} || $permissions{loc_delete});
Note:
See TracChangeset
for help on using the changeset viewer.