Skip to content
Snippets Groups Projects
Commit ad841e52 authored by David Siegfried's avatar David Siegfried Committed by Elmar Ludwig
Browse files

prevent php-errors, closes #1339

Closes #1339

Merge request studip/studip!873
parent 31adcf29
No related branches found
No related tags found
No related merge requests found
...@@ -88,7 +88,7 @@ class Resources_RoomPlanningController extends AuthenticatedController ...@@ -88,7 +88,7 @@ class Resources_RoomPlanningController extends AuthenticatedController
PageLayout::setTitle(_('Belegungsplan')); PageLayout::setTitle(_('Belegungsplan'));
$current_user = User::findCurrent(); $this->user = User::findCurrent();
$new_resource_id = Request::get('new_resource_id'); $new_resource_id = Request::get('new_resource_id');
if ($new_resource_id) { if ($new_resource_id) {
...@@ -101,11 +101,11 @@ class Resources_RoomPlanningController extends AuthenticatedController ...@@ -101,11 +101,11 @@ class Resources_RoomPlanningController extends AuthenticatedController
$resource_id = Request::get('resource_id'); $resource_id = Request::get('resource_id');
} }
$this->rooms = null; $this->rooms = null;
if ($current_user instanceof User) { if ($this->user instanceof User) {
$this->rooms = RoomManager::getUserRooms($current_user); $this->rooms = RoomManager::getUserRooms($this->user);
} }
if (!$resource_id) { if (!$resource_id) {
if ($current_user instanceof User) { if ($this->user instanceof User) {
//Get a list of all available rooms and let the user select //Get a list of all available rooms and let the user select
//one of those. //one of those.
$this->selection_link_template = $this->selection_link_template =
...@@ -147,23 +147,23 @@ class Resources_RoomPlanningController extends AuthenticatedController ...@@ -147,23 +147,23 @@ class Resources_RoomPlanningController extends AuthenticatedController
$plan_is_visible = false; $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 ($current_user instanceof User) { if ($this->user instanceof User) {
if ($this->display_all_requests) { if ($this->display_all_requests) {
$plan_is_visible = $this->resource->userHasPermission( $plan_is_visible = $this->resource->userHasPermission(
$current_user, $this->user,
'autor' 'autor'
); );
} else { } else {
$plan_is_visible = $this->resource->bookingPlanVisibleForUser($current_user); $plan_is_visible = $this->resource->bookingPlanVisibleForUser($this->user);
} }
$this->anonymous_view = false; $this->anonymous_view = false;
if ($this->resource->userHasPermission($current_user, 'admin')) { if ($this->resource->userHasPermission($this->user, 'admin')) {
$this->booking_types[] = 3; $this->booking_types[] = 3;
} }
} else { } else {
//If the plan visibility cannot be determined by the user, //If the plan visibility cannot be determined by the user,
//we can still check if the plan is visible to the public: //we can still check if the plan is visible to the public:
$plan_is_visible = $this->resource->bookingPlanVisibleForUser($current_user); $plan_is_visible = $this->resource->bookingPlanVisibleForUser($this->user);
} }
if (!$plan_is_visible) { if (!$plan_is_visible) {
throw new AccessDeniedException( throw new AccessDeniedException(
...@@ -173,11 +173,9 @@ class Resources_RoomPlanningController extends AuthenticatedController ...@@ -173,11 +173,9 @@ class Resources_RoomPlanningController extends AuthenticatedController
$this->user_has_request_permissions = false; $this->user_has_request_permissions = false;
$this->user_has_booking_permissions = false; $this->user_has_booking_permissions = false;
if ($current_user instanceof User) { if ($this->user instanceof User) {
$this->user_has_request_permissions = $this->resource->userHasRequestRights($current_user); $this->user_has_request_permissions = $this->resource->userHasRequestRights($this->user);
$this->user_has_booking_permissions = $this->resource->userHasBookingRights( $this->user_has_booking_permissions = $this->resource->userHasBookingRights($this->user);
$current_user
);
} }
if (!$this->user_has_booking_permissions && $this->display_all_requests) { if (!$this->user_has_booking_permissions && $this->display_all_requests) {
...@@ -217,7 +215,7 @@ class Resources_RoomPlanningController extends AuthenticatedController ...@@ -217,7 +215,7 @@ class Resources_RoomPlanningController extends AuthenticatedController
$views = new ViewsWidget(); $views = new ViewsWidget();
if ($GLOBALS['user']->id && ($GLOBALS['user']->id != 'nobody')) { if ($GLOBALS['user']->id && ($GLOBALS['user']->id != 'nobody')) {
if ($this->resource->userHasPermission($current_user)) { if ($this->resource->userHasPermission($this->user)) {
$views->addLink( $views->addLink(
_('Standard Zeitfenster'), _('Standard Zeitfenster'),
URLHelper::getURL( URLHelper::getURL(
...@@ -298,7 +296,7 @@ class Resources_RoomPlanningController extends AuthenticatedController ...@@ -298,7 +296,7 @@ class Resources_RoomPlanningController extends AuthenticatedController
Icon::create('add') Icon::create('add')
)->asDialog('size=auto'); )->asDialog('size=auto');
} }
if ($this->resource->userHasPermission($current_user)) { if ($this->resource->userHasPermission($this->user)) {
$actions->addLink( $actions->addLink(
_('Belegungsplan drucken'), _('Belegungsplan drucken'),
'javascript:void(window.print());', 'javascript:void(window.print());',
...@@ -361,10 +359,10 @@ class Resources_RoomPlanningController extends AuthenticatedController ...@@ -361,10 +359,10 @@ class Resources_RoomPlanningController extends AuthenticatedController
] ]
); );
if ($current_user instanceof User) { if ($this->user instanceof User) {
//No check necessary here: This part of the controller is only called //No check necessary here: This part of the controller is only called
//when a room has been selected before. //when a room has been selected before.
if (($this->resource instanceof Room) && RoomManager::userHasRooms($current_user)) { if (($this->resource instanceof Room) && RoomManager::userHasRooms($this->user)) {
$actions->addLink( $actions->addLink(
_('Anderen Raum wählen'), _('Anderen Raum wählen'),
URLHelper::getURL( URLHelper::getURL(
...@@ -409,8 +407,8 @@ class Resources_RoomPlanningController extends AuthenticatedController ...@@ -409,8 +407,8 @@ class Resources_RoomPlanningController extends AuthenticatedController
] ]
]; ];
if (!$this->anonymous_view) { if (!$this->anonymous_view) {
if ($current_user instanceof User) { if ($this->user instanceof User) {
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,
......
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