]> git.mjollnir.org Git - moodle.git/commitdiff
"MDL-14129, fix print_error"
authordongsheng <dongsheng>
Fri, 6 Jun 2008 03:15:53 +0000 (03:15 +0000)
committerdongsheng <dongsheng>
Fri, 6 Jun 2008 03:15:53 +0000 (03:15 +0000)
mod/glossary/comments.php
mod/glossary/deleteentry.php
mod/glossary/edit.php
mod/glossary/editcategories.php
mod/glossary/exportentry.php
mod/glossary/import.php
mod/glossary/index.php
mod/glossary/lib.php
mod/glossary/report.php

index ca3c03087d3bed40d100da697f9e3ea802765dd2..897d91bfae0a77a4708f02bef2d8463b23dd990e 100644 (file)
     global $USER, $CFG;
 
     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('invalidcousemodule');
     }
 
     if (! $entry = get_record("glossary_entries", "id", $eid)) {
-        print_error("Entry is incorrect");
+        print_error('invalidentry');
     }
 
     $context = get_context_instance(CONTEXT_MODULE, $cm->id);
index b1a62d1b25a3027b31608727f5fbfd6f384a3ceb..e59663b56da3893e56c9530ff4df984afd2f63dd 100644 (file)
 
 
     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 (! $entry = get_record("glossary_entries","id", $entry)) {
-        print_error("Entry ID was incorrect");
+        print_error('invalidentry');
     }
 
     require_login($course->id, false, $cm);
@@ -33,7 +33,7 @@
     $manageentries = has_capability('mod/glossary:manageentries', $context); 
     
     if (! $glossary = get_record("glossary", "id", $cm->instance)) {
-        print_error("Glossary is incorrect");
+        print_error('invalidid', 'glossary');
     }
 
 
                   navmenu($course, $cm));
 
     if (($entry->userid != $USER->id) and !$manageentries) { // guest id is never matched, no need for special check here
-        print_error("You can't delete other people's entries!");
+        print_error('nopermissiontodelentry');
     }
     $ineditperiod = ((time() - $entry->timecreated <  $CFG->maxeditingtime) || $glossary->editalways);
     if (!$ineditperiod and !$manageentries) {
-        print_error("You can't delete this. Time expired!");
+        print_error('errdeltimeexpired', 'glossary');
     }
 
 /// If data submitted, then process and store.
@@ -63,7 +63,7 @@
             $dbentry->glossaryid = $entry->sourceglossaryid;
             $dbentry->sourceglossaryid = 0;
             if (! update_record('glossary_entries', $dbentry)) {
-                print_error("Could not update your glossary");
+                print_error('cantupdateglossary', 'glossary');
             }
 
         } else {
index 69f535651b1c6530d956914e0ffa7caffab401d2..3575db4c10c431355e39655f58ec6973ffa67714 100644 (file)
@@ -14,34 +14,34 @@ $mode = optional_param('mode', '', PARAM_ALPHA);      // categories if by catego
 $hook = optional_param('hook', '', PARAM_ALPHANUM);   // CategoryID
 
 if (! $cm = get_coursemodule_from_id('glossary', $id)) {
-    print_error("Course Module ID was incorrect");
+    print_error('invalidcoursemodule');
 }
 
 $context = get_context_instance(CONTEXT_MODULE, $cm->id);
 
 if (! $course = get_record("course", "id", $cm->course)) {
-    print_error("Course is misconfigured");
+    print_error('coursemisconf');
 }
 
 require_login($course->id, false, $cm);
 
 if ( isguest() ) {
-    print_error("Guests are not allowed to edit glossaries", $_SERVER["HTTP_REFERER"]);
+    print_error('guestnoedit', 'glossary', $_SERVER["HTTP_REFERER"]);
 }
 
 if (! $glossary = get_record("glossary", "id", $cm->instance)) {
-    print_error("Course module is incorrect");
+    print_error('invalidid', 'glossary');
 }
 
 
 if ($e) { // if entry is specified
     if (!$entry  = get_record("glossary_entries", "id", $e)) {
-        print_error("Incorrect entry id");
+        print_error('invalidentry');
     }
     $ineditperiod = ((time() - $entry->timecreated <  $CFG->maxeditingtime) || $glossary->editalways);
     if (!has_capability('mod/glossary:manageentries', $context) and !($entry->userid == $USER->id and ($ineditperiod and has_capability('mod/glossary:write', $context)))) {
         //expired edit time is the most probable cause here
-        print_error('erredittimeexpired', 'glossary', "view.php?id=$cm->id&amp;mode=entry&amp;hook=$e");
+        print_error('erredittimeexpired', 'glossary', 'view.php?id=$cm->id&amp;mode=entry&amp;hook=$e');
     }
 } else { // new entry
     require_capability('mod/glossary:write', $context);
@@ -98,7 +98,7 @@ if ($mform->is_cancelled()){
                        "view.php?id=$cm->id&amp;mode=entry&amp;hook=$todb->id",
                        $todb->id, $cm->id);
         } else {
-            print_error("Could not update your glossary");
+            print_error('cantupdateglossary', 'glossary');
         }
     } else {
 
@@ -117,7 +117,7 @@ if ($mform->is_cancelled()){
             add_to_log($course->id, "glossary", "add entry",
                        "view.php?id=$cm->id&amp;mode=entry&amp;hook=$todb->id", $todb->id,$cm->id);
         } else {
-            print_error("Could not insert this new entry");
+            print_error('cantinsertent', 'glossary');
         }
 
     }
