From: dongsheng <dongsheng>
Date: Thu, 12 Jun 2008 10:55:23 +0000 (+0000)
Subject: "MDL-14129, fix all print_error"
X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=baa336f08e83738c039489b48224166252c8642e;p=moodle.git

"MDL-14129, fix all print_error"
---

diff --git a/mod/resource/index.php b/mod/resource/index.php
index d250991c5c..36810f67dc 100644
--- a/mod/resource/index.php
+++ b/mod/resource/index.php
@@ -5,7 +5,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, true);
diff --git a/mod/resource/lib.php b/mod/resource/lib.php
index 29a535869d..5ea5413395 100644
--- a/mod/resource/lib.php
+++ b/mod/resource/lib.php
@@ -39,15 +39,15 @@ class resource_base {
 
         if ($cmid) {
             if (! $this->cm = get_coursemodule_from_id('resource', $cmid)) {
-                print_error("Course Module ID was incorrect");
+                print_error('invalidcoursemodule');
             }
 
             if (! $this->course = $DB->get_record("course", array("id"=>$this->cm->course))) {
-                print_error("Course is misconfigured");
+                print_error('coursemisconf');
             }
 
             if (! $this->resource = $DB->get_record("resource", array("id"=>$this->cm->instance))) {
-                print_error("Resource ID was incorrect");
+                print_error('invalidid', 'resource');
             }
 
             $this->strresource  = get_string("modulename", "resource");
@@ -597,7 +597,7 @@ function resource_renamefiles($course, $wdir, $oldname, $name) {
                 $status .= "<li><a href=\"$CFG->wwwroot/mod/resource/view.php?id=$resource->cmid\" target=\"_blank\">$resource->name</a>: $resource->reference ==> $r->reference</li>";
                 if (!empty($CFG->resource_autofilerename)) {
                     if (!$DB->update_record('resource', $r)) {
-                        print_error("Error updating resource with ID $r->id.");
+                        print_error('cannotupdate', 'resource');
                     }
                 }
             }
diff --git a/mod/resource/mod_form.php b/mod/resource/mod_form.php
index 1eedb6a170..88de7d5aa8 100644
--- a/mod/resource/mod_form.php
+++ b/mod/resource/mod_form.php
@@ -13,7 +13,7 @@ class mod_resource_mod_form extends moodleform_mod {
             if($res = $DB->get_record('resource', array('id'=>$this->_instance))) {
                 $type = $res->type;
             } else {
-                print_error('incorrect assignment');
+                print_error('invalidassignment', 'resource');
             }
         } else {
             $type = required_param('type', PARAM_ALPHA);
@@ -53,4 +53,4 @@ class mod_resource_mod_form extends moodleform_mod {
     }
 
 }
-?>
\ No newline at end of file
+?>
diff --git a/mod/resource/type/directory/resource.class.php b/mod/resource/type/directory/resource.class.php
index a1fb4b3bb6..23bac67571 100644
--- a/mod/resource/type/directory/resource.class.php
+++ b/mod/resource/type/directory/resource.class.php
@@ -55,7 +55,7 @@ function display() {
     if ($subdir) {
         $relativepath = "$relativepath$subdir";
         if (stripos($relativepath, 'backupdata') !== FALSE or stripos($relativepath, $CFG->moddata) !== FALSE) {
-            print_error("Access not allowed!");
+            print_error('invalidaccess');
         }
 
         $subs = explode('/', $subdir);
diff --git a/mod/resource/type/file/localfile.php b/mod/resource/type/file/localfile.php
index 29b3cae7ff..c3bfdf5b64 100644
--- a/mod/resource/type/file/localfile.php
+++ b/mod/resource/type/file/localfile.php
@@ -8,7 +8,7 @@
     require_login();
 
     if (!$CFG->resource_allowlocalfiles) {
-        print_error('You cannot access this script');
+        print_error('cannotcallscript');
     }
 
     print_header(get_string('localfilechoose', 'resource'));
@@ -47,4 +47,4 @@
 
 <?php
     print_footer('empty');
-?>
\ No newline at end of file
+?>
diff --git a/mod/resource/view.php b/mod/resource/view.php
index 455a395641..d83e1ad7f8 100644
--- a/mod/resource/view.php
+++ b/mod/resource/view.php
@@ -8,27 +8,27 @@
 
     if ($r) {  // Two ways to specify the resource
         if (! $resource = $DB->get_record('resource', array('id'=>$r))) {
-            print_error('Resource ID was incorrect');
+            print_error('invalidid', 'resource');
         }
 
         if (! $cm = get_coursemodule_from_instance('resource', $resource->id, $resource->course)) {
-            print_error('Course Module ID was incorrect');
+            print_error('invalidcoursemodule');
         }
 
     } else if ($id) {
         if (! $cm = get_coursemodule_from_id('resource', $id)) {
-            print_error('Course Module ID was incorrect');
+            print_error('invalidcoursemodule');
         }
 
         if (! $resource = $DB->get_record('resource', array('id'=>$cm->instance))) {
-            print_error('Resource ID was incorrect');
+            print_error('invalidid', 'resource');
         }
     } else {
-        print_error('No valid parameters!!');
+        print_error('invalidaccessparameter');
     }
 
     if (! $course = $DB->get_record('course', array('id'=>$cm->course))) {
-        print_error('Incorrect course id');
+        print_error('invalidcourseid');
     }
 
     require_course_login($course, true, $cm);