} else if ($context->contextlevel == CONTEXT_MODULE) {
if (!$cm = get_record('course_modules', 'id', $context->instanceid)) {
- print_error('Incorrect module');
+ print_error('invalidmodule');
}
if (!$course = get_record('course', 'id', $cm->course)) {
- print_error('Incorrect course.');
+ print_error('invalidcourseid');
}
require_course_login($course, true, $cm);
$errorlink = $CFG->wwwroot.'/course/view.php?id='.$cm->course;
/// Now is the correct moment to install capabilities - after creation of legacy roles, but before assigning of roles
if (!assign_capability('moodle/site:doanything', CAP_ALLOW, $adminrole, $systemcontext->id)) {
- print_error('Could not assign moodle/site:doanything to the admin role');
+ print_error('cannotassignanthing');
}
if (!update_capabilities()) {
- print_error('Had trouble upgrading the core capabilities for the Roles System');
+ print_error('cannotupgradecaps');
}
/// Look inside user_admin, user_creator, user_teachers, user_students and
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
if (!array_key_exists($type, $legacyroles)) {
- print_error('Incorrect legacy role definition for type: '.$type);
+ print_error('invalidlegacy', '', '', $type);
}
if ($roles = get_roles_with_capability($legacyroles[$type], CAP_ALLOW)) {
/// check allowed context levels
if (!in_array($contextlevel, $allowed_contexts)) {
// fatal error, code must be fixed - probably typo or switched parameters
- print_error('Error: get_context_instance() called with incorrect context level "'.s($contextlevel).'"');
+ print_error('invalidcourselevel');
}
if (!is_array($instance)) {
// check for duplicate role name
if ($role = get_record('role','name', $name)) {
- print_error('there is already a role with this name!');
+ print_error('duplicaterolename');
}
if ($role = get_record('role','shortname', $shortname)) {
- print_error('there is already a role with this shortname!');
+ print_error('duplicateroleshortname');
}
$role = new object();
*/
function get_default_capabilities($legacyrole) {
if (!$allcaps = get_records('capabilities')) {
- print_error('Error: no capabilitites defined!');
+ print_error('nocaps', 'debug');
}
$alldefs = array();
$defaults = array();
// Remove from capabilities cache.
if (!delete_records('capabilities', 'name', $cachedcap->name)) {
- print_error('Could not delete deprecated capability '.$cachedcap->name);
+ print_error('cannotdeletecap', '', '', $cachedcap->name);
} else {
$removedcount++;
}
if($roles = get_roles_with_capability($cachedcap->name)) {
foreach($roles as $role) {
if (!unassign_capability($cachedcap->name, $role->id)) {
- print_error('Could not unassign deprecated capability '.
- $cachedcap->name.' from role '.$role->name);
+ print_error('cannotunassigncap', '', '', array($cachedcap->name, $role->name));
}
}
}
break;
default:
- print_error('This is an unknown context (' . $context->contextlevel . ') in get_child_contexts!');
+ print_error('unknowcontext', '', '', $context->contextlevel);
return false;
}
}
unset($data->$item);
}
if(!$blockobject->instance_config_save($data,$pinned)) {
- print_error('Error saving block configuration');
+ print_error('cannotsaveblock');
}
// And nothing more, continue with displaying the page
}
break;
case 'toggle':
if(empty($instance)) {
- print_error('Invalid block instance for '.$blockaction);
+ print_error('invalidblockinstance', '', '', $blockaction);
}
$instance->visible = ($instance->visible) ? 0 : 1;
if (!empty($pinned)) {
break;
case 'delete':
if(empty($instance)) {
- print_error('Invalid block instance for '. $blockaction);
+ print_error('invalidblockinstance', '', '', $blockaction);
}
blocks_delete_instance($instance, $pinned);
break;
case 'moveup':
if(empty($instance)) {
- print_error('Invalid block instance for '. $blockaction);
+ print_error('invalidblockinstance', '', '', $blockaction);
}
if($instance->weight == 0) {
break;
case 'movedown':
if(empty($instance)) {
- print_error('Invalid block instance for '. $blockaction);
+ print_error('invalidblockinstance', '', '', $blockaction);
}
if($instance->weight == max(array_keys($pageblocks[$instance->position]))) {
break;
case 'moveleft':
if(empty($instance)) {
- print_error('Invalid block instance for '. $blockaction);
+ print_error('invalidblockinstance', '', '', $blockaction);
}
// Where is the instance going to be moved?
break;
case 'moveright':
if(empty($instance)) {
- print_error('Invalid block instance for '. $blockaction);
+ print_error('invalidblockinstance', '', '', $blockaction);
}
// Where is the instance going to be moved?
$allblocks = blocks_get_record();
if(empty($allblocks)) {
- print_error('Could not retrieve blocks from the database');
+ print_error('cannotgetblock');
}
// Assemble the information to correlate block names to ids
}
}
} else {
- print_error('Upgrade of blocks system failed! (Could not update version in config table)');
+ print_error('cannotupgradeblock');
}
} else {
- print_error('Blocks tables could NOT be set up successfully!');
+ print_error('cannotsetupblock');
}
}
exit;
}
} else {
- print_error('Upgrade of blocks system failed! (Could not update version in config table)');
+ print_error('cannotupgradeblock');
}
} else {
- print_error('Upgrade failed! See blocks/version.php');
+ print_error('cannotupgradeblock');
}
} else if ($blocks_version < $CFG->blocks_version) {
$site = get_site();
if (!$blocks = get_list_of_plugins('blocks', 'db') ) {
- print_error('No blocks installed!');
+ print_error('noblocks', 'debug');
}
include_once($CFG->dirroot .'/blocks/moodleblock.class.php');
if(!class_exists('block_base')) {
- print_error('Class block_base is not defined or file not found for /blocks/moodleblock.class.php');
+ print_error('noblockbase');
}
foreach ($blocks as $blockname) {
// OK so far, now update the block record
$block->id = $currblock->id;
if (! update_record('block', $block)) {
- print_error('Could not update block '. $block->name .' record in block table!');
+ print_error('cannotupdateblock', '', '', $block->name);
}
$component = 'block/'.$block->name;
if (!update_capabilities($component)) {
- print_error('Could not update '.$block->name.' capabilities!');
+ print_error('nopermissiontoupdateblock', '', '', $block->name);
}
events_update_definition($component);
}
} else {
upgrade_log_start();
- print_error('Version mismatch: block '. $block->name .' can\'t downgrade '. $currblock->version .' -> '. $block->version .'!');
+ print_error('cannotdowngrade', 'debug', '', array($currblock->version, $block->version));
}
} else { // block not installed yet, so install it
// Duplicate block titles are not allowed, they confuse people
// AND PHP's associative arrays ;)
if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) {
- print_error('<strong>Naming conflict</strong>: block <strong>'.$block->name.'</strong> has the same title with an existing block, <strong>'.$conflictblock.'</strong>!');
+ print_error('blocknameconflict', '', '', array($block->name, $conflictblock));
} else if (CLI_UPGRADE) {
- print_error('Naming conflict: block "'.$block->name.'" has the same title with an existing block, "'.$conflictblock.'"!');
+ print_error('blocknameconflict', '', '', array($block->name, $conflictblock));
}
}
if (empty($updated_blocks)) {
echo '<hr />';
}
} else {
- print_error($block->name .' block could not be added to the block list!');
+ print_error('cannotaddblock', '', '', $block->name);
}
} else {
- print_error('Block '. $block->name .' tables could NOT be set up successfully!');
+ print_error('cannotsetupblock', '', '', $block->name);
}
}
global $USER;
if (!$filename = make_upload_directory('temp/csvimport/'.$type.'/'.$USER->id, false)) {
- print_error('Can not create temporary upload directory - verify moodledata permissions!');
+ print_error('cannotcreatetempdir');
}
// use current (non-conflicting) time stamp
return $iiid;
}
}
-?>
\ No newline at end of file
+?>
// If args is an array search keys courseid and name.
// Name represents editor name to load.
if ( !array_key_exists('courseid', $args) ) {
- print_error("Required variable courseid is missing!");
+ print_error('invalidcourseid');
}
if ( !array_key_exists('name', $args) ) {
- print_error("Required variable name is missing!");
+ print_error('missingvarname');
}
$courseid = clean_param($args['courseid'], PARAM_INT);
require_login();
if (empty($CFG->aspellpath)) {
- print_error('Spellchecker not configured');
+ print_error('spellcheckernotconf');
}
header('Content-type: text/html; charset=utf-8');
"onclick=\"this.target='$name'; return openpopup('$url', '$name', '$options', $fullscreen);\">$linkname</a>";
break;
default :
- print_error('Undefined element - can\'t create popup window.');
+ print_error('cannotcreatepopupwin');
break;
}
'a $cm parameter. If you get $cm using get_coursemodule_from_instance or '.
'get_coursemodule_from_id, this will be done automatically.', DEBUG_DEVELOPER);
if (!$cm->modname = get_field('modules', 'name', 'id', $cm->module)) {
- print_error('Cannot get the module type in build navigation.');
+ print_error('cannotmoduletype');
}
}
if (!isset($cm->name)) {
'a $cm parameter. If you get $cm using get_coursemodule_from_instance or '.
'get_coursemodule_from_id, this will be done automatically.', DEBUG_DEVELOPER);
if (!$cm->name = get_field($cm->modname, 'name', 'id', $cm->instance)) {
- print_error('Cannot get the module name in build navigation.');
+ print_error('cannotmodulename');
}
}
$navlinks[] = array(
$titles[] = get_string('helptext');
break;
default :
- print_error('Unknown help topic '.$item);
+ print_error('unknownhelp', '', '', $item);
}
}
$i++;