]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-20697 removing duplicate error string, fixing get_site() which is now using excep...
authorPetr Skoda <skodak@moodle.org>
Sun, 1 Nov 2009 09:10:09 +0000 (09:10 +0000)
committerPetr Skoda <skodak@moodle.org>
Sun, 1 Nov 2009 09:10:09 +0000 (09:10 +0000)
16 files changed:
auth/ldap/ntlmsso_attempt.php
auth/ldap/ntlmsso_finish.php
backup/backup_check.html
backup/backup_execute.html
backup/backup_form.html
backup/restore_check.html
backup/restore_execute.html
backup/restore_form.html
backup/restore_precheck.html
course/category.php
course/delete.php
course/import/activities/index.php
course/index.php
lang/en_utf8/debug.php
lib/datalib.php
login/index.php

index 3b1aaaaf1d675eb68024b47a35b6cdbe301ede3b..eb268bb0f29dff2d52e5bded2cb7d536b3ff8f8f 100644 (file)
@@ -8,9 +8,7 @@ httpsrequired();
 $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)) {
@@ -39,7 +37,3 @@ $msg = '<p>'.get_string('ntlmsso_attempting','auth_ldap').'</p>'
     . ' src="' . $CFG->wwwroot . '/auth/ldap/ntlmsso_magic.php?sesskey='
     . $sesskey . '" />';
 redirect($CFG->wwwroot . '/auth/ldap/ntlmsso_finish.php', $msg, 3);
-
-
-
-?>
index 0356df34e7b81942a2e78abfabe60b0fb5729d20..93e7455980ace102fa14cd24c3daa0d45daba35d 100644 (file)
@@ -8,9 +8,7 @@ httpsrequired();
 $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)) {
@@ -36,4 +34,3 @@ if (!$authplugin->ntlmsso_finish()) {
     redirect($CFG->httpswwwroot . '/login/index.php?authldap_skipntlmsso=1', 
              get_string('ntlmsso_failed','auth_ldap'), 3);
 }
-?>
index d5b034554c4e7a36870ae3bbe537f6050ea33a67..0019d537e48f73f062a46960eb4bb5f59f28a7f6 100644 (file)
@@ -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!");
     }
index fd16937f5015a5f51592e188765f4319a5b05f1e..44492e9bc99eb904a2628dbc8ef130d69be2f02c 100644 (file)
@@ -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);
index 2b08ff5f5218ae06c38d3b6af50aae3e1a006892..a4a70cee97453e6839d2bf423c300da483c84813 100644 (file)
@@ -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
index 528f3988cb027caf6d9d2aba5c28965b521cc0f2..a00e9cf69fc5dee6424f9f062e3f16e353bffad0 100644 (file)
     }
 
     //Check site
-    if (!$site = get_site()) {
-        print_error("siteisnotdefined", 'debug');
-    }
+    $site = get_site();
 
     // Non-cached - get accessinfo
     if (isset($USER->access)) {
index 083cd45bc489db1c9b92a4d98bfe1dbea972f0b0..a08418539f508fe6bd43084d02352c1da2343362 100644 (file)
@@ -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);
index 3e4c90354b879f974baa5b506ff459c0a61d3d6c..c443edffebe1567dab0d56b6acfb6de65118fb06 100644 (file)
@@ -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;
index e6cecbab11640b2ffb51a6862e4ee8afcac22847..20fcaa557774972d059eea717ffec61c1a9f43bc 100644 (file)
@@ -33,9 +33,7 @@
     }
 
     //Check site
-    if (!$site = get_site()) {
-        print_error("siteisnotdefined", 'debug');
-    }
+    $site = get_site();
 
     $errorstr = '';
     if (!empty($SESSION->restore->importing)) {
index 8b47748d033281a455a4ba8cfdbd54ba6b4dee6a..1e0ae1439771b67ee7fce46ed04dd5bb1d99f117 100644 (file)
     $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");
     }
index 567b3d8f88d3e1fd28975a66d03e4ac39dc8a117..eac3987abce8a22517ae9052698dc5389ce1aec2 100644 (file)
         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");
index 6814aab75c84124e77259ab6fabcfed2b6dee4bb..63f942cd31591892abbcfc5b6cd571618af100b3 100644 (file)
@@ -56,9 +56,7 @@ if (! ($course = $DB->get_record("course", array("id"=>$id)))) {
     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);
index 624efb02aa290bd33046bdac149fa5d774994bff..ff82fd5190030d5765be9a84e0e809b8602c9c42 100644 (file)
@@ -36,9 +36,7 @@ $moveto   = optional_param('moveto',-1,PARAM_INT);
 $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);
 
index 3f7bf2b6f3cb20f6c8dfcabc5fec9786e1e6688b..8f5f7bcfd91c0b51482dab4664fb09d0ace8a929 100644 (file)
@@ -31,7 +31,6 @@ $string['modulenotexist'] = '$a module doesn\'t exist';
 $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';
index a1fce76084b5d8a4cb8518c0cbed0064c9d3a04c..ab0281194cea17deff90396ff6c79507d474e465 100644 (file)
@@ -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;
@@ -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');
     }
 }
 
index a8c19e43b8b914e177dce8f957b7fef6dde4791f..0d03fadf5345e13d97957b0ce8fd11b82a948310 100644 (file)
@@ -61,9 +61,7 @@ httpsrequired();
 $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 = "";