]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-14129, creating error string
authordongsheng <dongsheng>
Thu, 10 Apr 2008 06:19:07 +0000 (06:19 +0000)
committerdongsheng <dongsheng>
Thu, 10 Apr 2008 06:19:07 +0000 (06:19 +0000)
admin/roles/assign.php
admin/roles/manage.php
admin/roles/override.php
admin/roles/tabs.php

index 435b1a818c1e74294e71aa28db9766115d7c41c7..9c07e2005911e36652028cc6fae8bed15a1193fd 100755 (executable)
@@ -34,7 +34,8 @@
     }
 
     if (! $context = get_context_instance_by_id($contextid)) {
-        print_error("Context ID was incorrect (can't find it)");
+        print_error('wrongcontextid', 'error');
+        
     }
 
     $inmeta = 0;
         if ($course = get_record('course', 'id', $courseid)) {
             $inmeta = $course->metacourse;
         } else {
-            print_error('Invalid course id');
+            print_error('invalidcourse', 'error');
         }
         $coursecontext = $context;
 
     } else if (!empty($courseid)){ // we need this for user tabs in user context
         if (!$course = get_record('course', 'id', $courseid)) {
-            print_error('Invalid course id');
+            print_error('invalidcourse', 'error');
         }
         $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
 
index 727ca64baa9a8f3174beb4646ddd9a42f879a91c..1d2b94b9ea7be9aa5d403ecfcea540222f281099 100755 (executable)
                     $role->description = $description;
 
                     if (!update_record('role', $role)) {
-                        print_error('Could not update role!');
+                        print_error('cannotupdaterole', 'error');
                     }
 
                     // set proper legacy type
 
         case 'delete':
             if (in_array($roleid, $defaultroles)) {
-                print_error('This role is used as one of the default system roles, it can not be deleted');
+                print_error('cannotdeleterole', 'error', '', 'this role is used as one of the default system roles, it can not be deleted');
             }
             if ($confirm and data_submitted() and confirm_sesskey()) {
                 if (!delete_role($roleid)) {
                     // partially deleted a role sitewide...?
                     mark_context_dirty($sitecontext->path);
 
-                    print_error('Could not delete role with ID '.$roleid);
+                    print_error('cannotdeleterolewithid', 'error', '', $roleid);
                 }
                 // deleted a role sitewide...
                 mark_context_dirty($sitecontext->path);
                     $above = $roles[$rolesort[$role->sortorder - 1]];
 
                     if (!switch_roles($role, $above)) {
-                        print_error("Cannot move role with ID $roleid");
+                        print_error('cannotmoverolewithid', 'error', '', $roleid);
                     }
                 }
             }
                     $below = $roles[$rolesort[$role->sortorder + 1]];
 
                     if (!switch_roles($role, $below)) {
-                        print_error("Cannot move role with ID $roleid");
+                        print_error('cannotmoverolewithid', 'error', '', $roleid);
                     }
                 }
             }
                 $role = stripslashes_safe($newrole);
         } else {
             if(!$role = get_record('role', 'id', $roleid)) {
-                print_error('Incorrect role ID!');
+                print_error('wrongroleid', 'error');
             }
             $role->legacytype = get_legacy_type($role->id);
         }
index a49409ad774a917f8194c3e3a9f194501cf9e37e..5b612b445ff12798674a93dc77b601d5013b27d2 100755 (executable)
@@ -9,24 +9,24 @@
     $cancel    = optional_param('cancel', 0, PARAM_BOOL);
 
     if (!$context = get_record('context', 'id', $contextid)) {
-        print_error('Bad context ID');
+        print_error('wrongcontextid', 'error');
     }
 
     if (!$sitecontext = get_context_instance(CONTEXT_SYSTEM)) {
-        print_error('No site ID');
+        print_error('nositeid', 'error');
     }
 
     if ($context->id == $sitecontext->id) {
-        print_error('Can not override base role capabilities');
+        print_error('cannotoverridebaserole', 'error');
     }
 
     if (!has_capability('moodle/role:override', $context)) {
-        print_error('You do not have permission to change overrides in this context!');
+        print_error('nopermissions', 'error', '', 'change overrides in this context!');
     }
 
     if ($courseid) {
         if (!$course = get_record('course', 'id', $courseid)) {
-            print_error('Bad course ID');
+            print_error('invalidcourse');
         }
 
         $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
index e19b81c704c3eb2a468f66b15a40eb338fe92349..7b17019d48cca6b92751aea0954b96b9322b077b 100755 (executable)
@@ -61,16 +61,16 @@ if ($currenttab != 'update') {
         case CONTEXT_MODULE:
             // get module type?
             if (!$cm = get_record('course_modules','id',$context->instanceid)) {
-                print_error('Bad course module ID');
+                print_error('invalidcoursemodule', 'error');
             }
             if (!$module = get_record('modules','id',$cm->module)) {  //$module->name;
-                print_error('Bad module ID');
+                print_error('invalidmodule', 'error');
             }
             if (!$course = get_record('course','id',$cm->course)) {
-                print_error('Bad course ID');
+                print_error('invalidcourse');
             }
             if (!$instance = get_record($module->name, 'id', $cm->instance)) {
-                print_error("The required instance of this module doesn't exist");
+                print_error('moduledoesnotexist', 'error');
             }
 
             require_login($course);