diff --git a/app/controllers/consultation/admin.php b/app/controllers/consultation/admin.php index 47d2ecdda94ae323eff01a537de5ccdd3785b78b..f15136a32158444fcde9ca22f79b29dfebd8897d 100644 --- a/app/controllers/consultation/admin.php +++ b/app/controllers/consultation/admin.php @@ -16,6 +16,10 @@ class Consultation_AdminController extends ConsultationController { parent::before_filter($action, $args); + if (!$this->range || $action === 'not_found') { + return; + } + if (!$this->range->isEditableByUser()) { throw new AccessDeniedException(); } diff --git a/app/controllers/consultation/consultation_controller.php b/app/controllers/consultation/consultation_controller.php index 1c25a9bddc75bee80a4fab2e25dbce6d45420209..d6927aff1818d32f97ea9b89200f57f9cd27d222 100644 --- a/app/controllers/consultation/consultation_controller.php +++ b/app/controllers/consultation/consultation_controller.php @@ -12,14 +12,21 @@ abstract class ConsultationController extends AuthenticatedController { parent::before_filter($action, $args); + $type = 'person'; if (Request::submitted('username')) { $this->range = User::findByUsername(Request::username('username')); } elseif (Request::submitted('cid')) { $this->range = Context::get(); + $type = 'object'; } else { $this->range = $GLOBALS['user']->getAuthenticatedUser(); } + if (!$this->range) { + $this->redirect($this->not_foundURL($type)); + return; + } + if ($this->range instanceof User) { URLHelper::addLinkParam('username', $this->range->username); } elseif ($this->range instanceof Course || $this->range instanceof Institute) { @@ -47,6 +54,12 @@ abstract class ConsultationController extends AuthenticatedController }; } + public function not_found_action(string $type): void + { + $this->type = $type; + $this->render_template('consultation/not_found', $this->layout); + } + protected function activateNavigation($path) { $path = ltrim($path, '/'); diff --git a/app/controllers/consultation/overview.php b/app/controllers/consultation/overview.php index e7456da5d9a78cf778c9000b5595ab13f13eb5e9..58d90132613a08382e9f0770633bc6fe61fb4ea3 100644 --- a/app/controllers/consultation/overview.php +++ b/app/controllers/consultation/overview.php @@ -14,6 +14,10 @@ class Consultation_OverviewController extends ConsultationController { parent::before_filter($action, $args); + if (!$this->range) { + return; + } + if ($this->range->isEditableByUser()) { $this->redirect('consultation/admin'); } diff --git a/app/views/consultation/not_found.php b/app/views/consultation/not_found.php new file mode 100644 index 0000000000000000000000000000000000000000..71cd0403d479e9647e6279f4ea10b3dd7b4cc8f4 --- /dev/null +++ b/app/views/consultation/not_found.php @@ -0,0 +1,10 @@ +<?php +/** + * @var string $type + */ +?> +<?= MessageBox::error( + $type === 'person' + ? _('Die Person, für die die Sprechstunden angezeigt werden sollen, ist nicht mehr vorhanden') + : _('Das Objekt, für das die Sprechstunden angezeigt werden sollen, ist nicht mehr vorhanden') +)->hideClose() ?>