]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-14129, create a new debug.php, and fix print_error() call
authordongsheng <dongsheng>
Wed, 9 Apr 2008 08:21:51 +0000 (08:21 +0000)
committerdongsheng <dongsheng>
Wed, 9 Apr 2008 08:21:51 +0000 (08:21 +0000)
admin/auth_config.php
admin/block.php
admin/blocks.php
admin/delete.php
admin/filters.php
admin/index.php
admin/langdoc.php
lang/en_utf8/debug.php [new file with mode: 0644]
lang/en_utf8/error.php

index 3165e5fcc52f5e4e75e97ffb802899069e4155ce..597305e9907bf3ce9734486bcafce4f76bb0ebfa 100644 (file)
@@ -34,7 +34,7 @@ if ($frm = data_submitted() and confirm_sesskey()) {
                     $plugin = "auth/$auth";
                     $name   = $matches[1];
                     if (!set_config($name, $value, $plugin)) {
-                        print_error("Problem saving config $name as $value for plugin $plugin");
+                        print_error("cannotsaveconfig", 'error', '', array($name, $value, $plugin));
                     }
                 }
             }
index ffe68d0d77b74315fa4a21802dea9952d341e32a..ccc58915db3550f867cd3373469aff223d080bd1 100644 (file)
@@ -9,14 +9,14 @@
     $blockid = required_param('block', PARAM_INT);
 
     if(!$blockrecord = blocks_get_record($blockid)) {
-        print_error('This block does not exist');
+        print_error('blockdoesnotexist', 'error');
     }
 
     admin_externalpage_setup('blocksetting'.$blockrecord->name);
 
     $block = block_instance($blockrecord->name);
     if($block === false) {
-        print_error('Problem in instantiating block object');
+        print_error('blockcannotinistantiate', 'error');
     }
 
     // Define the data we're going to silently include in the instance config form here,
