From: sam_marshall Date: Tue, 10 Oct 2006 17:23:24 +0000 (+0000) Subject: Wiki: fixed issue if you tried to set a page content to completely blank (you need... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=352b1adb8c3cd192a1eb21dd1ebb35150a6b27ea;p=moodle.git Wiki: fixed issue if you tried to set a page content to completely blank (you need to switch the html editor into text mode to get this, otherwise it puts in
, but one of our QA people managed to find it anyway). Also corrected whitespace on some of the lock stuff (weird - how did those tabs get in there? hrm) --- diff --git a/mod/wiki/view.php b/mod/wiki/view.php index 759273de6a..0a9b0c78d1 100644 --- a/mod/wiki/view.php +++ b/mod/wiki/view.php @@ -69,16 +69,23 @@ // 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.