]> git.mjollnir.org Git - moodle.git/commitdiff
"MDL-14129, fix print_error"
authordongsheng <dongsheng>
Thu, 15 May 2008 03:07:21 +0000 (03:07 +0000)
committerdongsheng <dongsheng>
Thu, 15 May 2008 03:07:21 +0000 (03:07 +0000)
lib/accesslib.php
lib/blocklib.php
lib/csvlib.class.php
lib/editorlib.php
lib/speller/server-scripts/spellchecker.php
lib/weblib.php

index 205d405564bcbfd71f03ef152938f92384c80211..b281e574b56bf99de4f31a5bac433b1ba32ad717 100755 (executable)
@@ -856,10 +856,10 @@ function require_capability($capability, $context, $userid=NULL, $doanything=tru
 
         } else if ($context->contextlevel == CONTEXT_MODULE) {
             if (!$cm = get_record('course_modules', 'id', $context->instanceid)) {
-                print_error('Incorrect module');
+                print_error('invalidmodule');
             }
             if (!$course = get_record('course', 'id', $cm->course)) {
-                print_error('Incorrect course.');
+                print_error('invalidcourseid');
             }
             require_course_login($course, true, $cm);
             $errorlink = $CFG->wwwroot.'/course/view.php?id='.$cm->course;
@@ -1713,10 +1713,10 @@ function moodle_install_roles() {
 /// Now is the correct moment to install capabilities - after creation of legacy roles, but before assigning of roles
 
     if (!assign_capability('moodle/site:doanything', CAP_ALLOW, $adminrole, $systemcontext->id)) {
-        print_error('Could not assign moodle/site:doanything to the admin role');
+        print_error('cannotassignanthing');
     }
     if (!update_capabilities()) {
-        print_error('Had trouble upgrading the core capabilities for the Roles System');
+        print_error('cannotupgradecaps');
     }
 
 /// Look inside user_admin, user_creator, user_teachers, user_students and
@@ -1929,7 +1929,7 @@ function assign_legacy_capabilities($capability, $legacyperms) {
         $systemcontext = get_context_instance(CONTEXT_SYSTEM);
 
         if (!array_key_exists($type, $legacyroles)) {
-            print_error('Incorrect legacy role definition for type: '.$type);
+            print_error('invalidlegacy', '', '', $type);
         }
 
         if ($roles = get_roles_with_capability($legacyroles[$type], CAP_ALLOW)) {
@@ -2386,7 +2386,7 @@ function get_context_instance($contextlevel, $instance=0) {
 /// check allowed context levels
     if (!in_array($contextlevel, $allowed_contexts)) {
         // fatal error, code must be fixed - probably typo or switched parameters
-        print_error('Error: get_context_instance() called with incorrect context level "'.s($contextlevel).'"');
+        print_error('invalidcourselevel');
     }
 
     if (!is_array($instance)) {
@@ -2514,11 +2514,11 @@ function create_role($name, $shortname, $description, $legacy='') {
     // check for duplicate role name
 
     if ($role = get_record('role','name', $name)) {
-        print_error('there is already a role with this name!');
+        print_error('duplicaterolename');
     }
 
     if ($role = get_record('role','shortname', $shortname)) {
-        print_error('there is already a role with this shortname!');
+        print_error('duplicateroleshortname');
     }
 
     $role = new object();
@@ -3077,7 +3077,7 @@ function get_cached_capabilities($component='moodle') {
  */
 function get_default_capabilities($legacyrole) {
     if (!$allcaps = get_records('capabilities')) {
-        print_error('Error: no capabilitites defined!');
+        print_error('nocaps', 'debug');
     }
     $alldefs = array();
     $defaults = array();
@@ -3253,7 +3253,7 @@ function capabilities_cleanup($component, $newcapdef=NULL) {
 
                 // Remove from capabilities cache.
                 if (!delete_records('capabilities', 'name', $cachedcap->name)) {
-                    print_error('Could not delete deprecated capability '.$cachedcap->name);
+                    print_error('cannotdeletecap', '', '', $cachedcap->name);
                 } else {
                     $removedcount++;
                 }
@@ -3261,8 +3261,7 @@ function capabilities_cleanup($component, $newcapdef=NULL) {
                 if($roles = get_roles_with_capability($cachedcap->name)) {
                     foreach($roles as $role) {
                         if (!unassign_capability($cachedcap->name, $role->id)) {
-                            print_error('Could not unassign deprecated capability '.
-                                    $cachedcap->name.' from role '.$role->name);
+                            print_error('cannotunassigncap', '', '', array($cachedcap->name, $role->name));
                         }
                     }
                 }
@@ -3679,7 +3678,7 @@ function get_child_contexts($context) {
         break;
 
         default:
-            print_error('This is an unknown context (' . $context->contextlevel . ') in get_child_contexts!');
+            print_error('unknowcontext', '', '', $context->contextlevel);
         return false;
     }
 }
index 4ebe500e25c1a38e18d6d36a399824495ca65ed2..f4e497f34b4abb41949cde016fb0a23c24c246df 100644 (file)
@@ -512,7 +512,7 @@ function blocks_execute_action($page, &$pageblocks, $blockaction, $instanceorid,
                     unset($data->$item);
                 }
                 if(!$blockobject->instance_config_save($data,$pinned)) {
-                    print_error('Error saving block configuration');
+                    print_error('cannotsaveblock');
                 }
                 // And nothing more, continue with displaying the page
             }
@@ -541,7 +541,7 @@ function blocks_execute_action($page, &$pageblocks, $blockaction, $instanceorid,
         break;
         case 'toggle':
             if(empty($instance))  {
-                print_error('Invalid block instance for '.$blockaction);
+                print_error('invalidblockinstance', '', '', $blockaction);
             }
             $instance->visible = ($instance->visible) ? 0 : 1;
             if (!empty($pinned)) {
@@ -552,13 +552,13 @@ function blocks_execute_action($page, &$pageblocks, $blockaction, $instanceorid,
         break;
         case 'delete':
             if(empty($instance))  {
-                print_error('Invalid block instance for '. $blockaction);
+                print_error('invalidblockinstance', '', '', $blockaction);
             }
             blocks_delete_instance($instance, $pinned);
         break;
         case 'moveup':
             if(empty($instance))  {
-                print_error('Invalid block instance for '. $blockaction);
+                print_error('invalidblockinstance', '', '', $blockaction);
             }
 
             if($instance->weight == 0) {
@@ -595,7 +595,7 @@ function blocks_execute_action($page, &$pageblocks, $blockaction, $instanceorid,
         break;
         case 'movedown':
             if(empty($instance))  {
-                print_error('Invalid block instance for '. $blockaction);
+                print_error('invalidblockinstance', '', '', $blockaction);
             }
 
             if($instance->weight == max(array_keys($pageblocks[$instance->position]))) {
@@ -632,7 +632,7 @@ function blocks_execute_action($page, &$pageblocks, $blockaction, $instanceorid,
         break;
         case 'moveleft':
             if(empty($instance))  {
-                print_error('Invalid block instance for '. $blockaction);
+                print_error('invalidblockinstance', '', '', $blockaction);
             }
 
             // Where is the instance going to be moved?
@@ -643,7 +643,7 @@ function blocks_execute_action($page, &$pageblocks, $blockaction, $instanceorid,
         break;
         case 'moveright':
             if(empty($instance))  {
-                print_error('Invalid block instance for '. $blockaction);
+                print_error('invalidblockinstance', '', '', $blockaction);
             }
 
             // Where is the instance going to be moved?
@@ -976,7 +976,7 @@ function blocks_repopulate_page($page) {
     $allblocks = blocks_get_record();
 
     if(empty($allblocks)) {
-        print_error('Could not retrieve blocks from the database');
+        print_error('cannotgetblock');
     }
 
     // Assemble the information to correlate block names to ids
@@ -1078,10 +1078,10 @@ function upgrade_blocks_db($continueto) {
                     }
                 }
             } else {
-                print_error('Upgrade of blocks system failed! (Could not update version in config table)');
+                print_error('cannotupgradeblock');
             }
         } else {
-            print_error('Blocks tables could NOT be set up successfully!');
+            print_error('cannotsetupblock');
         }
     }
 
@@ -1130,10 +1130,10 @@ function upgrade_blocks_db($continueto) {
                 exit;
                 }
             } else {
-                print_error('Upgrade of blocks system failed! (Could not update version in config table)');
+                print_error('cannotupgradeblock');
             }
         } else {
-            print_error('Upgrade failed!  See blocks/version.php');
+            print_error('cannotupgradeblock');
         }
 
     } else if ($blocks_version < $CFG->blocks_version) {
@@ -1166,12 +1166,12 @@ function upgrade_blocks_plugins($continueto) {
     $site = get_site();
 
     if (!$blocks = get_list_of_plugins('blocks', 'db') ) {
-        print_error('No blocks installed!');
+        print_error('noblocks', 'debug');
     }
 
     include_once($CFG->dirroot .'/blocks/moodleblock.class.php');
     if(!class_exists('block_base')) {
-        print_error('Class block_base is not defined or file not found for /blocks/moodleblock.class.php');
+        print_error('noblockbase');
     }
 
     foreach ($blocks as $blockname) {
@@ -1289,11 +1289,11 @@ function upgrade_blocks_plugins($continueto) {
                     // OK so far, now update the block record
                     $block->id = $currblock->id;
                     if (! update_record('block', $block)) {
-                        print_error('Could not update block '. $block->name .' record in block table!');
+                        print_error('cannotupdateblock', '', '', $block->name);
                     }
                     $component = 'block/'.$block->name;
                     if (!update_capabilities($component)) {
-                        print_error('Could not update '.$block->name.' capabilities!');
+                        print_error('nopermissiontoupdateblock', '', '', $block->name);
                     }
 
                     events_update_definition($component);
@@ -1306,7 +1306,7 @@ function upgrade_blocks_plugins($continueto) {
                 }
             } else {
                 upgrade_log_start();
-                print_error('Version mismatch: block '. $block->name .' can\'t downgrade '. $currblock->version .' -> '. $block->version .'!');
+                print_error('cannotdowngrade', 'debug', '', array($currblock->version, $block->version));
             }
 
         } else {    // block not installed yet, so install it
@@ -1326,9 +1326,9 @@ function upgrade_blocks_plugins($continueto) {
                 // Duplicate block titles are not allowed, they confuse people
                 // AND PHP's associative arrays ;)
                 if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) {
-                    print_error('<strong>Naming conflict</strong>: block <strong>'.$block->name.'</strong> has the same title with an existing block, <strong>'.$conflictblock.'</strong>!');
+                    print_error('blocknameconflict', '', '', array($block->name, $conflictblock));
                 } else if (CLI_UPGRADE) {
-                    print_error('Naming conflict: block "'.$block->name.'" has the same title with an existing block, "'.$conflictblock.'"!');
+                    print_error('blocknameconflict', '', '', array($block->name, $conflictblock));
                 }
             }
             if (empty($updated_blocks)) {
@@ -1372,10 +1372,10 @@ function upgrade_blocks_plugins($continueto) {
                     echo '<hr />';
                     }
                 } else {
-                    print_error($block->name .' block could not be added to the block list!');
+                    print_error('cannotaddblock', '', '', $block->name);
                 }
             } else {
-                print_error('Block '. $block->name .' tables could NOT be set up successfully!');
+                print_error('cannotsetupblock', '', '', $block->name);
             }
         }
 
index bb6f701cf1c452435118ab6919ac36ec1cd21211..ebfff5548c1b79f96461574f4e3e8fe193283523 100644 (file)
@@ -253,7 +253,7 @@ class csv_import_reader {
         global $USER;
 
         if (!$filename = make_upload_directory('temp/csvimport/'.$type.'/'.$USER->id, false)) {
-            print_error('Can not create temporary upload directory - verify moodledata permissions!');
+            print_error('cannotcreatetempdir');
         }
 
         // use current (non-conflicting) time stamp
@@ -265,4 +265,4 @@ class csv_import_reader {
         return $iiid;
     }
 }
-?>
\ No newline at end of file
+?>
index c65366c09cdc74fa5d4f960dd94c1fc4a90dd81c..e5ad3f570daabd549f9ec0c4948d8ed166dee895 100644 (file)
@@ -66,11 +66,11 @@ class editorObject {
             // If args is an array search keys courseid and name.
             // Name represents editor name to load.
             if ( !array_key_exists('courseid', $args) ) {
-                print_error("Required variable courseid is missing!");
+                print_error('invalidcourseid');
             }
 
             if ( !array_key_exists('name', $args) ) {
-                print_error("Required variable name is missing!");
+                print_error('missingvarname');
             }
 
             $courseid   = clean_param($args['courseid'], PARAM_INT);
index e6d26dc1400d7486026108110917178667c1735e..3747288fa9e05da8edcb5fdeaed1ce1a098b54cc 100644 (file)
@@ -3,7 +3,7 @@
     require_login();
 
 if (empty($CFG->aspellpath)) {
-    print_error('Spellchecker not configured');
+    print_error('spellcheckernotconf');
 }
 
 header('Content-type: text/html; charset=utf-8');
index 38f54b1171698f2fbb22b747478d47aecd30bcd0..0c7062ed05f7ec5f06e04ea9c0ad8f846e75d89d 100644 (file)
@@ -699,7 +699,7 @@ function element_to_popup_window ($type=null, $url=null, $name=null, $linkname=n
                        "onclick=\"this.target='$name'; return openpopup('$url', '$name', '$options', $fullscreen);\">$linkname</a>";
             break;
         default :
-            print_error('Undefined element - can\'t create popup window.');
+            print_error('cannotcreatepopupwin');
             break;
     }
 
@@ -3676,7 +3676,7 @@ function build_navigation($extranavlinks, $cm = null) {
                     'a $cm parameter. If you get $cm using get_coursemodule_from_instance or '.
                     'get_coursemodule_from_id, this will be done automatically.', DEBUG_DEVELOPER);
             if (!$cm->modname = get_field('modules', 'name', 'id', $cm->module)) {
-                print_error('Cannot get the module type in build navigation.');
+                print_error('cannotmoduletype');
             }
         }
         if (!isset($cm->name)) {
@@ -3684,7 +3684,7 @@ function build_navigation($extranavlinks, $cm = null) {
                     'a $cm parameter. If you get $cm using get_coursemodule_from_instance or '.
                     'get_coursemodule_from_id, this will be done automatically.', DEBUG_DEVELOPER);
             if (!$cm->name = get_field($cm->modname, 'name', 'id', $cm->instance)) {
-                print_error('Cannot get the module name in build navigation.');
+                print_error('cannotmodulename');
             }
         }
         $navlinks[] = array(
@@ -5755,7 +5755,7 @@ function editorhelpbutton(){
                     $titles[] = get_string('helptext');
                     break;
                 default :
-                    print_error('Unknown help topic '.$item);
+                    print_error('unknownhelp', '', '', $item);
             }
         }
         $i++;