|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 00003 // This file is part of Moodle - http://moodle.org/ 00004 // 00005 // Moodle is free software: you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation, either version 3 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // Moodle is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00017 00027 require_once(dirname(dirname(dirname(__FILE__))).'/config.php'); 00028 require_once(dirname(__FILE__).'/locallib.php'); 00029 00030 $cmid = required_param('cmid', PARAM_INT); // course module 00031 $phase = required_param('phase', PARAM_INT); // the code of the new phase 00032 $confirm = optional_param('confirm', false, PARAM_BOOL); // confirmation 00033 00034 $cm = get_coursemodule_from_id('workshop', $cmid, 0, false, MUST_EXIST); 00035 $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); 00036 $workshop = $DB->get_record('workshop', array('id' => $cm->instance), '*', MUST_EXIST); 00037 $workshop = new workshop($workshop, $cm, $course); 00038 00039 $PAGE->set_url($workshop->switchphase_url($phase), array('cmid' => $cmid, 'phase' => $phase)); 00040 00041 require_login($course, false, $cm); 00042 require_capability('mod/workshop:switchphase', $PAGE->context); 00043 00044 if ($confirm) { 00045 if (!confirm_sesskey()) { 00046 throw new moodle_exception('confirmsesskeybad'); 00047 } 00048 if (!$workshop->switch_phase($phase)) { 00049 print_error('errorswitchingphase', 'workshop', $workshop->view_url()); 00050 } 00051 $workshop->log('update switch phase', $workshop->view_url(), $workshop->phase); 00052 redirect($workshop->view_url()); 00053 } 00054 00055 $PAGE->set_title($workshop->name); 00056 $PAGE->set_heading($course->fullname); 00057 $PAGE->navbar->add(get_string('switchingphase', 'workshop')); 00058 00059 // 00060 // Output starts here 00061 // 00062 echo $OUTPUT->header(); 00063 echo $OUTPUT->confirm(get_string('switchphase' . $phase . 'info', 'workshop'), 00064 new moodle_url($PAGE->url, array('confirm' => 1)), $workshop->view_url()); 00065 echo $OUTPUT->footer();