"MDL-14129, fix hardcoded print_error"
authordongsheng <dongsheng>
Thu, 25 Sep 2008 02:09:49 +0000 (02:09 +0000)
committerdongsheng <dongsheng>
Thu, 25 Sep 2008 02:09:49 +0000 (02:09 +0000)
course/index.php
course/moodleform_mod.php
course/report/progress/index.php
course/togglecompletion.php
lang/en_utf8/error.php

index f77b1e15c9266acaa935fc67851e739e75f0458c..db389f752d93405303d45542429c2892553cc1ea 100644 (file)
         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));
index 03f7f84b19599ba46867983375e2bc997ed13c44..b7a749143f6a20ac3719607d4fc6a6332a394e20 100644 (file)
@@ -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];
         }
index d1d572763ec36f684f91d7f67c1220b1d38d1b1b..0a104a56e921345b9f1a2d1d37f85f7b2aa9923d 100644 (file)
@@ -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)
index 8c60765cd415fa806e661f4df3274f04902eca84..44a72c83d835ae6758670d3f7d34abf821d9d7a8 100644 (file)
@@ -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
index 85f506ca09a2bbe5ec8dc8f41e2e4c6ab05b9ec5..a070242d2c1059d11bda900040f96443d3d4d5a9 100644 (file)
@@ -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.<br />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';