3 Places an more intrusive warning message in front of the edit screen,
4 if someone else activated the edit box recently (as determined by lock
5 file). An unlock button will be present to override it (spiders may
6 activate the locking feature).
7 This is a poor replacement for the 'patchsaving' extension, and you
8 should normally rather use plugins/edit/warn instead of the lock
9 extension (both use same lock files). Needs EWIKI_TMP set correctly.
12 @title: concurrent edit locking
13 @desc: like the edit-warn extensions, this could be used where 'patchsaving' didn't work
16 $ewiki_plugins["edit_hook"][] = "ewiki_edit_lock";
18 function ewiki_edit_lock($id, &$data, $action) {
20 $keep = 500; // in seconds
24 if (!file_exists($dir = EWIKI_TMP."/edit.d/")) {
29 $lockfile = $dir . ewiki_lowercase($id) . ".lock";
31 if (file_exists($lockfile)) {
32 $time = filemtime($lockfile);
36 if ($_REQUEST["edit_unlock"]) {
41 #-- automatic unlock on save
42 elseif ($_SERVER["REQUEST_METHOD"] == "POST") {
48 if ($time + $keep > time()) {
49 $o = ewiki_t("<p class=\"system-message\"><b>_{Warning}</b>:"
50 . " _{This page is currently being edited by someone else},"
51 . " _{and therefore locked currently}."
53 . '<form action="'.$_SERVER[REQUEST_URI].'" method="POST">'
54 . '<input type="id" name="'."$action/$id".'">'
55 . '<input type="submit" name="edit_unlock" value="_{unlock}">'