]> git.mjollnir.org Git - moodle.git/commitdiff
"MDL-14129, fix print_error"
authordongsheng <dongsheng>
Tue, 20 May 2008 02:53:46 +0000 (02:53 +0000)
committerdongsheng <dongsheng>
Tue, 20 May 2008 02:53:46 +0000 (02:53 +0000)
14 files changed:
lib/adminlib.php
lib/authlib.php
lib/dml/oci8po_adodb_moodle_database.php
lib/dmllib_todo.php
lib/editor/htmlarea/coursefiles.php
lib/grade/grade_category.php
lib/grade/grade_grade.php
lib/grade/grade_item.php
lib/grade/grade_object.php
lib/gradelib.php
lib/locallib.php
lib/moodlelib.php
lib/pagelib.php
lib/simpletest/testeventslib.php

index 994baef1be1c3e95bbe676853b611fbc28a7a697..cbf960b4b5e76a2d8d017861a8e39ed1410330bf 100644 (file)
@@ -15,7 +15,7 @@ function upgrade_main_savepoint($result, $version) {
     if ($result) {
         if ($CFG->version >= $version) {
             // something really wrong is going on in main upgrade script
-            print_error("Upgrade savepoint: Can not upgrade main version from $CFG->version to $version.");
+            print_error('cannotdowngrade', 'debug', '', array($CFG->version, $version));
         }
         set_config('version', $version);
     } else {
@@ -141,7 +141,7 @@ function upgrade_plugins($type, $dir, $return) {
 
                 /// Install capabilities
                     if (!update_capabilities($type.'/'.$plug)) {
-                        print_error('Could not set up the capabilities for '.$plugin->name.'!');
+                        print_error('cannotsetupcapforplugin', '', '', $plugin->name);
                     }
                 /// Install events
                     events_update_definition($type.'/'.$plug);
@@ -184,7 +184,7 @@ function upgrade_plugins($type, $dir, $return) {
                     // OK so far, now update the plugins record
                     set_config($pluginversion, $plugin->version);
                     if (!update_capabilities($type.'/'.$plug)) {
-                        print_error('Could not update '.$plugin->name.' capabilities!');
+                        print_error('cannotupdateplugincap', '', '', $plugin->name);
                     }
                     events_update_definition($type.'/'.$plug);
                     notify(get_string('modulesuccess', '', $plugin->name), 'notifysuccess');
@@ -197,7 +197,7 @@ function upgrade_plugins($type, $dir, $return) {
             }
         } else {
             upgrade_log_start();
-            print_error('Version mismatch: '. $plugin->name .' can\'t downgrade '. $CFG->$pluginversion .' -> '. $plugin->version .' !');
+            print_error('cannotdowngrade', 'debug', '', array($CFG->pluginversion, $plugin->version));
         }
     }
 
@@ -231,7 +231,7 @@ function upgrade_activity_modules($return) {
     global $CFG, $interactive, $DB;
 
     if (!$mods = get_list_of_plugins('mod') ) {
-        print_error('No modules installed!');
+        print_error('nomodules', 'debug');
     }
 
     $updated_modules = false;
@@ -327,7 +327,7 @@ function upgrade_activity_modules($return) {
                     // OK so far, now update the modules record
                     $module->id = $currmodule->id;
                     if (!$DB->update_record('modules', $module)) {
-                        print_error('Could not update '. $module->name .' record in modules table!');
+                        print_error('cannotupdatemod', '', '', $module->name);
                     }
                     remove_dir($CFG->dataroot . '/cache', true); // flush cache
                     notify(get_string('modulesuccess', '', $module->name), 'notifysuccess');
@@ -340,7 +340,7 @@ function upgrade_activity_modules($return) {
 
             /// Update the capabilities table?
                 if (!update_capabilities('mod/'.$module->name)) {
-                    print_error('Could not update '.$module->name.' capabilities!');
+                    print_error('cannotupdatemodcap', '', '', $module->name);
                 }
                 events_update_definition('mod/'.$module->name);
 
@@ -348,7 +348,7 @@ function upgrade_activity_modules($return) {
 
             } else {
                 upgrade_log_start();
-                print_error('Version mismatch: '. $module->name .' can\'t downgrade '. $currmodule->version .' -> '. $module->version .' !');
+                print_error('cannotdowngrade', 'debug', '', array($currmodule->version, $module->version));
             }
 
         } else {    // module not installed yet, so install it
@@ -383,7 +383,7 @@ function upgrade_activity_modules($return) {
 
                 /// Capabilities
                     if (!update_capabilities('mod/'.$module->name)) {
-                        print_error('Could not set up the capabilities for '.$module->name.'!');
+                        print_error('cannotsetupcapformod', '', '', $module->name);
                     }
 
                 /// Events
@@ -564,16 +564,16 @@ function create_admin_user($user_input=NULL) {
             $user = $user_input;
         }
         if (!$user->id = $DB->insert_record('user', $user)) {
-            print_error('SERIOUS ERROR: Could not create admin user record !!!');
+            print_error('cannotcreateadminuser', 'debug');
         }
 
         if (!$user = $DB->get_record('user', array('id'=>$user->id))) {   // Double check.
-            print_error('User ID was incorrect (can\'t find it)');
+            print_error('invaliduserid');
         }
 
         // Assign the default admin roles to the new user.
         if (!$adminroles = get_roles_with_capability('moodle/legacy:admin', CAP_ALLOW)) {
-            print_error('No admin role could be found');
+            print_error('noadminrole', 'debug');
         }
         $sitecontext = get_context_instance(CONTEXT_SYSTEM);
         foreach ($adminroles as $adminrole) {
@@ -591,7 +591,7 @@ function create_admin_user($user_input=NULL) {
         redirect("$CFG->wwwroot/user/editadvanced.php?id=$user->id");  // Edit thyself
         }
     } else {
-        print_error('Can not create admin!');
+        print_error('cannotcreateadminuser', 'debug');
     }
 }
 
index 8996a979cfa8c540c6d215b28a3ec86962742e78..971c7d68c728bdb7d4a87f73f88e75496c5c434e 100644 (file)
@@ -80,7 +80,7 @@ class auth_plugin_base {
      * @return bool Authentication success or failure.
      */
     function user_login($username, $password) {
-        print_error('Abstract user_login() method must be overriden.');
+        print_error('mustbeoveride', 'debug', '', 'user_login()' );
     }
 
     /**
@@ -187,7 +187,7 @@ class auth_plugin_base {
      */
     function user_signup($user, $notify=true) {
         //override when can signup
-        print_error('user_signup method must be overriden if signup enabled');
+        print_error('mustbeoveride', 'debug', '', 'user_signup()' );
     }
 
     /**
@@ -208,7 +208,7 @@ class auth_plugin_base {
      */
     function user_confirm($username, $confirmsecret) {
         //override when can confirm
-        print_error('user_confirm method must be overriden if confirm enabled');
+        print_error('mustbeoveride', 'debug', '', 'user_confirm()' );
     }
 
     /**
index 29bfe7e2b940f952ea0dae5841da4681af5b3469..86990037f19af34e931f0d344332e2be836efa35 100644 (file)
@@ -231,7 +231,7 @@ error('todo');
         if (!empty($CFG->rolesactive)) {
             if (in_array($table, array('user_students', 'user_teachers', 'user_coursecreators', 'user_admins'))) {
                 if (debugging()) { var_dump(debug_backtrace()); }
-                print_error('This SQL relies on obsolete tables ('.$table.')!  Your code must be fixed by a developer.');
+                print_error('sqlrelyonobsoletetable', 'debug', '', $table);
             }
         }
 
@@ -342,7 +342,7 @@ error('todo');
         if (!empty($CFG->rolesactive)) {
             if (in_array($table, array('user_students', 'user_teachers', 'user_coursecreators', 'user_admins'))) {
                 if (debugging()) { var_dump(debug_backtrace()); }
-                print_error('This SQL relies on obsolete tables ('.$table.')!  Your code must be fixed by a developer.');
+                print_error('sqlrelyonobsoletetable', 'debug', '', $table);
             }
         }
 
index 03e0e08f2f7407536f088e0541d2ce9cdf49399a..94ebc2619203fd4dcaf9e8b8412685eb6f25107f 100644 (file)
@@ -399,7 +399,8 @@ function get_recordset_sql($sql, $limitfrom=null, $limitnum=null) {
             strpos($sql, ' '.$CFG->prefix.'user_coursecreators ') ||
             strpos($sql, ' '.$CFG->prefix.'user_admins ')) {
             if (debugging()) { var_dump(debug_backtrace()); }
-            print_error('This SQL relies on obsolete tables!  Your code must be fixed by a developer.');
+            print_error('sqlrelyonobsoletetable', 'debug', '',
+                    'user_student, user_teachers, user_coursecreators, user_admins');
         }
     }
 
@@ -1295,4 +1296,4 @@ error('todo');
     return $status;
 }
 
-?>
\ No newline at end of file
+?>
index 7a47f62f3ed8f03f6ac18c200b28325438cc057a..435aaf54ca973536148a06cb27bb732191e3e08b 100644 (file)
@@ -27,7 +27,7 @@
 
 
     if (! $course = get_record("course", "id", $id) ) {
-        print_error("That's an invalid course id");
+        print_error('invalidcourseid');
     }
 
     require_login($course);
     }
 
     if (! $basedir = make_upload_directory("$course->id")) {
-        print_error("The site administrator needs to fix the file permissions");
+        print_error('cannotcreateuploaddir');
     }
 
     $baseweb = $CFG->wwwroot;
                 }
 
                 if (!zip_files($files,"$basedir/$wdir/$name")) {
-                    print_error("zipfileserror","error");
+                    print_error('zipfileserror');
                 }
 
                 clearfilelist();
index b5fc1880408f662f239eaa7452da44e9c6c68710..f6b9d8ff1e53f4f3b38d0b25587c0dfc171cb2c8 100644 (file)
@@ -298,7 +298,7 @@ class grade_category extends grade_object {
     function insert($source=null) {
 
         if (empty($this->courseid)) {
-            print_error('Can not insert grade category without course id!');
+            print_error('cannotinsertgrade');
         }
 
         if (empty($this->parent)) {
@@ -1046,11 +1046,11 @@ class grade_category extends grade_object {
         }
 
         if ($parentid == $this->id) {
-            print_error('Can not assign self as parent!');
+            print_error('cannotassignselfasparent');
         }
 
         if (empty($this->parent) and $this->is_course_category()) {
-            print_error('Course category can not have parent!');
+            print_error('cannothaveparentcate');
         }
 
         // find parent and check course id
index 694d2923a6cabfc0445398f3e90f7522c1faeb1b..f367a846b191d9542bbd31d421d09d1dfb98f827 100644 (file)
@@ -560,7 +560,7 @@ class grade_grade extends grade_object {
         global $CFG;
 
         if (count($grade_grades) !== count($grade_items)) {
-            print_error('Incorrect size of arrays in params of grade_grade::get_hiding_affected()!');
+            print_error('invalidarraysize', 'debug', '', 'grade_grade::get_hiding_affected()!');
         }
 
         $dependson = array();
index b5b10c5204d9524e34a9c5ea57d2967530d07485..a9c289a9587317151c8bd8b092edba9f20c618ff 100644 (file)
@@ -370,7 +370,7 @@ class grade_item extends grade_object {
         global $CFG;
 
         if (empty($this->courseid)) {
-            print_error('Can not insert grade item without course id!');
+            print_error('cannotinsertgrade');
         }
 
         // load scale if needed
@@ -1190,7 +1190,7 @@ class grade_item extends grade_object {
      */
     function set_parent($parentid) {
         if ($this->is_course_item() or $this->is_category_item()) {
-            print_error('Can not set parent for category or course item!');
+            print_error('cannotsetparentforcatoritem');
         }
 
         if ($this->categoryid == $parentid) {
index c96a97235408348c99a48c04e7edfd3a4dadc47a..0525c79cafd183148e1f3ce79bcba2fd861964a1 100644 (file)
@@ -110,7 +110,7 @@ class grade_object {
      * @return object grade_object instance or false if none found.
      */
     function fetch($params) {
-        print_error('Abstract method fetch() not overridden in '.get_class($this));
+        print_error('mustbeoveride', 'debug', '', 'fetch()');
     }
 
     /**
@@ -121,7 +121,7 @@ class grade_object {
      * @return array array of grade_object insatnces or false if none found.
      */
     function fetch_all($params) {
-        print_error('Abstract method fetch_all() not overridden in '.get_class($this));
+        print_error('mustbeoveride', 'debug', '', 'fetch_all()');
     }
 
     /**
@@ -133,7 +133,7 @@ class grade_object {
         if ($instances = grade_object::fetch_all_helper($table, $classname, $params)) {
             if (count($instances) > 1) {
                 // we should not tolerate any errors here - problems might appear later
-                print_error('Found more than one record in fetch() !');
+                print_error('morethanonerecordinfetch');
             }
             return reset($instances);
         } else {
index 5607b7dc7e3ac1d034993c63366bb363b7f96d47..d697ae7699138f78aecd7405c0f8169065cb44bf 100644 (file)
@@ -840,7 +840,7 @@ function grade_regrade_final_grades($courseid, $userid=null, $updated_item=null)
     if ($userid) {
         // one raw grade updated for one user
         if (empty($updated_item)) {
-            print_error("updated_item_id can not be null!");
+            print_error("cannotbenull", 'debug', '', "updated_item");
         }
         if ($course_item->needsupdate) {
             $updated_item->force_regrading();
@@ -951,7 +951,7 @@ function grade_grab_legacy_grades($courseid) {
     global $CFG;
 
     if (!$mods = get_list_of_plugins('mod') ) {
-        print_error('No modules installed!');
+        print_error('nomodules', 'debug');
     }
 
     foreach ($mods as $mod) {
@@ -997,7 +997,7 @@ function grade_grab_course_grades($courseid, $modname=null) {
     }
 
     if (!$mods = get_list_of_plugins('mod') ) {
-        print_error('No modules installed!');
+        print_error('nomodules', 'debug');
     }
 
     foreach ($mods as $mod) {
index 957eb37fd5d76991529df3acf119a14d63d52921..16ab63ba0638e8d88c000f3e2b90fa03d3495d0d 100644 (file)
@@ -163,13 +163,13 @@ function upgrade_local_db($continueto) {
                     }
                 }
             } else {
-                print_error('Upgrade of local database customisations failed! (Could not update version in config table)');
+                print_error('cannotupgradedbcustom', 'debug');
             }
         } else {
             if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) {
                 $DB->set_debug(false);
             }
-            print_error('Upgrade failed!  See local/version.php');
+            print_error('upgradefail', 'debug', '', 'local/version.php');
         }
 
     } else if ($local_version < $CFG->local_version) {
index f049feb359c4983736827de76235c4bec659c6ba..ac8c80eb32c3d35dc033aec5a44f32091db9351c 100644 (file)
@@ -306,7 +306,7 @@ function required_param($parname, $type=PARAM_CLEAN) {
     } else if (isset($_GET[$parname])) {
         $param = $_GET[$parname];
     } else {
-        print_error('A required parameter ('.$parname.') was missing');
+        print_error('missingparam', '', '', $parname);
     }
 
     return clean_param($param, $type);
@@ -596,7 +596,7 @@ function clean_param($param, $type) {
             }
 
         default:                 // throw error, switched parameters in optional_param or another serious problem
-            print_error("Unknown parameter type: $type");
+            print_error("unknowparamtype", '', '', $type);
     }
 }
 
@@ -1806,7 +1806,7 @@ function course_setup($courseorid=0) {
             $COURSE = clone($course);
         } else {
             if (!$COURSE = get_record('course', 'id', $courseorid)) {
-                print_error('Invalid course ID');
+                print_error('invalidcourseid');
             }
         }
     }
@@ -2148,7 +2148,7 @@ function require_user_key_login($script, $instance=null) {
     global $nomoodlecookie, $USER, $SESSION, $CFG;
 
     if (empty($nomoodlecookie)) {
-        print_error('Incorrect use of require_key_login() - session cookies must be disabled!');
+        print_error('sessioncookiesdisable');
     }
 
 /// extra safety
@@ -2157,22 +2157,22 @@ function require_user_key_login($script, $instance=null) {
     $keyvalue = required_param('key', PARAM_ALPHANUM);
 
     if (!$key = get_record('user_private_key', 'script', $script, 'value', $keyvalue, 'instance', $instance)) {
-        print_error('Incorrect key');
+        print_error('invalidkey');
     }
 
     if (!empty($key->validuntil) and $key->validuntil < time()) {
-        print_error('Expired key');
+        print_error('expiredkey');
     }
 
     if ($key->iprestriction) {
         $remoteaddr = getremoteaddr();
         if ($remoteaddr == '' or !address_in_subnet($remoteaddr, $key->iprestriction)) {
-            print_error('Client IP address mismatch');
+            print_error('ipmismatch');
         }
     }
 
     if (!$user = get_record('user', 'id', $key->userid)) {
-        print_error('Incorrect user record');
+        print_error('invaliduserid');
     }
 
 /// emulate normal session
@@ -2215,7 +2215,7 @@ function create_user_key($script, $userid, $instance=null, $iprestriction=null,
     }
 
     if (!insert_record('user_private_key', $key)) {
-        print_error('Can not insert new key');
+        print_error('cannotinsertkey');
     }
 
     return $key->value;
@@ -2716,7 +2716,7 @@ function get_auth_plugin($auth) {
 
     // check the plugin exists first
     if (! exists_auth_plugin($auth)) {
-        print_error("Authentication plugin '$auth' not found.");
+        print_error('authpluginnotfound', 'debug', '', $auth);
     }
 
     // return auth plugin instance
@@ -3478,7 +3478,7 @@ function remove_course_contents($courseid, $showfeedback=true) {
     $result = true;
 
     if (! $course = get_record('course', 'id', $courseid)) {
-        print_error('Course ID was incorrect (can\'t find it)');
+        print_error('invalidcourseid');
     }
 
     $strdeleted = get_string('deleted');
@@ -3529,7 +3529,7 @@ function remove_course_contents($courseid, $showfeedback=true) {
             }
         }
     } else {
-        print_error('No modules are installed!');
+        print_error('nomodules', 'debug');
     }
 
 /// Give local code a chance to delete its references to this course.
@@ -4275,7 +4275,7 @@ function reset_password_and_mail($user) {
     $newpassword = generate_password();
 
     if (!$userauth->user_update_password(addslashes_recursive($user), addslashes($newpassword))) {
-        print_error("Could not set user password!");
+        print_error("cannotsetpassword");
     }
 
     $a = new object();
index 2b10047aa5a4987d6d0975d1398dc6c5ac167234..7477f58655327dbd9e681267def09b4edfc268ac 100644 (file)
@@ -32,7 +32,7 @@ function page_import_types($path) {
     if(is_file($file)) {
         require($file);
         if(!isset($DEFINEDPAGES)) {
-            print_error('Imported '.$file.' but found no page classes');
+            print_error('nopageclass', 'debug', '', $page);
         }
         return $types[$path] = $DEFINEDPAGES;
     }
@@ -314,7 +314,7 @@ class page_course extends page_base {
     // Do NOT load up "expensive" resouces (e.g. SQL data) here!
     function init_quick($data) {
         if(empty($data->pageid) && !defined('ADMIN_STICKYBLOCKS')) {
-            print_error('Cannot quickly initialize page: empty course id');
+            print_error('cannotinitpage', '', '', null);
         }
         parent::init_quick($data);
     }
@@ -338,7 +338,7 @@ class page_course extends page_base {
         }
 
         if(empty($this->courserecord) && !defined('ADMIN_STICKYBLOCKS')) {
-            print_error('Cannot fully initialize page: invalid course id '. $this->id);
+            print_error('cannotinitpage', '', '', $this->id);
         }
 
         $this->context = get_context_instance(CONTEXT_COURSE, $this->id);
@@ -588,18 +588,18 @@ class page_generic_activity extends page_base {
             return;
         }
         if(empty($this->activityname)) {
-            print_error('Page object derived from page_generic_activity but did not define $this->activityname');
+            print_error('noactivityname', 'debug');
         }
         if (!$this->modulerecord = get_coursemodule_from_instance($this->activityname, $this->id)) {
-            print_error('Cannot fully initialize page: invalid '.$this->activityname.' instance id '. $this->id);
+            print_error('cannotinitpager', 'debug', '', array($this->activityname, $this->id));
         }
         $this->courserecord = get_record('course', 'id', $this->modulerecord->course);
         if(empty($this->courserecord)) {
-            print_error('Cannot fully initialize page: invalid course id '. $this->modulerecord->course);
+            print_error('invalidcourseid');
         }
         $this->activityrecord = get_record($this->activityname, 'id', $this->id);
         if(empty($this->activityrecord)) {
-            print_error('Cannot fully initialize page: invalid '.$this->activityname.' id '. $this->id);
+            print_error('cannotinitpager', 'debug', '', array($this->activityname, $this->id));
         }
         $this->full_init_done = true;
     }
index 65bb588def65bf50411cc8caba902fcc938940a8..52889457087baf58e71e475e79bcc99f10f5e1a2 100755 (executable)
@@ -36,7 +36,7 @@ function sample_function_handler($eventdata) {
         return true;
     }
 
-    print_error('Incorrect eventadata submitted: '.$eventdata);
+    print_error('invalideventdata', '', '', $eventdata);
 }
 
 // test handler class with static method
@@ -70,7 +70,7 @@ class sample_handler_class {
             return true;
         }
 
-        print_error('Incorrect eventadata submitted: '.$eventdata);
+        print_error('invalideventdata', '', '', $eventdata);
     }
 }
 
@@ -197,4 +197,4 @@ class eventslib_test extends UnitTestCase {
 
 }
 
-?>
\ No newline at end of file
+?>