From 6022c4f56033a368931a64172bd3cb1203cd2b12 Mon Sep 17 00:00:00 2001 From: sam_marshall Date: Thu, 22 Feb 2007 17:46:27 +0000 Subject: [PATCH] MDL-8621 Fixed wiki locking --- mod/wiki/lib.php | 7 +++++-- mod/wiki/view.php | 7 +++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/mod/wiki/lib.php b/mod/wiki/lib.php index 41d890662a..cd73d9eba6 100644 --- a/mod/wiki/lib.php +++ b/mod/wiki/lib.php @@ -1585,7 +1585,8 @@ function wiki_get_post_actions() { * @param string $pagename Name of page. * @return array Two-element array with a boolean true (if lock has been obtained) * or false (if lock was held by somebody else). If lock was held by someone else, - * the values of the wiki_locks entry are held in the second element. + * the values of the wiki_locks entry are held in the second element; if lock was + * held by current user then the the second element has a member ->id only. */ function wiki_obtain_lock($wikiid,$pagename) { global $USER; @@ -1627,7 +1628,9 @@ function wiki_obtain_lock($wikiid,$pagename) { $_SESSION[SESSION_WIKI_LOCKS]=array(); } $_SESSION[SESSION_WIKI_LOCKS][$wikiid.'_'.$pagename]=$lockid; - return array(true,null); + $lockdata=new StdClass; + $lockdata->id=$lockid; + return array(true,$lockdata); } /** diff --git a/mod/wiki/view.php b/mod/wiki/view.php index 49cb7e219f..02d75639e6 100644 --- a/mod/wiki/view.php +++ b/mod/wiki/view.php @@ -8,6 +8,7 @@ require_once("lib.php"); #require_once("$CFG->dirroot/course/lib.php"); // For side-blocks require_once($CFG->libdir . '/ajax/ajaxlib.php'); + require_js(array('yui_yahoo','yui_connection')); $ewiki_action = optional_param('ewiki_action', '', PARAM_ALPHA); // Action on Wiki-Page $id = optional_param('id', 0, PARAM_INT); // Course Module ID, or @@ -448,8 +449,7 @@ "; } } else { - // OK, the page is now locked to us. Put in the AJAX for keeping the lock - print require_js(array('yui_yahoo','yui_connection')); + // OK, the page is now locked to us. Put in the AJAX for keeping the lock $strlockcancelled=get_string('lockcancelled','wiki'); $strnojslockwarning=get_string('nojslockwarning','wiki'); $intervalms=WIKI_LOCK_RECONFIRM*1000; @@ -469,14 +469,13 @@ function handleFailure(o) { } intervalID=setInterval(function() { YAHOO.util.Connect.asyncRequest('POST','confirmlock.php', - {success:handleResponse,failure:handleFailure},'lockid=$lockid'); + {success:handleResponse,failure:handleFailure},'lockid={$lock->id}'); },$intervalms); "; - // Print editor etc print $content; } -- 2.39.5