Skip to content

Commit

Permalink
"MDL-14129, fix print_error"
Browse files Browse the repository at this point in the history
  • Loading branch information
dongsheng committed May 14, 2008
1 parent c7a4be5 commit 1bb0aa0
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 19 deletions.
10 changes: 5 additions & 5 deletions grade/edit/tree/action.php
Expand Up @@ -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'];
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion grade/edit/tree/calculation.php
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions grade/edit/tree/category.php
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
}
}

Expand Down
14 changes: 7 additions & 7 deletions grade/edit/tree/grade.php
Expand Up @@ -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
Expand All @@ -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');
}
}

Expand Down
4 changes: 2 additions & 2 deletions grade/edit/tree/index.php
Expand Up @@ -59,7 +59,7 @@

} else {
if (!$element = $gtree->locate_element($eid)) {
print_error('Incorrect element id!', '', $returnurl);
print_error('invalidelementid', '', $returnurl);
}
$object = $element['object'];
}
Expand Down Expand Up @@ -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();
Expand Down
15 changes: 13 additions & 2 deletions lang/en_utf8/error.php
Expand Up @@ -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!';
Expand All @@ -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.';
Expand Down Expand Up @@ -119,20 +122,23 @@
$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';
$string['invalidevent'] = 'Invalid event';
$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';
Expand Down Expand Up @@ -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 <a href=\"http://moodle.org/download/mimetex/\">http://moodle.org/download/mimetex/</a>, or obtain the C source from <a href=\"http://www.forkosh.com/mimetex.zip\"> http://www.forkosh.com/mimetex.zip</a>, compile it and put the executable into your moodle/filter/tex/ directory.';
$string['mimetexnotexecutable'] = 'Custom mimetex is not executable!';
Expand Down Expand Up @@ -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.';
Expand Down

0 comments on commit 1bb0aa0

Please sign in to comment.