]> git.mjollnir.org Git - moodle.git/commitdiff
"MDL-14129, fix print_error"
authordongsheng <dongsheng>
Thu, 5 Jun 2008 08:42:35 +0000 (08:42 +0000)
committerdongsheng <dongsheng>
Thu, 5 Jun 2008 08:42:35 +0000 (08:42 +0000)
mod/glossary/comment.php
mod/glossary/export.php
mod/glossary/print.php
mod/glossary/rate.php

index fa6e690137f46d4d3d446ca4320fe692b9d10cbd..6c4adbfb43427254366d9f633b36fa668ae9b740 100644 (file)
@@ -7,7 +7,7 @@ require_once('comment_form.php');
 $action = optional_param('action','add', PARAM_ACTION);
 
 if (isguest()) {
-    print_error('Guests are not allowed to post comments!');
+    print_error('guestnocomment');
 }
 
 switch ($action) {
@@ -21,7 +21,7 @@ switch ($action) {
         glossary_comment_edit();
         die;
     default:
-        print_error('Incorrect action specified');
+        print_error('invalidaction');
 }
 
 /**
@@ -33,23 +33,23 @@ function glossary_comment_add() {
     $eid = optional_param('eid', 0, PARAM_INT); // Entry ID
 
     if (!$entry = get_record('glossary_entries', 'id', $eid)) {
-        print_error('Entry is incorrect');
+        print_error('invalidentry');
     }
     if (!$glossary = get_record('glossary', 'id', $entry->glossaryid)) {
-        print_error('Incorrect glossary');
+        print_error('invalidid', 'glossary');
     }
     if (!$cm = get_coursemodule_from_instance('glossary', $glossary->id)) {
-        print_error('Course Module ID was incorrect');
+        print_error('invalidcoursemodule');
     }
     if (!$course = get_record('course', 'id', $cm->course)) {
-        print_error('Course is misconfigured');
+        print_error('coursemisconf');
     }
 
     require_login($course->id, false, $cm);
     $context = get_context_instance(CONTEXT_MODULE, $cm->id);
     /// Both the configuration and capability must allow comments
     if (!$glossary->allowcomments or !has_capability('mod/glossary:comment', $context)) {
-        print_error('You can\'t add comments to this glossary!');
+        print_error('nopermissiontocomment');
     }
 
     $mform = new mod_glossary_comment_form();
@@ -70,7 +70,7 @@ function glossary_comment_add() {
         $newcomment->userid       = $USER->id;
 
         if (!$newcomment->id = insert_record('glossary_comments', $newcomment)) {
-            print_error('Could not insert this new comment');
+            print_error('cannotinsertcomment');
         } else {
             add_to_log($course->id, 'glossary', 'add comment', "comments.php?id=$cm->id&amp;eid=$entry->id", "$newcomment->id", $cm->id);
         }
@@ -94,28 +94,28 @@ function glossary_comment_delete() {
     $confirm = optional_param('confirm', 0, PARAM_BOOL); // delete confirmation
 
     if (!$comment = get_record('glossary_comments', 'id', $cid)) {
-        print_error('Comment is incorrect');
+        print_error('invalidcomment');
     }
     if (!$entry = get_record('glossary_entries', 'id', $comment->entryid)) {
-        print_error('Entry is incorrect');
+        print_error('invalidentry');
     }
     if (!$glossary = get_record('glossary', 'id', $entry->glossaryid)) {
-        print_error('Incorrect glossary');
+        print_error('invalidid', 'glossary');
     }
     if (!$cm = get_coursemodule_from_instance('glossary', $glossary->id)) {
-        print_error('Course Module ID was incorrect');
+        print_error('invalidcoursemodule');
     }
     if (!$course = get_record('course', 'id', $cm->course)) {
-        print_error('Course is misconfigured');
+        print_error('coursemisconf');
     }
 
     require_login($course->id, false, $cm);
     $context = get_context_instance(CONTEXT_MODULE, $cm->id);
     if (($comment->userid <> $USER->id) and !has_capability('mod/glossary:managecomments', $context)) {
-        print_error('You can\'t delete other people\'s comments!');
+        print_error('nopermissiontodelcomment', 'glossary');
     }
     if (!$glossary->allowcomments and !has_capability('mod/glossary:managecomments', $context)) {
-        print_error('You can\'t delete comments in this glossary!');
+        print_error('nopermissiontodelinglossary', 'glossary');
     }
 
     if (data_submitted() and $confirm) {
@@ -147,32 +147,32 @@ function glossary_comment_edit() {
     $cid = optional_param('cid', 0, PARAM_INT); // Comment ID
 
     if (!$comment = get_record('glossary_comments', 'id', $cid)) {
-        print_error('Comment is incorrect');
+        print_error('invalidcomment');
     }
     if (!$entry = get_record('glossary_entries', 'id', $comment->entryid)) {
-        print_error('Entry is incorrect');
+        print_error('invalidentry');
     }
     if (!$glossary = get_record('glossary', 'id', $entry->glossaryid)) {
-        print_error('Incorrect glossary');
+        print_error('invalidid', 'glossary');
     }
     if (!$cm = get_coursemodule_from_instance('glossary', $glossary->id)) {
-        print_error('Course Module ID was incorrect');
+        print_error('invalidcoursemodule');
     }
     if (!$course = get_record('course', 'id', $cm->course)) {
-        print_error('Course is misconfigured');
+        print_error('coursemisconf');
     }
 
     require_login($course->id, false, $cm);
     $context = get_context_instance(CONTEXT_MODULE, $cm->id);
     if (!$glossary->allowcomments and !has_capability('mod/glossary:managecomments', $context)) {
-        print_error('You can\'t edit comments in this glossary!');
+        print_error('nopermissiontodelinglossary', 'glossary');
     }
     if (($comment->userid <> $USER->id) and !has_capability('mod/glossary:managecomments', $context)) {
-        print_error('You can\'t edit other people\'s comments!');
+        print_error('nopermissiontoeditcomment');
     }
     $ineditperiod = ((time() - $comment->timemodified <  $CFG->maxeditingtime) || $glossary->editalways);
     if ((!has_capability('mod/glossary:comment', $context) or !$ineditperiod) and !has_capability('mod/glossary:managecomments', $context)) {
-        print_error('You can\'t edit this. Time expired!');
+        print_error('cannoteditcommentexpired');
     }
 
     $mform = new mod_glossary_comment_form();
@@ -189,7 +189,7 @@ function glossary_comment_edit() {
         $updatedcomment->timemodified = time();
 
         if (!update_record('glossary_comments', $updatedcomment)) {
-            print_error('Could not update this comment');
+            print_error('cannotupdatecomment');
         } else {
             add_to_log($course->id, 'glossary', 'update comment', "comments.php?id=$cm->id&amp;eid=$entry->id", "$updatedcomment->id",$cm->id);
         }
index ae77f1497eb635910db0e8789ffebf1d2b9bba6b..2fb96b1fb3ad878b180f791babec355ebd052ae2 100644 (file)
     $cat = optional_param('cat',0, PARAM_ALPHANUM);
 
     if (! $cm = get_coursemodule_from_id('glossary', $id)) {
-        print_error("Course Module ID was incorrect");
+        print_error('invalidcoursemodule');
     }
 
     if (! $course = get_record("course", "id", $cm->course)) {
-        print_error("Course is misconfigured");
+        print_error('coursemisconf');
     }
 
     if (! $glossary = get_record("glossary", "id", $cm->instance)) {
-        print_error("Course module is incorrect");
+        print_error('invalidid', 'glossary');
     }
 
     require_login($course->id, false, $cm);  
index 278659aaa20c7a2ab377912a21fe9708c2a3c1c3..c2390ba44c46e0010b0e9e320c4a9b278961ef8f 100644 (file)
     $sortkey = optional_param('sortkey','UPDATE', PARAM_ALPHA); // Sorting key
 
     if (! $cm = get_coursemodule_from_id('glossary', $id)) {
-        print_error("Course Module ID was incorrect");
+        print_error('invalidcoursemodule');
     }
 
     if (! $course = get_record("course", "id", $cm->course)) {
-        print_error("Course is misconfigured");
+        print_error('coursemisconf');
     }
 
     if (! $glossary = get_record("glossary", "id", $cm->instance)) {
-        print_error("Course module is incorrect");
+        print_error('invalidid', 'glossary');
     }
 
     if ( !$entriesbypage = $glossary->entbypage ) {
index c323e72c1c2614f8503705a5535e7e23c3a86f52..5e86bb0a45dcd86e39ce3ff023b0f96ae3fc9cda 100644 (file)
@@ -9,27 +9,27 @@
     $glossaryid = required_param('glossaryid', PARAM_INT); // The forum the rated posts are from
 
     if (!$glossary = get_record('glossary', 'id', $glossaryid)) {
-        print_error("Incorrect glossary id");
+        print_error('invalidid', 'glossary');
     }
 
     if (!$course = get_record('course', 'id', $glossary->course)) {
-        print_error("Course ID was incorrect");
+        print_error('invalidcourseid');
     }
 
     if (!$cm = get_coursemodule_from_instance('glossary', $glossary->id)) {
-        print_error("Course Module ID was incorrect");
+        print_error('invalidcoursemodule');
     }
 
     require_login($course, false, $cm);
 
     if (isguestuser()) {
-        print_error("Guests are not allowed to rate entries.");
+        print_error('guestnorate');
     }
 
     $context = get_context_instance(CONTEXT_MODULE, $cm->id);
 
     if (!$glossary->assessed) {
-        print_error("Rating of items not allowed!");
+        print_error('nopermissiontorate');
     }
 
     if ($glossary->assessed == 2) {
@@ -52,7 +52,7 @@
             }
 
             if ($entry->glossaryid != $glossary->id) {
-                print_error("This is not valid entry!");
+                print_error('invalidentry');
             }
 
             if ($glossary->assesstimestart and $glossary->assesstimefinish) {
@@ -77,7 +77,7 @@
                     $oldrating->rating = $rating;
                     $oldrating->time = time();
                     if (! update_record("glossary_ratings", $oldrating)) {
-                        print_error("Could not update an old rating ($entry = $rating)");
+                        print_error('cannotinsertrate', '', '', array($entry, $rating));
                     }
                     glossary_update_grades($glossary, $entry->userid);
                 }
@@ -90,7 +90,7 @@
                 $newrating->rating  = $rating;
 
                 if (! insert_record("glossary_ratings", $newrating)) {
-                    print_error("Could not insert a new rating ($entry->id = $rating)");
+                    print_error('cannotinsertrate', '', '', array($entry->id, $rating));
                 }
                 glossary_update_grades($glossary, $entry->userid);
             }
@@ -99,7 +99,7 @@
         redirect($returnurl, get_string("ratingssaved", "glossary"));
 
     } else {
-        print_error("This page was not accessed correctly");
+        print_error('invalidaccess');
     }
 
 ?>