3 * Handles what happens when a user with appropriate permission attempts to
4 * override a wiki page editing lock.
6 * @copyright © 2006 The Open University
7 * @author s.marshall@open.ac.uk
8 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
9 * @package package_name
12 require_once('../../config.php');
14 $id=required_param('id',PARAM_INT
);
15 $page=required_param('page',PARAM_RAW
);
17 if (! $cm = get_coursemodule_from_id('wiki', $id)) {
18 error("Course Module ID was incorrect");
20 if (! $course = get_record("course", "id", $cm->course
)) {
21 error("Course is misconfigured");
23 if (! $wiki = get_record("wiki", "id", $cm->instance
)) {
24 error("Course module is incorrect");
27 if(!confirm_sesskey()) {
28 error("Session key not set");
30 if(!data_submitted()) {
31 error("Only POST requests accepted");
34 require_course_login($course, true, $cm);
36 $modcontext = get_context_instance(CONTEXT_MODULE
, $cm->id
);
37 if(!has_capability('mod/wiki:overridelock', $modcontext)) {
38 error("You do not have the capability to override editing locks");
41 $actions = explode('/', $page,2);
42 if(count($actions)!=2) {
43 error("Unsupported page value");
45 $pagename=addslashes($actions[1]);
46 if(!delete_records('wiki_locks','pagename',$pagename,'wikiid', $wiki->id
)) {
47 error('Unable to delete lock record');
50 redirect("view.php?id=$id&page=".urlencode($page));