Commit 581544989da7e462ff43780dae67b63f845c3d95
1 parent
b1fdf986
added error checking for deletion
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@1078 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
15 additions
and
2 deletions
lib/roles/Role.inc
| ... | ... | @@ -131,14 +131,27 @@ class Role { |
| 131 | 131 | global $default, $lang_err_database, $lang_err_object_key; |
| 132 | 132 | //only delete the object if it exists in the database |
| 133 | 133 | if ($this->iId >= 0) { |
| 134 | + //check to see if role is linked to a folder | |
| 134 | 135 | $sql = $default->db; |
| 135 | - $result = $sql->query("DELETE FROM $default->owl_roles_table WHERE id = $this->iId"); | |
| 136 | - if ($result) { | |
| 136 | + $query = "SELECT role_id FROM ". $default->owl_groups_folders_approval_table ." WHERE role_id = '" . $this->iId . "'"; | |
| 137 | + $sql->query($query); | |
| 138 | + $rows = $sql->num_rows($sql); | |
| 139 | + | |
| 140 | + if ($rows > 0){ | |
| 141 | + // duplicate link exists | |
| 142 | + $_SESSION["errorMessage"] = "Role::The Role " . $this->sName . " is Assigned to a folder!"; | |
| 143 | + return false; | |
| 144 | + | |
| 145 | + }else{ | |
| 146 | + $sql = $default->db; | |
| 147 | + $result = $sql->query("DELETE FROM $default->owl_roles_table WHERE id = $this->iId"); | |
| 148 | + if ($result) { | |
| 137 | 149 | return true; |
| 138 | 150 | } |
| 139 | 151 | $_SESSION["errorMessage"] = $lang_err_database; |
| 140 | 152 | return false; |
| 141 | 153 | } |
| 154 | + } | |
| 142 | 155 | $_SESSION["errorMessage"] = $lang_err_object_key; |
| 143 | 156 | return false; |
| 144 | 157 | } | ... | ... |