]> git.mjollnir.org Git - moodle.git/commitdiff
"MDL-14129, fix print_error"
authordongsheng <dongsheng>
Thu, 1 May 2008 05:44:41 +0000 (05:44 +0000)
committerdongsheng <dongsheng>
Thu, 1 May 2008 05:44:41 +0000 (05:44 +0000)
calendar/event.php
calendar/lib.php
course/search.php
course/unenrol.php
lang/en_utf8/assignment.php
lang/en_utf8/error.php

index e065f2699351419ee6bf79820442e4b910d8b09d..457493cb55035df308313d33f5ff59c5257a2504 100644 (file)
                 print_error('invalidevent');
             }
             if(!calendar_edit_event_allowed($event)) {
-                print_error('You are not authorized to do this');
+                print_error('nopermissions');
             }
         break;
 
             $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()) {
                     $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) {
                 case 'select':
                 break;
                 default:
-                    print_error('Unsupported event type');
+                    print_error('unsupportedevent');
             }
 
             $form->format = $defaultformat;
                     $courseid = SITEID;
                 }
                 if (!$course = get_record('course', 'id', $courseid)) {
-                    print_error('Incorrect course ID');
+                    print_error('invalidcourse');
                 }
                 
                 $groupid = groups_get_course_group($course);
@@ -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');
index 58524751a7a0e64d88b03db8c1e841235a0c12ee..b80c51ab9fbe0ee68ae7cac1c2a1b877ce93e18b 100644 (file)
@@ -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
index 1dda5f1b6f0816339f7b66e0f21eba2f10e4e1ca..f169006ee6b58e71b7c074ddd2880f32cdffea42 100644 (file)
     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();
     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
                 continue;
             }
             if (!$course = get_record('course', 'id', $courseid)) {
-                print_error( "Could not read data for courseid=$courseid" );
+                print_error('invalidcourseid', '', '', $courseid);
             }
             $courses[$courseid] = $course;
         }
     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
                 continue;
             }
             if (!$course = get_record('course', 'id', $courseid)) {
-                print_error( "Could not read data for courseid=$courseid" );
+                print_error('invalidcourseid', '', '', $courseid);
             }
             $courses[$courseid] = $course;
         }
index 74e877defac2844d71258130f5f7a83880cda4e4..bede2873b426ea216e4ab806335fed62caf6f275 100644 (file)
     }
 
     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);
@@ -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);
             }
         }
 
@@ -59,7 +60,7 @@
     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);
@@ -67,7 +68,7 @@
 
         } 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
@@ -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(),
index 39a08892476e24858b7b65c3ae5a7dee087a0b65..911f72703c72f625ff1396f4b8b35befbc3f52fe 100644 (file)
@@ -81,6 +81,7 @@ $string['helpuploadsingle'] = '<p>This type of assignment allows each participan
    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';
index 56480d66e2228d3ba51e233f39264fd9aefb9deb..b41f0922747d7fd9c60c33c9f7cd54ce7d5ad6dc 100644 (file)
@@ -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]\"!';
@@ -91,6 +93,7 @@ $string['invalidaccessparameter'] = 'Invalid access parameter.';
 $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';
@@ -99,7 +102,9 @@ $string['invalidfiletype'] = '\"$a\" is not a valid file type';
 $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';
@@ -168,6 +173,7 @@ $string['unicodeupgradeerror'] = 'Sorry, but your database is not already in Uni
 $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\"';