aboutsummaryrefslogtreecommitdiff
path: root/app/controllers/resources/resource.php
diff options
context:
space:
mode:
authorMoritz Strohm <strohm@data-quest.de>2023-11-23 15:46:58 +0000
committerMoritz Strohm <strohm@data-quest.de>2023-11-23 15:46:58 +0000
commit39be220dfa709b1eb1d4a30a56befed08d53f765 (patch)
tree049b1171b84470a3c395a229fe954079fa6fd43a /app/controllers/resources/resource.php
parent9cbde5e91c0061cd8893a563abd02f258688f4f8 (diff)
prevent temporary permissions to be deleted when managing them for one user, re #2158
Merge request studip/studip!2019
Diffstat (limited to 'app/controllers/resources/resource.php')
-rw-r--r--app/controllers/resources/resource.php48
1 files changed, 25 insertions, 23 deletions
diff --git a/app/controllers/resources/resource.php b/app/controllers/resources/resource.php
index 59cd681..47d6b99 100644
--- a/app/controllers/resources/resource.php
+++ b/app/controllers/resources/resource.php
@@ -1125,30 +1125,32 @@ class Resources_ResourceController extends AuthenticatedController
}
}
- //Now we must remove all permissions where the resource_id is given
- //and where the user_id is not in the $user_ids array which has been
- //filled above.
- if ($user_ids) {
- $deleted_permissions = ResourceTemporaryPermission::deleteBySql(
- 'resource_id = :resource_id
- AND
- user_id NOT IN ( :user_ids )',
- [
- 'resource_id' => $this->resource_id,
- 'user_ids' => $user_ids
- ]
- );
- } else {
- //In case no user_ids are collected above all permissions
- //for the resource have to be deleted:
- $deleted_permissions = ResourceTemporaryPermission::deleteBySQL(
- 'resource_id = :resource_id',
- [
- 'resource_id' => $this->resource_id,
- ]
- );
+ $deleted_permissions = 0;
+ if (!$this->single_user_mode) {
+ //Now we must remove all permissions where the resource_id is given
+ //and where the user_id is not in the $user_ids array which has been
+ //filled above.
+ if ($user_ids) {
+ $deleted_permissions = ResourceTemporaryPermission::deleteBySql(
+ 'resource_id = :resource_id
+ AND
+ user_id NOT IN ( :user_ids )',
+ [
+ 'resource_id' => $this->resource_id,
+ 'user_ids' => $user_ids
+ ]
+ );
+ } else {
+ //In case no user_ids are collected above all permissions
+ //for the resource have to be deleted:
+ $deleted_permissions = ResourceTemporaryPermission::deleteBySQL(
+ 'resource_id = :resource_id',
+ [
+ 'resource_id' => $this->resource_id,
+ ]
+ );
+ }
}
-
if (count($errors)) {
PageLayout::postError(
_('Die folgenden Fehler traten auf beim Speichern der Berechtigungen:'),