From 33aa5723ca1b7a40d7ad590fb19fb237d8097fce Mon Sep 17 00:00:00 2001 From: dongsheng Date: Wed, 30 Apr 2008 04:09:29 +0000 Subject: [PATCH] "MDL-14129, fix print_error call" --- calendar/event.php | 2 +- file.php | 18 +++++++++--------- index.php | 2 +- lang/en_utf8/debug.php | 1 + lang/en_utf8/error.php | 3 +++ lang/en_utf8/forum.php | 1 + 6 files changed, 16 insertions(+), 11 deletions(-) diff --git a/calendar/event.php b/calendar/event.php index 3fe21b87e888c..e065f26993514 100644 --- a/calendar/event.php +++ b/calendar/event.php @@ -107,7 +107,7 @@ $title = get_string('deleteevent', 'calendar'); $event = get_record('event', 'id', $eventid); if($event === false) { - print_error('Invalid event'); + print_error('invalidevent'); } if(!calendar_edit_event_allowed($event)) { print_error('You are not authorized to do this'); diff --git a/file.php b/file.php index dc23897ca420e..efd78a5604001 100644 --- a/file.php +++ b/file.php @@ -28,9 +28,9 @@ // relative path must start with '/', because of backup/restore!!! if (!$relativepath) { - print_error('No valid arguments supplied or incorrect server configuration'); + print_error('invalidargorconf'); } else if ($relativepath{0} != '/') { - print_error('No valid arguments supplied, path does not start with slash!'); + print_error('pathdoesnotstartslash'); } $pathname = $CFG->dataroot.$relativepath; @@ -38,18 +38,18 @@ // extract relative path components $args = explode('/', trim($relativepath, '/')); if (count($args) == 0) { // always at least courseid, may search for index.html in course root - print_error('No valid arguments supplied'); + print_error('invalidarguments'); } // security: limit access to existing course subdirectories if (($args[0]!='blog') and (!$course = get_record_sql("SELECT * FROM {$CFG->prefix}course WHERE id='".(int)$args[0]."'"))) { - print_error('Invalid course ID'); + print_error('invalidcourseid'); } // security: prevent access to "000" or "1 something" directories // hack for blogs, needs proper security check too if (($args[0] != 'blog') and ($args[0] != $course->id)) { - print_error('Invalid course ID'); + print_error('invalidcourseid'); } // security: login to course if necessary @@ -57,7 +57,7 @@ // in order to avoid messing redirects. MDL-14495 if ($args[0] == 'blog') { if (empty($CFG->bloglevel)) { - print_error('Blogging is disabled!'); + print_error('blogdisable', 'blog'); } else if ($CFG->bloglevel < BLOG_GLOBAL_LEVEL) { require_login(0, true, null, false); } else if ($CFG->forcelogin) { @@ -78,7 +78,7 @@ // security: only editing teachers can access backups if ((count($args) >= 2) and (strtolower($args[1]) == 'backupdata')) { if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_COURSE, $course->id))) { - print_error('Access not allowed'); + print_error('nopermissions'); } else { $lifetime = 0; //disable browser caching for backups } @@ -108,7 +108,7 @@ $lifetime = 0; // do not cache assignments, students may reupload them if (!has_capability('mod/assignment:grade', get_context_instance(CONTEXT_COURSE, $course->id)) and $args[4] != $USER->id) { - print_error('Access not allowed'); + print_error('nopermissions'); } } @@ -152,7 +152,7 @@ "AND r.type = 'file' " . "AND r.reference = '{$reference}'"; if (count_records_sql($sql)) { - print_error('Access not allowed'); + print_error('nopermissions'); } } diff --git a/index.php b/index.php index b79eebc71365b..0b5c9d41d5e47 100644 --- a/index.php +++ b/index.php @@ -194,7 +194,7 @@ require_once($CFG->dirroot .'/mod/forum/lib.php'); if (! $newsforum = forum_get_course_forum($SITE->id, 'news')) { - print_error('Could not find or create a main news forum for the site'); + print_error('cannotfindorcreateforum', 'forum'); } if (!empty($USER->id)) { diff --git a/lang/en_utf8/debug.php b/lang/en_utf8/debug.php index d0d11ccb7008b..099cbaf2cd981 100644 --- a/lang/en_utf8/debug.php +++ b/lang/en_utf8/debug.php @@ -15,6 +15,7 @@ $string['erroroccur'] = 'An error has occurred 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['nomodules'] = 'No modules found!!'; $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 3d771fd9c2953..9d5fe5dd6fbe0 100644 --- a/lang/en_utf8/error.php +++ b/lang/en_utf8/error.php @@ -86,10 +86,12 @@ $string['guestnoeditprofileother'] = 'The guest user profile cannot be edited'; $string['invalidaction'] = 'Invalid action parameter.'; $string['invalidarguments'] = 'No valid arguments supplied'; +$string['invalidargorconf'] = 'No valid arguments supplied or incorrect server configuration'; $string['invalidaccessparameter'] = 'Invalid access parameter.'; $string['invalidcourse'] = 'Invalid course'; $string['invalidcourseid'] = 'You are tring to use an invalid course ID: ($a)'; $string['invalidcoursemodule'] = 'Bad course module ID'; +$string['invalidevent'] = 'Invalid event'; $string['invalidcoursenameshort'] = 'Invalid short course name'; $string['invalidevent'] = 'Invalid event'; $string['invalidfieldname'] = '\"$a\" is not a valid field name'; @@ -147,6 +149,7 @@ $string['onlyeditingteachers'] = 'Only editing teachers can do that.'; $string['onlyeditown'] = 'You can only edit your own information'; $string['pagenotexist'] = 'An unusual error occurred (tried to reach a page that doesn\'t exist).'; +$string['pathdoesnotstartslash'] = 'No valid arguments supplied, path does not start with slash!'; $string['pleasereport'] = 'If you have time, please let us know what you were trying to do when the error occurred:'; $string['pluginrequirementsnotmet'] = 'Plugin \"$a->pluginname\" ($a->pluginversion) could not be installed. It requires a newer version of Moodle (currently you are using $a->currentmoodle, you need $a->requiremoodle).'; $string['processingstops'] = 'Processing stops here. Remaining records ignored.'; diff --git a/lang/en_utf8/forum.php b/lang/en_utf8/forum.php index d27588b2ae8c7..ce9e661a63915 100644 --- a/lang/en_utf8/forum.php +++ b/lang/en_utf8/forum.php @@ -29,6 +29,7 @@ $string['cannotviewpostyet'] = 'You cannot read other students questions in this discussion yet because you haven\'t posted'; $string['cannotadddiscussion'] = 'Adding discussions to this forum requires group membership.'; $string['cannotadddiscussionall'] = 'You do not have permission to add a new discussion topic for all participants.'; +$string['cannotfindorcreateforum'] = 'Could not find or create a main news forum for the site'; $string['cleanreadtime'] = 'Mark old posts as read hour'; $string['configcleanreadtime'] = 'The hour of the day to clean old posts from the \'read\' table.'; $string['configdisplaymode'] = 'The default display mode for discussions if one isn\'t set.';