Skip to content

Commit

Permalink
MDL-14129, remove all the other error() call
Browse files Browse the repository at this point in the history
  • Loading branch information
dongsheng committed Apr 4, 2008
1 parent f44ee03 commit 5a2a533
Show file tree
Hide file tree
Showing 422 changed files with 2,327 additions and 2,287 deletions.
2 changes: 1 addition & 1 deletion admin/auth_config.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
$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");
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions admin/block.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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) {
Expand Down
12 changes: 6 additions & 6 deletions admin/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,23 @@

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);
Expand All @@ -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)) {
Expand Down Expand Up @@ -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();
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions admin/cliupgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -1234,10 +1234,10 @@
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!");
}
}

Expand Down
2 changes: 1 addition & 1 deletion admin/delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
}

if (!confirm_sesskey()) {
error('This script was called wrongly');
print_error('This script was called wrongly');
}

/// OK, here goes ...
Expand Down
2 changes: 1 addition & 1 deletion admin/filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
6 changes: 3 additions & 3 deletions admin/filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down
34 changes: 17 additions & 17 deletions admin/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,37 +50,37 @@
$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.");
}


/// Check settings in config.php

$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:
Expand All @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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();
Expand All @@ -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 {
Expand All @@ -401,15 +401,15 @@
}
} 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");
}
}

/// Updated human-readable release version if necessary

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!!");
}
}

Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down
26 changes: 13 additions & 13 deletions admin/lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,15 @@
$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();
if (LANG_SEARCH_EXTRA) {
$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!");
}
}

Expand Down Expand Up @@ -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.
Expand All @@ -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")) {
Expand All @@ -363,15 +363,15 @@

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";
Expand All @@ -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'];
Expand All @@ -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);
Expand All @@ -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");
}
}

Expand All @@ -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();
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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");
}
}

Expand Down
Loading

0 comments on commit 5a2a533

Please sign in to comment.