diff options
| author | Moritz Strohm <strohm@data-quest.de> | 2025-10-02 07:31:04 +0000 |
|---|---|---|
| committer | Moritz Strohm <strohm@data-quest.de> | 2025-10-02 07:31:04 +0000 |
| commit | 2dc5aaea055932df52d0b08992dfdd4b76718411 (patch) | |
| tree | f931e38591f2b64abe7a800209d82ebf0d44204d /app/controllers/resources | |
| parent | 11ca5b13005a3338515aa49381e41fa5ef56f3a1 (diff) | |
extended circular mail functionality in room management, closes #5804
Closes #5804
Merge request studip/studip!4427
Diffstat (limited to 'app/controllers/resources')
| -rw-r--r-- | app/controllers/resources/messages.php | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/app/controllers/resources/messages.php b/app/controllers/resources/messages.php index da3ca87..ae966e0 100644 --- a/app/controllers/resources/messages.php +++ b/app/controllers/resources/messages.php @@ -32,7 +32,11 @@ class Resources_MessagesController extends AuthenticatedController $this->current_user = User::findCurrent(); - if (!ResourceManager::userHasGlobalPermission($this->current_user, 'admin')) { + if ( + !ResourceManager::userHasGlobalPermission($this->current_user) + && !RoomManager::userHasRooms($this->current_user) + ) { + //The user has neither global nor specific user permissions on resources. throw new AccessDeniedException(); } @@ -40,7 +44,23 @@ class Resources_MessagesController extends AuthenticatedController $this->recipient_selection = 'permission'; $this->clipboard_id = ''; $this->min_permission = ''; + $this->room_ids = Request::getArray('room_ids'); $this->selected_rooms = []; + $new_room_id_list = []; + if (count($this->room_ids) > 0) { + $rooms = Room::findMany($this->room_ids, 'ORDER BY name ASC'); + foreach ($rooms as $room) { + //The current user must have at least user permissions to preselect a room. + if ($room->userHasPermission($this->current_user)) { + //Set the room as selected room and put its ID in the new room-ID list. + $this->selected_rooms[] = $room; + $new_room_id_list[] = $room->id; + } + } + } + //Filter out all rooms from the room-ID list where the user does not have user permissions: + $old_room_id_list = $this->room_ids; + $this->room_ids = $new_room_id_list; $this->room_search = new QuickSearch( 'room_name', @@ -66,12 +86,19 @@ class Resources_MessagesController extends AuthenticatedController $this->recipient_selection = Request::get('recipient_selection'); $this->room_selection = Request::get('room_selection'); - $this->room_ids = Request::getArray('room_ids'); - $this->selected_rooms = Room::findMany($this->room_ids); $this->clipboard_id = Request::int('clipboard_id'); //First validation: + if (empty($this->room_ids)) { + if (empty($old_room_id_list)) { + PageLayout::postError(_('Sie haben keinen Raum ausgewählt.')); + } else { + PageLayout::postError(_('Sie haben an den ausgewählten Räumen nicht die erforderlichen Berechtigungen, um eine Rundmail zu senden.')); + } + return; + } + if (!in_array($this->room_selection, ['search', 'clipboard'])) { PageLayout::postError( _('Die Raumauswahl ist ungültig!') @@ -227,7 +254,9 @@ class Resources_MessagesController extends AuthenticatedController PageLayout::postInfo( _('Für die gewählten Räume gibt es keine Empfänger!') ); - $this->relocate('resources/messages/index'); + if (!Request::isDialog()) { + $this->relocate('resources/messages/index'); + } return; } |