@@ -34,7 +34,7 @@
              print_error('confirmsesskeybad', 'error');
         }
         if(!$block->has_config()) {
-            print_error('This block does not support global configuration');
+            print_error('blockcannotconfig', 'error');
         }
         $remove = array_keys($hiddendata);
         foreach($remove as $item) {
index 05131c396ede036f2a8d61942baeb217d295cabd..d585b9f9779d76277e340b0d45689f5c268f32c0 100644 (file)
@@ -33,7 +33,7 @@
 
     if (!empty($hide) && confirm_sesskey()) {
         if (!$block = get_record('block', 'id', $hide)) {
-            print_error("Block doesn't exist!");
+            print_error('blockdoesnotexist', 'error');
         }
         set_field('block', 'visible', '0', 'id', $block->id);      // Hide block
         admin_get_root(true, false);  // settings not required - only pages
@@ -41,7 +41,7 @@
 
     if (!empty($show) && confirm_sesskey() ) {
         if (!$block = get_record('block', 'id', $show)) {
-            print_error("Block doesn't exist!");
+            print_error('blockdoesnotexist', 'error');
         }
         set_field('block', 'visible', '1', 'id', $block->id);      // Show block
         admin_get_root(true, false);  // settings not required - only pages
@@ -49,7 +49,7 @@
 
     if (!empty($multiple) && confirm_sesskey()) {
         if (!$block = blocks_get_record($multiple)) {
-            print_error("Block doesn't exist!");
+            print_error('blockdoesnotexist', 'error');
         }
         $block->multiple = !$block->multiple;
         update_record('block', $block);
@@ -61,7 +61,7 @@
         print_heading($strmanageblocks);
 
         if (!$block = blocks_get_record($delete)) {
-            print_error("Block doesn't exist!");
+            print_error('blockdoesnotexist', 'error');
         }
 
         if (!block_is_compatible($block->name)) {
index bc70d504813e5ff3533106a33f8002c4a340e948..afc7ea9933e11e88fb1f8ba2a48f063cc08ce5fc 100644 (file)
@@ -37,7 +37,7 @@
     }
 
     if (!confirm_sesskey()) {
-        print_error('This script was called wrongly');
+        print_error('wrongcall', 'error');
     }
 
     /// OK, here goes ...
index acfad110568cb0f7491d2689391a457cc57681c8..06ce1c88f59175acb90436e755d9aa3c9da464f5 100644 (file)
@@ -52,8 +52,8 @@
 
     case 'show':
         // check filterpath is valid
-        if (!array_key_exists($filterpath, $installedfilters)) {
-            print_error("Filter $filterpath is not currently installed", '', $url);
+        if (!array_key_exists($filterpath, $installedfilters)) 
+            print_error('filternotinstalled', 'error', $url, $filterpath);
         } elseif (array_search($filterpath,$activefilters)) {
             // filterpath is already active - doubleclick??
         } else {
@@ -67,7 +67,7 @@
         $key=array_search($filterpath, $activefilters);
         // check filterpath is valid
         if ($key===false) {
-            print_error("Filter $filterpath is not currently active", '', $url);
+            print_error("filternotactive", 'error', $url, $filterpath );
         } elseif ($key>=(count($activefilters)-1)) {
             // cannot be moved any further down - doubleclick??
         } else {
@@ -82,7 +82,7 @@
         $key=array_search($filterpath, $activefilters);
         // check filterpath is valid
         if ($key===false) {
-            print_error("Filter $filterpath is not currently active", '', $url);
+            print_error("filternotactive", 'error', $url, $filterpath );
         } elseif ($key<1) {
             //cannot be moved any further up - doubleclick??
         } else {
index 4cea1b6b7cd54ed1837181ccbeb7d087f8ec4983..051d1d40daa849feec436047fe671fa974fcc849 100644 (file)
     $documentationlink = '<a href="http://docs.moodle.org/en/Installation">Installation docs</a>';
 
     if (ini_get_bool('session.auto_start')) {
-        print_error("The PHP server variable 'session.auto_start' should be Off - $documentationlink");
+        print_error('phpvaroff', 'debug', '', array('session.auto_start', $documentationlink));
     }
 
     if (ini_get_bool('magic_quotes_runtime')) {
-        print_error("The PHP server variable 'magic_quotes_runtime' should be Off - $documentationlink");
+        print_error('phpvaroff', 'debug', '', array('magic_quotes_runtime', $documentationlink));
     }
 
     if (!ini_get_bool('file_uploads')) {
-        print_error("The PHP server variable 'file_uploads' is not turned On - $documentationlink");
+        print_error('phpvaron', 'debug', '', array('file_uploads', $documentationlink));
     }
 
     if (empty($CFG->prefix) && $CFG->dbfamily != 'mysql') {  //Enforce prefixes for everybody but mysql
-        print_error('$CFG->prefix can\'t be empty for your target DB (' . $CFG->dbtype . ')');
+        print_error('prefixcannotbeempty', 'debug', '', array($CFG->prefix, $CFG->dbtype));
     }
 
     if ($CFG->dbfamily == 'oracle' && strlen($CFG->prefix) > 2) { //Max prefix length for Oracle is 2cc
-        print_error('$CFG->prefix maximum allowed length for Oracle DBs is 2cc.');
+        print_error('prefixlimit', 'debug', '', $CFG->prefix);
     }
 
 /// Check that config.php has been edited
 
     if ($CFG->wwwroot == "http://example.com/moodle") {
-        print_error("Moodle has not been configured yet.  You need to edit config.php first.");
+        print_error('configmoodle', 'debug');
     }
 
 
 
     $dirroot = dirname(realpath("../index.php"));
     if (!empty($dirroot) and $dirroot != $CFG->dirroot) {
-        print_error("Please fix your settings in config.php:
-              <p>You have:
-              <p>\$CFG->dirroot = \"".addslashes($CFG->dirroot)."\";
-              <p>but it should be:
-              <p>\$CFG->dirroot = \"".addslashes($dirroot)."\";",
-              "./");
+        print_error('fixsetting', 'debug', '', array(addslashes($CFG->dirroot), addslashes($dirroot)));
     }
 
 /// Set some necessary variables during set-up to avoid PHP warnings later on this page
     }
 
     if (!$version or !$release) {
-        print_error('Main version.php was not readable or specified'); // without version, stop
+        print_error('withoutversion', 'debug'); // without version, stop
     }
 
 /// Check if the main tables have been installed yet or not.
         } else if (file_exists("$CFG->libdir/db/$CFG->dbtype.sql")) {
             $status = modify_database("$CFG->libdir/db/$CFG->dbtype.sql"); //Old method
         } else {
-            print_error("Error: Your database ($CFG->dbtype) is not yet fully supported by Moodle or install.xml is not present.  See the lib/db directory.");
+            print_error('dbnotsupport', 'debug', '', $CFG->dbtype);
         }
 
         // all new installs are in unicode - keep for backwards compatibility and 1.8 upgrade checks
             notify($strdatabasesuccess, "green");
             require_once $CFG->dirroot.'/mnet/lib.php';
         } else {
-            print_error("Error: Main databases NOT set up successfully");
+            print_error('dbnotsetup', 'debug');
         }
         print_continue('index.php');
         print_footer('none');
                         moodle_install_roles();
                         set_config('rolesactive', 1);
                     } else if (!update_capabilities()) {
-                        print_error('Had trouble upgrading the core capabilities for the Roles System');
+                        print_error('cannotupgradecapabilities', 'debug');
                     }
                     // update core events
                     events_update_definition();
                         print_footer('none');
                         exit;
                     } else {
-                        print_error('Upgrade failed!  (Could not update version in config table)');
+                        print_error('cannotupdateversion', 'debug');
                     }
             /// Main upgrade not success
                 } else {
         }
     } else {
         if (!set_config("version", $version)) {
-            print_error("A problem occurred inserting current version into databases");
+            print_error('cannotupdateversion', 'debug');
         }
     }
 
 
     if ($release <> $CFG->release) {  // Update the release version
         if (!set_config("release", $release)) {
-            print_error("ERROR: Could not update release version in database!!");
+            print_error("cannotupdaterelease", 'debug');
         }
     }
 
         $newsite->timemodified = time();
 
         if (!$newid = insert_record('course', $newsite)) {
-            print_error("Serious Error! Could not set up the site!");
+            print_error('cannotsetupsite', 'error');
         }
         // make sure course context exists
         get_context_instance(CONTEXT_COURSE, $newid);
         $cat->name = get_string('miscellaneous');
         $cat->depth = 1;
         if (!$catid = insert_record('course_categories', $cat)) {
-            print_error("Serious Error! Could not set up a default course category!");
+            print_error('cannotsetupcategory', 'error');
         }
         // make sure category context exists
         get_context_instance(CONTEXT_COURSECAT, $catid);
