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 1, 2008
1 parent 1d2c714 commit f581f8d
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 20 deletions.
14 changes: 7 additions & 7 deletions calendar/event.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
print_error('invalidevent');
}
if(!calendar_edit_event_allowed($event)) {
print_error('You are not authorized to do this');
print_error('nopermissions');
}
break;

Expand All @@ -120,10 +120,10 @@
$repeats = optional_param('repeats', 0, PARAM_INT);

if($event === false) {
print_error('Invalid event');
print_error('invalidevent');
}
if(!calendar_edit_event_allowed($event)) {
print_error('You are not authorized to do this');
print_error('nopermissions');
}

if($form = data_submitted()) {
Expand Down Expand Up @@ -211,7 +211,7 @@
$form->timeduration = 0;
}
if(!calendar_add_event_allowed($form)) {
print_error('You are not authorized to do this');
print_error('nopermissions');
}
validate_form($form, $err);
if (count($err) == 0) {
Expand Down Expand Up @@ -488,7 +488,7 @@
case 'select':
break;
default:
print_error('Unsupported event type');
print_error('unsupportedevent');
}

$form->format = $defaultformat;
Expand All @@ -504,7 +504,7 @@
$courseid = SITEID;
}
if (!$course = get_record('course', 'id', $courseid)) {
print_error('Incorrect course ID');
print_error('invalidcourse');
}

