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
13 require_once('../../config.php');
15 $id=required_param('id',PARAM_INT
);
16 $page=required_param('page',PARAM_RAW
);
18 if (! $cm = get_coursemodule_from_id('wiki', $id)) {
19 error("Course Module ID was incorrect");
21 if (! $course = get_record("course", "id", $cm->course
)) {
22 error("Course is misconfigured");
24 if (! $wiki = get_record("wiki", "id", $cm->instance
)) {
25 error("Course module is incorrect");
28 if(!confirm_sesskey()) {
29 error("Session key not set");
31 if(!data_submitted()) {
32 error("Only POST requests accepted");
35 require_course_login($course, true, $cm);
37 $modcontext = get_context_instance(CONTEXT_MODULE
, $cm->id
);
38 if(!has_capability('mod/wiki:overridelock', $modcontext)) {
39 error("You do not have the capability to override editing locks");
42 $actions = explode('/', $page,2);
43 if(count($actions)!=2) {
44 error("Unsupported page value");
46 $pagename=addslashes($actions[1]);
47 if(!delete_records('wiki_locks','pagename',$pagename,'wikiid', $wiki->id
)) {
48 error('Unable to delete lock record');
51 redirect("view.php?id=$id&page=".urlencode($page));