Permalink
Browse files

Wiki: fixed issue if you tried to set a page content to completely bl…

…ank (you need to switch the html editor into text mode to get this, otherwise it puts in <br/>, 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)
  • Loading branch information...
1 parent 1bece91 commit e364a5368d738edbdb9af985c931a4b1734c8842 sam_marshall committed Oct 10, 2006
Showing with 16 additions and 9 deletions.
  1. +16 −9 mod/wiki/view.php
View
25 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.

0 comments on commit e364a53

Please sign in to comment.