$plugin = "auth/$auth";
$name = $matches[1];
if (!set_config($name, $value, $plugin)) {
- error("Problem saving config $name as $value for plugin $plugin");
+ print_error("Problem saving config $name as $value for plugin $plugin");
}
}
}
$blockid = required_param('block', PARAM_INT);
if(!$blockrecord = blocks_get_record($blockid)) {
- error('This block does not exist');
+ print_error('This block does not exist');
}
admin_externalpage_setup('blocksetting'.$blockrecord->name);
$block = block_instance($blockrecord->name);
if($block === false) {
- error('Problem in instantiating block object');
+ print_error('Problem in instantiating block object');
}
// Define the data we're going to silently include in the instance config form here,
if ($config = data_submitted()) {
if (!confirm_sesskey()) {
- error(get_string('confirmsesskeybad', 'error'));
+ print_error('confirmsesskeybad', 'error');
}
if(!$block->has_config()) {
- error('This block does not support global configuration');
+ print_error('This block does not support global configuration');
}
$remove = array_keys($hiddendata);
foreach($remove as $item) {
if (!empty($hide) && confirm_sesskey()) {
if (!$block = get_record('block', 'id', $hide)) {
- error("Block doesn't exist!");
+ print_error("Block doesn't exist!");
}
set_field('block', 'visible', '0', 'id', $block->id); // Hide block
admin_get_root(true, false); // settings not required - only pages
if (!empty($show) && confirm_sesskey() ) {
if (!$block = get_record('block', 'id', $show)) {
- error("Block doesn't exist!");
+ print_error("Block doesn't exist!");
}
set_field('block', 'visible', '1', 'id', $block->id); // Show block
admin_get_root(true, false); // settings not required - only pages
if (!empty($multiple) && confirm_sesskey()) {
if (!$block = blocks_get_record($multiple)) {
- error("Block doesn't exist!");
+ print_error("Block doesn't exist!");
}
$block->multiple = !$block->multiple;
update_record('block', $block);
print_heading($strmanageblocks);
if (!$block = blocks_get_record($delete)) {
- error("Block doesn't exist!");
+ print_error("Block doesn't exist!");
}
if (!block_is_compatible($block->name)) {
/// Get and sort the existing blocks
if (false === ($blocks = get_records('block'))) {
- error('No blocks found!'); // Should never happen
+ print_error('No blocks found!'); // Should never happen
}
$incompatible = array();
}
if(empty($blockbyname)) {
- error('One or more blocks are registered in the database, but they all failed to load!');
+ print_error('One or more blocks are registered in the database, but they all failed to load!');
}
ksort($blockbyname);
mark_context_dirty('/'.SYSCONTEXTID);
// do nothing
} else {
- error("Serious Error! Could not set up a default course category!");
+ print_error("Serious Error! Could not set up a default course category!");
}
} else {
- error("Serious Error! Could not set up the site!");
+ print_error("Serious Error! Could not set up the site!");
}
}
}
if (!confirm_sesskey()) {
- error('This script was called wrongly');
+ print_error('This script was called wrongly');
}
/// OK, here goes ...
// check session key
if (!confirm_sesskey()) {
- error( get_string('confirmsesskeybad', 'error' ) );
+ print_error('confirmsesskeybad', 'error');
}
$configpath = $CFG->dirroot.'/filter/'.$filtername.'/filterconfig.php';
case 'show':
// check filterpath is valid
if (!array_key_exists($filterpath, $installedfilters)) {
- error("Filter $filterpath is not currently installed", $url);
+ print_error("Filter $filterpath is not currently installed", '', $url);
} elseif (array_search($filterpath,$activefilters)) {
// filterpath is already active - doubleclick??
} else {
$key=array_search($filterpath, $activefilters);
// check filterpath is valid
if ($key===false) {
- error("Filter $filterpath is not currently active", $url);
+ print_error("Filter $filterpath is not currently active", '', $url);
} elseif ($key>=(count($activefilters)-1)) {
// cannot be moved any further down - doubleclick??
} else {
$key=array_search($filterpath, $activefilters);
// check filterpath is valid
if ($key===false) {
- error("Filter $filterpath is not currently active", $url);
+ print_error("Filter $filterpath is not currently active", '', $url);
} elseif ($key<1) {
//cannot be moved any further up - doubleclick??
} else {
$documentationlink = '<a href="http://docs.moodle.org/en/Installation">Installation docs</a>';
if (ini_get_bool('session.auto_start')) {
- error("The PHP server variable 'session.auto_start' should be Off - $documentationlink");
+ print_error("The PHP server variable 'session.auto_start' should be Off - $documentationlink");
}
if (ini_get_bool('magic_quotes_runtime')) {
- error("The PHP server variable 'magic_quotes_runtime' should be Off - $documentationlink");
+ print_error("The PHP server variable 'magic_quotes_runtime' should be Off - $documentationlink");
}
if (!ini_get_bool('file_uploads')) {
- error("The PHP server variable 'file_uploads' is not turned On - $documentationlink");
+ print_error("The PHP server variable 'file_uploads' is not turned On - $documentationlink");
}
if (empty($CFG->prefix) && $CFG->dbfamily != 'mysql') { //Enforce prefixes for everybody but mysql
- error('$CFG->prefix can\'t be empty for your target DB (' . $CFG->dbtype . ')');
+ print_error('$CFG->prefix can\'t be empty for your target DB (' . $CFG->dbtype . ')');
}
if ($CFG->dbfamily == 'oracle' && strlen($CFG->prefix) > 2) { //Max prefix length for Oracle is 2cc
- error('$CFG->prefix maximum allowed length for Oracle DBs is 2cc.');
+ print_error('$CFG->prefix maximum allowed length for Oracle DBs is 2cc.');
}
/// Check that config.php has been edited
if ($CFG->wwwroot == "http://example.com/moodle") {
- error("Moodle has not been configured yet. You need to edit config.php first.");
+ print_error("Moodle has not been configured yet. You need to edit config.php first.");
}
$dirroot = dirname(realpath("../index.php"));
if (!empty($dirroot) and $dirroot != $CFG->dirroot) {
- error("Please fix your settings in config.php:
+ print_error("Please fix your settings in config.php:
<p>You have:
<p>\$CFG->dirroot = \"".addslashes($CFG->dirroot)."\";
<p>but it should be:
}
if (is_readable("$CFG->dirroot/version.php")) {
- include_once("$CFG->dirroot/version.php"); # defines $version
+ include_once("$CFG->dirroot/version.php"); // defines $version
}
if (!$version or !$release) {
- error('Main version.php was not readable or specified');# without version, stop
+ print_error('Main version.php was not readable or specified'); // without version, stop
}
/// Check if the main tables have been installed yet or not.
} else if (file_exists("$CFG->libdir/db/$CFG->dbtype.sql")) {
$status = modify_database("$CFG->libdir/db/$CFG->dbtype.sql"); //Old method
} else {
- error("Error: Your database ($CFG->dbtype) is not yet fully supported by Moodle or install.xml is not present. See the lib/db directory.");
+ print_error("Error: Your database ($CFG->dbtype) is not yet fully supported by Moodle or install.xml is not present. See the lib/db directory.");
}
// all new installs are in unicode - keep for backwards compatibility and 1.8 upgrade checks
notify($strdatabasesuccess, "green");
require_once $CFG->dirroot.'/mnet/lib.php';
} else {
- error("Error: Main databases NOT set up successfully");
+ print_error("Error: Main databases NOT set up successfully");
}
print_continue('index.php');
print_footer('none');
moodle_install_roles();
set_config('rolesactive', 1);
} else if (!update_capabilities()) {
- error('Had trouble upgrading the core capabilities for the Roles System');
+ print_error('Had trouble upgrading the core capabilities for the Roles System');
}
// update core events
events_update_definition();
print_footer('none');
exit;
} else {
- error('Upgrade failed! (Could not update version in config table)');
+ print_error('Upgrade failed! (Could not update version in config table)');
}
/// Main upgrade not success
} else {
}
} else {
if (!set_config("version", $version)) {
- error("A problem occurred inserting current version into databases");
+ print_error("A problem occurred inserting current version into databases");
}
}
if ($release <> $CFG->release) { // Update the release version
if (!set_config("release", $release)) {
- error("ERROR: Could not update release version in database!!");
+ print_error("ERROR: Could not update release version in database!!");
}
}
$newsite->timemodified = time();
if (!$newid = insert_record('course', $newsite)) {
- error("Serious Error! Could not set up the site!");
+ print_error("Serious Error! Could not set up the site!");
}
// make sure course context exists
get_context_instance(CONTEXT_COURSE, $newid);
$cat->name = get_string('miscellaneous');
$cat->depth = 1;
if (!$catid = insert_record('course_categories', $cat)) {
- error("Serious Error! Could not set up a default course category!");
+ print_error("Serious Error! Could not set up a default course category!");
}
// make sure category context exists
get_context_instance(CONTEXT_COURSECAT, $catid);
$stringfiles += lang_extra_locations();
}
if (count($stringfiles) == 0) {
- error("Could not find English language pack!");
+ print_error("Could not find English language pack!");
}
} elseif ($mode == 'helpfiles') {
$helpfiles = lang_help_standard_locations();
$helpfiles += lang_help_extra_locations();
}
if (count($helpfiles) == 0) {
- error("Could not find help files in the English language pack!");
+ print_error("Could not find help files in the English language pack!");
}
}
echo $o;
if (! $files = get_directory_list("$CFG->dirroot/lang/en_utf8/help", "CVS")) {
- error("Could not find English language help files!");
+ print_error("Could not find English language help files!");
}
foreach ($files as $filekey => $file) { // check all the help files.
}
if (! $files = get_directory_list("$CFG->dirroot/lang/en_utf8/docs", "CVS")) {
- error("Could not find English language docs files!");
+ print_error("Could not find English language docs files!");
}
foreach ($files as $filekey => $file) { // check all the docs files.
if (!file_exists("$langdir/docs/$file")) {
if (!file_exists($langbase) ){
if (!lang_make_directory($langbase) ){
- error('ERROR: Could not create base lang directory ' . $langbase);
+ print_error('ERROR: Could not create base lang directory ' . $langbase);
} else {
echo '<div class="notifysuccess">Created directory '.
$langbase .'</div>'."<br />\n";
}
if (!$uselocal && !file_exists($langdir)) {
if (!lang_make_directory($langdir)) {
- error('ERROR: Could not create directory '.$langdir);
+ print_error('ERROR: Could not create directory '.$langdir);
} else {
echo '<div class="notifysuccess">Created directory '.
$langdir .'</div>'."<br />\n";
if ($currentfile <> '') {
if (!$fileinfo = lang_get_file_info($currentfile, $stringfiles)) {
- error('Unable to find info for: '.$currentfile);
+ print_error('Unable to find info for: '.$currentfile);
}
// check the filename is set up correctly, prevents bugs similar to MDL-10920
$location = $fileinfo['location'];
if ($location || $plugin) {
// file in an extra location
if ($currentfile != "{$prefix}{$plugin}.php") {
- error("Non-core filename mismatch. The file $currentfile should be {$prefix}{$plugin}.php");
+ print_error("Non-core filename mismatch. The file $currentfile should be {$prefix}{$plugin}.php");
}
if (!$uselocal) {
notify($streditingnoncorelangfile);
} else {
// file in standard location
if ($currentfile != $filename) {
- error("Core filename mismatch. The file $currentfile should be $filename");
+ print_error("Core filename mismatch. The file $currentfile should be $filename");
}
}
if (isset($_POST['currentfile'])){ // Save a file
if (!confirm_sesskey()) {
- error(get_string('confirmsesskeybad', 'error'));
+ print_error('confirmsesskeybad', 'error');
}
$newstrings = array();
if (lang_save_file($saveinto, $currentfile, $newstrings, $uselocal, $packstring)) {
notify(get_string("changessaved")." ($saveinto/$currentfile)", "notifysuccess");
} else {
- error("Could not save the file '$saveinto/$currentfile'!", "lang.php?mode=compare&currentfile=$currentfile");
+ print_error("Could not save the file '$saveinto/$currentfile'!", '', "lang.php?mode=compare&currentfile=$currentfile");
}
unset($packstring);
}
if (isset($_POST['currentfile'])) { // Save a file
if (!confirm_sesskey()) {
- error(get_string('confirmsesskeybad', 'error'));
+ print_error('confirmsesskeybad', 'error');
}
if (lang_help_save_file($saveto, $currentfile, $_POST['filedata'])) {
notify(get_string("changessaved")." ($saveto/$currentfile)", "notifysuccess");
} else {
- error("Could not save the file '$currentfile'!", "lang.php?mode=helpfiles&currentfile=$currentfile&sesskey=$USER->sesskey");
+ print_error("Could not save the file '$currentfile'!", '', "lang.php?mode=helpfiles&currentfile=$currentfile&sesskey=$USER->sesskey");
}
}
if (langdoc_save_file($langdir, $currentfile, $_POST['filedata'])) {
notify(get_string("changessaved")." ($langdir/$currentfile)", "green");
} else {
- error("Could not save the file '$currentfile'!", "langdoc.php?currentfile=$currentfile&sesskey=$USER->sesskey");
+ print_error("Could not save the file '$currentfile'!", '', "langdoc.php?currentfile=$currentfile&sesskey=$USER->sesskey");
}
}
}
// Get all files from /docs directory
if (! $files = get_directory_list("$CFG->dirroot/lang/en_utf8/docs", "CVS")) {
- error("Could not find English language docs files!");
+ print_error("Could not find English language docs files!");
}
$options = array();
// Get all files from /help directory
if (! $files = get_directory_list("$CFG->dirroot/lang/en_utf8/help", "CVS")) {
- error("Could not find English language help files!");
+ print_error("Could not find English language help files!");
}
foreach ($files as $filekey => $file) { // check all the help files.
//reset and diagnose lang cache permissions
@unlink($CFG->dataroot.'/cache/languages');
if (file_exists($CFG->dataroot.'/cache/languages')) {
- error('Language cache can not be deleted, please fix permissions in dataroot/cache/languages!');
+ print_error('Language cache can not be deleted, please fix permissions in dataroot/cache/languages!');
}
get_list_of_languages(true); //refresh lang cache
//Check folder exists
if (! make_upload_directory(SITEID)) { // Site folder
- error("Could not create site folder. The site administrator needs to fix the file permissions");
+ print_error("Could not create site folder. The site administrator needs to fix the file permissions");
}
$filename = $CFG->dataroot.'/'.SITEID.'/maintenance.html';
if (!extension_loaded('openssl')) {
admin_externalpage_print_header();
set_config('mnet_dispatcher_mode', 'off');
- print_error('requiresopenssl', 'mnet', '', NULL, true);
+ print_error('requiresopenssl', 'mnet');
}
if (!$site = get_site()) {
admin_externalpage_print_header();
set_config('mnet_dispatcher_mode', 'off');
- print_error('nosite', '', '', NULL, true);
+ print_error('nosite');
}
if (!function_exists('curl_init') ) {
admin_externalpage_print_header();
set_config('mnet_dispatcher_mode', 'off');
- print_error('nocurl', 'mnet', '', NULL, true);
+ print_error('nocurl', 'mnet');
}
if (!isset($CFG->mnet_dispatcher_mode)) {
if (set_config('mnet_dispatcher_mode', $form->mode)) {
redirect('index.php', get_string('changessaved'));
} else {
- error('Invalid action parameter.', 'index.php');
+ print_error('Invalid action parameter.', '', 'index.php');
}
}
} elseif (!empty($form->submit) && $form->submit == get_string('delete')) {
if (!extension_loaded('openssl')) {
admin_externalpage_print_header();
- print_error('requiresopenssl', 'mnet', '', NULL, true);
+ print_error('requiresopenssl', 'mnet');
}
if (!$site = get_site()) {
admin_externalpage_print_header();
- print_error('nosite', '', '', NULL, true);
+ print_error('nosite', '');
}
if (!function_exists('curl_init') ) {
admin_externalpage_print_header();
- print_error('nocurl', 'mnet', '', NULL, true);
+ print_error('nocurl', 'mnet');
}
/// Initialize variables.
if(!function_exists('xmlrpc_encode_request')) {
trigger_error("You must have xml-rpc enabled in your PHP build to use this feature.");
- error(get_string('xmlrpc-missing', 'mnet'),'peers.php');
+ print_error('xmlrpc-missing', 'mnet','peers.php');
exit;
}
$temp_wwwroot = clean_param($form->wwwroot, PARAM_URL);
if ($temp_wwwroot !== $form->wwwroot) {
trigger_error("We now parse the wwwroot with PARAM_URL. Your URL will need to have a valid TLD, etc.");
- error(get_string("invalidurl", 'mnet'),'peers.php');
+ print_error("invalidurl", 'mnet','peers.php');
exit;
}
unset($temp_wwwroot);
if (isset($form->public_key)) {
$form->public_key = clean_param($form->public_key, PARAM_PEM);
if (empty($form->public_key)) {
- error(get_string("invalidpubkey", 'mnet'),'peers.php?step=update&hostid='.$mnet_peer->id);
+ print_error("invalidpubkey", 'mnet', 'peers.php?step=update&hostid='.$mnet_peer->id);
exit;
} else {
$oldkey = $mnet_peer->public_key;
foreach ($mnet_peer->error as $err) {
$errmsg .= $err['code'] . ': ' . $err['text'].'<br />';
}
- error(get_string("invalidpubkey", 'mnet') . $errmsg ,'peers.php?step=update&hostid='.$mnet_peer->id);
+ //error(get_string("invalidpubkey", 'mnet') . $errmsg ,'peers.php?step=update&hostid='.$mnet_peer->id);
+ print_error("invalidpubkey", 'mnet', 'peers.php?step=update&hostid='.$mnet_peer->id, $errmsg);
exit;
}
}
// PREVENT DUPLICATE RECORDS ///////////////////////////////////////////
if ('input' == $form->step) {
if ( isset($mnet_peer->id) && $mnet_peer->id > 0 ) {
- error(get_string("hostexists", 'mnet', $mnet_peer->id),'peers.php?step=update&hostid='.$mnet_peer->id);
+ print_error("hostexists", 'mnet', 'peers.php?step=update&hostid='.$mnet_peer->id, $mnet_peer->id);
}
}
if ($bool) {
redirect('peers.php?step=update&hostid='.$mnet_peer->id, get_string('changessaved'));
} else {
- error('Invalid action parameter.', 'index.php');
+ print_error('Invalid action parameter.', '', 'index.php');
}
}
}
if (!empty($hide) and confirm_sesskey()) {
if (!$module = get_record("modules", "name", $hide)) {
- error("Module doesn't exist!");
+ print_error("Module doesn't exist!");
}
set_field("modules", "visible", "0", "id", $module->id); // Hide main module
// Remember the visibility status in visibleold
if (!empty($show) and confirm_sesskey()) {
if (!$module = get_record("modules", "name", $show)) {
- error("Module doesn't exist!");
+ print_error("Module doesn't exist!");
}
set_field("modules", "visible", "1", "id", $module->id); // Show main module
set_field('course_modules', 'visible', '1', 'visibleold',
} else { // Delete everything!!
if ($delete == "forum") {
- error("You can not delete the forum module!!");
+ print_error("You can not delete the forum module!!");
}
if (!$module = get_record("modules", "name", $delete)) {
- error("Module doesn't exist!");
+ print_error("Module doesn't exist!");
}
// OK, first delete all the relevant instances from all course sections
/// Get and sort the existing modules
if (!$modules = get_records("modules")) {
- error("No modules found!!"); // Should never happen
+ print_error("No modules found!!"); // Should never happen
}
foreach ($modules as $module) {
if (!$tables = $db->Metatables() ) { // No tables yet at all.
- error("no tables");
+ print_error("no tables");
}
print_simple_box_start('center');
}
if (!confirm_sesskey()) {
- error(get_string('confirmsesskeybad', 'error'));
+ print_error('confirmsesskeybad', 'error');
}
if (!$admin = get_admin()) {
- error("No admins");
+ print_error("No admins");
}
if (!$admin->country and $CFG->country) {
print_simple_box_start('center');
if (!db_replace($search, $replace)) {
- error('An error has occured during this process');
+ print_error('An error has occured during this process');
}
print_simple_box_end();
}
if (!$course = get_record("course","id",$courseid)) {
- error("That's an invalid course id");
+ print_error("That's an invalid course id");
}
if (!empty($userid)) {
if (!$user = get_record('user','id',$userid)) {
- error("That's an invalid user id");
+ print_error("That's an invalid user id");
}
}
}
if (! $context = get_context_instance_by_id($contextid)) {
- error("Context ID was incorrect (can't find it)");
+ print_error("Context ID was incorrect (can't find it)");
}
$inmeta = 0;
if ($course = get_record('course', 'id', $courseid)) {
$inmeta = $course->metacourse;
} else {
- error('Invalid course id');
+ print_error('Invalid course id');
}
$coursecontext = $context;
} else if (!empty($courseid)){ // we need this for user tabs in user context
if (!$course = get_record('course', 'id', $courseid)) {
- error('Invalid course id');
+ print_error('Invalid course id');
}
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
$role->description = $description;
if (!update_record('role', $role)) {
- error('Could not update role!');
+ print_error('Could not update role!');
}
// set proper legacy type
case 'delete':
if (in_array($roleid, $defaultroles)) {
- error('This role is used as one of the default system roles, it can not be deleted');
+ print_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);
- error('Could not delete role with ID '.$roleid);
+ print_error('Could not delete role with ID '.$roleid);
}
// deleted a role sitewide...
mark_context_dirty($sitecontext->path);
$above = $roles[$rolesort[$role->sortorder - 1]];
if (!switch_roles($role, $above)) {
- error("Cannot move role with ID $roleid");
+ print_error("Cannot move role with ID $roleid");
}
}
}
$below = $roles[$rolesort[$role->sortorder + 1]];
if (!switch_roles($role, $below)) {
- error("Cannot move role with ID $roleid");
+ print_error("Cannot move role with ID $roleid");
}
}
}
$role = stripslashes_safe($newrole);
} else {
if(!$role = get_record('role', 'id', $roleid)) {
- error('Incorrect role ID!');
+ print_error('Incorrect role ID!');
}
$role->legacytype = get_legacy_type($role->id);
}
$cancel = optional_param('cancel', 0, PARAM_BOOL);
if (!$context = get_record('context', 'id', $contextid)) {
- error('Bad context ID');
+ print_error('Bad context ID');
}
if (!$sitecontext = get_context_instance(CONTEXT_SYSTEM)) {
- error('No site ID');
+ print_error('No site ID');
}
if ($context->id == $sitecontext->id) {
- error('Can not override base role capabilities');
+ print_error('Can not override base role capabilities');
}
if (!has_capability('moodle/role:override', $context)) {
- error('You do not have permission to change overrides in this context!');
+ print_error('You do not have permission to change overrides in this context!');
}
if ($courseid) {
if (!$course = get_record('course', 'id', $courseid)) {
- error('Bad course ID');
+ print_error('Bad course ID');
}
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
case CONTEXT_MODULE:
// get module type?
if (!$cm = get_record('course_modules','id',$context->instanceid)) {
- error('Bad course module ID');
+ print_error('Bad course module ID');
}
if (!$module = get_record('modules','id',$cm->module)) { //$module->name;
- error('Bad module ID');
+ print_error('Bad module ID');
}
if (!$course = get_record('course','id',$cm->course)) {
- error('Bad course ID');
+ print_error('Bad course ID');
}
if (!$instance = get_record($module->name, 'id', $cm->instance)) {
- error("The required instance of this module doesn't exist");
+ print_error("The required instance of this module doesn't exist");
}
require_login($course);
$confirm = optional_param('confirm', 0, PARAM_BOOL);
if ($CFG->version < 2005042300) {
- error("This script does not work with this old version of Moodle");
+ print_error("This script does not work with this old version of Moodle");
}
if (!$site = get_site()) {
$confirm = optional_param('confirm', 0, PARAM_BOOL);
if ($CFG->version < 2004013101) {
- error("This script does not work with this old version of Moodle");
+ print_error("This script does not work with this old version of Moodle");
}
if (!$site = get_site()) {
require_capability('moodle/site:uploadusers', get_context_instance(CONTEXT_SYSTEM, SITEID));
if (!$site = get_site()) {
- error("Could not find site-level course");
+ print_error("Could not find site-level course");
}
if (!$adminuser = get_admin()) {
- error("Could not find site admin");
+ print_error("Could not find site admin");
}
$strfile = get_string('file');
unset($content);
if ($readcount === false) {
- error($cir->get_error(), $returnurl);
+ print_error($cir->get_error(), '', $returnurl);
} else if ($readcount == 0) {
- error(get_string('csvemptyfile', 'error'), $returnurl);
+ print_error('csvemptyfile', 'error', $returnurl);
}
// continue to form2
}
if (!$columns = $cir->get_columns()) {
- error('Error reading temporary file', $returnurl);
+ print_error('Error reading temporary file', '', $returnurl);
}
$mform = new admin_uploaduser_form2(null, $columns);
// get initial date from form1
$site = get_site();
if (!has_capability('moodle/user:update', $sitecontext) and !has_capability('moodle/user:delete', $sitecontext)) {
- error('You do not have the required permission to edit/delete users.');
+ print_error('You do not have the required permission to edit/delete users.');
}
$stredit = get_string('edit');
if ($confirmuser and confirm_sesskey()) {
if (!$user = get_record('user', 'id', $confirmuser)) {
- error("No such user!", '', true);
+ print_error("No such user!");
}
$auth = get_auth_plugin($user->auth);
} else if ($delete and confirm_sesskey()) { // Delete a selected user, after confirmation
if (!has_capability('moodle/user:delete', $sitecontext)) {
- error('You do not have the required permission to delete a user.');
+ print_error('You do not have the required permission to delete a user.');
}
if (!$user = get_record('user', 'id', $delete)) {
- error("No such user!", '', true);
+ print_error("No such user!");
}
if (is_primary_admin($user->id)) {
- error("You are not allowed to delete the primary admin user!", '', true);
+ print_error("You are not allowed to delete the primary admin user!");
}
if ($confirm != md5($delete)) {
} else if ($acl and confirm_sesskey()) {
if (!has_capability('moodle/user:delete', $sitecontext)) {
// TODO: this should be under a separate capability
- error('You are not permitted to modify the MNET access control list.');
+ print_error('You are not permitted to modify the MNET access control list.');
}
if (!$user = get_record('user', 'id', $acl)) {
- error("No such user.", '', true);
+ print_error("No such user.");
}
if (!is_mnet_remote_user($user)) {
- error('Users in the MNET access control list must be remote MNET users.');
+ print_error('Users in the MNET access control list must be remote MNET users.');
}
$accessctrl = strtolower(required_param('accessctrl', PARAM_ALPHA));
if ($accessctrl != 'allow' and $accessctrl != 'deny') {
- error('Invalid access parameter.');
+ print_error('Invalid access parameter.');
}
$aclrecord = get_record('mnet_sso_access_control', 'username', $user->username, 'mnet_host_id', $user->mnethostid);
if (empty($aclrecord)) {
$aclrecord->username = $user->username;
$aclrecord->accessctrl = $accessctrl;
if (!insert_record('mnet_sso_access_control', $aclrecord)) {
- error("Database error - Couldn't modify the MNET access control list.", '', true);
+ print_error("Database error - Couldn't modify the MNET access control list.");
}
} else {
$aclrecord->accessctrl = $accessctrl;
if (!update_record('mnet_sso_access_control', $aclrecord)) {
- error("Database error - Couldn't modify the MNET access control list.", '', true);
+ print_error("Database error - Couldn't modify the MNET access control list.");
}
}
$mnethosts = get_records('mnet_host', '', '', 'id', 'id,wwwroot,name');
}
if (empty($CFG->messaging)) {
- error("Messaging is disabled on this site");
+ print_error("Messaging is disabled on this site");
}
//TODO: add support for large number of users
/// Do the job, setting result as needed
if (!data_submitted('nomatch')) { ///Basic prevention
- error('Wrong action call');
+ print_error('Wrong action call');
}
/// Get parameters
/// Do the job, setting result as needed
if (!data_submitted('nomatch')) { ///Basic prevention
- error('Wrong action call');
+ print_error('Wrong action call');
}
/// Get parameters
/// Do the job, setting result as needed
if (!data_submitted('nomatch')) { ///Basic prevention
- error('Wrong action call');
+ print_error('Wrong action call');
}
/// Get parameters
/// Do the job, setting result as needed
if (!data_submitted('nomatch')) { ///Basic prevention
- error('Wrong action call');
+ print_error('Wrong action call');
}
/// Get parameters
/// Do the job, setting result as needed
if (!data_submitted('nomatch')) { ///Basic prevention
- error('Wrong action call');
+ print_error('Wrong action call');
}
/// Get parameters
break;
}
} else {
- error($xmldb_action->getError());
+ print_error($xmldb_action->getError());
}
} else {
error ("Error: cannot instantiate class (actions/$action/$actionclass)");
/// Define variables used in page
if (!$site = get_site()) {
- error("No site found!");
+ print_error("No site found!");
}
$authsequence = get_enabled_auth_plugins(true); // auths, in sequence
/// Define variables used in page
if (!$site = get_site()) {
- error("No site found!");
+ print_error("No site found!");
}
$authsequence = get_enabled_auth_plugins(true); // auths, in sequence
* @return bool Authentication success or failure.
*/
function user_login($username, $password) {
- return false; // error("Remote MNET users cannot login locally.");
+ return false; // print_error("Remote MNET users cannot login locally.");
}
/**
or is_mnet_remote_user($USER)
or $USER->username == 'guest'
or empty($USER->id)) {
- error(get_string('notpermittedtojump', 'mnet'));
+ print_error('notpermittedtojump', 'mnet');
}
// check for SSO publish permission first
if ($this->has_service($mnethostid, 'sso_sp') == false) {
- error(get_string('hostnotconfiguredforsso', 'mnet'));
+ print_error('hostnotconfiguredforsso', 'mnet');
}
// set RPC timeout to 30 seconds if not configured
$mnet_session->expires = time() + (integer)ini_get('session.gc_maxlifetime');
$mnet_session->session_id = session_id();
if (! $mnet_session->id = insert_record('mnet_session', addslashes_object($mnet_session))) {
- error(get_string('databaseerror', 'mnet'));
+ print_error('databaseerror', 'mnet');
}
} else {
$mnet_session->useragent = sha1($_SERVER['HTTP_USER_AGENT']);
$mnet_session->expires = time() + (integer)ini_get('session.gc_maxlifetime');
$mnet_session->session_id = session_id();
if (false == update_record('mnet_session', addslashes_object($mnet_session))) {
- error(get_string('databaseerror', 'mnet'));
+ print_error('databaseerror', 'mnet');
}
}
// verify the remote host is configured locally before attempting RPC call
if (! $remotehost = get_record('mnet_host', 'wwwroot', $remotewwwroot)) {
- error(get_string('notpermittedtoland', 'mnet'));
+ print_error('notpermittedtoland', 'mnet');
}
// get the originating (ID provider) host info
list($code, $message) = array_map('trim',explode(':', $errormessage, 2));
if($code == 702) {
$site = get_site();
- print_error('mnet_session_prohibited','mnet', $remotewwwroot, format_string($site->fullname));
+ print_error('mnet_session_prohibited', 'mnet', $remotewwwroot, format_string($site->fullname));
exit;
}
$message .= "ERROR $code:<br/>$errormessage<br/>";
}
- error("RPC auth/mnet/user_authorise:<br/>$message");
+ print_error("RPC auth/mnet/user_authorise:<br/>$message");
}
unset($mnetrequest);
// TODO: refactor into a separate function
if (empty($localuser) || ! $localuser->id) {
if (empty($this->config->auto_add_remote_users)) {
- error(get_string('nolocaluser', 'mnet'));
+ print_error('nolocaluser', 'mnet');
}
$remoteuser->mnethostid = $remotehost->id;
if (! insert_record('user', addslashes_object($remoteuser))) {
- error(get_string('databaseerror', 'mnet'));
+ print_error('databaseerror', 'mnet');
}
$firsttime = true;
if (! $localuser = get_record('user', 'username', addslashes($remoteuser->username), 'mnethostid', $remotehost->id)) {
- error(get_string('nolocaluser', 'mnet'));
+ print_error('nolocaluser', 'mnet');
}
}
if (!$bool) {
// TODO: Jonathan to clean up mess
// Actually, this should never happen (modulo race conditions) - ML
- error("updating user failed in mnet/auth/confirm_mnet_session ");
+ print_error("updating user failed in mnet/auth/confirm_mnet_session ");
}
// set up the session
$mnet_session->expires = time() + (integer)$session_gc_maxlifetime;
$mnet_session->session_id = session_id();
if (! $mnet_session->id = insert_record('mnet_session', addslashes_object($mnet_session))) {
- error(get_string('databaseerror', 'mnet'));
+ print_error('databaseerror', 'mnet');
}
} else {
$mnet_session->expires = time() + (integer)$session_gc_maxlifetime;
require_once dirname(dirname(dirname(__FILE__))) . '/config.php';
if (!is_enabled_auth('mnet')) {
- error('mnet is disabled');
+ print_error('mnet is disabled');
}
// grab the GET params - wantsurl could be anything - take it
$url = $mnetauth->start_jump_session($hostid, $wantsurl);
if (empty($url)) {
- error('DEBUG: Jump session was not started correctly or blank URL returned.'); // TODO: errors
+ print_error('DEBUG: Jump session was not started correctly or blank URL returned.'); // TODO: errors
}
redirect($url);
}
if (!is_enabled_auth('mnet')) {
- error('mnet is disabled');
+ print_error('mnet is disabled');
}
// grab the GET params
$token = required_param('token', PARAM_BASE64);
/// Define variables used in page
if (!$site = get_site()) {
- error("No site found!");
+ print_error("No site found!");
}
if (empty($CFG->langmenu)) {
if (!empty($id)) {
require_login($id);
if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_COURSE, $id))) {
- error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php");
+ print_error("You need to be a teacher or admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
}
} else {
require_login();
if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_SYSTEM))) {
- error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
+ print_error("You need to be an admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
}
}
if (!empty($to)) {
if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_COURSE, $to))) {
- error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php");
+ print_error("You need to be a teacher or admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
}
}
//Check site
if (!$site = get_site()) {
- error("Site not found!");
+ print_error("Site not found!");
}
//Check necessary functions exists. Thanks to gregb@crowncollege.edu
//Get and check course
if (! $course = get_record("course", "id", $id)) {
- error("Course ID was incorrect (can't find it)");
+ print_error("Course ID was incorrect (can't find it)");
}
//Print header
if (!empty($course->id)) {
if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_COURSE, $course->id))) {
if (empty($to)) {
- error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php");
+ print_error("You need to be a teacher or admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
} else {
if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_COURSE, $to))) {
- error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php");
+ print_error("You need to be a teacher or admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
}
}
}
} else {
if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_SYSTEM, SITEID))) {
- error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
+ print_error("You need to be an admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
}
}
//Check site
if (!$site = get_site()) {
- error("Site not found!");
+ print_error("Site not found!");
}
if ($count == 0) {
notice("No backupable modules are installed!");
}
if (!execute_sql("DELETE FROM {$CFG->prefix}backup_ids WHERE backup_code = '{$backupprefs->backup_unique_code}'",false)){
- error('Couldn\'t delete previous backup ids.');
+ print_error('Couldn\'t delete previous backup ids.');
}
?>
if (!empty($course->id)) {
if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_COURSE, $course->id))) {
if (empty($to)) {
- error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php");
+ print_error("You need to be a teacher or admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
} else {
if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_COURSE, $to))) {
- error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php");
+ print_error("You need to be a teacher or admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
}
}
}
} else {
if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_SYSTEM, SITEID))) {
- error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
+ print_error("You need to be an admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
}
}
//Check site
if (!$site = get_site()) {
- error("Site not found!");
+ print_error("Site not found!");
}
$preferences = new StdClass;
if (!empty($course->id)) {
if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_COURSE, $course->id))) {
if (empty($to)) {
- error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php");
+ print_error("You need to be a teacher or admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
} else {
if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_COURSE, $to))) {
- error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php");
+ print_error("You need to be a teacher or admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
}
}
}
} else {
if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_SYSTEM))) {
- error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
+ print_error("You need to be an admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
}
}
//Check site
if (!$site = get_site()) {
- error("Site not found!");
+ print_error("Site not found!");
}
//Checks for the required files/functions to backup every mod
}
}
} else {
- error("Upgrade of backup system failed! (Could not update version in config table)");
+ print_error("Upgrade of backup system failed! (Could not update version in config table)");
}
} else {
- error("Backup tables could NOT be set up successfully!");
+ print_error("Backup tables could NOT be set up successfully!");
}
}
}
}
} else {
- error("Upgrade of backup system failed! (Could not update version in config table)");
+ print_error("Upgrade of backup system failed! (Could not update version in config table)");
}
} else {
- error("Upgrade failed! See backup/version.php");
+ print_error("Upgrade failed! See backup/version.php");
}
} else if ($backup_version < $CFG->backup_version) {
if(!function_exists('utf8_encode')) {
if (empty($justcheck)) {
- error('You need to add XML support to your PHP installation');
+ print_error('You need to add XML support to your PHP installation');
} else {
return false;
}
require_login($id);
if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_COURSE, $id))) {
if (empty($to)) {
- error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php");
+ print_error("You need to be a teacher or admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
} else {
if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_COURSE, $to))
&& !has_capability('moodle/site:import', get_context_instance(CONTEXT_COURSE, $to))) {
- error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php");
+ print_error("You need to be a teacher or admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
}
}
}
} else {
if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_SYSTEM, SITEID))) {
- error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
+ print_error("You need to be an admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
}
}
//Check site
if (!$site = get_site()) {
- error("Site not found!");
+ print_error("Site not found!");
}
//Check necessary functions exists. Thanks to gregb@crowncollege.edu
//Get and check course
if (! $course = get_record("course", "id", $id)) {
- error("Course ID was incorrect (can't find it)");
+ print_error("Course ID was incorrect (can't find it)");
}
//Print header
} else if ($launch == "execute") {
//Prevent multiple restore executions...
if (empty($SESSION->cancontinue)) {
- error("Multiple restore execution not allowed!");
+ print_error("Multiple restore execution not allowed!");
}
//Unset this for the future
unset($SESSION->cancontinue);
// check for session objects
if (empty($info) or empty($course_header)) {
- error( 'important information missing from SESSION' );
+ print_error( 'important information missing from SESSION' );
}
//Check admin
if (!empty($id)) {
if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_COURSE, $id))) {
- error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php");
+ print_error("You need to be a teacher or admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
}
} else {
if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_SYSTEM, SITEID))) {
- error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
+ print_error("You need to be an admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
}
}
//Check site
if (!$site = get_site()) {
- error("Site not found!");
+ print_error("Site not found!");
}
//Depending the selected restoreto:
} else if ((($restore->restoreto == 0 or $restore->restoreto == 1) and ($restore->course_id != 0)) or ($restore->restoreto == 2)) {
//Final access control check
if ($restore->course_id == 0 and !user_can_create_courses()) {
- error("You need to be a creator or admin to restore into new course!");
+ print_error("You need to be a creator or admin to restore into new course!");
} else if ($restore->course_id != 0 and !has_capability('moodle/site:restore', get_context_instance(CONTEXT_COURSE, $restore->course_id))) {
- error("You need to be an edit teacher or admin to restore into selected course!");
+ print_error("You need to be an edit teacher or admin to restore into selected course!");
}
$show_continue_button = true;
//Check if we've selected any mod's user info and restore->users
if (!empty($id)) {
if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_COURSE, $id))) {
if (empty($to)) {
- error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php");
+ print_error("You need to be a teacher or admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
} else {
if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_COURSE, $to))
&& !has_capability('moodle/site:import', get_context_instance(CONTEXT_COURSE, $to))) {
- error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php");
+ print_error("You need to be a teacher or admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
}
}
}
} else {
if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_SYSTEM, SITEID))) {
- error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
+ print_error("You need to be an admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
}
}
//Check site
if (!$site = get_site()) {
- error("Site not found!");
+ print_error("Site not found!");
}
$errorstr = '';
$status = restore_execute($restore,$info,$course_header,$errorstr);
if (!$status) {
- error ("An error has occurred and the restore could not be completed!");
+ print_error ("An error has occurred and the restore could not be completed!");
}
if (empty($restore->importing)) {
//Get objects from session
if (!($info = $SESSION->info)) {
- error( 'info object missing from session' );
+ print_error( 'info object missing from session' );
}
if (!($course_header = $SESSION->course_header)) {
- error( 'course_header object missing from session' );
+ print_error( 'course_header object missing from session' );
}
$restore_gradebook_history = optional_param('restore_gradebook_history', 0, PARAM_INT);
//Check admin
if (!empty($id)) {
if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_COURSE, $id))) {
- error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php");
+ print_error("You need to be a teacher or admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
}
} else {
if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_SYSTEM))) {
- error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
+ print_error("You need to be an admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
}
}
//Check site
if (!$site = get_site()) {
- error("Site not found!");
+ print_error("Site not found!");
}
//Checks for the required files/functions to restore every mod
}
return true;
}
-?>
\ No newline at end of file
+?>
if (!empty($id)) {
if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_COURSE, $id))) {
if (empty($to)) {
- error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php");
+ print_error("You need to be a teacher or admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
} else {
if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_COURSE, $to))
&& !has_capability('moodle/site:import', get_context_instance(CONTEXT_COURSE, $to))) {
- error("You need to be a teacher or admin user to use this page.", "$CFG->wwwroot/login/index.php");
+ print_error("You need to be a teacher or admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
}
}
}
} else {
if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_SYSTEM, SITEID))) {
- error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
+ print_error("You need to be an admin user to use this page.", '', "$CFG->wwwroot/login/index.php");
}
}
//Check site
if (!$site = get_site()) {
- error("Site not found!");
+ print_error("Site not found!");
}
$errorstr = '';
$status = restore_precheck($id,$file,$errorstr);
if (!$status) {
- error("An error occured");
+ print_error("An error occured");
}
?>
} else {
// should not happen, as we check in restore_chech.php
// but handle the error if it does
- error("This backup file contains external Moodle Network Hosts that are not configured locally.");
+ print_error("This backup file contains external Moodle Network Hosts that are not configured locally.");
}
}
unset($user->mnethosturl);
/**
* @param string $errorstr passed by reference, if silent is true,
- * errorstr will be populated and this function will return false rather than calling error() or notify()
+ * errorstr will be populated and this function will return false rather than calling print_error() or notify()
* @param boolean $noredirect (optional) if this is passed, this function will not print continue, or
* redirect to the next step in the restore process, instead will return $backup_unique_code
*/
//Open file for writing
//First, we check the course_id backup data folder exists and create it as necessary in CFG->dataroot
if (!$dest_dir = make_upload_directory("$restore->course_id/backupdata")) { // Backup folder
- error("Could not create backupdata folder. The site administrator needs to fix the file permissions");
+ print_error("Could not create backupdata folder. The site administrator needs to fix the file permissions");
}
$status = check_dir_exists($dest_dir,true);
$restorelog_file = fopen("$dest_dir/restorelog.html","a");
//Check site
if (!$site = get_site()) {
- error("Site not found!");
+ print_error("Site not found!");
}
//Check necessary functions exists. Thanks to gregb@crowncollege.edu
// Ensure that the logged in user is not using the guest account
if (isguest()) {
- error(get_string('noguestpost', 'forum'), $referrer);
+ print_error('noguestpost', 'forum', $referrer);
}
if ($act == 'updfeed') {
if (!$managefeeds) {
- error(get_string('noguestpost', 'forum').
- ' You are not allowed to make modifications to this RSS feed at this time.',
- $referrer);
+ //print_error(get_string('noguestpost', 'forum').
+ // ' You are not allowed to make modifications to this RSS feed at this time.',
+ // $referrer);
+ print_error('noguestpost', 'forum', $referrer, 'You are not allowed to make modifications to this RSS feed at this time.');
}
if (empty($url)) {
- error( 'URL not defined for rss feed' );
+ print_error( 'URL not defined for rss feed' );
}
// By capturing the output from fetch_rss this way
$dataobject->url = addslashes($url);
if (!update_record('block_rss_client', $dataobject)) {
- error('There was an error trying to update rss feed with id:'. $rssid);
+ print_error('There was an error trying to update rss feed with id:'. $rssid);
}
$message .= '<br />'. get_string('feedupdated', 'block_rss_client');
$canaddsharedfeeds = has_capability('block/rss_client:createsharedfeeds', $context);
if (!$canaddprivfeeds && !$canaddsharedfeeds) {
- error('You do not have the permission to add RSS feeds');
+ print_error('You do not have the permission to add RSS feeds');
}
if (empty($url)) {
- error('URL not defined for rss feed');
+ print_error('URL not defined for rss feed');
}
$dataobject->userid = $USER->id;
$dataobject->description = '';
$rssid = insert_record('block_rss_client', $dataobject);
if (!$rssid) {
- error('There was an error trying to add a new rss feed:'. $url);
+ print_error('There was an error trying to add a new rss feed:'. $url);
}
// By capturing the output from fetch_rss this way
$dataobject->title = addslashes($rss->channel['title']);
}
if (!update_record('block_rss_client', $dataobject)) {
- error('There was an error trying to update rss feed with id:'. $rssid);
+ print_error('There was an error trying to update rss feed with id:'. $rssid);
}
$message .= '<br />'. get_string('feedadded', 'block_rss_client');
}
} else if ($act == 'delfeed') {
if (!$managefeeds) {
- error(get_string('noguestpost', 'forum').
- ' You are not allowed to make modifications to this RSS feed at this time.',
- $referrer);
+ //print_error(get_string('noguestpost', 'forum').
+ // ' You are not allowed to make modifications to this RSS feed at this time.',
+ // $referrer);
+ print_error('noguestpost', 'forum', $referrer, 'You are not allowed to make modifications to this RSS feed at this time.');
}
$file = $CFG->dataroot .'/cache/rsscache/'. $rssid .'.xml';
$courserecord = NULL;
} else {
if (! ($courserecord = get_record('course', 'id', $this->courseid)) ) {
- error( 'You are tring to view an invalid course. Id: ('. $this->courseid .')' );
+ print_error( 'You are tring to view an invalid course. Id: ('. $this->courseid .')' );
}
}
$this->full_init_done = true;
require_login($courseid);
if (empty($CFG->bloglevel)) {
- error('Blogging is disabled!');
+ print_error('Blogging is disabled!');
}
if (isguest()) {
- error(get_string('noguestpost', 'blog'));
+ print_error('noguestpost', 'blog');
}
$sitecontext = get_context_instance(CONTEXT_SYSTEM, SITEID);
if (!has_capability('moodle/blog:create', $sitecontext) and !has_capability('moodle/blog:manageentries', $sitecontext)) {
- error('You can not post or edit blogs.');
+ print_error('You can not post or edit blogs.');
}
// Make sure that the person trying to edit have access right
if ($id) {
if (!$existing = get_record('post', 'id', $id)) {
- error('Wrong blog post id');
+ print_error('Wrong blog post id');
}
if (!blog_user_can_edit_post($existing)) {
- error(get_string('notallowedtoedit', 'blog'));
+ print_error('notallowedtoedit', 'blog');
}
$userid = $existing->userid;
$returnurl = $CFG->wwwroot.'/blog/index.php?userid='.$existing->userid;
} else {
if (!has_capability('moodle/blog:create', $sitecontext)) {
- error(get_string('nopost', 'blog')); // manageentries is not enough for adding
+ print_error('nopost', 'blog'); // manageentries is not enough for adding
}
$existing = false;
$userid = $USER->id;
if ($action=='delete'){
if (!$existing) {
- error('Incorrect blog post id');
+ print_error('Incorrect blog post id');
}
if (data_submitted() and $confirm and confirm_sesskey()) {
do_delete($existing);
case 'edit':
if (!$existing) {
- error('Incorrect blog post id');
+ print_error('Incorrect blog post id');
}
do_edit($fromform, $blogeditform);
break;
default :
- error('Unknown action!');
+ print_error('Unknown action!');
}
redirect($returnurl);
}
case 'edit':
if (!$existing) {
- error('Incorrect blog post id');
+ print_error('Incorrect blog post id');
}
$post->id = $existing->id;
$post->subject = $existing->subject;
}
break;
default :
- error('Unknown action!');
+ print_error('Unknown action!');
}
// done here in order to allow deleting of posts with wrong user id above
if (!$user = get_record('user', 'id', $userid)) {
- error('Incorrect user id');
+ print_error('Incorrect user id');
}
$navlinks = array();
$navlinks[] = array('name' => fullname($user), 'link' => "$CFG->wwwroot/user/view.php?id=$userid", 'type' => 'misc');
add_to_log(SITEID, 'blog', 'delete', 'index.php?userid='. $post->userid, 'deleted blog entry with entry id# '. $post->id);
if (!$status) {
- error('Error occured while deleting post', $returnurl);
+ print_error('Error occured while deleting post', '', $returnurl);
}
}
add_to_log(SITEID, 'blog', 'add', 'index.php?userid='.$post->userid.'&postid='.$post->id, $post->subject);
} else {
- error('There was an error adding this post in the database', $returnurl);
+ print_error('There was an error adding this post in the database', '', $returnurl);
}
}
add_to_log(SITEID, 'blog', 'update', 'index.php?userid='.$USER->id.'&postid='.$post->id, $post->subject);
} else {
- error('There was an error updating this post in the database', $returnurl);
+ print_error('There was an error updating this post in the database', '', $returnurl);
}
}
if (!$course = get_record('course', 'id', $courseid)) {
- error('The course number was incorrect ('. $courseid .')');
+ print_error('The course number was incorrect ('. $courseid .')');
}
// Bounds for block widths
// needed also for user tabs later
if (!$course = get_record('course', 'id', $courseid)) {
- error('Wrong course id');
+ print_error('Wrong course id');
}
$navlinks = array();
case 'user':
$participants = get_string('participants');
if (!$user = get_record('user', 'id', $filterselect)) {
- error('Wrong user id');
+ print_error('Wrong user id');
}
if ($course->id != SITEID) {
if (empty($CFG->bloglevel)) {
- error('Blogging is disabled!');
+ print_error('Blogging is disabled!');
}
$sitecontext = get_context_instance(CONTEXT_SYSTEM, SITEID);
case 'site':
if ($CFG->bloglevel < BLOG_SITE_LEVEL) {
- error('Site blogs is not enabled');
+ print_error('Site blogs is not enabled');
}
if ($CFG->bloglevel < BLOG_GLOBAL_LEVEL) {
require_login();
}
if (!has_capability('moodle/blog:view', $sitecontext)) {
- error('You do not have the required permissions to view all site blogs');
+ print_error('You do not have the required permissions to view all site blogs');
}
break;
case 'course':
if ($CFG->bloglevel < BLOG_COURSE_LEVEL) {
- error('Course blogs is not enabled');
+ print_error('Course blogs is not enabled');
}
if (!$course = get_record('course', 'id', $filterselect)) {
- error('Incorrect course id specified');
+ print_error('Incorrect course id specified');
}
$courseid = $course->id;
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
require_login($course);
if (!has_capability('moodle/blog:view', $coursecontext)) {
- error('You do not have the required permissions to view blogs in this course');
+ print_error('You do not have the required permissions to view blogs in this course');
}
break;
case 'group':
if ($CFG->bloglevel < BLOG_GROUP_LEVEL) {
- error('Group blogs is not enabled');
+ print_error('Group blogs is not enabled');
}
// fix for MDL-9268
if (! $group = groups_get_group($filterselect)) { //TODO:check.
- error('Incorrect group id specified');
+ print_error('Incorrect group id specified');
}
if (!$course = get_record('course', 'id', $group->courseid)) {
- error('Incorrect course id specified');
+ print_error('Incorrect course id specified');
}
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
$courseid = $course->id;
require_login($course);
if (!has_capability('moodle/blog:view', $coursecontext)) {
- error('You do not have the required permissions to view blogs in this course/group');
+ print_error('You do not have the required permissions to view blogs in this course/group');
}
if (groups_get_course_groupmode($course) == SEPARATEGROUPS
and !has_capability('moodle/site:accessallgroups', $coursecontext)) {
case 'user':
if ($CFG->bloglevel < BLOG_USER_LEVEL) {
- error('Blogs is not enabled');
+ print_error('Blogs is not enabled');
}
if (!$user = get_record('user', 'id', $filterselect)) {
- error('Incorrect user id');
+ print_error('Incorrect user id');
}
if ($USER->id == $filterselect) {
if (!has_capability('moodle/blog:create', $sitecontext)
and !has_capability('moodle/blog:view', $sitecontext)) {
- error('You do not have your own blog, sorry.');
+ print_error('You do not have your own blog, sorry.');
}
} else {
$personalcontext = get_context_instance(CONTEXT_USER, $filterselect);
if (!has_capability('moodle/blog:view', $sitecontext)
and !has_capability('moodle/user:readuserblogs', $personalcontext)) {
- error('You do not have the required permissions to read user blogs');
+ print_error('You do not have the required permissions to read user blogs');
}
if (!blog_user_can_view_user_post($filterselect)) {
- error('You can not view blog of this user, sorry.');
+ print_error('You can not view blog of this user, sorry.');
}
}
$userid = $filterselect;
break;
default:
- error('Incorrect blog filter type specified');
+ print_error('Incorrect blog filter type specified');
break;
}
}
if (empty($CFG->bloglevel)) {
- error('Blogging is disabled!');
+ print_error('Blogging is disabled!');
}
require_capability('moodle/blog:view', $context);
$pagesize = required_param('pagesize', PARAM_INT);
if ($pagesize < 1) {
- error('invalid page size');
+ print_error('invalid page size');
}
set_user_preference('blogpagesize', $pagesize);
$title = get_string('deleteevent', 'calendar');
$event = get_record('event', 'id', $eventid);
if($event === false) {
- error('Invalid event');
+ print_error('Invalid event');
}
if(!calendar_edit_event_allowed($event)) {
- error('You are not authorized to do this');
+ print_error('You are not authorized to do this');
}
break;
$repeats = optional_param('repeats', 0, PARAM_INT);
if($event === false) {
- error('Invalid event');
+ print_error('Invalid event');
}
if(!calendar_edit_event_allowed($event)) {
- error('You are not authorized to do this');
+ print_error('You are not authorized to do this');
}
if($form = data_submitted()) {
$form->timeduration = 0;
}
if(!calendar_add_event_allowed($form)) {
- error('You are not authorized to do this');
+ print_error('You are not authorized to do this');
}
validate_form($form, $err);
if (count($err) == 0) {
case 'select':
break;
default:
- error('Unsupported event type');
+ print_error('Unsupported event type');
}
$form->format = $defaultformat;
$courseid = SITEID;
}
if (!$course = get_record('course', 'id', $courseid)) {
- error('Incorrect course ID');
+ print_error('Incorrect course ID');
}
$groupid = groups_get_course_group($course);
// Timestamps must be >= course startdate
$course = get_record('course', 'id', $form->courseid);
if($course === false) {
- error('Event belongs to invalid course');
+ print_error('Event belongs to invalid course');
}
else if($form->timestart < $course->startdate) {
$err['timestart'] = get_string('errorbeforecoursestart', 'calendar');
// TODO: rewrite this hack somehow
if (!calendar_edit_event_allowed($event)){ // cannot manage entries, eg. student
if(!$assignment = get_record('assignment','id',$event->instance)){
- // error("assignment ID was incorrect");
+ // print_error("assignment ID was incorrect");
continue;
}
// assign assignment to assignment object to use hidden_is_hidden method
}
if (!$site = get_site()) {
- error("Site isn't defined!");
+ print_error("Site isn't defined!");
}
if (empty($id)) {
- error("Category not known!");
+ print_error("Category not known!");
}
if (!$context = get_context_instance(CONTEXT_COURSECAT, $id)) {
- error("Category not known!");
+ print_error("Category not known!");
}
if (!$category = get_record("course_categories", "id", $id)) {
- error("Category not known!");
+ print_error("Category not known!");
}
if (has_capability('moodle/course:create', $context)) {
} else {
if (!$category->visible) {
- error(get_string('notavailable', 'error'));
+ print_error('notavailable', 'error');
}
$navbaritem = print_course_search("", true, "navbar");
$adminediting = false;
require_capability('moodle/category:update', get_context_instance(CONTEXT_COURSECAT, $moveto));
if (! $destcategory = get_record("course_categories", "id", $data->moveto)) {
- error("Error finding the category");
+ print_error("Error finding the category");
}
require_login();
if (!can_delete_course($id)) {
- error('You do not have the permission to delete this course.');
+ print_error('You do not have the permission to delete this course.');
}
if (!$site = get_site()) {
- error("Site not found!");
+ print_error("Site not found!");
}
$strdeletecourse = get_string("deletecourse");
$strcategories = get_string("categories");
if (! $course = get_record("course", "id", $id)) {
- error("Course ID was incorrect (can't find it)");
+ print_error("Course ID was incorrect (can't find it)");
}
$category = get_record("course_categories", "id", $course->category);
}
if ($delete != md5($course->timemodified)) {
- error("The check variable was wrong - try again");
+ print_error("The check variable was wrong - try again");
}
if (!confirm_sesskey()) {
- error(get_string('confirmsesskeybad', 'error'));
+ print_error('confirmsesskeybad', 'error');
}
// OK checks done, delete the course now.
if($id == SITEID){
// don't allow editing of 'site course' using this from
- error('You cannot edit the site course using this form');
+ print_error('You cannot edit the site course using this form');
}
if (!$course = get_record('course', 'id', $id)) {
- error('Course ID was incorrect');
+ print_error('Course ID was incorrect');
}
require_login($course->id);
$category = get_record('course_categories', 'id', $course->category);
$course = null;
require_login();
if (!$category = get_record('course_categories', 'id', $categoryid)) {
- error('Category ID was incorrect');
+ print_error('Category ID was incorrect');
}
require_capability('moodle/course:create', get_context_instance(CONTEXT_COURSECAT, $category->id));
} else {
require_login();
- error('Either course id or category must be specified');
+ print_error('Either course id or category must be specified');
}
/// prepare course
$resort = optional_param('resort', 0, PARAM_BOOL);
if (!$site = get_site()) {
- error("Site isn't defined!");
+ print_error("Site isn't defined!");
}
if ($categoryadd) { // Show Add category form: if $id is given, it is used as the parent category
$strtitle = get_string("editcategorysettings");
$context = get_context_instance(CONTEXT_COURSECAT, $id);
if (!$category = get_record("course_categories", "id", $id)) {
- error("Category not known!");
+ print_error("Category not known!");
}
}
}
if (!update_record('course_categories', $newcategory)) {
- error( "Could not update the category '$newcategory->name' ");
+ print_error( "Could not update the category '$newcategory->name' ");
} else {
if ($newcategory->parent == 0) {
$redirect_link = 'index.php?categoryedit=on';
} else {
if (!$category->visible) {
- error(get_string('notavailable', 'error'));
+ print_error('notavailable', 'error');
}
$navbaritem = print_course_search("", true, "navbar");
$adminediting = false;
require_capability('moodle/category:update', get_context_instance(CONTEXT_COURSECAT, $moveto));
if (!$destcategory = get_record("course_categories", "id", $data->moveto)) {
- error("Error finding the destination category");
+ print_error("Error finding the destination category");
}
// TODO function to move the category
}
$id = required_param('id',PARAM_INT); // Week ID
if (! $section = get_record("course_sections", "id", $id)) {
- error("Course section is incorrect");
+ print_error("Course section is incorrect");
}
if (! $course = get_record("course", "id", $section->course)) {
- error("Could not find the course!");
+ print_error("Could not find the course!");
}
require_login($course->id);
$timenow = time();
if (! set_field("course_sections", "summary", $form->summary, "id", $section->id)) {
- error("Could not update the summary!");
+ print_error("Could not update the summary!");
}
add_to_log($course->id, "course", "editsection", "editsection.php?id=$section->id", "$section->section");
}
if (! $course = get_record('course', 'id', $id) ) {
- error("That's an invalid course id");
+ print_error("That's an invalid course id");
}
if (! $context = get_context_instance(CONTEXT_COURSE, $course->id) ) {
- error("That's an invalid course id");
+ print_error("That's an invalid course id");
}
/// do not use when in course login as
if (($marker >=0) and has_capability('moodle/course:setcurrentsection', $context) and confirm_sesskey()) {
$course->marker = $marker;
if (! set_field("course", "marker", $marker, "id", $course->id)) {
- error("Could not mark that topic for this course");
+ print_error("Could not mark that topic for this course");
}
}
if (($marker >=0) && has_capability('moodle/course:setcurrentsection', $context) && confirm_sesskey()) {
$course->marker = $marker;
if (! set_field("course", "marker", $marker, "id", $course->id)) {
- error("Could not mark that topic for this course");
+ print_error("Could not mark that topic for this course");
}
}
$id = required_param('id', PARAM_INT); // course id to import TO
if (!$course = get_record('course', 'id', $id)) {
- error("That's an invalid course id");
+ print_error("That's an invalid course id");
}
require_login($course->id);
$strimportactivities = get_string('importactivities');
if (! ($course = get_record("course", "id", $id)) ) {
- error("That's an invalid course id");
+ print_error("That's an invalid course id");
}
if (!$site = get_site()){
- error("Couldn't get site course");
+ print_error("Couldn't get site course");
}
require_login($course->id);
$syscontext = get_context_instance(CONTEXT_SYSTEM, SITEID);
if (!has_capability('moodle/course:manageactivities', $tocontext)) {
- error("You need do not have the required permissions to import activities to this course");
+ print_error("You need do not have the required permissions to import activities to this course");
}
// if we're not a course creator , we can only import from our own courses.
if ($from = get_record('course', 'id', $fromcourse)) {
if (!has_capability('moodle/course:manageactivities', $fromcontext)) {
- error("You need to have the required permissions in the course you are importing data from, as well");
+ print_error("You need to have the required permissions in the course you are importing data from, as well");
}
if (!empty($filename) && file_exists($CFG->dataroot.'/'.$filename) && !empty($SESSION->import_preferences)) {
$restore = backup_to_restore_array($SESSION->import_preferences);
$id = required_param('id', PARAM_INT); // Course id
if (! $course = get_record('course', 'id', $id) ) {
- error("That's an invalid course id");
+ print_error("That's an invalid course id");
}
require_login($course->id);
if (!has_capability('moodle/course:managegroups', $context)) {
- error("You do not have the required permissions to manage groups.");
+ print_error("You do not have the required permissions to manage groups.");
}
//if (!confirm_sesskey()) {
- // error(get_string('confirmsesskeybad', 'error'));
+ // print_error('confirmsesskeybad', 'error');
//}
$strimportgroups = get_string("importgroups");
if ( !(isset($required[$h]) or
isset($optionalDefaults[$h]) or
isset($optional[$h])) ) {
- error(get_string('invalidfieldname', 'error', $h), 'index.php?id='.$id.'&sesskey='.$USER->sesskey);
+ print_error('invalidfieldname', 'error', 'index.php?id='.$id.'&sesskey='.$USER->sesskey, $h);
}
if ( isset($required[$h]) ) {
$required[$h] = 2;
// check for required fields
foreach ($required as $key => $value) {
if ($value < 2) {
- error(get_string('fieldrequired', 'error', $key), 'uploaduser.php?id='.$id.'&sesskey='.$USER->sesskey);
+ print_error('fieldrequired', 'error', 'uploaduser.php?id='.$id.'&sesskey='.$USER->sesskey, $key);
}
}
$linenum = 2; // since header is line 1
foreach ($record as $name => $value) {
// check for required values
if (isset($required[$name]) and !$value) {
- error(get_string('missingfield', 'error', $name). " ".
- get_string('erroronline', 'error', $linenum) .". ".
- get_string('processingstops', 'error'),
- 'uploaduser.php?sesskey='.$USER->sesskey);
+ //error(get_string('missingfield', 'error', $name). " ".
+ // get_string('erroronline', 'error', $linenum) .". ".
+ // get_string('processingstops', 'error'),
+ // 'uploaduser.php?sesskey='.$USER->sesskey);
+ print_error('missingfield', 'error', 'uploaduser.php?sesskey='.$USER->sesskey, $name);
}
else if ($name == "groupname") {
$newgroup->name = addslashes($value);
}
if (! $course = get_record("course", "id", $id)) {
- error("Course ID was incorrect (can't find it)");
+ print_error("Course ID was incorrect (can't find it)");
}
require_login($course->id);
$addcourse = clean_param($addcourse, PARAM_INT);
set_time_limit(180);
if (!add_to_metacourse($course->id,$addcourse)) {
- error("Could not add the selected course to this meta course!");
+ print_error("Could not add the selected course to this meta course!");
}
}
} else if ($remove and !empty($frm->removeselect) and confirm_sesskey()) {
set_time_limit(180);
$removecourse = clean_param($removecourse, PARAM_INT);
if (! remove_from_metacourse($course->id,$removecourse)) {
- error("Could not remove the selected course from this meta course!");
+ print_error("Could not remove the selected course from this meta course!");
}
}
} else if ($showall and confirm_sesskey()) {
$context = $sysctx;
if (!$site = get_site()) {
- error('Site isn\'t defined!');
+ print_error('Site isn\'t defined!');
}
if ($CFG->forcelogin) {
if ($childcats = get_records('course_categories', 'parent', $deletecat->id)) {
foreach ($childcats as $childcat) {
if (! set_field('course_categories', 'parent', $deletecat->parent, 'id', $childcat->id)) {
- error('Could not update a child category!', 'index.php');
+ print_error('Could not update a child category!', 'index.php');
}
}
}
if ($childcourses = get_records('course', 'category', $deletecat->id)) {
foreach ($childcourses as $childcourse) {
if (! set_field('course', 'category', $deletecat->parent, 'id', $childcourse->id)) {
- error('Could not update a child course!', 'index.php');
+ print_error('Could not update a child course!', 'index.php');
}
}
}
unset($tempcat);
$tempcat->name = get_string('miscellaneous');
if (!$tempcat->id = insert_record('course_categories', $tempcat)) {
- error('Serious error: Could not create a default category!');
+ print_error('Serious error: Could not create a default category!');
}
$tempcat->context = get_context_instance(CONTEXT_COURSECAT, $tempcat->id);
mark_context_dirty('/'.SYSCONTEXTID);
$name = optional_param('name', false, PARAM_RAW); // Course short name
if (!$id and !$name) {
- error("Must specify course id or short name");
+ print_error("Must specify course id or short name");
}
if ($name) {
if (! $course = get_record("course", "shortname", $name) ) {
- error("That's an invalid short course name");
+ print_error("That's an invalid short course name");
}
} else {
if (! $course = get_record("course", "id", $id) ) {
- error("That's an invalid course id");
+ print_error("That's an invalid course id");
}
}
$context = get_context_instance(CONTEXT_COURSE, $course->id);
if ((!course_parent_visible($course) || (! $course->visible)) && !has_capability('moodle/course:viewhiddencourses', $context)) {
- error(get_string('coursehidden'), $CFG->wwwroot .'/');
+ print_error('coursehidden', '', $CFG->wwwroot .'/');
}
print_header(get_string("summaryof", "", $course->fullname));
}
asort($modnames, SORT_LOCALE_STRING);
} else {
- error("No modules are installed!");
+ print_error("No modules are installed!");
}
if ($rawmods = get_course_mods($courseid)) {
global $USER, $CFG;
if (empty($USER->id)) {
- error("It shouldn't be possible to see My Moodle without being logged in.");
+ print_error("It shouldn't be possible to see My Moodle without being logged in.");
}
$courses = get_my_courses($USER->id, 'visible DESC,sortorder ASC', array('summary'));
*/
function print_standard_coursemodule_settings($form, $features=null) {
if (! $course = get_record('course', 'id', $form->course)) {
- error("This course doesn't exist");
+ print_error("This course doesn't exist");
}
print_groupmode_setting($form, $course);
if (!empty($features->groupings)) {
if (empty($course)) {
if (! $course = get_record('course', 'id', $form->course)) {
- error("This course doesn't exist");
+ print_error("This course doesn't exist");
}
}
if ($form->coursemodule) {
if (! $cm = get_record('course_modules', 'id', $form->coursemodule)) {
- error("This course module doesn't exist");
+ print_error("This course module doesn't exist");
}
$groupmode = groups_get_activity_groupmode($cm);
} else {
if (empty($course)) {
if (! $course = get_record('course', 'id', $form->course)) {
- error("This course doesn't exist");
+ print_error("This course doesn't exist");
}
}
if ($form->coursemodule) {
if (! $cm = get_record('course_modules', 'id', $form->coursemodule)) {
- error("This course module doesn't exist");
+ print_error("This course module doesn't exist");
}
} else {
$cm = null;
function print_visible_setting($form, $course=NULL) {
if (empty($course)) {
if (! $course = get_record('course', 'id', $form->course)) {
- error("This course doesn't exist");
+ print_error("This course doesn't exist");
}
}
if ($form->coursemodule) {
}
if (! $course = get_record('course', 'id', $id)) {
- error("Course ID was incorrect");
+ print_error("Course ID was incorrect");
}
/// User must be logged in
require_login($course);
require_capability('moodle/user:loginas', $coursecontext);
if (!has_capability('moodle/course:view', $coursecontext, $userid, false)) {
- error('This user is not in this course!');
+ print_error('This user is not in this course!');
}
if (has_capability('moodle/site:doanything', $coursecontext, $userid, false)) {
print_error('nologinas');
{$CFG->prefix}modules md
WHERE cm.id = '$update' AND
md.id = cm.module")){
- error('Invalid course module id!');
+ print_error('Invalid course module id!');
}
$returntomod = optional_param('return', 0, PARAM_BOOL);
if (file_exists("../mod/$modname/mod_form.php")) {
if (empty($mod->coursemodule)) { //add
if (! $course = get_record("course", "id", $mod->course)) {
- error("This course doesn't exist");
+ print_error("This course doesn't exist");
}
$mod->instance = '';
$mod->coursemodule = '';
} else { //delete and update
if (! $cm = get_record("course_modules", "id", $mod->coursemodule)) {
- error("This course module doesn't exist");
+ print_error("This course module doesn't exist");
}
if (! $course = get_record("course", "id", $cm->course)) {
- error("This course doesn't exist");
+ print_error("This course doesn't exist");
}
$mod->instance = $cm->instance;
$mod->coursemodule = $cm->id;
if (file_exists($modlib)) {
include_once($modlib);
} else {
- error("This module is missing important code! ($modlib)");
+ print_error("This module is missing important code! ($modlib)");
}
$addinstancefunction = $mod->modulename."_add_instance";
$updateinstancefunction = $mod->modulename."_update_instance";
include_once($moderr);
die;
}
- error("Could not update the $mod->modulename", "view.php?id=$course->id");
+ print_error("Could not update the $mod->modulename", '', "view.php?id=$course->id");
}
if (is_string($return)) {
- error($return, "view.php?id=$course->id");
+ print_error($return, '', "view.php?id=$course->id");
}
if (isset($mod->visible)) {
case "add":
if (!course_allowed_module($course,$mod->modulename)) {
- error("This module ($mod->modulename) has been disabled for this particular course");
+ print_error("This module ($mod->modulename) has been disabled for this particular course");
}
if (!isset($mod->name) || trim($mod->name) == '') {
include_once($moderr);
die;
}
- error("Could not add a new instance of $mod->modulename", "view.php?id=$course->id");
+ print_error("Could not add a new instance of $mod->modulename", '', "view.php?id=$course->id");
}
if (is_string($return)) {
- error($return, "view.php?id=$course->id");
+ print_error($return, '', "view.php?id=$course->id");
}
if (!isset($mod->groupmode)) { // to deal with pre-1.5 modules
// to each other, so we have to update one of them twice.
if (! $mod->coursemodule = add_course_module($mod) ) {
- error("Could not add a new course module");
+ print_error("Could not add a new course module");
}
if (! $sectionid = add_mod_to_section($mod) ) {
- error("Could not add the new course module to that section");
+ print_error("Could not add the new course module to that section");
}
if (! set_field("course_modules", "section", $sectionid, "id", $mod->coursemodule)) {
- error("Could not update the course module with the correct section");
+ print_error("Could not update the course module with the correct section");
}
if (!isset($mod->visible)) { // We get the section's visible field status
"$mod->modulename $mod->instance", $mod->coursemodule);
break;
default:
- error("No mode defined");
+ print_error("No mode defined");
}
if ((!empty($movetosection) or !empty($moveto)) and confirm_sesskey()) {
if (! $cm = get_record("course_modules", "id", $USER->activitycopy)) {
- error("The copied course module doesn't exist!");
+ print_error("The copied course module doesn't exist!");
}
if (!empty($movetosection)) {
if (! $section = get_record("course_sections", "id", $movetosection)) {
- error("This section doesn't exist");
+ print_error("This section doesn't exist");
}
$beforecm = NULL;
} else { // normal moveto
if (! $beforecm = get_record("course_modules", "id", $moveto)) {
- error("The destination course module doesn't exist");
+ print_error("The destination course module doesn't exist");
}
if (! $section = get_record("course_sections", "id", $beforecm->section)) {
- error("This section doesn't exist");
+ print_error("This section doesn't exist");
}
}
require_capability('moodle/course:manageactivities', $context);
if (!ismoving($section->course)) {
- error("You need to copy something first!");
+ print_error("You need to copy something first!");
}
moveto_module($cm, $section, $beforecm);
$id = required_param('id',PARAM_INT);
if (! $cm = get_record("course_modules", "id", $id)) {
- error("This course module doesn't exist");
+ print_error("This course module doesn't exist");
}
require_login($cm->course); // needed to setup proper $COURSE
}
if (!set_field("course_modules", "indent", $cm->indent, "id", $cm->id)) {
- error("Could not update the indent level on that course module");
+ print_error("Could not update the indent level on that course module");
}
if (SITEID == $cm->course) {
} else if (!empty($hide) and confirm_sesskey()) {
if (! $cm = get_record("course_modules", "id", $hide)) {
- error("This course module doesn't exist");
+ print_error("This course module doesn't exist");
}
require_login($cm->course); // needed to setup proper $COURSE
} else if (!empty($show) and confirm_sesskey()) {
if (! $cm = get_record("course_modules", "id", $show)) {
- error("This course module doesn't exist");
+ print_error("This course module doesn't exist");
}
require_login($cm->course); // needed to setup proper $COURSE
require_capability('moodle/course:activityvisibility', $context);
if (! $section = get_record("course_sections", "id", $cm->section)) {
- error("This module doesn't exist");
+ print_error("This module doesn't exist");
}
if (! $module = get_record("modules", "id", $cm->module)) {
- error("This module doesn't exist");
+ print_error("This module doesn't exist");
}
if ($module->visible and ($section->visible or (SITEID == $cm->course))) {
$id = required_param( 'id', PARAM_INT );
if (! $cm = get_record("course_modules", "id", $id)) {
- error("This course module doesn't exist");
+ print_error("This course module doesn't exist");
}
require_login($cm->course); // needed to setup proper $COURSE
} else if (!empty($copy) and confirm_sesskey()) { // value = course module
if (! $cm = get_record("course_modules", "id", $copy)) {
- error("This course module doesn't exist");
+ print_error("This course module doesn't exist");
}
require_login($cm->course); // needed to setup proper $COURSE
require_capability('moodle/course:manageactivities', $context);
if (! $section = get_record("course_sections", "id", $cm->section)) {
- error("This module doesn't exist");
+ print_error("This module doesn't exist");
}
if (! $module = get_record("modules", "id", $cm->module)) {
- error("This module doesn't exist");
+ print_error("This module doesn't exist");
}
if (! $instance = get_record($module->name, "id", $cm->instance)) {
- error("Could not find the instance of this module");
+ print_error("Could not find the instance of this module");
}
$USER->activitycopy = $copy;
} else if (!empty($delete) and confirm_sesskey()) { // value = course module
if (! $cm = get_record("course_modules", "id", $delete)) {
- error("This course module doesn't exist");
+ print_error("This course module doesn't exist");
}
if (! $course = get_record("course", "id", $cm->course)) {
- error("This course doesn't exist");
+ print_error("This course doesn't exist");
}
require_login($cm->course); // needed to setup proper $COURSE
require_capability('moodle/course:manageactivities', $context);
if (! $module = get_record("modules", "id", $cm->module)) {
- error("This module doesn't exist");
+ print_error("This module doesn't exist");
}
if (! $instance = get_record($module->name, "id", $cm->instance)) {
if (! delete_course_module($cm->id)) {
notify("Could not delete the $module->name (coursemodule)");
}
- error("The required instance of this module didn't exist. Module deleted.",
+ print_error("The required instance of this module didn't exist. Module deleted.",
"$CFG->wwwroot/course/view.php?id=$course->id");
}
} else if (!empty($update) and confirm_sesskey()) { // value = course module
if (! $cm = get_record("course_modules", "id", $update)) {
- error("This course module doesn't exist");
+ print_error("This course module doesn't exist");
}
if (! $course = get_record("course", "id", $cm->course)) {
- error("This course doesn't exist");
+ print_error("This course doesn't exist");
}
require_login($course->id); // needed to setup proper $COURSE
require_capability('moodle/course:manageactivities', $context);
if (! $module = get_record("modules", "id", $cm->module)) {
- error("This module doesn't exist");
+ print_error("This module doesn't exist");
}
if (! $form = get_record($module->name, "id", $cm->instance)) {
- error("The required instance of this module doesn't exist");
+ print_error("The required instance of this module doesn't exist");
}
if (! $cw = get_record("course_sections", "id", $cm->section)) {
- error("This course section doesn't exist");
+ print_error("This course section doesn't exist");
}
if (isset($return)) {
if (! $cm = get_record("course_modules", "id", $duplicate)) {
- error("This course module doesn't exist");
+ print_error("This course module doesn't exist");
}
if (! $course = get_record("course", "id", $cm->course)) {
- error("This course doesn't exist");
+ print_error("This course doesn't exist");
}
require_login($course->id); // needed to setup proper $COURSE
require_capability('moodle/course:manageactivities', $context);
if (! $module = get_record("modules", "id", $cm->module)) {
- error("This module doesn't exist");
+ print_error("This module doesn't exist");
}
if (! $form = get_record($module->name, "id", $cm->instance)) {
- error("The required instance of this module doesn't exist");
+ print_error("The required instance of this module doesn't exist");
}
if (! $cw = get_record("course_sections", "id", $cm->section)) {
- error("This course section doesn't exist");
+ print_error("This course section doesn't exist");
}
if (isset($return)) {
$section = required_param('section',PARAM_INT);
if (! $course = get_record("course", "id", $id)) {
- error("This course doesn't exist");
+ print_error("This course doesn't exist");
}
if (! $module = get_record("modules", "name", $add)) {
- error("This module type doesn't exist");
+ print_error("This module type doesn't exist");
}
$context = get_context_instance(CONTEXT_COURSE, $course->id);
require_capability('moodle/course:manageactivities', $context);
if (!course_allowed_module($course,$module->id)) {
- error("This module has been disabled for this particular course");
+ print_error("This module has been disabled for this particular course");
}
require_login($course->id); // needed to setup proper $COURSE
}
} else {
- error("No action was specified");
+ print_error("No action was specified");
}
require_login($course->id); // needed to setup proper $COURSE
$course = required_param('course', PARAM_INT);
if (! $course = get_record("course", "id", $course)) {
- error("This course doesn't exist");
+ print_error("This course doesn't exist");
}
require_login($course);
require_capability('moodle/course:manageactivities', $context);
if (! $module = get_record("modules", "name", $add)) {
- error("This module type doesn't exist");
+ print_error("This module type doesn't exist");
}
$cw = get_course_section($section, $course->id);
if (!course_allowed_module($course, $module->id)) {
- error("This module has been disabled for this particular course");
+ print_error("This module has been disabled for this particular course");
}
$cm = null;
$navlinksinstancename = '';
} else if (!empty($update)) {
if (! $cm = get_record("course_modules", "id", $update)) {
- error("This course module doesn't exist");
+ print_error("This course module doesn't exist");
}
if (! $course = get_record("course", "id", $cm->course)) {
- error("This course doesn't exist");
+ print_error("This course doesn't exist");
}
require_login($course); // needed to setup proper $COURSE
require_capability('moodle/course:manageactivities', $context);
if (! $module = get_record("modules", "id", $cm->module)) {
- error("This module doesn't exist");
+ print_error("This module doesn't exist");
}
if (! $form = get_record($module->name, "id", $cm->instance)) {
- error("The required instance of this module doesn't exist");
+ print_error("The required instance of this module doesn't exist");
}
if (! $cw = get_record("course_sections", "id", $cm->section)) {
- error("This course section doesn't exist");
+ print_error("This course section doesn't exist");
}
$form->coursemodule = $cm->id;
$CFG->pagepath .= '/mod';
}
} else {
- error('Invalid operation.');
+ print_error('Invalid operation.');
}
$modmoodleform = "$CFG->dirroot/mod/$module->name/mod_form.php";
require_once($modmoodleform);
} else {
- error('No formslib form description file found for this activity.');
+ print_error('No formslib form description file found for this activity.');
}
$modlib = "$CFG->dirroot/mod/$module->name/lib.php";
if (file_exists($modlib)) {
include_once($modlib);
} else {
- error("This module is missing important code! ($modlib)");
+ print_error("This module is missing important code! ($modlib)");
}
$mformclassname = 'mod_'.$module->name.'_mod_form';
if (empty($fromform->coursemodule)) { //add
$cm = null;
if (! $course = get_record("course", "id", $fromform->course)) {
- error("This course doesn't exist");
+ print_error("This course doesn't exist");
}
$fromform->instance = '';
$fromform->coursemodule = '';
} else { //update
if (! $cm = get_record("course_modules", "id", $fromform->coursemodule)) {
- error("This course module doesn't exist");
+ print_error("This course module doesn't exist");
}
if (! $course = get_record("course", "id", $cm->course)) {
- error("This course doesn't exist");
+ print_error("This course doesn't exist");
}
$fromform->instance = $cm->instance;
$fromform->coursemodule = $cm->id;
$returnfromfunc = $updateinstancefunction($fromform);
if (!$returnfromfunc) {
- error("Could not update the $fromform->modulename", "view.php?id=$course->id");
+ print_error("Could not update the $fromform->modulename", '', "view.php?id=$course->id");
}
if (is_string($returnfromfunc)) {
- error($returnfromfunc, "view.php?id=$course->id");
+ print_error($returnfromfunc, '', "view.php?id=$course->id");
}
set_coursemodule_visible($fromform->coursemodule, $fromform->visible);
}
if (!course_allowed_module($course,$fromform->modulename)) {
- error("This module ($fromform->modulename) has been disabled for this particular course");
+ print_error("This module ($fromform->modulename) has been disabled for this particular course");
}
$returnfromfunc = $addinstancefunction($fromform);
if (!$returnfromfunc) {
- error("Could not add a new instance of $fromform->modulename", "view.php?id=$course->id");
+ print_error("Could not add a new instance of $fromform->modulename", '', "view.php?id=$course->id");
}
if (is_string($returnfromfunc)) {
- error($returnfromfunc, "view.php?id=$course->id");
+ print_error($returnfromfunc, '', "view.php?id=$course->id");
}
$fromform->instance = $returnfromfunc;
// to each other, so we have to update one of them twice.
if (! $fromform->coursemodule = add_course_module($fromform) ) {
- error("Could not add a new course module");
+ print_error("Could not add a new course module");
}
if (! $sectionid = add_mod_to_section($fromform) ) {
- error("Could not add the new course module to that section");
+ print_error("Could not add the new course module to that section");
}
if (! set_field("course_modules", "section", $sectionid, "id", $fromform->coursemodule)) {
- error("Could not update the course module with the correct section");
+ print_error("Could not update the course module with the correct section");
}
// make sure visibility is set correctly (in particular in calendar)
"view.php?id=$fromform->coursemodule",
"$fromform->instance", $fromform->coursemodule);
} else {
- error("Data submitted is invalid.");
+ print_error("Data submitted is invalid.");
}
// sync idnumber with grade_item
$id = required_param('id', PARAM_INT);
if (!$course = get_record('course', 'id', $id) ) {
- error("That's an invalid course id");
+ print_error("That's an invalid course id");
}
require_login($course);
if (!empty($param->user)) {
if (!$u = get_record('user', 'id', $param->user) ) {
- error("That's an invalid user!");
+ print_error("That's an invalid user!");
}
$userinfo = fullname($u);
}
$id = required_param('id', PARAM_INT); // course id to import TO
if (!$course = get_record('course', 'id', $id)) {
- error("That's an invalid course id");
+ print_error("That's an invalid course id");
}
require_login($course->id);
$date = optional_param('date', 0, PARAM_INT); // A time of a day (in GMT)
if (! $course = get_record("course", "id", $id)) {
- error("Course is misconfigured");
+ print_error("Course is misconfigured");
}
require_login($course->id);
if (! (has_capability('moodle/site:viewreports', $context)
or ($course->showreports and $USER->id == $user)) ) {
- error("Sorry, you aren't allowed to see this.");
+ print_error("Sorry, you aren't allowed to see this.");
}
if ($user) {
if (! $user = get_record("user", "id", $user)) {
- error("Can not find that user");
+ print_error("Can not find that user");
}
}
if ($hostid == $CFG->mnet_localhost_id) {
if (!$course = get_record('course', 'id', $id) ) {
- error('That\'s an invalid course id'.$id);
+ print_error('That\'s an invalid course id'.$id);
}
} else {
$course_stub = array_pop(get_records_select('mnet_log', " hostid='$hostid' AND course='$id' ", '', '*', '', '1'));
if ($user) {
if (!$u = get_record('user', 'id', $user) ) {
- error('That\'s an invalid user!');
+ print_error('That\'s an invalid user!');
}
$userinfo = fullname($u, has_capability('moodle/site:viewfullnames', $context));
}
$page = optional_param('page', 0, PARAM_INT); // which page to show
if (! $course = get_record("course", "id", $id) ) {
- error("That's an invalid course id");
+ print_error("That's an invalid course id");
}
require_login($course);
$context = get_context_instance(CONTEXT_COURSE, $course->id);
if (!has_capability('moodle/site:viewreports', $context)) {
- error('You need do not have the required permission to view this report');
+ print_error('You need do not have the required permission to view this report');
}
add_to_log($course->id, "course", "report live", "report/log/live.php?id=$course->id", $course->id);
$id = required_param('id',PARAM_INT); // course id
if (!$course = get_record('course', 'id', $id)) {
- error('Course id is incorrect.');
+ print_error('Course id is incorrect.');
}
require_login($course);
print_heading(format_string($course->fullname));
if (!$logstart = get_field_sql("SELECT MIN(time) FROM {$CFG->prefix}log")) {
- error('Logs not available');
+ print_error('Logs not available');
}
echo '<div class="loginfo">'.get_string('computedfromlogs', 'admin', userdate($logstart)).'</div>';
$roleid = optional_param('roleid',0,PARAM_INT);
if (!$course = get_record("course","id",$courseid)) {
- error("That's an invalid course id");
+ print_error("That's an invalid course id");
}
if (!empty($userid)) {
if (!$user = get_record('user','id',$userid)) {
- error("That's an invalid user id");
+ print_error("That's an invalid user id");
}
}
$context = get_context_instance(CONTEXT_COURSE, $course->id);
if (!has_capability('moodle/site:viewreports', $context)) {
- error('You need do not have the required permission to view reports for this course');
+ print_error('You need do not have the required permission to view reports for this course');
}
stats_check_uptodate($course->id);
require_once($CFG->dirroot.'/course/report/stats/lib.php');
if (empty($CFG->enablestats)) {
- error("Stats is not enabled.");
+ print_error("Stats is not enabled.");
}
$courseid = required_param('course', PARAM_INT);
}
if (!$course = get_record("course","id",$courseid)) {
- error("That's an invalid course id");
+ print_error("That's an invalid course id");
}
if (!empty($userid)) {
if (!$user = get_record('user','id',$userid)) {
- error("That's an invalid user id");
+ print_error("That's an invalid user id");
}
}
$reportoptions = stats_get_report_options($course->id, $mode);
$timeoptions = report_stats_timeoptions($mode);
if (empty($timeoptions)) {
- error(get_string('nostatstodisplay'), $CFG->wwwroot.'/course/view.php?id='.$course->id);
+ print_error('nostatstodisplay', '', $CFG->wwwroot.'/course/view.php?id='.$course->id);
}
$table->width = 'auto';
.' ORDER BY u.lastname, u.firstname ASC';
if (!$us = get_records_sql($sql)) {
- error('Cannot enter detailed view: No users found for this course.');
+ print_error('Cannot enter detailed view: No users found for this course.');
}
foreach ($us as $u) {
if (!empty($report) && !empty($time)) {
if ($report == STATS_REPORT_LOGINS && $course->id != SITEID) {
- error('This type of report is only available for the site course');
+ print_error('This type of report is only available for the site course');
}
$param = stats_get_parameters($time,$report,$course->id,$mode);
require_login();
if (isguest()) {
- error("No guests here!");
+ print_error("No guests here!");
}
if (empty($CFG->enablecourserequests)) {
$id = required_param('id', PARAM_INT);
if (!$course = get_record('course', 'id', $id)) {
- error("Course is misconfigured");
+ print_error("Course is misconfigured");
}
require_login($course);
$id = required_param('id', PARAM_INT); // course id
if (! $course = get_record("course", "id", $id)) {
- error("Course ID was incorrect");
+ print_error("Course ID was incorrect");
}
require_login($course);
if (!empty($moveto) and $data = data_submitted() and confirm_sesskey()) { // Some courses are being moved
if (! $destcategory = get_record("course_categories", "id", $data->moveto)) {
- error("Error finding the category");
+ print_error("Error finding the category");
}
$courses = array();
if (!empty($blocklist) and confirm_sesskey()) {
$blockid = $blocklist;
if (!$blocks = get_records('block_instance', 'blockid', $blockid)) {
- error( "Could not read data for blockid=$blockid" );
+ print_error( "Could not read data for blockid=$blockid" );
}
// run through blocks and get (unique) courses
continue;
}
if (!$course = get_record('course', 'id', $courseid)) {
- error( "Could not read data for courseid=$courseid" );
+ print_error( "Could not read data for courseid=$courseid" );
}
$courses[$courseid] = $course;
}
elseif (!empty($modulelist) and confirm_sesskey()) {
$modulename = $modulelist;
if (!$modules = get_records($modulename)) {
- error( "Could not read data for module=$modulename" );
+ print_error( "Could not read data for module=$modulename" );
}
// run through modules and get (unique) courses
continue;
}
if (!$course = get_record('course', 'id', $courseid)) {
- error( "Could not read data for courseid=$courseid" );
+ print_error( "Could not read data for courseid=$courseid" );
}
$courses[$courseid] = $course;
}
}
if (! $course = get_record('course', 'id', $id) ) {
- error('Invalid course id');
+ print_error('Invalid course id');
}
if (! $context = get_context_instance(CONTEXT_COURSE, $course->id)) {
- error('Invalid context');
+ print_error('Invalid context');
}
require_login($course->id);
// verify user may unassign all roles at course context
foreach($roles as $role) {
if (!user_can_assign($context, $role->roleid)) {
- error('Can not unassign this user from role id:'.$role->roleid);
+ print_error('Can not unassign this user from role id:'.$role->roleid);
}
}
if ($confirm and confirm_sesskey()) {
if ($userid) {
if (! role_unassign(0, $userid, 0, $context->id)) {
- error("An error occurred while trying to unenrol that person.");
+ print_error("An error occurred while trying to unenrol that person.");
}
add_to_log($course->id, 'course', 'unenrol', "view.php?id=$course->id", $userid);
} else {
if (! role_unassign(0, $USER->id, 0, $context->id)) {
- error("An error occurred while trying to unenrol you.");
+ print_error("An error occurred while trying to unenrol you.");
}
// force a refresh of mycourses
if ($userid) {
if (!$user = get_record('user', 'id', $userid)) {
- error('That user does not exist!');
+ print_error('That user does not exist!');
}
$strunenrolsure = get_string('unenrolsure', '', fullname($user, true));
notice_yesno($strunenrolsure, "unenrol.php?id=$id&user=$user->id&confirm=yes&sesskey=".sesskey(),
$perpage = optional_param('perpage', 100, PARAM_INT);
if (! $course = get_record("course", "id", $id)) {
- error("Course id is incorrect.");
+ print_error("Course id is incorrect.");
}
if (! $user = get_record("user", "id", $user)) {
- error("User ID is incorrect");
+ print_error("User ID is incorrect");
}
//require_login($course);
// if in either context, we can read report, then we can proceed
if (!(has_capability('moodle/site:viewreports', $coursecontext) or ($course->showreports and $USER->id == $user->id) or has_capability('moodle/user:viewuseractivitiesreport', $personalcontext))) {
- error("You are not allowed to look at this page");
+ print_error("You are not allowed to look at this page");
}
add_to_log($course->id, "course", "user report", "user.php?id=$course->id&user=$user->id&mode=$mode", "$user->id");
case 'stats':
if (empty($CFG->enablestats)) {
- error("Stats is not enabled.");
+ print_error("Stats is not enabled.");
}
require_once($CFG->dirroot.'/lib/statslib.php');
$timeoptions = stats_get_time_options($now,$lastweekend,$lastmonthend,$earliestday,$earliestweek,$earliestmonth);
if (empty($timeoptions)) {
- error(get_string('nostatstodisplay'), $CFG->wwwroot.'/course/user.php?id='.$course->id.'&user='.$user->id.'&mode=outline');
+ print_error('nostatstodisplay', '', $CFG->wwwroot.'/course/user.php?id='.$course->id.'&user='.$user->id.'&mode=outline');
}
// use the earliest.
$stats = get_records_sql($sql);
if (empty($stats)) {
- error(get_string('nostatstodisplay'), $CFG->wwwroot.'/course/user.php?id='.$course->id.'&user='.$user->id.'&mode=outline');
+ print_error('nostatstodisplay', '', $CFG->wwwroot.'/course/user.php?id='.$course->id.'&user='.$user->id.'&mode=outline');
}
// MDL-10818, do not display broken graph when user has no permission to view graph
if (empty($id) && empty($name) && empty($idnumber)) {
- error("Must specify course id, short name or idnumber");
+ print_error("Must specify course id, short name or idnumber");
}
if (!empty($name)) {
if (! ($course = get_record('course', 'shortname', $name)) ) {
- error('Invalid short course name');
+ print_error('Invalid short course name');
}
} else if (!empty($idnumber)) {
if (! ($course = get_record('course', 'idnumber', $idnumber)) ) {
- error('Invalid course idnumber');
+ print_error('Invalid course idnumber');
}
} else {
if (! ($course = get_record('course', 'id', $id)) ) {
- error('Invalid course id');
+ print_error('Invalid course id');
}
}
$section->id = insert_record('course_sections', $section);
}
if (! $sections = get_all_sections($course->id) ) { // Try again
- error('Error finding or creating section structures for this course');
+ print_error('Error finding or creating section structures for this course');
}
}
if (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] != 443) { // MDL-9836
if (empty($CFG->loginhttps)) {
- error(get_string('httpsrequired', 'enrol_authorize'));
+ print_error('httpsrequired', 'enrol_authorize');
} else {
$wwwsroot = str_replace('http:','https:', $CFG->wwwroot);
redirect("$wwwsroot/course/enrol.php?id=$course->id");
break;
}
if (!empty($authorizeerror)) {
- error($authorizeerror);
+ print_error($authorizeerror);
}
}
$frmenrol->display();
$paymentmethodsenabled = get_list_of_payment_methods();
$paymentmethod = optional_param('paymentmethod', $paymentmethodsenabled[0], PARAM_ALPHA);
if (!in_array($paymentmethod, $paymentmethodsenabled)) {
- error("Invalid payment method: $paymentmethod");
+ print_error("Invalid payment method: $paymentmethod");
}
$mform =& $this->_form;
require_once('const.php');
require_once('locallib.php');
require_once('localfuncs.php');
- require_once('authorizenetlib.php');
+ require_once('authorizenet.class.php');
/// Parameters
$orderid = optional_param('order', 0, PARAM_INT);
/// Get course
if (! $course = get_record('course', 'id', $courseid)) {
- error('Could not find that course');
+ print_error('Could not find that course');
}
/// Only SITE users can access to this page
require_login(); // Don't use $courseid! User may want to see old orders.
if (has_capability('moodle/legacy:guest', get_context_instance(CONTEXT_SYSTEM), $USER->id, false)) {
- error("Guests cannot use this page.");
+ print_error("Guests cannot use this page.");
}
/// Load strings. All strings should be defined here. locallib.php uses these strings.
if ($perpage > 100) { $perpage = 100; }
$perpagemenus = array(5 => 5, 10 => 10, 20 => 20, 50 => 50, 100 => 100);
$perpagemenu = popup_form($baseurl.'&status='.$status.'&course='.$courseid.'&perpage=',$perpagemenus,'perpagemenu',$perpage,'','','',true);
- $table->define_columns(array('id', 'userid', 'timecreated', 'status', ''));
+ $table->define_columns(array('id', 'userid', 'timecreated', 'status', 'action'));
$table->define_headers(array($authstrs->orderid, $authstrs->shopper, $strs->time, $strs->status, $perpagemenu));
$table->define_baseurl($baseurl."&status=$status&course=$courseid&perpage=$perpage");
+ $table->no_sorting('action');
$table->sortable(true, 'id', SORT_DESC);
$table->pageable(true);
$table->setup();
$confirm = optional_param('confirm', 0, PARAM_BOOL);
if (!$order = get_record('enrol_authorize', 'id', $orderid)) {
- error("Order $orderid not found.", "$CFG->wwwroot/enrol/authorize/index.php");
+ print_error("Order $orderid not found.", '', "$CFG->wwwroot/enrol/authorize/index.php");
}
if (!$course = get_record('course', 'id', $order->courseid)) {
- error("Could not find that course id $order->courseid", "$CFG->wwwroot/enrol/authorize/index.php");
+ print_error("Could not find that course id $order->courseid", '', "$CFG->wwwroot/enrol/authorize/index.php");
}
if (!$user = get_record('user', 'id', $order->userid)) {
- error("Could not find that user id $order->userid", "$CFG->wwwroot/enrol/authorize/index.php");
+ print_error("Could not find that user id $order->userid", '', "$CFG->wwwroot/enrol/authorize/index.php");
}
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
require_capability('enrol/authorize:managepayments', $coursecontext);
}
- $settled = authorize_settled($order);
+ $settled = AuthorizeNet::settled($order);
$statusandactions = authorize_get_status_action($order);
$color = authorize_get_status_color($statusandactions->status);
if ($confirm && confirm_sesskey()) {
$message = '';
$extra = NULL;
- if (AN_APPROVED == authorize_action($order, $message, $extra, AN_ACTION_PRIOR_AUTH_CAPTURE)) {
+ if (AN_APPROVED == AuthorizeNet::process($order, $message, $extra, AN_ACTION_PRIOR_AUTH_CAPTURE)) {
if (empty($CFG->an_test)) {
if (enrol_into_course($course, $user, 'authorize')) {
if (!empty($CFG->enrol_mailstudents)) {
}
$upto = round($order->amount - $refunded, 2);
if ($upto <= 0) {
- error("Refunded to original amount: $order->amount", "$CFG->wwwroot/enrol/authorize/index.php?order=$orderid");
+ print_error("Refunded to original amount: $order->amount", '', "$CFG->wwwroot/enrol/authorize/index.php?order=$orderid");
}
$amount = round(optional_param('amount', $upto), 2);
if ($amount > $upto) {
- error("Can be refunded to $upto", "$CFG->wwwroot/enrol/authorize/index.php?order=$orderid");
+ print_error("Can be refunded to $upto", '', "$CFG->wwwroot/enrol/authorize/index.php?order=$orderid");
}
if ($confirm && confirm_sesskey()) {
$extra = new stdClass;
$extra->orderid = $orderid;
$extra->amount = $amount;
$message = '';
- $success = authorize_action($order, $message, $extra, AN_ACTION_CREDIT);
+ $success = AuthorizeNet::process($order, $message, $extra, AN_ACTION_CREDIT);
if (AN_APPROVED == $success || AN_REVIEW == $success) {
if (empty($CFG->an_test)) {
if (empty($extra->id)) {
if ($confirm && confirm_sesskey()) {
$extra = NULL;
$message = '';
- if (AN_APPROVED == authorize_action($order, $message, $extra, AN_ACTION_VOID)) {
+ if (AN_APPROVED == AuthorizeNet::process($order, $message, $extra, AN_ACTION_VOID)) {
if (empty($CFG->an_test)) {
redirect("$CFG->wwwroot/enrol/authorize/index.php?order=$orderid");
}
$suborder = get_record_sql($sql);
if (!$suborder) { // not found
- error("Transaction can not be voided because of already been voided.", "$CFG->wwwroot/enrol/authorize/index.php?order=$orderid");
+ print_error("Transaction can not be voided because of already been voided.", '', "$CFG->wwwroot/enrol/authorize/index.php?order=$orderid");
}
$refundedstatus = authorize_get_status_action($suborder);
unset($suborder->courseid);
if ($confirm && confirm_sesskey()) {
$message = '';
$extra = NULL;
- if (AN_APPROVED == authorize_action($suborder, $message, $extra, AN_ACTION_VOID)) {
+ if (AN_APPROVED == AuthorizeNet::process($suborder, $message, $extra, AN_ACTION_VOID)) {
if (empty($CFG->an_test)) {
if (!empty($unenrol)) {
role_unassign(0, $order->userid, 0, $coursecontext->id);
switch ($order->status) {
case AN_STATUS_AUTH:
- if (authorize_expired($order)) {
+ if (AuthorizeNet::expired($order)) {
if ($canmanage) {
$ret->actions = array(ORDER_DELETE);
}
return $ret;
case AN_STATUS_AUTHCAPTURE:
- if (authorize_settled($order)) {
+ if (AuthorizeNet::settled($order)) {
if ($canmanage) {
if (($order->paymentmethod == AN_METHOD_CC) || ($order->paymentmethod == AN_METHOD_ECHECK && !empty($order->refundinfo))) {
$ret->actions = array(ORDER_REFUND);
return $ret;
case AN_STATUS_CREDIT:
- if (authorize_settled($order)) {
+ if (AuthorizeNet::settled($order)) {
$ret->status = 'settled';
}
else {
/// Open the file and get first line
$handle = fopen($filename, "r");
if (!$handle) {
- error('CANNOT OPEN CSV FILE');
+ print_error('CANNOT OPEN CSV FILE');
}
$firstline = fgetcsv($handle, 8192, ",");
$numfields = count($firstline);
if ($numfields != 49 && $numfields != 70) {
@fclose($handle);
- error('INVALID CSV FILE; Each line must include 49 or 70 fields');
+ print_error('INVALID CSV FILE; Each line must include 49 or 70 fields');
}
/// Re-sort fields
}
if (empty($csvfields)) {
@fclose($handle);
- error("<b>INVALID CSV FILE:</b> First line must include 'Header Fields' and
+ print_error("<b>INVALID CSV FILE:</b> First line must include 'Header Fields' and
the file must be type of <br />'Expanded Fields/Comma Separated'<br />or<br />
'Expanded Fields with CAVV Result Code/Comma Separated'");
}
if (empty($course->password)) {
// do not allow entry when no course password set
// automatic login when manual primary, no login when secondary at all!!
- error('illegal enrolment attempted');
+ print_error('illegal enrolment attempted');
}
$groupid = $this->check_group_entry($course->id, $form->password);
// require_capability('moodle/role:assign', $context, NULL, false);
if (!role_unassign(0, $userrecord->id, 0, $context->id)) {
- error("An error occurred while trying to unenrol that person.");
+ print_error("An error occurred while trying to unenrol that person.");
}
return true;
list($code, $errormessage) = array_map('trim',explode(':', $errormessage, 2));
$message .= "ERROR $code:<br/>$errormessage<br/>";
}
- error("RPC enrol/mnet/available_courses:<br/>$message");
+ print_error("RPC enrol/mnet/available_courses:<br/>$message");
}
return false;
}
/// Keep out casual intruders
if (empty($_POST) or !empty($_GET)) {
- error("Sorry, you can not use the script that way.");
+ print_error("Sorry, you can not use the script that way.");
}
/// Read all the data from PayPal and get it ready for later;
/// Work out who to send the message to
if (!$admin = get_admin() ) {
- error('Could not find an admin user!');
+ print_error('Could not find an admin user!');
}
$supportuser = new object;
// relative path must start with '/', because of backup/restore!!!
if (!$relativepath) {
- error('No valid arguments supplied or incorrect server configuration');
+ print_error('No valid arguments supplied or incorrect server configuration');
} else if ($relativepath{0} != '/') {
- error('No valid arguments supplied, path does not start with slash!');
+ print_error('No valid arguments supplied, path does not start with slash!');
}
$pathname = $CFG->dataroot.$relativepath;
// extract relative path components
$args = explode('/', trim($relativepath, '/'));
if (count($args) == 0) { // always at least courseid, may search for index.html in course root
- error('No valid arguments supplied');
+ print_error('No valid arguments supplied');
}
// security: limit access to existing course subdirectories
if (($args[0]!='blog') and (!$course = get_record_sql("SELECT * FROM {$CFG->prefix}course WHERE id='".(int)$args[0]."'"))) {
- error('Invalid course ID');
+ print_error('Invalid course ID');
}
// security: prevent access to "000" or "1 something" directories
// hack for blogs, needs proper security check too
if (($args[0] != 'blog') and ($args[0] != $course->id)) {
- error('Invalid course ID');
+ print_error('Invalid course ID');
}
// security: login to course if necessary
if ($args[0] == 'blog') {
if (empty($CFG->bloglevel)) {
- error('Blogging is disabled!');
+ print_error('Blogging is disabled!');
} else if ($CFG->bloglevel < BLOG_GLOBAL_LEVEL) {
require_login();
} else if ($CFG->forcelogin) {
// security: only editing teachers can access backups
if ((count($args) >= 2) and (strtolower($args[1]) == 'backupdata')) {
if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_COURSE, $course->id))) {
- error('