Commit 5a2a5331 authored by dongsheng's avatar dongsheng
Browse files

MDL-14129, remove all the other error() call

parent f44ee03b
......@@ -34,7 +34,7 @@ if ($frm = data_submitted() and confirm_sesskey()) {
$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");
}
}
}
......
......@@ -9,14 +9,14 @@
$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,
......@@ -31,10 +31,10 @@
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) {
......
......@@ -33,7 +33,7 @@
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
......@@ -41,7 +41,7 @@
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
......@@ -49,7 +49,7 @@
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);
......@@ -61,7 +61,7 @@
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)) {
......@@ -123,7 +123,7 @@
/// 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();
......@@ -143,7 +143,7 @@
}
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);
......
......@@ -1234,10 +1234,10 @@ if ( file_exists(dirname(dirname(__FILE__)) . '/config.php')) {
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!");
}
}
......
......@@ -37,7 +37,7 @@
}
if (!confirm_sesskey()) {
error('This script was called wrongly');
print_error('This script was called wrongly');
}
/// OK, here goes ...
......
......@@ -31,7 +31,7 @@
// check session key
if (!confirm_sesskey()) {
error( get_string('confirmsesskeybad', 'error' ) );
print_error('confirmsesskeybad', 'error');
}
$configpath = $CFG->dirroot.'/filter/'.$filtername.'/filterconfig.php';
......
......@@ -53,7 +53,7 @@
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 {
......@@ -67,7 +67,7 @@
$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 {
......@@ -82,7 +82,7 @@
$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 {
......
......@@ -50,29 +50,29 @@
$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.");
}
......@@ -80,7 +80,7 @@
$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:
......@@ -100,11 +100,11 @@
}
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.
......@@ -186,7 +186,7 @@
} 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
......@@ -223,7 +223,7 @@
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');
......@@ -367,7 +367,7 @@
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();
......@@ -383,7 +383,7 @@
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 {
......@@ -401,7 +401,7 @@
}
} 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");
}
}
......@@ -409,7 +409,7 @@
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!!");
}
}
......@@ -495,7 +495,7 @@
$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);
......@@ -508,7 +508,7 @@
$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);
......
......@@ -164,7 +164,7 @@
$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();
......@@ -172,7 +172,7 @@
$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!");
}
}
......@@ -331,7 +331,7 @@
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.
......@@ -343,7 +343,7 @@
}
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")) {
......@@ -363,7 +363,7 @@
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";
......@@ -371,7 +371,7 @@
}
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";
......@@ -390,7 +390,7 @@
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'];
......@@ -400,7 +400,7 @@
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);
......@@ -409,7 +409,7 @@
} 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");
}
}
......@@ -435,7 +435,7 @@
if (isset($_POST['currentfile'])){ // Save a file
if (!confirm_sesskey()) {
error(get_string('confirmsesskeybad', 'error'));
print_error('confirmsesskeybad', 'error');
}
$newstrings = array();
......@@ -463,7 +463,7 @@
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&amp;currentfile=$currentfile");
print_error("Could not save the file '$saveinto/$currentfile'!", '', "lang.php?mode=compare&amp;currentfile=$currentfile");
}
unset($packstring);
}
......@@ -707,12 +707,12 @@
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&amp;currentfile=$currentfile&amp;sesskey=$USER->sesskey");
print_error("Could not save the file '$currentfile'!", '', "lang.php?mode=helpfiles&amp;currentfile=$currentfile&amp;sesskey=$USER->sesskey");
}
}
......
......@@ -51,7 +51,7 @@
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");
}
}
}
......@@ -63,7 +63,7 @@
// 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();
......@@ -83,7 +83,7 @@
// 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.
......
......@@ -30,7 +30,7 @@
//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
......
......@@ -10,7 +10,7 @@
//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';
......
......@@ -17,19 +17,19 @@
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)) {
......@@ -43,7 +43,7 @@
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')) {
......
......@@ -15,17 +15,17 @@ require_capability('moodle/site:config', $context, $USER->id, true, "nopermissio
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.
......@@ -59,7 +59,7 @@ if (($form = data_submitted()) && confirm_sesskey()) {
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;
}
......@@ -82,7 +82,7 @@ if (($form = data_submitted()) && confirm_sesskey()) {
$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);
......@@ -103,7 +103,7 @@ if (($form = data_submitted()) && confirm_sesskey()) {
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&amp;hostid='.$mnet_peer->id);
print_error("invalidpubkey", 'mnet', 'peers.php?step=update&amp;hostid='.$mnet_peer->id);
exit;
} else {
$oldkey = $mnet_peer->public_key;
......@@ -116,7 +116,8 @@ if (($form = data_submitted()) && confirm_sesskey()) {
foreach ($mnet_peer->error as $err) {
$errmsg .= $err['code'] . ': ' . $err['text'].'<br />';
}
error(get_string("invalidpubkey", 'mnet') . $errmsg ,'peers.php?step=update&amp;hostid='.$mnet_peer->id);
//error(get_string("invalidpubkey", 'mnet') . $errmsg ,'peers.php?step=update&amp;hostid='.$mnet_peer->id);
print_error("invalidpubkey", 'mnet', 'peers.php?step=update&amp;hostid='.$mnet_peer->id, $errmsg);
exit;
}
}
......@@ -127,7 +128,7 @@ if (($form = data_submitted()) && confirm_sesskey()) {
// 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&amp;hostid='.$mnet_peer->id);
print_error("hostexists", 'mnet', 'peers.php?step=update&amp;hostid='.$mnet_peer->id, $mnet_peer->id);
}
}
......@@ -138,7 +139,7 @@ if (($form = data_submitted()) && confirm_sesskey()) {
if ($bool) {
redirect('peers.php?step=update&amp;hostid='.$mnet_peer->id, get_string('changessaved'));
} else {
error('Invalid action parameter.', 'index.php');
print_error('Invalid action parameter.', '', 'index.php');
}
}
}
......
......@@ -34,7 +34,7 @@
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
......@@ -57,7 +57,7 @@
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',
......@@ -89,11 +89,11 @@
} 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
......@@ -180,7 +180,7 @@
/// 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) {
......
......@@ -25,7 +25,7 @@ if (!$go or !data_submitted() or !confirm_sesskey()) { /// Print a form
if (!$tables = $db->Metatables() ) { // No tables yet at all.
error("no tables");
print_error("no tables");
}
print_simple_box_start('center');
......
......@@ -12,11 +12,11 @@
}
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) {
......
......@@ -35,7 +35,7 @@ if (!data_submitted() or !$search or !$replace or !confirm_sesskey()) { /// Pr
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();
......
......@@ -32,12 +32,12 @@
}
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)) {