"MDL-14129, fix hardcoded print_error"

This commit is contained in:
dongsheng
2008-09-25 02:09:49 +00:00
parent 85c30b9c91
commit 9b34dc6e75
5 changed files with 13 additions and 9 deletions
+6 -6
View 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