From 8e9d88f2f6b5660687c9bd5decbac890126c13e5 Mon Sep 17 00:00:00 2001 From: dongsheng Date: Thu, 10 Apr 2008 03:44:09 +0000 Subject: [PATCH] MDL-14129, creating error string --- admin/multilangupgrade.php | 2 +- admin/register.php | 2 +- admin/replace.php | 2 +- admin/upgradeforumread.php | 2 +- admin/upgradelogs.php | 2 +- admin/uploadpicture.php | 4 ++-- admin/uploaduser.php | 2 +- admin/user.php | 22 +++++++++++----------- lang/en_utf8/debug.php | 5 +++++ lang/en_utf8/error.php | 6 ++++++ 10 files changed, 30 insertions(+), 19 deletions(-) diff --git a/admin/multilangupgrade.php b/admin/multilangupgrade.php index 257bea2c72..72dff0ae44 100644 --- a/admin/multilangupgrade.php +++ b/admin/multilangupgrade.php @@ -25,7 +25,7 @@ if (!$go or !data_submitted() or !confirm_sesskey()) { /// Print a form if (!$tables = $db->Metatables() ) { // No tables yet at all. - print_error("no tables"); + print_error('notables', 'debug'); } print_simple_box_start('center'); diff --git a/admin/register.php b/admin/register.php index 877b787a1f..bb0ce17266 100644 --- a/admin/register.php +++ b/admin/register.php @@ -16,7 +16,7 @@ } if (!$admin = get_admin()) { - print_error("No admins"); + print_error('noadmins', 'error'); } if (!$admin->country and $CFG->country) { diff --git a/admin/replace.php b/admin/replace.php index 98783ca507..1a6a2a35d1 100644 --- a/admin/replace.php +++ b/admin/replace.php @@ -35,7 +35,7 @@ if (!data_submitted() or !$search or !$replace or !confirm_sesskey()) { /// Pr print_simple_box_start('center'); if (!db_replace($search, $replace)) { - print_error('An error has occured during this process'); + print_error('erroroccur', debug); } print_simple_box_end(); diff --git a/admin/upgradeforumread.php b/admin/upgradeforumread.php index edf0c4d791..55b46579ec 100644 --- a/admin/upgradeforumread.php +++ b/admin/upgradeforumread.php @@ -9,7 +9,7 @@ $confirm = optional_param('confirm', 0, PARAM_BOOL); if ($CFG->version < 2005042300) { - print_error("This script does not work with this old version of Moodle"); + print_error('doesnotworkwitholdversion', 'debug'); } if (!$site = get_site()) { diff --git a/admin/upgradelogs.php b/admin/upgradelogs.php index fa27125d0a..9a7ebed6d9 100644 --- a/admin/upgradelogs.php +++ b/admin/upgradelogs.php @@ -8,7 +8,7 @@ $confirm = optional_param('confirm', 0, PARAM_BOOL); if ($CFG->version < 2004013101) { - print_error("This script does not work with this old version of Moodle"); + print_error('doesnotworkwitholdversion', 'debug'); } if (!$site = get_site()) { diff --git a/admin/uploadpicture.php b/admin/uploadpicture.php index 99dce0de52..e39111e102 100644 --- a/admin/uploadpicture.php +++ b/admin/uploadpicture.php @@ -35,11 +35,11 @@ require_login(); require_capability('moodle/site:uploadusers', get_context_instance(CONTEXT_SYSTEM, SITEID)); if (!$site = get_site()) { - print_error("Could not find site-level course"); + print_error('cannotfindsite', 'error'); } if (!$adminuser = get_admin()) { - print_error("Could not find site admin"); + print_error('noadmins', 'error'); } $strfile = get_string('file'); diff --git a/admin/uploaduser.php b/admin/uploaduser.php index b8f8854d9f..101dba6e7b 100755 --- a/admin/uploaduser.php +++ b/admin/uploaduser.php @@ -110,7 +110,7 @@ if (empty($iid)) { } if (!$columns = $cir->get_columns()) { - print_error('Error reading temporary file', '', $returnurl); + print_error('cannotreadtmpfile', 'error', $returnurl); } $mform = new admin_uploaduser_form2(null, $columns); // get initial date from form1 diff --git a/admin/user.php b/admin/user.php index eb1fd6f559..0eb045da65 100644 --- a/admin/user.php +++ b/admin/user.php @@ -22,7 +22,7 @@ $site = get_site(); if (!has_capability('moodle/user:update', $sitecontext) and !has_capability('moodle/user:delete', $sitecontext)) { - print_error('You do not have the required permission to edit/delete users.'); + print_error('nopermissions', 'error', '', 'edit/delete users'); } $stredit = get_string('edit'); @@ -40,7 +40,7 @@ if ($confirmuser and confirm_sesskey()) { if (!$user = get_record('user', 'id', $confirmuser)) { - print_error("No such user!"); + print_error('nousers'); } $auth = get_auth_plugin($user->auth); @@ -56,15 +56,15 @@ } else if ($delete and confirm_sesskey()) { // Delete a selected user, after confirmation if (!has_capability('moodle/user:delete', $sitecontext)) { - print_error('You do not have the required permission to delete a user.'); + print_error('nopermissions', 'error', '', 'delete a user'); } if (!$user = get_record('user', 'id', $delete)) { - print_error("No such user!"); + print_error('nousers', 'error'); } if (is_primary_admin($user->id)) { - print_error("You are not allowed to delete the primary admin user!"); + print_error('nopermissions', 'error', '', 'delete the primary admin user'); } if ($confirm != md5($delete)) { @@ -84,17 +84,17 @@ } else if ($acl and confirm_sesskey()) { if (!has_capability('moodle/user:delete', $sitecontext)) { // TODO: this should be under a separate capability - print_error('You are not permitted to modify the MNET access control list.'); + print_error('nopermissions', 'error', '', 'modify the NMET access control list'); } if (!$user = get_record('user', 'id', $acl)) { - print_error("No such user."); + print_error('nousers', 'error'); } if (!is_mnet_remote_user($user)) { - print_error('Users in the MNET access control list must be remote MNET users.'); + print_error('usermustbemnet', 'error'); } $accessctrl = strtolower(required_param('accessctrl', PARAM_ALPHA)); if ($accessctrl != 'allow' and $accessctrl != 'deny') { - print_error('Invalid access parameter.'); + print_error('invalidaccessparameter', 'error'); } $aclrecord = get_record('mnet_sso_access_control', 'username', $user->username, 'mnet_host_id', $user->mnethostid); if (empty($aclrecord)) { @@ -103,12 +103,12 @@ $aclrecord->username = $user->username; $aclrecord->accessctrl = $accessctrl; if (!insert_record('mnet_sso_access_control', $aclrecord)) { - print_error("Database error - Couldn't modify the MNET access control list."); + print_error('dbnotinsert', 'debug', '', 'the MNET access control list'); } } else { $aclrecord->accessctrl = $accessctrl; if (!update_record('mnet_sso_access_control', $aclrecord)) { - print_error("Database error - Couldn't modify the MNET access control list."); + print_error('dbnotupdate', 'debug', '', 'the MNET access control list'); } } $mnethosts = get_records('mnet_host', '', '', 'id', 'id,wwwroot,name'); diff --git a/lang/en_utf8/debug.php b/lang/en_utf8/debug.php index 35ea066847..58e972c463 100644 --- a/lang/en_utf8/debug.php +++ b/lang/en_utf8/debug.php @@ -7,9 +7,14 @@ $string['cannotupdateversion'] = 'Upgrade failed! (Could not update version in $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['dbnotinsert'] = 'Database error - Cannot insert ($a)'; +$string['dbnotupdate'] = 'Database error - Cannot update ($a)' $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['doesnotworkwitholdversion'] = 'This script does not work with this old verion of moodle'; +$string['erroroccur'] = 'An error has occured during this process'; $string['fixsetting'] = 'Please fix your settings in config.php:

You have:

\$CFG->dirroot = \"$a[0]\";

but it should be:

\$CFG->dirroot = \"$a[1]\"

'; +$string['notables'] = 'No Tables!'; $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])'; diff --git a/lang/en_utf8/error.php b/lang/en_utf8/error.php index 297740afe0..d09ff857e1 100644 --- a/lang/en_utf8/error.php +++ b/lang/en_utf8/error.php @@ -25,6 +25,8 @@ $string['cannotfinddocs'] = 'Cannot find \"$a\" language docs files'; $string['cannotfindinfo'] = 'Cannot find info for: \"$a\"'; $string['cannotfindhelp'] = 'Cannot find \"$a\" language help files'; $string['cannotfindlang'] = 'Cannot find \"$a\" language pack!'; +$string['cannotfindsite'] = 'Cannot find site-level course'; +$string['cannotreadtmpfile'] = 'Error reading temporary file'; $string['cannotsavefile'] = 'Cannot save the file \"$a\".'; $string['cannotsavemd5file'] = 'Cannot save md5 file.'; $string['cannotsavezipfile'] = 'Cannot save ZIP file.'; @@ -65,6 +67,7 @@ $string['groupnotaddederror'] = 'Group \"$a\" not added'; $string['groupunknown'] = 'Group $a not associated to specified course'; $string['guestnoeditprofile'] = 'The guest user cannot edit their profile'; $string['guestnoeditprofileother'] = 'The guest user profile cannot be edited'; +$string['invalidaccessparameter'] = 'Invalid access parameter.'; $string['invalidcourse'] = 'Invalid course'; $string['invalidfieldname'] = '\"$a\" is not a valid field name'; $string['invalidfiletype'] = '\"$a\" is not a valid file type'; @@ -94,6 +97,8 @@ $string['mustbeteacher'] = 'You must be a teacher to look at this page'; $string['nocontext'] = 'Sorry, but that course is not a valid context'; $string['noinstances'] = 'There are no instances of $a in this course!'; $string['nologinas'] = 'You are not allowed to login as that user'; +$string['noadmins'] = 'No administrators!'; +$string['nousers'] = 'No such user!'; $string['nonmeaningfulcontent'] = 'Non meaningful content'; $string['noparticipatorycms'] = 'Sorry, but you have no participatory course modules to report on.'; $string['nopermissions'] = 'Sorry, but you do not currently have permissions to do that ($a)'; @@ -124,6 +129,7 @@ $string['unknownuseraction'] = 'Sorry, I do not understand this user action.'; $string['userautherror'] = 'Unknown auth plugin.'; $string['userauthunsupported'] = 'Auth plugin not supported here.'; $string['useremailduplicate'] = 'Duplicate address'; +$string['usermustbemnet'] = 'Users in the MNET access control list must be remote MNET users.'; $string['usernotaddedadmin'] = 'Can not delete admin accounts.'; $string['usernotaddederror'] = 'User not added - error.'; $string['usernotaddedregistered'] = 'User not added - already registered.'; -- 2.39.5