MDL-14129, creating error string

This commit is contained in:
dongsheng 2008-04-10 06:19:07 +00:00
parent 51770f92eb
commit 6848005374
4 changed files with 19 additions and 18 deletions

View File

@ -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;
@ -43,13 +44,13 @@
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);

View File

@ -222,7 +222,7 @@
$role->description = $description;
if (!update_record('role', $role)) {
print_error('Could not update role!');
print_error('cannotupdaterole', 'error');
}
// set proper legacy type
@ -249,7 +249,7 @@
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)) {
@ -257,7 +257,7 @@
// 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);
@ -286,7 +286,7 @@
$above = $roles[$rolesort[$role->sortorder - 1]];
if (!switch_roles($role, $above)) {
print_error("Cannot move role with ID $roleid");
print_error('cannotmoverolewithid', 'error', '', $roleid);
}
}
}
@ -301,7 +301,7 @@
$below = $roles[$rolesort[$role->sortorder + 1]];
if (!switch_roles($role, $below)) {
print_error("Cannot move role with ID $roleid");
print_error('cannotmoverolewithid', 'error', '', $roleid);
}
}
}
@ -436,7 +436,7 @@
$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);
}

View File

@ -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);

View File

@ -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);