aboutsummaryrefslogtreecommitdiff
path: root/app/controllers/course/change_view.php
blob: 58cc9957880b4821964df53475643d99153f8e61 (plain)
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
<?php
/**
 * change_view.php - contains Course_ChangeViewController
 *
 * This controller realises a redirector for administrative pages
 *
 * 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      Thomas Hackl <thomas.hackl@uni-passau.de>
 * @license     http://www.gnu.org/licenses/gpl-2.0.html GPL version 2
 * @category    Stud.IP
 * @since       2.2
 */
class Course_ChangeViewController extends AuthenticatedController
{
    // see Trails_Controller#before_filter
    public function before_filter(&$action, &$args)
    {
        parent::before_filter($action, $args);

        $this->course_id = Course::findCurrent()->id;
    }

    /**
     * Sets the current course into participant view.
     * Only available for tutor upwards.
     *
     * @throws Trails_Exception Someone with unfitting rights tried to call here.
     */
    public function set_changed_view_action()
    {
        if (!$GLOBALS['perm']->have_studip_perm('tutor', $this->course_id)) {
            throw new AccessDeniedException();
        }
        $_SESSION["seminar_change_view_{$this->course_id}"] = 'autor';
        $this->relocate('course/overview');
    }

    /**
     * Resets a course currently in participant view to normal view
     * with real rights.
     *
     * @throws Trails_Exception Someone with unfitting rights tried to call here.
     */
    public function reset_changed_view_action()
    {
        unset($_SESSION["seminar_change_view_{$this->course_id}"]);
        $this->relocate('course/management');
    }
}