From dbf91d9d632547d87948f9f3c47504e1f5505867 Mon Sep 17 00:00:00 2001 From: dongsheng Date: Sat, 26 Apr 2008 11:02:51 +0000 Subject: [PATCH] MDL-14129, fix print_error --- course/user.php | 8 ++++---- course/view.php | 10 +++++----- lang/en_utf8/error.php | 7 +++++++ 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/course/user.php b/course/user.php index 8768086eac..8806e66139 100644 --- a/course/user.php +++ b/course/user.php @@ -14,11 +14,11 @@ $perpage = optional_param('perpage', 100, PARAM_INT); if (! $course = get_record("course", "id", $id)) { - print_error("Course id is incorrect."); + print_error('invalidcourseid', 'error'); } if (! $user = get_record("user", "id", $user)) { - print_error("User ID is incorrect"); + print_error('invaliduserid', 'error'); } //require_login($course); @@ -29,7 +29,7 @@ // if in either context, we can read report, then we can proceed if (!(has_capability('moodle/site:viewreports', $coursecontext) or ($course->showreports and $USER->id == $user->id) or has_capability('moodle/user:viewuseractivitiesreport', $personalcontext))) { - print_error("You are not allowed to look at this page"); + print_error('nopermissiontoviewpage', 'error'); } add_to_log($course->id, "course", "user report", "user.php?id=$course->id&user=$user->id&mode=$mode", "$user->id"); @@ -102,7 +102,7 @@ case 'stats': if (empty($CFG->enablestats)) { - print_error("Stats is not enabled."); + print_error('statsdisable', 'error'); } require_once($CFG->dirroot.'/lib/statslib.php'); diff --git a/course/view.php b/course/view.php index 60b7547526..5fc275c5f2 100644 --- a/course/view.php +++ b/course/view.php @@ -22,20 +22,20 @@ if (empty($id) && empty($name) && empty($idnumber)) { - print_error("Must specify course id, short name or idnumber"); + print_error('unspecifycourseid', 'error'); } if (!empty($name)) { if (! ($course = get_record('course', 'shortname', $name)) ) { - print_error('Invalid short course name'); + print_error('invalidcoursenameshort', 'error'); } } else if (!empty($idnumber)) { if (! ($course = get_record('course', 'idnumber', $idnumber)) ) { - print_error('Invalid course idnumber'); + print_error('invalidcourseid', 'error'); } } else { if (! ($course = get_record('course', 'id', $id)) ) { - print_error('Invalid course id'); + print_error('invalidcourseid', 'error'); } } @@ -218,7 +218,7 @@ $section->id = insert_record('course_sections', $section); } if (! $sections = get_all_sections($course->id) ) { // Try again - print_error('Error finding or creating section structures for this course'); + print_error('cannotcreateorfindstructs', 'error'); } } diff --git a/lang/en_utf8/error.php b/lang/en_utf8/error.php index 811b5dd691..b8d3e844bf 100644 --- a/lang/en_utf8/error.php +++ b/lang/en_utf8/error.php @@ -17,6 +17,7 @@ $string['cannotcreatelangdir'] = 'Cannot create lang dir.'; $string['cannotcreatelangbase'] = 'Error: Could not create base lang directory.'; $string['cannotcreatetempdir'] = 'Cannot create temp dir.'; $string['cannotcreatesitedir'] = 'Cannot create site folder. The site administrator needs to fix the file permissions.'; +$string['cannotcreateorfindstructs'] = 'Error finding or creating section structures for this course'; $string['cannotcustomizelocallang'] = 'You do not have permission to customize the strings translation. This permission is controlled by the capability "moodle/site:langeditlocal". Set this capability to allow you to edit local language packages in case you want to modify translations for your site.'; $string['cannotdeletelangcache'] = 'Language cache can not be deleted, please fix permissions in dataroot/cache/languages!'; $string['cannotdeleterole'] = 'It can not be deleted, because $a'; @@ -89,6 +90,8 @@ $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['invalidcoursenameshort'] = 'Invalid short course name'; +$string['invalidevent'] = 'Invalid event'; $string['invalidfieldname'] = '\"$a\" is not a valid field name'; $string['invalidfiletype'] = '\"$a\" is not a valid file type'; $string['invalidgroupid'] = 'INcorrect group id specified.'; @@ -134,6 +137,7 @@ $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)'; +$string['nopermissiontoviewpage'] = 'You are not allowed to look at this patge'; $string['nosite'] = 'No sites'; $string['nositeid'] = 'No site ID'; $string['nostatstodisplay'] = 'There is no available data to display, sorry.'; @@ -157,13 +161,16 @@ $string['sessionipnomatch'] = 'Sorry, but your IP number seems to have changed f $string['statscatchupmode'] = 'Statistics is currently in catchup mode. So far $a->daysdone day(s) have been processed and $a->dayspending are pending. Check back soon!'; $string['tagnotfound'] = 'The specified tag was not found in the database'; $string['unicodeupgradeerror'] = 'Sorry, but your database is not already in Unicode, and this version of Moodle is not able to migrate your database to Unicode. Please upgrade to Moodle 1.7.x first and perform the Unicode migration from the Admin page. After that is done you should be able to migrate to Moodle $a'; +$string['unspecifycourseid'] = 'Must specify course id, short name or idnumber'; $string['statsnodata'] = 'There is no available data for that combination of course and time period.'; +$string['statsdisable'] = 'Stats is not enabled.'; $string['unknowaction']= 'Unknown action!'; $string['unknowncourse'] = 'Unknown course named \"$a\"'; $string['unknowncourseidnumber'] = 'Unknown Course ID \"$a\"'; $string['unknowngroup'] = 'Unknown group \"$a\"'; $string['unknownrole'] = 'Unknown role \"$a\"'; $string['unknownuseraction'] = 'Sorry, I do not understand this user action.'; +$string['unsupportedevent'] = 'Unsupported event type'; $string['urlnotdefinerss'] = 'URL not defined for rss feed'; $string['userautherror'] = 'Unknown auth plugin.'; $string['userauthunsupported'] = 'Auth plugin not supported here.'; -- 2.39.5