mirrored from git://git.moodle.org/moodle.git
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wiki enhancement: edit locking (uses AJAX)
- Loading branch information
sam_marshall
committed
Sep 25, 2006
1 parent
f775a51
commit 22e846c
Showing
10 changed files
with
291 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
/** | ||
* This script is called through AJAX. It confirms that a user is still | ||
* trying to edit a page that they have locked (they haven't closed | ||
* their browser window or something). | ||
* | ||
* @copyright © 2006 The Open University | ||
* @author s.marshall@open.ac.uk | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License | ||
* @package wiki | ||
*//** */ | ||
|
||
require_once("../../config.php"); | ||
|
||
header('Content-Type: text/plain'); | ||
|
||
if(empty($_POST['lockid'])) { | ||
print 'noid'; | ||
exit; | ||
} | ||
|
||
$lockid=(int)$_POST['lockid']; | ||
if($lock=get_record('wiki_locks','id',$lockid)) { | ||
$lock->lockedseen=time(); | ||
update_record('wiki_locks',$lock); | ||
print 'ok'; | ||
} else { | ||
print 'cancel'; // Tells user their lock has been cancelled. | ||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
/** | ||
* Handles what happens when a user with appropriate permission attempts to | ||
* override a wiki page editing lock. | ||
* | ||
* @copyright © 2006 The Open University | ||
* @author s.marshall@open.ac.uk | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License | ||
* @package package_name | ||
*//** */ | ||
|
||
require_once('../../config.php'); | ||
|
||
$id=required_param('id',PARAM_INT); | ||
$page=required_param('page',PARAM_RAW); | ||
|
||
if (! $cm = get_coursemodule_from_id('wiki', $id)) { | ||
error("Course Module ID was incorrect"); | ||
} | ||
if (! $course = get_record("course", "id", $cm->course)) { | ||
error("Course is misconfigured"); | ||
} | ||
if (! $wiki = get_record("wiki", "id", $cm->instance)) { | ||
error("Course module is incorrect"); | ||
} | ||
|
||
if(!confirm_sesskey()) { | ||
error("Session key not set"); | ||
} | ||
if(!data_submitted()) { | ||
error("Only POST requests accepted"); | ||
} | ||
|
||
require_course_login($course, true, $cm); | ||
|
||
$modcontext = get_context_instance(CONTEXT_MODULE, $cm->id); | ||
if(!has_capability('mod/wiki:overridelock', $modcontext)) { | ||
error("You do not have the capability to override editing locks"); | ||
} | ||
|
||
$actions = explode('/', $page,2); | ||
if(count($actions)!=2) { | ||
error("Unsupported page value"); | ||
} | ||
$pagename=addslashes($actions[1]); | ||
if(!delete_records('wiki_locks','pagename',$pagename,'wikiid', $wiki->id)) { | ||
error('Unable to delete lock record'); | ||
} | ||
|
||
redirect("view.php?id=$id&page=".urlencode($page)); | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.