Skip to content
Snippets Groups Projects
Commit ac94824e authored by Jan-Hendrik Willms's avatar Jan-Hendrik Willms
Browse files

fixes #3477

Closes #3477

Merge request studip/studip!2373
parent 57e27803
No related branches found
No related tags found
No related merge requests found
...@@ -16,6 +16,10 @@ class Consultation_AdminController extends ConsultationController ...@@ -16,6 +16,10 @@ class Consultation_AdminController extends ConsultationController
{ {
parent::before_filter($action, $args); parent::before_filter($action, $args);
if (!$this->range || $action === 'not_found') {
return;
}
if (!$this->range->isEditableByUser()) { if (!$this->range->isEditableByUser()) {
$this->redirect('consultation/overview'); $this->redirect('consultation/overview');
return; return;
......
...@@ -12,14 +12,21 @@ abstract class ConsultationController extends AuthenticatedController ...@@ -12,14 +12,21 @@ abstract class ConsultationController extends AuthenticatedController
{ {
parent::before_filter($action, $args); parent::before_filter($action, $args);
$type = 'person';
if (Request::submitted('username')) { if (Request::submitted('username')) {
$this->range = User::findByUsername(Request::username('username')); $this->range = User::findByUsername(Request::username('username'));
} elseif (Request::submitted('cid')) { } elseif (Request::submitted('cid')) {
$this->range = Context::get(); $this->range = Context::get();
$type = 'object';
} else { } else {
$this->range = $GLOBALS['user']->getAuthenticatedUser(); $this->range = $GLOBALS['user']->getAuthenticatedUser();
} }
if (!$this->range) {
$this->redirect($this->not_foundURL($type));
return;
}
if ($this->range instanceof User) { if ($this->range instanceof User) {
URLHelper::addLinkParam('username', $this->range->username); URLHelper::addLinkParam('username', $this->range->username);
} elseif ($this->range instanceof Course || $this->range instanceof Institute) { } elseif ($this->range instanceof Course || $this->range instanceof Institute) {
...@@ -47,6 +54,12 @@ abstract class ConsultationController extends AuthenticatedController ...@@ -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) protected function activateNavigation($path)
{ {
$path = ltrim($path, '/'); $path = ltrim($path, '/');
......
...@@ -14,6 +14,10 @@ class Consultation_OverviewController extends ConsultationController ...@@ -14,6 +14,10 @@ class Consultation_OverviewController extends ConsultationController
{ {
parent::before_filter($action, $args); parent::before_filter($action, $args);
if (!$this->range) {
return;
}
if ($this->range->isEditableByUser()) { if ($this->range->isEditableByUser()) {
$this->redirect('consultation/admin'); $this->redirect('consultation/admin');
return; return;
......
<?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() ?>
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