1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
<?php
/**
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* @author Moritz Strohm <strohm@data-quest.de>
* @license http://www.gnu.org/licenses/gpl-2.0.html GPL version 2
* @category Stud.IP
* @since 3.5.alpha-svn
*/
class ArchiveController extends AuthenticatedController
{
public function before_filter(&$action, &$args)
{
$sections = [
'overview' => _('Übersicht'),
'forum' => _('Forum'),
'wiki' => _('Wiki'),
];
parent::before_filter($action, $args);
$navigation = new Navigation(_('Archiv'), $this->url_for('archive'));
foreach ($sections as $key => $label) {
$navigation->addSubNavigation($key, new Navigation(
$label,
$this->url_for("archive/{$key}/{$args[0]}")
));
}
Navigation::addItem('/archive', $navigation);
// Set page title, activate appropriate navigation item and load course
PageLayout::setTitle(_('Veranstaltungsarchiv'));
if (Navigation::hasItem("/archive/{$action}")) {
Navigation::activateItem("/archive/{$action}");
}
// Setup sidebar
$search = new SearchWidget(URLHelper::getURL('dispatch.php/search/archive'));
$search->addNeedle(
_('Suche im Veranstaltungsarchiv'),
'criteria',
_('Name der archivierten Veranstaltung')
);
Sidebar::get()->addWidget($search);
}
public function overview_action($course_id)
{
$this->course = ArchivedCourse::find($course_id);
}
public function forum_action($course_id)
{
$this->course = ArchivedCourse::find($course_id);
}
public function wiki_action($course_id)
{
$this->course = ArchivedCourse::find($course_id);
}
public function delete_action($course_id)
{
if (!Request::isPost()) {
throw new MethodNotAllowedException();
}
if (archiv_check_perm($course_id) !== 'admin') {
throw new AccessDeniedException();
}
$course = ArchivedCourse::find($course_id);
if ($course) {
$course_name = $course->name;
if ($course->delete()) {
PageLayout::postSuccess(sprintf(
_('Die Veranstaltung %1$s wurde aus dem Archiv gelöscht!'),
htmlReady($course_name)
));
} else {
PageLayout::postError(sprintf(
_('Fehler beim Löschen der Veranstaltung %1$s aus dem Archiv!'),
htmlReady($course_name)
));
}
}
// This action is called from the course archive search page.
// Because of that we should redirect to that page when this action is
// finished:
$this->redirect(URLHelper::getURL('dispatch.php/search/archive', [
'criteria' => Request::get('criteria'),
'teacher' => Request::get('teacher'),
'semester' => Request::get('semester'),
'institute' => Request::get('institute'),
'my_courses_only' => Request::int('my_courses_only'),
]));
}
}
|