-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathforward_2nd_level.php
More file actions
93 lines (83 loc) · 3.58 KB
/
forward_2nd_level.php
File metadata and controls
93 lines (83 loc) · 3.58 KB
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
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle 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 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* @package local_edusupport
* @copyright 2020 Center for Learningmanagement (www.lernmanagement.at)
* @author Robert Schrenk
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// This file forwards a forum discussion to the 2nd level support.
require_once('../../config.php');
require_once($CFG->libdir . '/adminlib.php');
// phpcs:ignore Squiz.PHP.CommentedOutCode.Found
/* require_once($CFG->dirroot . '/local/edusupport/classes/lib.php'); */
$d = required_param('d', PARAM_INT);
$revoke = optional_param('revoke', 0, PARAM_BOOL);
$discussion = $DB->get_record('forum_discussions', ['id' => $d], '*', MUST_EXIST);
$courseid = $discussion->course;
$context = \context_course::instance($discussion->course);
$PAGE->set_context($context);
require_login($discussion->course);
$PAGE->set_url(new moodle_url('/local/edusupport/forward_2nd_level.php', ['d' => $d, 'revoke' => $revoke]));
$title = get_string(empty($revoke) ? 'issue_assign_nextlevel' : 'issue_revoke', 'local_edusupport');
$PAGE->set_title($title);
$PAGE->set_heading($title);
$todiscussion = new moodle_url('/mod/forum/discuss.php', ['d' => $d]);
if (!has_capability('local/edusupport:canforward2ndlevel', $context)) {
echo $OUTPUT->header();
echo $OUTPUT->render_from_template('local_edusupport/alert', [
'content' => get_string('missing_permission', 'local_edusupport'),
'type' => 'danger',
'url' => $todiscussion->__toString(),
]);
} else {
if (empty($revoke)) {
if (\local_edusupport\lib::set_2nd_level($d)) {
redirect($todiscussion->__toString());
echo $OUTPUT->header();
echo $OUTPUT->render_from_template('local_edusupport/alert', [
'content' => get_string('success'),
'type' => 'success',
'url' => $todiscussion->__toString(),
]);
} else {
echo $OUTPUT->header();
echo $OUTPUT->render_from_template('local_edusupport/alert', [
'content' => get_string('issue_assign_nextlevel:error', 'local_edusupport'),
'type' => 'danger',
'url' => $todiscussion->__toString(),
]);
}
} else {
if (\local_edusupport\lib::revoke_issue($d)) {
redirect($todiscussion->__toString());
echo $OUTPUT->header();
echo $OUTPUT->render_from_template('local_edusupport/alert', [
'content' => get_string('success'),
'type' => 'success',
'url' => $todiscussion->__toString(),
]);
} else {
echo $OUTPUT->header();
echo $OUTPUT->render_from_template('local_edusupport/alert', [
'content' => get_string('issue_revoke:error', 'local_edusupport'),
'type' => 'danger',
'url' => $todiscussion->__toString(),
]);
}
}
}
echo $OUTPUT->footer();