$groupid = groups_get_course_group($course);
Expand Down Expand Up @@ -593,7 +593,7 @@ function validate_form(&$form, &$err) {
// Timestamps must be >= course startdate
$course = get_record('course', 'id', $form->courseid);
if($course === false) {
print_error('Event belongs to invalid course');
print_error('invalidcourse');
}
else if($form->timestart < $course->startdate) {
$err['timestart'] = get_string('errorbeforecoursestart', 'calendar');
Expand Down
2 changes: 1 addition & 1 deletion calendar/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ function calendar_get_upcoming($courses, $groups, $users, $daysinfuture, $maxeve
// TODO: rewrite this hack somehow
if (!calendar_edit_event_allowed($event)){ // cannot manage entries, eg. student
if(!$assignment = get_record('assignment','id',$event->instance)){
// print_error("assignment ID was incorrect");
// print_error("invalidid", 'assignment');
continue;
}
// assign assignment to assignment object to use hidden_is_hidden method
Expand Down
10 changes: 5 additions & 5 deletions course/search.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
if (!empty($moveto) and $data = data_submitted() and confirm_sesskey()) { // Some courses are being moved

if (! $destcategory = get_record("course_categories", "id", $data->moveto)) {
print_error("Error finding the category");
print_error('cannotfindcategory', '', '', $data->moveto);
}

$courses = array();
Expand All @@ -124,7 +124,7 @@
if (!empty($blocklist) and confirm_sesskey()) {
$blockid = $blocklist;
if (!$blocks = get_records('block_instance', 'blockid', $blockid)) {
print_error( "Could not read data for blockid=$blockid" );
print_error( 'blockcannotread', '', '', $blockid);
}

// run through blocks and get (unique) courses
Expand All @@ -137,7 +137,7 @@
continue;
}
if (!$course = get_record('course', 'id', $courseid)) {
print_error( "Could not read data for courseid=$courseid" );
print_error('invalidcourseid', '', '', $courseid);
}
$courses[$courseid] = $course;
}
Expand All @@ -147,7 +147,7 @@
elseif (!empty($modulelist) and confirm_sesskey()) {
$modulename = $modulelist;
if (!$modules = get_records($modulename)) {
print_error( "Could not read data for module=$modulename" );
print_error('invalidmodulename', '', '', $modulename);
}

// run through modules and get (unique) courses
Expand All @@ -158,7 +158,7 @@
continue;
}
if (!$course = get_record('course', 'id', $courseid)) {
print_error( "Could not read data for courseid=$courseid" );
print_error('invalidcourseid', '', '', $courseid);
}
$courses[$courseid] = $course;
}
Expand Down
13 changes: 7 additions & 6 deletions course/unenrol.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
}

if (! $course = get_record('course', 'id', $id) ) {
print_error('Invalid course id');
print_error('invalidcourseid');
}

if (! $context = get_context_instance(CONTEXT_COURSE, $course->id)) {
print_error('Invalid context');
print_error('invalidcontext');
}

require_login($course->id);
Expand All @@ -43,7 +43,8 @@
// verify user may unassign all roles at course context
foreach($roles as $role) {
if (!user_can_assign($context, $role->roleid)) {
print_error('Can not unassign this user from role id:'.$role->roleid);
print_error('cannotunassignrolefrom', '', '',
$role->roleid);
}
}

Expand All @@ -59,15 +60,15 @@
if ($confirm and confirm_sesskey()) {
if ($userid) {
if (! role_unassign(0, $userid, 0, $context->id)) {
print_error("An error occurred while trying to unenrol that person.");
print_error("unenrolerror");
}

add_to_log($course->id, 'course', 'unenrol', "view.php?id=$course->id", $userid);
redirect($CFG->wwwroot.'/user/index.php?id='.$course->id);

} else {
if (! role_unassign(0, $USER->id, 0, $context->id)) {
print_error("An error occurred while trying to unenrol you.");
print_error("unenrolerror");
}

// force a refresh of mycourses
Expand All @@ -88,7 +89,7 @@

if ($userid) {
if (!$user = get_record('user', 'id', $userid)) {
print_error('That user does not exist!');
print_error('nousers');
}
$strunenrolsure = get_string('unenrolsure', '', fullname($user, true));
notice_yesno($strunenrolsure, "unenrol.php?id=$id&amp;user=$user->id&amp;confirm=yes&amp;sesskey=".sesskey(),
Expand Down
1 change: 1 addition & 0 deletions lang/en_utf8/assignment.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
a zipped web site, or anything you ask them to submit.</p>';
$string['hideintro'] = 'Hide description before available date';
$string['itemstocount'] = 'Count';
$string['invalidid'] = 'assignment ID was incorrect';
$string['late'] = '$a late';
$string['maximumgrade'] = 'Maximum grade';
$string['maximumsize'] = 'Maximum size';
Expand Down
8 changes: 7 additions & 1 deletion lang/en_utf8/error.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
$string['adminprimarynoedit'] = 'The primary admin cannot be edited by others';
$string['blockdoesnotexist'] = 'This block does not exist';
$string['blockcannotinistantiate'] = 'Problem in instantiating block object';
$string['blockcannotread'] = 'Could not read data for blockid= $a ';
$string['blockcannotconfig'] = 'This block does not support global configuration';
$string['backupcontainexternal'] = 'This backup file contains external Moodle Network Hosts that are not configured locally.';
$string['backuptablefail'] = 'Backup tables could NOT be set up successfully!';
$string['cannotassignrole'] = 'Cannot assign role in course';
$string['cannotunassignrolefrom'] = 'Can not unassign this user from role id: $a';
$string['cannotaddrss'] = 'You do not have permission to add rss feeds';
$string['cannotsaveconfig'] = 'Problem saving config \"$a[0]\" as \"$a[1]\" for plugin \"$a[2]\"';
$string['cannotsavefile'] = 'Cannot save the file\"$a[0]\/$a[1]\"!';
Expand Down Expand Up @@ -91,6 +93,7 @@
$string['invalidcourse'] = 'Invalid course';
$string['invalidcourseid'] = 'You are tring to use an invalid course ID: ($a)';
$string['invalidcoursemodule'] = 'Bad course module ID';
$string['invalidcontext'] = 'Invalid context';
$string['invalidevent'] = 'Invalid event';
$string['invalidcoursenameshort'] = 'Invalid short course name';
$string['invalidevent'] = 'Invalid event';
Expand All @@ -99,7 +102,9 @@
$string['invalidgroupid'] = 'INcorrect group id specified.';
$string['invalidipformat'] = 'Invalid IP address format';
$string['invalidmd5'] = 'Invalid md5';
$string['invalidmodule'] = 'Invalid module ID';
$string['invalidmodule'] = 'Invalid module';
$string['invalidmoduleid'] = 'Invalid module ID: $a';
$string['invalidmodulename'] = 'Invalid module name: $a';
$string['invalidpagesize'] = 'Invalid page size';
$string['invalidrequest'] = 'Invalid request';
$string['invalidrole'] = 'Invalid role';
Expand Down Expand Up @@ -168,6 +173,7 @@
$string['unspecifycourseid'] = 'Must specify course id, short name or idnumber';
$string['statsnodata'] = 'There is no available data for that combination of course and time period.';
$string['statsdisable'] = 'Stats is not enabled.';
$string['unenrolerror'] = 'An error occurred while trying to unenrol that person.';
$string['unknowaction']= 'Unknown action!';
$string['unknowncourse'] = 'Unknown course named \"$a\"';
$string['unknowncourseidnumber'] = 'Unknown Course ID \"$a\"';
Expand Down

0 comments on commit f581f8d

Please sign in to comment.