Skip to content
Snippets Groups Projects
Commit 1970f66b authored by David Siegfried's avatar David Siegfried
Browse files

prevent php-warnings, closes #1782

Closes #1782

Merge request studip/studip!1164
parent 61d8f52b
No related branches found
No related tags found
No related merge requests found
...@@ -98,7 +98,8 @@ class Resources_RoomPlanningController extends AuthenticatedController ...@@ -98,7 +98,8 @@ class Resources_RoomPlanningController extends AuthenticatedController
'resources/room_planning/booking_plan/' . $new_resource_id 'resources/room_planning/booking_plan/' . $new_resource_id
); );
} }
$this->user_is_global_resource_admin = ResourceManager::userHasGlobalPermission($this->user, 'admin');
$this->show_global_admin_actions = $this->user_is_global_resource_admin;
if (!$resource_id) { if (!$resource_id) {
$resource_id = Request::get('resource_id'); $resource_id = Request::get('resource_id');
} }
...@@ -146,7 +147,6 @@ class Resources_RoomPlanningController extends AuthenticatedController ...@@ -146,7 +147,6 @@ class Resources_RoomPlanningController extends AuthenticatedController
//and the user has at least 'user' permissions on the resource. //and the user has at least 'user' permissions on the resource.
//The booking plan is also visible when the resource is a room //The booking plan is also visible when the resource is a room
//and its booking plan is publicly available. //and its booking plan is publicly available.
$plan_is_visible = false;
$this->anonymous_view = true; $this->anonymous_view = true;
$this->booking_types = [0, 1, 2]; $this->booking_types = [0, 1, 2];
if ($this->user instanceof User) { if ($this->user instanceof User) {
...@@ -450,11 +450,12 @@ class Resources_RoomPlanningController extends AuthenticatedController ...@@ -450,11 +450,12 @@ class Resources_RoomPlanningController extends AuthenticatedController
public function semester_plan_action($resource_id = null) public function semester_plan_action($resource_id = null)
{ {
$current_user = User::findCurrent(); $this->user = User::findCurrent();
if (!($current_user instanceof User)) { if (!($this->user instanceof User)) {
throw new AccessDeniedException(); throw new AccessDeniedException();
} }
$this->rooms = RoomManager::getUserRooms($current_user);
$this->rooms = RoomManager::getUserRooms($this->user);
$sidebar = Sidebar::get(); $sidebar = Sidebar::get();
if (Request::get('semester_id')) { if (Request::get('semester_id')) {
$this->semester = Semester::find(Request::get('semester_id')); $this->semester = Semester::find(Request::get('semester_id'));
...@@ -539,7 +540,7 @@ class Resources_RoomPlanningController extends AuthenticatedController ...@@ -539,7 +540,7 @@ class Resources_RoomPlanningController extends AuthenticatedController
//The booking plan is also visible when the resource is a room //The booking plan is also visible when the resource is a room
//and its booking plan is publicly available. //and its booking plan is publicly available.
$plan_is_visible = $plan_is_visible =
$this->resource->bookingPlanVisibleForUser($current_user); $this->resource->bookingPlanVisibleForUser($this->user);
if (!$plan_is_visible) { if (!$plan_is_visible) {
throw new AccessDeniedException( throw new AccessDeniedException(
...@@ -547,12 +548,11 @@ class Resources_RoomPlanningController extends AuthenticatedController ...@@ -547,12 +548,11 @@ class Resources_RoomPlanningController extends AuthenticatedController
); );
} }
$this->user_is_global_resource_admin = ResourceManager::userHasGlobalPermission($this->user, 'admin');
$this->user_has_booking_permissions = $this->resource->userHasBookingRights( $this->show_global_admin_actions = $this->user_is_global_resource_admin;
$current_user $this->user_has_booking_permissions = $this->resource->userHasBookingRights($this->user);
); $this->booking_types = [0, 1, 2];
$this->booking_types = [0, 1, 2]; if ($this->resource->userHasPermission($this->user, 'admin')) {
if ($this->resource->userHasPermission($current_user, 'admin')) {
$this->booking_types[] = 3; $this->booking_types[] = 3;
} }
if ($this->user_has_booking_permissions) { if ($this->user_has_booking_permissions) {
...@@ -737,7 +737,7 @@ class Resources_RoomPlanningController extends AuthenticatedController ...@@ -737,7 +737,7 @@ class Resources_RoomPlanningController extends AuthenticatedController
'text' => _('Reservierung') 'text' => _('Reservierung')
], ],
]; ];
if ($this->resource->userHasPermission($current_user, 'admin')) { if ($this->resource->userHasPermission($this->user, 'admin')) {
$planned_booking_colour = ColourValue::find('Resources.BookingPlan.PlannedBooking.Bg'); $planned_booking_colour = ColourValue::find('Resources.BookingPlan.PlannedBooking.Bg');
$this->table_keys[] = [ $this->table_keys[] = [
'colour' => (string)$planned_booking_colour, 'colour' => (string)$planned_booking_colour,
......
...@@ -350,7 +350,7 @@ class RoomManagement_OverviewController extends AuthenticatedController ...@@ -350,7 +350,7 @@ class RoomManagement_OverviewController extends AuthenticatedController
$search = new SearchWidget($this->roomsURL()); $search = new SearchWidget($this->roomsURL());
$search->setTitle(_('Raumsuche')); $search->setTitle(_('Raumsuche'));
$search->addNeedle(_('Gebäude oder Raum'), 'building_room_name', true); $search->addNeedle(_('Gebäude oder Raum'), 'building_room_name', true);
$sidebar->addWidget($search); $sidebar->addWidget($search);
// search for all rooms // search for all rooms
...@@ -360,7 +360,7 @@ class RoomManagement_OverviewController extends AuthenticatedController ...@@ -360,7 +360,7 @@ class RoomManagement_OverviewController extends AuthenticatedController
ON resources.parent_id = pr.id ON resources.parent_id = pr.id
WHERE rc.class_name IN ( :room_class_names )"; WHERE rc.class_name IN ( :room_class_names )";
// narrow down rooms according to search parameter (room or building name) // narrow down rooms according to search parameter (room or building name)
$rooms_sql_with_request = $rooms_sql . $rooms_sql_with_request = $rooms_sql .
"AND (resources.name LIKE CONCAT('%', :room_name, '%') "AND (resources.name LIKE CONCAT('%', :room_name, '%')
OR pr.name LIKE CONCAT('%', :building_name, '%'))"; OR pr.name LIKE CONCAT('%', :building_name, '%'))";
...@@ -380,7 +380,7 @@ class RoomManagement_OverviewController extends AuthenticatedController ...@@ -380,7 +380,7 @@ class RoomManagement_OverviewController extends AuthenticatedController
//the user has at least user permissions: //the user has at least user permissions:
$rooms_parameter['user_id'] = $this->user->id; $rooms_parameter['user_id'] = $this->user->id;
$rooms_parameter['now'] = time(); $rooms_parameter['now'] = time();
// did the user search for a specific room or building name? // did the user search for a specific room or building name?
$rooms_sql = Request::get('building_room_name') ? $rooms_sql_with_request : $rooms_sql; $rooms_sql = Request::get('building_room_name') ? $rooms_sql_with_request : $rooms_sql;
......
...@@ -122,7 +122,8 @@ ...@@ -122,7 +122,8 @@
[ [
'grouped_rooms' => RoomManager::groupRooms($rooms), 'grouped_rooms' => RoomManager::groupRooms($rooms),
'link_template' => $selection_link_template, 'link_template' => $selection_link_template,
'show_in_dialog' => false 'show_in_dialog' => false,
'show_global_admin_actions' => $show_global_admin_actions,
] ]
) ?> ) ?>
<? else: ?> <? else: ?>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment