Changeset 293
Legend:
- Unmodified
- Added
- Removed
-
trunk/DNSDB.pm
r292 r293 1849 1849 # -> ... 1850 1850 my $failmsg = ''; 1851 my $resultmsg = ''; 1852 1853 # collect some pieces for logging and error messages 1854 my $groupname = groupName($dbh,$groupid); 1855 my $parid = parentID($dbh, (id => $groupid, type => 'group')); 1851 1856 1852 1857 # Wrap all the SQL in a transaction 1853 1858 eval { 1854 my $sth = $dbh->prepare("SELECT count(*) FROM domains WHERE group_id=?"); 1855 $sth->execute($groupid); 1856 my ($domcnt) = $sth->fetchrow_array; 1857 $failmsg = "Can't remove group ".groupName($dbh,$groupid); 1859 # Check for Things in the group 1860 $failmsg = "Can't remove group $groupname"; 1861 my ($grpcnt) = $dbh->selectrow_array("SELECT count(*) FROM groups WHERE parent_group_id=?", undef, ($groupid)); 1862 die "$grpcnt groups still in group\n" if $grpcnt; 1863 my ($domcnt) = $dbh->selectrow_array("SELECT count(*) FROM domains WHERE group_id=?", undef, ($groupid)); 1858 1864 die "$domcnt domains still in group\n" if $domcnt; 1859 1860 $sth = $dbh->prepare("delete from default_records where group_id=?"); 1861 $failmsg = "Failed to delete default records for ".groupName($dbh,$groupid); 1862 $sth->execute($groupid); 1863 $sth = $dbh->prepare("delete from groups where group_id=?"); 1864 $failmsg = "Failed to remove group ".groupName($dbh,$groupid); 1865 $sth->execute($groupid); 1865 my ($usercnt) = $dbh->selectrow_array("SELECT count(*) FROM users WHERE group_id=?", undef, ($groupid)); 1866 die "$usercnt users still in group\n" if $usercnt; 1867 1868 $failmsg = "Failed to delete default records for $groupname"; 1869 $dbh->do("DELETE from default_records WHERE group_id=?", undef, ($groupid)); 1870 $failmsg = "Failed to delete default reverse records for $groupname"; 1871 $dbh->do("DELETE from default_rev_records WHERE group_id=?", undef, ($groupid)); 1872 $failmsg = "Failed to remove group $groupname"; 1873 $dbh->do("DELETE from groups WHERE group_id=?", undef, ($groupid)); 1874 1875 _log($dbh, (group_id => $parid, entry => "Deleted group $groupname")); 1876 $resultmsg = "Deleted group $groupname"; 1866 1877 1867 1878 # once we get here, we should have suceeded. … … 1872 1883 my $msg = $@; 1873 1884 eval { $dbh->rollback; }; 1885 if ($config{log_failures}) { 1886 _log($dbh, (group_id => $parid, entry => "$failmsg: $msg")); 1887 $dbh->commit; # since we enabled transactions earlier 1888 } 1874 1889 return ('FAIL',"$failmsg: $msg"); 1875 } else {1876 return ('OK','OK'); 1877 }1890 } 1891 1892 return ('OK',$resultmsg); 1878 1893 } # end delGroup() 1879 1894 -
trunk/dns.cgi
r292 r293 974 974 975 975 } elsif ($webvar{del} eq 'ok') { 976 my $deleteme = groupName($dbh,$webvar{id}); # get this before we delete it...977 my $delparent = parentID($dbh, (id => $webvar{id}, type => 'group'));978 976 my ($code,$msg) = delGroup($dbh, $webvar{id}); 979 977 if ($code eq 'OK') { 980 978 ##fixme: need to clean up log when deleting a major container 981 logaction(0, $session->param("username"), $delparent, "Deleted group $deleteme"); 982 changepage(page => "grpman", resultmsg => "Deleted group $deleteme"); 979 changepage(page => "grpman", resultmsg => $msg); 983 980 } else { 984 981 # need to find failure mode 985 logaction(0, $session->param("username"), $delparent, "Failed to delete group $deleteme: $msg") 986 if $config{log_failures}; 987 changepage(page => "grpman", errmsg => "Error deleting group $deleteme: $msg"); 982 changepage(page => "grpman", errmsg => $msg); 988 983 } 989 984 } else {
Note:
See TracChangeset
for help on using the changeset viewer.