Skip to content

Commit

Permalink
MDL-20697 removing duplicate error string, fixing get_site() which is…
Browse files Browse the repository at this point in the history
… now using exceptions
  • Loading branch information
skodak committed Nov 1, 2009
1 parent 7b51fb6 commit 3f77c15
Show file tree
Hide file tree
Showing 16 changed files with 20 additions and 54 deletions.
8 changes: 1 addition & 7 deletions auth/ldap/ntlmsso_attempt.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
$PAGE->set_url(new moodle_url($CFG->wwwroot.'/auth/ldap/ntlmsso_attempt.php'));

/// Define variables used in page
if (!$site = get_site()) {
print_error("siteisnotdefined");
}
$site = get_site();

$authsequence = get_enabled_auth_plugins(true); // auths, in sequence
if (!in_array('ldap',$authsequence,true)) {
Expand Down Expand Up @@ -39,7 +37,3 @@
. ' src="' . $CFG->wwwroot . '/auth/ldap/ntlmsso_magic.php?sesskey='
. $sesskey . '" />';
redirect($CFG->wwwroot . '/auth/ldap/ntlmsso_finish.php', $msg, 3);



?>
5 changes: 1 addition & 4 deletions auth/ldap/ntlmsso_finish.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
$PAGE->set_url(new moodle_url($CFG->wwwroot.'/auth/ldap/ntlmsso_finish.php'));

/// Define variables used in page
if (!$site = get_site()) {
print_error("siteisnotdefined", 'debug');
}
$site = get_site();

$authsequence = get_enabled_auth_plugins(true); // auths, in sequence
if (!in_array('ldap',$authsequence,true)) {
Expand All @@ -36,4 +34,3 @@
redirect($CFG->httpswwwroot . '/login/index.php?authldap_skipntlmsso=1',
get_string('ntlmsso_failed','auth_ldap'), 3);
}
?>
4 changes: 1 addition & 3 deletions backup/backup_check.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@


//Check site
if (!$site = get_site()) {
print_error("siteisnotdefined", 'debug');
}
$site = get_site();
if ($count == 0) {
notice("No backupable modules are installed!");
}
Expand Down
4 changes: 1 addition & 3 deletions backup/backup_execute.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@


//Check site
if (!$site = get_site()) {
print_error("siteisnotdefined", 'debug');
}
$site = get_site();

$preferences = new StdClass;
backup_fetch_prefs_from_request($preferences,$count,$course);
Expand Down
4 changes: 1 addition & 3 deletions backup/backup_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@
}

//Check site
if (!$site = get_site()) {
print_error("siteisnotdefined", 'debug');
}
$site = get_site();

//Checks for the required files/functions to backup every mod
//And check if there is data about it
Expand Down
4 changes: 1 addition & 3 deletions backup/restore_check.html
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,7 @@
}

//Check site
if (!$site = get_site()) {
print_error("siteisnotdefined", 'debug');
}
$site = get_site();

// Non-cached - get accessinfo
if (isset($USER->access)) {
Expand Down
4 changes: 1 addition & 3 deletions backup/restore_execute.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@
}

//Check site
if (!$site = get_site()) {
print_error("siteisnotdefined", 'debug');
}
$site = get_site();
$errorstr = '';

$status = restore_execute($restore,$info,$course_header,$errorstr);
Expand Down
4 changes: 1 addition & 3 deletions backup/restore_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@
}

//Check site
if (!$site = get_site()) {
print_error("siteisnotdefined", 'debug');
}
$site = get_site();

//Checks for the required files/functions to restore every mod
$count = 0;
Expand Down
4 changes: 1 addition & 3 deletions backup/restore_precheck.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@
}

//Check site
if (!$site = get_site()) {
print_error("siteisnotdefined", 'debug');
}
$site = get_site();

$errorstr = '';
if (!empty($SESSION->restore->importing)) {
Expand Down
6 changes: 2 additions & 4 deletions course/category.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@
$moveto = optional_param('moveto', 0, PARAM_INT);
$resort = optional_param('resort', 0, PARAM_BOOL);

if (!$site = get_site()) {
print_error('siteisnotdefined', 'debug');
}

$site = get_site();

if (empty($id)) {
print_error("unknowcategory");
}
Expand Down
6 changes: 2 additions & 4 deletions course/delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@
print_error('cannotdeletecourse');
}

if (!$site = get_site()) {
print_error("siteisnotdefined", 'debug');
}

$site = get_site();

$strdeletecourse = get_string("deletecourse");
$stradministration = get_string("administration");
$strcategories = get_string("categories");
Expand Down
4 changes: 1 addition & 3 deletions course/import/activities/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@
print_error("invalidcourseid");
}

if (!$site = get_site()){
print_error("siteisnotdefined", 'debug');
}
$site = get_site();

require_login($course->id);
$tocontext = get_context_instance(CONTEXT_COURSE, $id);
Expand Down
4 changes: 1 addition & 3 deletions course/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@
$moveup = optional_param('moveup',0,PARAM_INT);
$movedown = optional_param('movedown',0,PARAM_INT);

if (!$site = get_site()) {
print_error('siteisnotdefined', 'debug');
}
$site = get_site();

$systemcontext = get_context_instance(CONTEXT_SYSTEM);

Expand Down
1 change: 0 additions & 1 deletion lang/en_utf8/debug.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
$string['phpvaroff'] = 'The PHP server variable \'$a->name\' should be Off - $a->link';
$string['phpvaron'] = 'The PHP server variable \'$a->name\' is not turned On - $a->link';
$string['sessionmissing'] = '$a object missing from session';
$string['siteisnotdefined'] = 'Site is not defined!';
$string['sqlrelyonobsoletetable'] = 'This SQL relies on obsolete table(s): $a! Your code must be fixed by a developer.';
$string['withoutversion'] = 'Main version.php file is missing, not readable or broken.';
$string['xmlizeunavailable'] = 'xmlize functions are not available';
Expand Down
8 changes: 4 additions & 4 deletions lib/datalib.php
Original file line number Diff line number Diff line change
Expand Up @@ -405,9 +405,7 @@ function get_users_confirmed() {
/**
* Returns $course object of the top-level site.
*
* @global object
* @global object
* @return bool|object A {@link $COURSE} object for the site
* @return object A {@link $COURSE} object for the site, exception if not found
*/
function get_site() {
global $SITE, $DB;
Expand All @@ -419,7 +417,9 @@ function get_site() {
if ($course = $DB->get_record('course', array('category'=>0))) {
return $course;
} else {
return false;
// course table exists, but the site is not there,
// unfortunately there is no automatic way to recover
throw new moodle_exception('nosite', 'error');
}
}

Expand Down
4 changes: 1 addition & 3 deletions login/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@
$PAGE->set_url("$CFG->httpswwwroot/login/index.php");

/// Define variables used in page
if (!$site = get_site()) {
print_error('siteisnotdefined', 'debug');
}
$site = get_site();

if (empty($CFG->langmenu)) {
$langmenu = "";
Expand Down

0 comments on commit 3f77c15

Please sign in to comment.