index d0da1fea4040f18f71c4321640383337b278d58e..0413b2d3b0687a025290d97f9bed760422fdc989 100644 (file)
     $action = strtolower($action);
 
     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('invalidcoursemodule');
     }
 
     if ($hook > 0) {
         if ($category = get_record("glossary_categories","id",$hook)) {
             //Check it belongs to the same glossary
             if ($category->glossaryid != $glossary->id) {
-                print_error("Glossary is incorrect");
+                print_error('invalidid', 'glossary');
             }
         } else {
-            print_error("Category is incorrect");
+            print_error('invalidcategoryid');
         }
     }
 
@@ -68,7 +68,7 @@
                 $cat->usedynalink = $usedynalink;
 
                 if ( !update_record("glossary_categories", $cat) ) {
-                    print_error("Weird error. The category was not updated.");
+                    print_error('cannotupdatecategory');
                     redirect("editcategories.php?id=$cm->id");
                 } else {
                     add_to_log($course->id, "glossary", "edit category", "editcategories.php?id=$cm->id", $hook,$cm->id);
                 $cat->glossaryid = $glossary->id;
 
                 if ( ! $cat->id = insert_record("glossary_categories", $cat) ) {
-                    print_error("Weird error. The category was not inserted.");
+                    print_error('cannotinsertcategory');
 
                     redirect("editcategories.php?id=$cm->id");
                 } else {
index 05e2a09820016056f2330e396b0cb694bf405a17..8df0522ac12ec4f3d37339d907e8149d32abb83c 100644 (file)
     require_capability('mod/glossary:export', $context);
 
     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');
     }
 
     $strglossaries   = get_string('modulenameplural', 'glossary');
@@ -66,7 +66,7 @@
                 $dbentry->sourceglossaryid = $glossary->id;
                 
                 if (! update_record('glossary_entries', $dbentry)) {
-                    print_error('Could not export the entry to the main glossary');
+                    print_error('cantexportentry', 'glossary');
                 } else {
                     print_simple_box_start('center', '60%');
                     echo '<p align="center"><font size="3">'.$entryexported.'</font></p></font>';
index ca1b8c5b538527384f7530380cf6a9bf9b98d9d5..1e6041a2f6bcf02c6fddd104c746244c5c1784da 100644 (file)
     $hook     = optional_param('hook', 'ALL', 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);  
                     // to each other, so we have to update one of them twice.
 
                     if (! $currmodule = get_record("modules", "name", 'glossary')) {
-                        print_error("Glossary module doesn't exist");
+                        print_error('modulenotexist', 'debug', '', 'Glossary');
                     }
                     $mod->module = $currmodule->id;
                     $mod->course = $course->id;
                     $mod->section = 0;
 
                     if (! $mod->coursemodule = add_course_module($mod) ) {
-                        print_error("Could not add a new course module");
+                        print_error('cannotaddcoursemodule');
                     }
 
                     if (! $sectionid = add_mod_to_section($mod) ) {
-                        print_error("Could not add the new course module to that section");
+                        print_error('cannotaddcoursemoduletosection');
                     }
                     //We get the section's visible field status
                     $visible = get_field("course_sections","visible","id",$sectionid);
 
                     if (! set_field("course_modules", "visible", $visible, "id", $mod->coursemodule)) {
-                        print_error("Could not update the course module with the correct visibility");
+                        print_error('cannotupdatemod', '', '', $mod->coursemodule);
                     }
 
                     if (! set_field("course_modules", "section", $sectionid, "id", $mod->coursemodule)) {
-                        print_error("Could not update the course module with the correct section");
+                        print_error('cannotupdatemod', '', '', $mod->coursemodule);
                     }
                     add_to_log($course->id, "course", "add mod",
                                "../mod/$mod->modulename/view.php?id=$mod->coursemodule",
index 8386a22e1c0fcd549fada4f31ad6a65199d030c4..8e2976b4b020506556cc573df6ce31aa2242f34d 100644 (file)
@@ -11,7 +11,7 @@
     $id = required_param('id', PARAM_INT);   // course
 
     if (!$course = $DB->get_record('course', array('id'=>$id))) {
-        print_error("Course ID is incorrect");
+        print_error('invalidcourseid');
     }
 
     require_course_login($course);
index b1cfc983453b88e1cffee595fdf02a60e12d5cca..755c09ff173e8606c9229f85515f004668ec231a 100644 (file)
@@ -50,7 +50,7 @@ function glossary_add_instance($glossary) {
     //Check displayformat is a valid one
     $formats = get_list_of_plugins('mod/glossary/formats','TEMPLATE');
     if (!in_array($glossary->displayformat, $formats)) {
-        print_error("This format doesn't exist!");
+        print_error('unknowformat', '', '', $glossary->displayformat);
     }
 
     if ($returnid = $DB->insert_record("glossary", $glossary)) {
@@ -92,7 +92,7 @@ function glossary_update_instance($glossary) {
     //Check displayformat is a valid one
     $formats = get_list_of_plugins('mod/glossary/formats','TEMPLATE');
     if (!in_array($glossary->displayformat, $formats)) {
-        print_error("This format doesn't exist!");
+        print_error('unknowformat', '', '', $glossary->displayformat);
     }
 
     if ($return = $DB->update_record("glossary", $glossary)) {
@@ -1652,13 +1652,13 @@ function glossary_print_dynaentry($courseid, $entries, $displayformat = -1) {
     if ( $entries ) {
         foreach ( $entries as $entry ) {
             if (! $glossary = get_record('glossary', 'id', $entry->glossaryid)) {
-                print_error('Glossary ID was incorrect or no longer exists');
+                print_error('invalidid', 'glossary');
             }
             if (! $course = get_record('course', 'id', $glossary->course)) {
-                print_error('Glossary is misconfigured - don\'t know what course it\'s from');
+                print_error('coursemisconf');
             }
             if (!$cm = get_coursemodule_from_instance('glossary', $entry->glossaryid, $glossary->course) ) {
-                print_error('Glossary is misconfigured - don\'t know what course module it is');
+                print_error('invalidid', 'glossary');
             }
 
             //If displayformat is present, override glossary->displayformat
index b89d56d3bd1621a9127da8c66b4271228d4d7772..537255d10173146a9eb81d32dbfc19c4ebd559d1 100644 (file)
@@ -9,30 +9,30 @@
     $sort = optional_param('sort', '', PARAM_ALPHA);
 
     if (! $entry = get_record('glossary_entries', 'id', $id)) {
-        print_error("Entry ID was incorrect");
+        print_error('invalidentry');
     }
 
     if (! $glossary = get_record('glossary', 'id', $entry->glossaryid)) {
-        print_error("Glossary ID was incorrect");
+        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, $course->id)) {
-        print_error("Course Module ID was incorrect");
+        print_error('invalidcoursemodule');
     }
 
     require_login($course, false, $cm);
     $context = get_context_instance(CONTEXT_MODULE, $cm->id);
 
     if (!$glossary->assessed) {
-        print_error("This activity does not use ratings");
+        print_error('nopermissiontorate');
     }
 
     if (!has_capability('mod/glossary:manageentries', $context) and $USER->id != $entry->userid) {
-        print_error("You can only look at results for your own entries");
+        print_error('nopermissiontoviewresult', 'glossary');
     }
 
     switch ($sort) {