diff --git a/app/controllers/consultation/admin.php b/app/controllers/consultation/admin.php index e5a709fa314eaaa43f47fbe39f0d2606dd5bc929..7acb7259291d3d7e8cd55c2b6306abf2cf39ebd5 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()) { $this->redirect('consultation/overview'); return; 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 c8085f2cd3a56d8e39bdacc1b7ceaed0a6dd5dcd..ce6cd316b0e97fa1c970fd418b8117b725bbcc6b 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'); return; 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() ?>