Commit dd8a3ce6adfe4635ef89eb7d25feee8b905d5260
1 parent
b87be9f4
added userIsUnitAdministratorForFolder method
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@660 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
19 additions
and
1 deletions
lib/security/permission.inc
| @@ -73,7 +73,7 @@ class Permission { | @@ -73,7 +73,7 @@ class Permission { | ||
| 73 | if (Permission::userHasGroupWritePermissionForFolder($iFolderID) || | 73 | if (Permission::userHasGroupWritePermissionForFolder($iFolderID) || |
| 74 | Permission::userHasWriteRoleForFolder($iFolderID) || | 74 | Permission::userHasWriteRoleForFolder($iFolderID) || |
| 75 | Permission::userIsSystemAdministrator() || | 75 | Permission::userIsSystemAdministrator() || |
| 76 | - Permission::userIsUnitAdministrator($iFolderID)) { | 76 | + Permission::userIsUnitAdministratorForFolder($iFolderID)) { |
| 77 | return true; | 77 | return true; |
| 78 | } | 78 | } |
| 79 | $_SESSION["errorMessage"] = $lang_err_user_folder_write . "id " . $iFolderID; | 79 | $_SESSION["errorMessage"] = $lang_err_user_folder_write . "id " . $iFolderID; |
| @@ -357,6 +357,24 @@ class Permission { | @@ -357,6 +357,24 @@ class Permission { | ||
| 357 | return $sql->next_record(); | 357 | return $sql->next_record(); |
| 358 | } | 358 | } |
| 359 | 359 | ||
| 360 | + /** | ||
| 361 | + * Checks if the current user is a unit administrator | ||
| 362 | + * | ||
| 363 | + * @return boolean true if the user is the unit administrator for the unit to which the folder belongs, false otherwise | ||
| 364 | + */ | ||
| 365 | + function userIsUnitAdministratorForFolder($iFolderID) { | ||
| 366 | + global $default; | ||
| 367 | + $sql = new Owl_DB(); | ||
| 368 | + $sql->query("SELECT UGL.group_id " . | ||
| 369 | + "FROM $default->owl_users_groups_table AS UGL INNER JOIN $default->owl_groups_units_table AS GUL ON GUL.group_id = UGL.group_id " . | ||
| 370 | + "INNER JOIN $default->owl_groups_table AS GL ON GL.id = UGL.group_id " . | ||
| 371 | + "INNER JOIN $default->owl_groups_folders_table AS GFL ON GFL.group_id = UGL.group_id " . | ||
| 372 | + "WHERE UGL.user_id = " . $_SESSION["userID"] . " " . | ||
| 373 | + "AND GL.is_unit_admin = 1 " . | ||
| 374 | + "AND GFL.folder_id = $iFolderID"); | ||
| 375 | + return $sql->next_record(); | ||
| 376 | + } | ||
| 377 | + | ||
| 360 | /** | 378 | /** |
| 361 | * Checks if the current user is a guest user | 379 | * Checks if the current user is a guest user |
| 362 | * | 380 | * |