From 5832a6f34b5d661e7387a3bb7fc005f2dfd7860a Mon Sep 17 00:00:00 2001 From: dongsheng Date: Thu, 24 Apr 2008 02:48:36 +0000 Subject: [PATCH] MDL-14129, fix print_error call --- backup/lib.php | 10 +++++----- backup/restore.php | 12 ++++++------ backup/restorelib.php | 4 ++-- backup/try.php | 2 +- lang/en_utf8/error.php | 6 ++++++ 5 files changed, 20 insertions(+), 14 deletions(-) diff --git a/backup/lib.php b/backup/lib.php index f54eef308d..b992db1b41 100644 --- a/backup/lib.php +++ b/backup/lib.php @@ -375,10 +375,10 @@ } } } else { - print_error("Upgrade of backup system failed! (Could not update version in config table)"); + print_error("upgradeversionfail"); } } else { - print_error("Backup tables could NOT be set up successfully!"); + print_error("backuptablefail"); } } @@ -448,10 +448,10 @@ } } } else { - print_error("Upgrade of backup system failed! (Could not update version in config table)"); + print_error("upgradeversionfail"); } } else { - print_error("Upgrade failed! See backup/version.php"); + print_error('upgradefail', '', '','See backup/version.php'); } } else if ($backup_version < $CFG->backup_version) { @@ -590,7 +590,7 @@ if(!function_exists('utf8_encode')) { if (empty($justcheck)) { - print_error('You need to add XML support to your PHP installation'); + print_error('needphpext', '', '', 'XML'); } else { return false; } diff --git a/backup/restore.php b/backup/restore.php index 826bb96ce5..475054aba7 100644 --- a/backup/restore.php +++ b/backup/restore.php @@ -53,23 +53,23 @@ require_login($id); if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_COURSE, $id))) { if (empty($to)) { - print_error("You need to be a teacher or admin user to use this page.", '', "$CFG->wwwroot/login/index.php"); + print_error("cannotuseadminadminorteacher", '', "$CFG->wwwroot/login/index.php"); } else { if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_COURSE, $to)) && !has_capability('moodle/site:import', get_context_instance(CONTEXT_COURSE, $to))) { - print_error("You need to be a teacher or admin user to use this page.", '', "$CFG->wwwroot/login/index.php"); + print_error("cannotuseadminadminorteacher", '', "$CFG->wwwroot/login/index.php"); } } } } else { if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_SYSTEM, SITEID))) { - print_error("You need to be an admin user to use this page.", '', "$CFG->wwwroot/login/index.php"); + print_error("cannotuseadmin", '', "$CFG->wwwroot/login/index.php"); } } //Check site if (!$site = get_site()) { - print_error("Site not found!"); + print_error("cannotfindsite"); } //Check necessary functions exists. Thanks to gregb@crowncollege.edu @@ -118,7 +118,7 @@ //Get and check course if (! $course = get_record("course", "id", $id)) { - print_error("Course ID was incorrect (can't find it)"); + print_error('invalidcourseid', '', '', $id); } //Print header @@ -161,7 +161,7 @@ } else if ($launch == "execute") { //Prevent multiple restore executions... if (empty($SESSION->cancontinue)) { - print_error("Multiple restore execution not allowed!"); + print_error('multiplerestorenotallow'); } //Unset this for the future unset($SESSION->cancontinue); diff --git a/backup/restorelib.php b/backup/restorelib.php index b2ddf34e52..f8b4919ff8 100644 --- a/backup/restorelib.php +++ b/backup/restorelib.php @@ -2445,7 +2445,7 @@ define('RESTORE_GROUPS_GROUPINGS', 3); } else { // should not happen, as we check in restore_chech.php // but handle the error if it does - print_error("This backup file contains external Moodle Network Hosts that are not configured locally."); + print_error('backupcontainexternal', 'error'); } } unset($user->mnethosturl); @@ -8192,7 +8192,7 @@ define('RESTORE_GROUPS_GROUPINGS', 3); //Open file for writing //First, we check the course_id backup data folder exists and create it as necessary in CFG->dataroot if (!$dest_dir = make_upload_directory("$restore->course_id/backupdata")) { // Backup folder - print_error("Could not create backupdata folder. The site administrator needs to fix the file permissions"); + print_error('cannotcreatebackupdir'); } $status = check_dir_exists($dest_dir,true); $restorelog_file = fopen("$dest_dir/restorelog.html","a"); diff --git a/backup/try.php b/backup/try.php index 16d0c0e077..a845a6c3c4 100644 --- a/backup/try.php +++ b/backup/try.php @@ -11,7 +11,7 @@ //Check site if (!$site = get_site()) { - print_error("Site not found!"); + print_error("cannotfindsite"); } //Check necessary functions exists. Thanks to gregb@crowncollege.edu diff --git a/lang/en_utf8/error.php b/lang/en_utf8/error.php index 80fbbf3cde..811b5dd691 100644 --- a/lang/en_utf8/error.php +++ b/lang/en_utf8/error.php @@ -7,10 +7,12 @@ $string['blockdoesnotexist'] = 'This block does not exist'; $string['blockcannotinistantiate'] = 'Problem in instantiating block object'; $string['blockcannotconfig'] = 'This block does not support global configuration'; $string['backupcontainexternal'] = 'This backup file contains external Moodle Network Hosts that are not configured locally.'; +$string['backuptablefail'] = 'Backup tables could NOT be set up successfully!'; $string['cannotassignrole'] = 'Cannot assign role in course'; $string['cannotaddrss'] = 'You do not have permission to add rss feeds'; $string['cannotsaveconfig'] = 'Problem saving config \"$a[0]\" as \"$a[1]\" for plugin \"$a[2]\"'; $string['cannotsavefile'] = 'Cannot save the file\"$a[0]\/$a[1]\"!'; +$string['cannotcreatebackupdir'] = 'Could not create backupdata folder. The site administrator needs to fix the file permissions'; $string['cannotcreatelangdir'] = 'Cannot create lang dir.'; $string['cannotcreatelangbase'] = 'Error: Could not create base lang directory.'; $string['cannotcreatetempdir'] = 'Cannot create temp dir.'; @@ -121,6 +123,8 @@ $string['moduledoesnotexist'] = 'The instance of this module doesn\'t exist'; $string['modulemissingcode'] = 'Module $a is missing the code needed to perform this function'; $string['modulerequirementsnotmet'] = 'Module \"$a->modulename\" ($a->moduleversion) could not be installed. It requires a newer version of Moodle (currently you are using $a->currentmoodle, you need $a->requiremoodle).'; $string['mustbeteacher'] = 'You must be a teacher to look at this page'; +$string['multiplerestorenotallow'] = 'Multiple restore execution not allowed!'; +$string['needphpext'] = 'You need to add $a support to your PHP installation'; $string['noblocks'] = 'No blocks found!'; $string['nocontext'] = 'Sorry, but that course is not a valid context'; $string['noinstances'] = 'There are no instances of $a in this course!'; @@ -180,6 +184,8 @@ $string['usernotupdatedadmin'] = 'Can not update admin accounts.'; $string['usernotupdatederror'] = 'User not updated - error.'; $string['usernotupdatednotexists'] = 'User not updated - does not exist.'; $string['updatersserror'] = 'There was an error trying to update rss feed with id: $a'; +$string['upgradeversionfail'] = 'Upgrade of backup system failed! (Could not update version in config table)'; +$string['upgradefail'] = 'Upgrade failed! $a'; $string['wrongcall'] = 'This script is called wrongly'; $string['wrongcontextid'] = 'Context ID was incorrect (cannot find it)'; $string['wrongdestpath'] = 'Wrong destination path.'; -- 2.39.5