]> git.mjollnir.org Git - moodle.git/commitdiff
Bug #5960 - can't delete or edit comments; merged from MOODLE_16_STABLE
authorskodak <skodak>
Thu, 29 Jun 2006 06:48:31 +0000 (06:48 +0000)
committerskodak <skodak>
Thu, 29 Jun 2006 06:48:31 +0000 (06:48 +0000)
mod/data/comment.php

index 594caaf20f6bd339c7580e141fbe58d270831da2..28ec4b9e2f441534fc8b3b1a01a3c1d1fa179f58 100755 (executable)
@@ -1,4 +1,4 @@
-<?php
+<?php  // $Id$
 
     require_once('../../config.php');
     require_once('lib.php');
@@ -11,7 +11,7 @@
     $mode = optional_param('mode','',PARAM_ALPHA);
     $commentid = optional_param('commentid','',PARAM_INT);
     $confirm = optional_param('confirm','',PARAM_INT);
-    $commentcontent = optional_param('commentcontent','',PARAM_NOTAGS);
+    $commentcontent = trim(optional_param('commentcontent','',PARAM_NOTAGS));
     $template = optional_param('template','',PARAM_ALPHA);
 
 
         }
     }
 
-    $commentcontent = trim($commentcontent);
-    if (empty($commentcontent)) {
-        redirect('view.php?rid='.$record->id.'&amp;page='.$page, get_string('commentempty', 'data'));
-    }
-
     switch ($mode) {
         case 'add':
+            if (empty($commentcontent)) {
+                redirect('view.php?rid='.$record->id.'&amp;page='.$page, get_string('commentempty', 'data'));
+            }
+
             $newcomment = new object;
             $newcomment->userid = $USER->id;
             $newcomment->created = time();
         break;
         
         case 'editcommit':  //update db
+            if (empty($commentcontent)) {
+                redirect('view.php?rid='.$record->id.'&amp;page='.$page, get_string('commentempty', 'data'));
+            }
+
             if ($comment) {
                 $newcomment = new object;
                 $newcomment->id = $comment->id;