From 9b34dc6e7547fe6dc85244ec30ed98a63be10fb5 Mon Sep 17 00:00:00 2001 From: dongsheng Date: Thu, 25 Sep 2008 02:09:49 +0000 Subject: [PATCH] "MDL-14129, fix hardcoded print_error" --- course/index.php | 2 +- course/moodleform_mod.php | 2 +- course/report/progress/index.php | 2 +- course/togglecompletion.php | 12 ++++++------ lang/en_utf8/error.php | 4 ++++ 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/course/index.php b/course/index.php index f77b1e15c9..db389f752d 100644 --- a/course/index.php +++ b/course/index.php @@ -100,7 +100,7 @@ require_once('delete_category_form.php'); if (!$deletecat = $DB->get_record('course_categories', array('id'=>$delete))) { - error('Incorrect category id', 'index.php'); + print_error('invalidcategoryid'); } $heading = get_string('deletecategory', '', format_string($deletecat->name)); diff --git a/course/moodleform_mod.php b/course/moodleform_mod.php index 03f7f84b19..b7a749143f 100644 --- a/course/moodleform_mod.php +++ b/course/moodleform_mod.php @@ -249,7 +249,7 @@ class moodleform_mod extends moodleform { $matches=array(); if (!preg_match('/^mod_([^_]+)_mod_form$/', $this->_formname, $matches)) { debugging('Use $modname parameter or rename form to mod_xx_mod_form, where xx is name of your module'); - error('Unknown module name for form'); + print_error('unknownmodulename'); } $modname=$matches[1]; } diff --git a/course/report/progress/index.php b/course/report/progress/index.php index d1d572763e..0a104a56e9 100644 --- a/course/report/progress/index.php +++ b/course/report/progress/index.php @@ -6,7 +6,7 @@ global $DB; // Get course $course=$DB->get_record('course',array('id'=>required_param('course',PARAM_INT))); if(!$course) { - error('Specified course not found'); + print_error('invalidcourseid'); } // Sort (default lastname, optionally firstname) diff --git a/course/togglecompletion.php b/course/togglecompletion.php index 8c60765cd4..44a72c83d8 100644 --- a/course/togglecompletion.php +++ b/course/togglecompletion.php @@ -13,27 +13,27 @@ switch($targetstate) { case COMPLETION_INCOMPLETE: break; default: - error('Unsupported completion state'); + print_error('unsupportedstate'); } $fromajax=optional_param('fromajax',0,PARAM_INT); function error_or_ajax($message) { global $fromajax; if($fromajax) { - print $message; + print get_string($message, 'error'); exit; } else { - error($message); + print_error($message); } } // Get course-modules entry if(!($cm=$DB->get_record('course_modules',array('id'=>$cmid)))) { - error_or_ajax('Activity ID unknown'); + error_or_ajax('invalidactivityid'); } if(!($course=$DB->get_record('course',array('id'=>$cm->course)))) { - error_or_ajax('Missing course (database corrupt?)'); + error_or_ajax('invalidcourseid'); } // Check user is logged in @@ -41,7 +41,7 @@ require_login($course); // Check completion state is manual if($cm->completion!=COMPLETION_TRACKING_MANUAL) { - error_or_ajax('Activity does not provide manual completion tracking'); + error_or_ajax('cannotmanualctrack'); } // Now change state diff --git a/lang/en_utf8/error.php b/lang/en_utf8/error.php index 85f506ca09..a070242d2c 100644 --- a/lang/en_utf8/error.php +++ b/lang/en_utf8/error.php @@ -83,6 +83,7 @@ $string['cannotgetdata'] = 'Cannot get data'; $string['cannotgradeuser'] = 'Cannot grade this user'; $string['cannothaveparentcate'] = 'Course category cannot have parent!'; $string['cannotmailconfirm'] = 'Error sending password change confirmation email'; +$string['cannotmanualctrack'] = 'Activity does not provide manual completion tracking'; $string['cannotmapfield'] = 'Mapping collision detected - two fields maps to the same grade item $a'; $string['cannotmarktopic'] = 'Could not mark that topic for this course'; $string['cannotmoverolewithid'] = 'Cannot move role with ID $a'; @@ -223,6 +224,7 @@ $string['guestnorate'] = 'Guests are not allowed to rate entries'; $string['guestnoeditprofileother'] = 'The guest user profile cannot be edited'; $string['hashpoolproblem'] = 'Incorrect pool file content $a.'; $string['invalidaction'] = 'Invalid action parameter'; +$string['invalidactivityid'] = 'Invalid Activity ID'; $string['invalidarguments'] = 'No valid arguments supplied'; $string['invalidargorconf'] = 'No valid arguments supplied or incorrect server configuration'; $string['invalidaccessparameter'] = 'Invalid access parameter'; @@ -404,11 +406,13 @@ $string['unknownhelp'] = 'Unknown help topic $a'; $string['unknowngroup'] = 'Unknown group \"$a\"'; $string['unknownrole'] = 'Unknown role \"$a\"'; $string['unknownuseraction'] = 'Sorry, I do not understand this user action'; +$string['unknownmodulename'] = 'Unknown module name for form'; $string['unknoworder'] = 'Unknown ordering'; $string['unknowparamtype'] = 'Unknown parameter type: $a'; $string['unknowquestiontype'] = 'Unsupported question type $a'; $string['unknowuploadaction'] = 'Error: Unknown upload action ($a)'; $string['unsupportedevent'] = 'Unsupported event type'; +$string['unsupportedstate'] = 'Unsupported completion state'; $string['upgraderequires19'] = 'Error: New Moodle version was installed on server, unfortunately upgrade from the previous version is not supported.
Please upgrade first to latest 1.9.x release. You can also return to previous version by reinstalling original files.'; $string['urlnotdefinerss'] = 'URL not defined for RSS feed'; $string['userautherror'] = 'Unknown auth plugin'; -- 2.39.5