index b456ac1961afa255ae605c58ff6596ba590f3c20..a645ea8fb91a6c5591c5ba584e4c0931d49d885e 100755 (executable)
@@ -51,7 +51,7 @@
             if (langdoc_save_file($langdir, $currentfile, $_POST['filedata'])) {
                 notify(get_string("changessaved")." ($langdir/$currentfile)", "green");
             } else {
-                print_error("Could not save the file '$currentfile'!", '', "langdoc.php?currentfile=$currentfile&sesskey=$USER->sesskey");
+                print_error("cannotsavefile", 'error', "langdoc.php?currentfile=$currentfile&sesskey=$USER->sesskey", $currentfile);
             }
         }
     }
@@ -63,7 +63,7 @@
     // Get all files from /docs directory
 
     if (! $files = get_directory_list("$CFG->dirroot/lang/en_utf8/docs", "CVS")) {
-        print_error("Could not find English language docs files!");
+        print_error('cannotfinddocs', 'error', '', 'English');
     }
 
     $options = array();
@@ -83,7 +83,7 @@
     // Get all files from /help directory
 
     if (! $files = get_directory_list("$CFG->dirroot/lang/en_utf8/help", "CVS")) {
-        print_error("Could not find English language help files!");
+        print_error("cannotfindhelp", "error", "", "English");
     }
 
     foreach ($files as $filekey => $file) {    // check all the help files.
diff --git a/lang/en_utf8/debug.php b/lang/en_utf8/debug.php
new file mode 100644 (file)
index 0000000..35ea066
--- /dev/null
@@ -0,0 +1,19 @@
+<?php
+/*
+ * debug information for developer only
+ */
+$string['cannotupgradecapabilities'] = 'Had trouble upgrading the core capabilities for the Roles System';
+$string['cannotupdateversion'] = 'Upgrade failed!  (Could not update version in config table)';
+$string['cannotupdaterelease'] = 'ERROR: Could not update release version in database!!';
+$string['cannotsetupsite'] = 'Serious Error! Could not set up the site!';
+$string['configmoodle'] = 'Moodle has not been configured yet. You need to edit config.php first.';
+$string['dbnotsupport'] = 'Error: Your database ($a) is not yet fully supported by Moodle or install.xml is not present. See the lib/db directory.';
+$string['dbnotsetup'] = 'Error: Main databases NOT set up successfully';
+$string['fixsetting'] = 'Please fix your settings in config.php: <p>You have:</p> <p>\$CFG->dirroot = \"$a[0]\";</p> <p>but it should be:</p> <p>\$CFG->dirroot = \"$a[1]\"</p>';
+$string['phpvaroff'] = 'The PHP server variable \'$a[0]\' should be Off - $a[1]';
+$string['phpvaron'] = 'The PHP server variable \'$a[0]\' is not turned On - $a[1]';
+$string['prefixcannotbeempty'] = 'Table prefix \"$a[0]\" cannot be empty for your target DB ($a[1])';
+$string['prefixlimit'] = 'Table prefix \"$a\" maximum allowed length for Oracle DBs is 2cc.';
+$string['withoutversion'] = 'Main version.php was not readable or specified';
+
+?>
index 280e756dedc02a3a6a5e727b016d565ed31f28bc..2a63508a2acae7bf32d977aa31b22801a309f7eb 100644 (file)
@@ -22,6 +22,8 @@ $string['cannotfindhelp'] = 'Cannot find \"$a\" language help files';
 $string['cannotsavefile'] = 'Cannot save the file \"$a\".';
 $string['cannotsavemd5file'] = 'Cannot save md5 file.';
 $string['cannotsavezipfile'] = 'Cannot save ZIP file.';
+$string['cannotsetupcategory'] = 'Serious Error! Could not set up a default course category!';
+$string['cannotsetupsite'] = 'Serious Error! Could not set up the site!';
 $string['cannotunzipfile'] = 'Cannot unzip file.';
 $string['cannotviewprofile'] = 'You can not view the profile of this user.';
 $string['cantunenrollfrommetacourse'] = 'You can not unenrol from this meta course.';
@@ -47,6 +49,8 @@ $string['errorreadingfile'] = 'Error reading file \"$a\"';
 $string['errorunzippingfiles'] = 'Error unzipping files';
 $string['fieldrequired'] = '\"$a\" is a required field';
 $string['filenotfound'] = 'Sorry, the requested file could not be found';
+$string['filternotinstalled'] = 'Filter $a is not currently installed';
+$string['filternotactive'] = 'Filter $a is not currently active';
 $string['forumblockingtoomanyposts'] = 'You have exceeded the posting threshold set for this forum.';
 $string['groupalready'] = 'User already belongs to group $a';
 $string['groupexistforcourse'] = 'Group \"$a\" already exists for this course';
@@ -127,6 +131,7 @@ $string['usernotrenamedoff'] = 'User not renamed - renaming not allowed.';
 $string['usernotupdatedadmin'] = 'Can not update admin accounts.';
 $string['usernotupdatederror'] = 'User not updated - error.';
 $string['usernotupdatednotexists'] = 'User not updated - does not exist.';
+$string['wrongcall'] = 'This script is called wrongly';
 $string['wrongdestpath'] = 'Wrong destination path.';
 $string['wrongsourcebase'] = 'Wrong source URL base.';
 $string['wrongzipfilename'] = 'Wrong ZIP filename.';