From 1bb0aa0f068fa276832ab9156531a02e3bcf8281 Mon Sep 17 00:00:00 2001 From: dongsheng Date: Wed, 14 May 2008 07:24:28 +0000 Subject: [PATCH] "MDL-14129, fix print_error" --- grade/edit/tree/action.php | 10 +++++----- grade/edit/tree/calculation.php | 2 +- grade/edit/tree/category.php | 4 ++-- grade/edit/tree/grade.php | 14 +++++++------- grade/edit/tree/index.php | 4 ++-- lang/en_utf8/error.php | 15 +++++++++++++-- 6 files changed, 30 insertions(+), 19 deletions(-) diff --git a/grade/edit/tree/action.php b/grade/edit/tree/action.php index c6722edd476c3..7dcc15014db47 100644 --- a/grade/edit/tree/action.php +++ b/grade/edit/tree/action.php @@ -46,7 +46,7 @@ // what are we working with? if (!$element = $gtree->locate_element($eid)) { - print_error('Incorrect element id!', '', $returnurl); + print_error('invalidelementid', '', $returnurl); } $object = $element['object']; $type = $element['type']; @@ -56,7 +56,7 @@ case 'hide': if ($eid and confirm_sesskey()) { if (!has_capability('moodle/grade:manage', $context) and !has_capability('moodle/grade:hide', $context)) { - print_error('No permission to hide!', '', $returnurl); + print_error('nopermissiontohide', '', $returnurl); } if ($type == 'grade' and empty($object->id)) { $object->insert(); @@ -68,7 +68,7 @@ case 'show': if ($eid and confirm_sesskey()) { if (!has_capability('moodle/grade:manage', $context) and !has_capability('moodle/grade:hide', $context)) { - print_error('No permission to show!', '', $returnurl); + print_error('nopermissiontoshow', '', $returnurl); } if ($type == 'grade' and empty($object->id)) { $object->insert(); @@ -80,7 +80,7 @@ case 'lock': if ($eid and confirm_sesskey()) { if (!has_capability('moodle/grade:manage', $context) and !has_capability('moodle/grade:lock', $context)) { - print_error('No permission to lock!', '', $returnurl); + print_error('nopermissiontolock', '', $returnurl); } if ($type == 'grade' and empty($object->id)) { $object->insert(); @@ -92,7 +92,7 @@ case 'unlock': if ($eid and confirm_sesskey()) { if (!has_capability('moodle/grade:manage', $context) and !has_capability('moodle/grade:unlock', $context)) { - print_error('No permission to unlock!', '', $returnurl); + print_error('nopermissiontounlock', '', $returnurl); } if ($type == 'grade' and empty($object->id)) { $object->insert(); diff --git a/grade/edit/tree/calculation.php b/grade/edit/tree/calculation.php index 06e9e27850dea..92366fa8c6ca8 100644 --- a/grade/edit/tree/calculation.php +++ b/grade/edit/tree/calculation.php @@ -46,7 +46,7 @@ $returnurl = $gpr->get_return_url($CFG->wwwroot.'/grade/report.php?id='.$course->id); if (!$grade_item = grade_item::fetch(array('id'=>$id, 'courseid'=>$course->id))) { - print_error('Incorect item id'); + print_error('invaliditemid'); } // activity items and items without grade can not have calculation diff --git a/grade/edit/tree/category.php b/grade/edit/tree/category.php index 073f4019caa17..4ababb02d917b 100644 --- a/grade/edit/tree/category.php +++ b/grade/edit/tree/category.php @@ -48,7 +48,7 @@ if ($id) { if (!$grade_category = grade_category::fetch(array('id'=>$id, 'courseid'=>$course->id))) { - print_error('Incorrect category id!'); + print_error('invalidcategory'); } $grade_category->apply_forced_settings(); $category = $grade_category->get_record_data(); @@ -98,7 +98,7 @@ // Handle user preferences if (isset($data->pref_aggregationview)) { if (!grade_report::set_pref('aggregationview', $data->pref_aggregationview, $grade_category->id)) { - print_error("Could not set preference aggregationview to $value for this grade category"); + print_error('cannotsetprefgrade', '', '', $value); } } diff --git a/grade/edit/tree/grade.php b/grade/edit/tree/grade.php index 5b0463c79d67b..777ea989211bb 100644 --- a/grade/edit/tree/grade.php +++ b/grade/edit/tree/grade.php @@ -50,27 +50,27 @@ // security checks! if (!empty($id)) { if (!$grade = get_record('grade_grades', 'id', $id)) { - print_error('Incorrect grade id'); + print_error('invalidgroupid'); } if (!empty($itemid) and $itemid != $grade->itemid) { - print_error('Incorrect itemid'); + print_error('invaliditemid'); } $itemid = $grade->itemid; if (!empty($userid) and $userid != $grade->userid) { - print_error('Incorrect userid'); + print_error('invaliduser'); } $userid = $grade->userid; unset($grade); } else if (empty($userid) or empty($itemid)) { - print_error('Missing userid and itemid'); + print_error('missinguseranditemid'); } if (!$grade_item = grade_item::fetch(array('id'=>$itemid, 'courseid'=>$courseid))) { - print_error('Can not find grade_item'); + print_error('cannofindgradeitem'); } // now verify grading user has access to all groups or is member of the same group when separate groups used in course @@ -83,10 +83,10 @@ } } if (!$ok) { - print_error('Can not grade this user'); + print_error('cannotgradeuser'); } } else { - print_error('Can not grade this user'); + print_error('cannotgradeuser'); } } diff --git a/grade/edit/tree/index.php b/grade/edit/tree/index.php index 4c34e7f46d27a..a9a196ba1f26e 100644 --- a/grade/edit/tree/index.php +++ b/grade/edit/tree/index.php @@ -59,7 +59,7 @@ } else { if (!$element = $gtree->locate_element($eid)) { - print_error('Incorrect element id!', '', $returnurl); + print_error('invalidelementid', '', $returnurl); } $object = $element['object']; } @@ -112,7 +112,7 @@ if ($eid and confirm_sesskey()) { $moveafter = required_param('moveafter', PARAM_ALPHANUM); if(!$after_el = $gtree->locate_element($moveafter)) { - print_error('Incorect element id in moveafter', '', $returnurl); + print_error('invalidelementid', '', $returnurl); } $after = $after_el['object']; $parent = $after->get_parent_category(); diff --git a/lang/en_utf8/error.php b/lang/en_utf8/error.php index a56180f67fa51..1fd6c1d85c20e 100644 --- a/lang/en_utf8/error.php +++ b/lang/en_utf8/error.php @@ -39,11 +39,13 @@ $string['cannotfindcomponent'] = 'Cannot find component.'; $string['cannotfindcategory'] = 'Cannot find category record from database by ID - $a'; $string['cannotfinddocs'] = 'Cannot find \"$a\" language docs files'; +$string['cannofindgradeitem'] = 'Can not find grade_item'; $string['cannotfindgroup'] = 'Unable to find group'; $string['cannotfindinfo'] = 'Cannot find info for: \"$a\"'; $string['cannotfindhelp'] = 'Cannot find \"$a\" language help files'; $string['cannotfindlang'] = 'Cannot find \"$a\" language pack!'; $string['cannotfindsite'] = 'Cannot find site-level course'; +$string['cannotgradeuser'] = 'Can not grade this user'; $string['cannotmarktopic'] = 'Could not mark that topic for this course'; $string['cannotmoverolewithid'] = 'Cannot move role with ID $a'; $string['cannotmetacourse'] = 'Cannot not add the selected course to this meta course!'; @@ -56,6 +58,7 @@ $string['cannotinsertrecord'] = 'Could not insert new record ID $a'; $string['cannotsavemd5file'] = 'Cannot save md5 file.'; $string['cannotsavezipfile'] = 'Cannot save ZIP file.'; +$string['cannotsetprefgrade'] = 'Could not set preference aggregationview to $a for this grade category'; $string['cannotsetupcategory'] = 'Serious Error! Could not set up a default course category!'; $string['cannotsetupsite'] = 'Serious Error! Could not set up the site!'; $string['cannotunzipfile'] = 'Cannot unzip file.'; @@ -119,12 +122,14 @@ $string['invalidarguments'] = 'No valid arguments supplied'; $string['invalidargorconf'] = 'No valid arguments supplied or incorrect server configuration'; $string['invalidaccessparameter'] = 'Invalid access parameter.'; +$string['invalidcategory'] = 'Incorrect category id!'; $string['invalidcourse'] = 'Invalid course'; $string['invalidcourseid'] = 'You are tring to use an invalid course ID: ($a)'; $string['invalidcourselevel'] = 'Incorrect context level'; $string['invalidcoursemodule'] = 'Invalid course module ID'; $string['invalidcontext'] = 'Invalid context'; $string['invaliddata'] = 'Data submitted is invalid.'; +$string['invalidelementid'] = 'Incorrect element id!'; $string['invalidenrol'] = 'illegal enrolment attempted'; $string['invalidevent'] = 'Invalid event'; $string['invalidcoursenameshort'] = 'Invalid short course name'; @@ -132,7 +137,8 @@ $string['invalidfieldname'] = '\"$a\" is not a valid field name'; $string['invalidfiletype'] = '\"$a\" is not a valid file type'; $string['invalidformatpara'] = 'Incorrect format for choose parameter'; -$string['invalidgroupid'] = 'INcorrect group id specified.'; +$string['invalidgroupid'] = 'Incorrect group id specified.'; +$string['invaliditemid'] = 'Incorect item id'; $string['invalidipformat'] = 'Invalid IP address format'; $string['invalidmd5'] = 'Invalid md5'; $string['invalidmodule'] = 'Invalid module'; @@ -165,6 +171,7 @@ $string['logfilenotavailable'] = 'Logs not available'; $string['messagingdisable'] = 'Messaging is disabled on this site'; $string['missingfield'] = 'Field \"$a\" is missing.'; +$string['missinguseranditemid'] = 'Missing userid and itemid'; $string['missingrequiredfield'] = 'Some required field is missing'; $string['mimetexisnotexist'] = 'Your system is not configured to run mimeTeX. You need to download the appropriate executable for you PHP_OS platform from http://moodle.org/download/mimetex/, or obtain the C source from http://www.forkosh.com/mimetex.zip, compile it and put the executable into your moodle/filter/tex/ directory.'; $string['mimetexnotexecutable'] = 'Custom mimetex is not executable!'; @@ -192,8 +199,12 @@ $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['nopermissiontomkdir'] = 'Cannot create folder. The site administrator needs to fix the file permissions'; +$string['nopermissiontohide'] = 'No permission to hide!'; $string['nopermissiontoimportact'] = 'You do not have the required permissions to import activities to this course'; +$string['nopermissiontolock'] = 'No permission to lock!'; +$string['nopermissiontomkdir'] = 'Cannot create folder. The site administrator needs to fix the file permissions'; +$string['nopermissiontoshow'] = 'No permission to show!'; +$string['nopermissiontounlock'] = 'No permission to unlock!'; $string['nopermissiontoviewpage'] = 'You are not allowed to look at this page'; $string['nopermissiontoviewletergrade'] = 'Missing permission to view letter grades'; $string['nopermissiontomanagegroup'] = 'You do not have the required permissions to manage groups.';