}
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);
$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);
}
$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);
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);