]> git.mjollnir.org Git - moodle.git/commitdiff
Wiki: fixed issue if you tried to set a page content to completely blank (you need...
authorsam_marshall <sam_marshall>
Tue, 10 Oct 2006 17:23:24 +0000 (17:23 +0000)
committersam_marshall <sam_marshall>
Tue, 10 Oct 2006 17:23:24 +0000 (17:23 +0000)
Also corrected whitespace on some of the lock stuff (weird - how did those tabs get in there? hrm)

mod/wiki/view.php

index 759273de6af5b98f452ebdfda98a2f2f92a3b2ce..0a9b0c78d1a27622b467d9781702e0c2682f258a 100644 (file)
     
        // Remove lock when we go to another wiki page (such as the cancel page)
     if(!$reallyedit) {
-               wiki_release_lock($wiki->id,$pagename);
+        wiki_release_lock($wiki->id,$pagename);
     }
-    
-    // We must have the edit lock in order to be permitted to save    
-    if(!empty($_POST['content'])) {
-           list($ok,$lock)=wiki_obtain_lock($wiki->id,$pagename);
-           if(!$ok) {
-                       $strsavenolock=get_string('savenolock','wiki');
-                   error($strsavenolock,$CFG->wwwroot.'/mod/wiki/view.php?id='.$cm->id.'&page=view/'.urlencode($pagename));
-           }
+    if(array_key_exists('content',$_POST)) {
+        // Do not allow blank content because it causes problems (the wiki decides
+        // the page should automatically go into edit mode, but Moodle doesn't realise
+        // this and filters out the JS)
+        if($_POST['content']=='') {
+            $_POST['content']="\n";
+            $_REQUEST['content']="\n";
+        }
+
+        // We must have the edit lock in order to be permitted to save    
+       list($ok,$lock)=wiki_obtain_lock($wiki->id,$pagename);
+       if(!$ok) {
+           $strsavenolock=get_string('savenolock','wiki');
+           error($strsavenolock,$CFG->wwwroot.'/mod/wiki/view.php?id='.$cm->id.'&page=view/'.urlencode($pagename));
+       }
     }
     
     /// Add the course module 'groupmode' to the wiki object, for easy access.