]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-8621 Fixed wiki locking
authorsam_marshall <sam_marshall>
Thu, 22 Feb 2007 17:46:27 +0000 (17:46 +0000)
committersam_marshall <sam_marshall>
Thu, 22 Feb 2007 17:46:27 +0000 (17:46 +0000)
mod/wiki/lib.php
mod/wiki/view.php

index 41d890662abf88b353646d0e13fab0640e5f205d..cd73d9eba68725e3f24c23c0d48fd2136258be44 100644 (file)
@@ -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);
 }
 
 /**
index 49cb7e219fbdb376e5b18153e12d4de240839c72..02d75639e6858aacb555c96b072f9e7a49d3266a 100644 (file)
@@ -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
 ";
             }
         } 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);
 </script>
 <noscript><p>
 $strnojslockwarning
 </p></noscript>
 ";
-            
             // Print editor etc
             print $content;
         }