forked from sbourget/moodle-mod_pcast
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapproveepisode.php
60 lines (47 loc) · 2.21 KB
/
approveepisode.php
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
<?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/>.
/**
* Page for approving pcast episodes
*
* @package mod_pcast
* @copyright 2010 Stephen Bourget
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once(dirname(__FILE__) . '/../../config.php');
require_once(dirname(__FILE__).'/lib.php');
require_once(dirname(__FILE__).'/locallib.php');
$eid = required_param('eid', PARAM_INT); // Episode ID
$mode = optional_param('mode', PCAST_APPROVAL_VIEW, PARAM_ALPHANUM);
$hook = optional_param('hook', 'ALL', PARAM_CLEAN);
$episode = $DB->get_record('pcast_episodes', array('id'=> $eid), '*', MUST_EXIST);
$pcast = $DB->get_record('pcast', array('id'=> $episode->pcastid), '*', MUST_EXIST);
$cm = get_coursemodule_from_instance('pcast', $pcast->id, 0, false, MUST_EXIST);
$course = $DB->get_record('course', array('id'=> $cm->course), '*', MUST_EXIST);
require_login($course, false, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_capability('mod/pcast:approve', $context);
$url = new moodle_url('/mod/pcast/approveepisode.php', array('eid'=>$eid, 'mode'=>$mode, 'hook'=>$hook));
$PAGE->set_url($url);
$PAGE->set_context($context);
if (!$episode->approved and confirm_sesskey()) {
$newepisode = new object();
$newepisode->id = $episode->id;
$newepisode->approved = 1;
$newepisode->timemodified = time();
$DB->update_record("pcast_episodes", $newepisode);
add_to_log($course->id, "pcast", "approve episode", "showepisode.php?eid=$eid", "$eid", $cm->id);
}
redirect("view.php?id=$cm->id&mode=$mode&hook=$hook");