]> git.mjollnir.org Git - moodle.git/commitdiff
Consistent use of get_site() instead of checking course->category directly
authormartin <martin>
Thu, 11 Jul 2002 05:30:10 +0000 (05:30 +0000)
committermartin <martin>
Thu, 11 Jul 2002 05:30:10 +0000 (05:30 +0000)
admin/index.php
admin/site.php
admin/user.php
course/edit.php
course/enrol.php
course/lib.php
lib/moodlelib.php

index 05e7e76dfb2a251cd767b36731dede31f1e8b1f9..887b800384642f535250a191c4e77b9ecc97d0cb 100644 (file)
@@ -79,7 +79,7 @@
     }
 
     // Set up the overall site name etc.
-    if (! $course = get_record("course", "category", 0)) {
+    if (! $site = get_site()) {
         redirect("site.php");
     }
 
@@ -93,7 +93,7 @@
 
     // At this point, the databases exist, and the user is an admin
 
-    print_header("$course->fullname: Administration Page","$course->fullname: Administration Page", "Admin");
+    print_header("$site->fullname: Administration Page","$site->fullname: Administration Page", "Admin");
 
     echo "<UL>";
     echo "<LI><B><A HREF=\"site.php\">Site settings</A></B>";
     echo "<LI><B>View Logs</B>";
     echo "</UL>";
 
-
     print_footer();
 ?>
 
index 25beac9e44c9ba8c3bf5ef6b3f6f62f3655cc802..946b1328351e00116cb4fbf1a6eedd508b523d4f 100644 (file)
@@ -2,7 +2,7 @@
 
        require("../config.php");
 
-    $course = get_record("course", "category", 0);
+    $course = get_site();
 
 /// If data submitted, then process and store.
 
index eabbf8ebc5c9c6ce75714841b10144dbc9e7db87..56853008b44fd087b593a6af1fddf845df0cd607 100644 (file)
@@ -28,7 +28,7 @@
             error("User ID was incorrect (can't find it)");
         }
 
-        if (! $course = get_record("course", "category", 0)) {
+        if (! $course = get_site()) {
             error("Could not find site-level course");
         }
 
index 97bb32155e939980cfe1ca1375087e61fa71d3cb..0db5511ccbeb9c8b7eb061c69e2e0679ef85126c 100644 (file)
@@ -22,7 +22,7 @@
             error("Only administrators can use this page");
         }
 
-        if (! $site = get_record("course", "category", 0)) {
+        if (! $site = get_site()) {
             redirect("$CFG->wwwroot/admin/");
         }
     }
index 257a8d7bf5c2d61f0e97837e756f16690ce1b241..2ac8dc9e7929db1bee9136e3751b73a6cb42e377 100644 (file)
@@ -43,7 +43,7 @@
     }
 
 
-    if (! $site = get_record("course", "category", "0") ) {
+    if (! $site = get_site()) {
         error("Could not find a site!");
     }
 
index d0f2e7fb97738654c481d4f6fa9c587e58ad1503..492edc49338aa3e3e30a6dbf06228576f096dd8f 100644 (file)
@@ -192,7 +192,7 @@ function print_course($course) {
 
     global $CFG;
 
-    if (! $site = get_record("course", "category", "0") ) {
+    if (! $site = get_site()) {
         error("Could not find a site!");
     }
 
index 6d1679b06b55891169cb26540166ce6b47f5ecff..370e7a0278e75343ce5d30b35c68df3dfd3b9d71 100644 (file)
@@ -54,7 +54,7 @@ function print_navigation ($navigation) {
    global $CFG;
 
    if ($navigation) {
-       if (! $site = get_record("course", "category", 0)) {
+       if (! $site = get_site()) {
            $site->shortname = get_string("home");;
        }
        echo "<A TARGET=_top HREF=\"$CFG->wwwroot/\">$site->shortname</A> -> $navigation";
@@ -749,7 +749,7 @@ function get_user_info_from_db($field, $value) {
             $rs->MoveNext();
         }
 
-        if ($course = get_record("course", "category", 0)) {  
+        if ($course = get_site()) {
             // Everyone is always a member of the top course
             $user->student["$course->id"] = true;
         }
@@ -1094,16 +1094,19 @@ function get_directory_list( $rootdir ) {
 
 /// STRING TRANSLATION  ////////////////////////////////////////
 
-function print_string($identifier, $module="", $a="", $b="", $c="") {
-    echo get_string($identifier, $module, $a, $b, $c);
+function print_string($identifier, $module="", $a=NULL) {
+    echo get_string($identifier, $module, $a);
 }
 
 
-function get_string($identifier, $module="", $a="", $b="", $c="") {
+function get_string($identifier, $module="", $a=NULL) {
 // Return the translated string specified by $identifier as 
 // for $module.  Uses the same format files as STphp.
-// $a, $b and $c are optional variables that may be used 
+// $a is an object, string or number that can be used
 // within translation strings
+//
+// eg "hello \$a->firstname \$a->lastname"
+// or "hello \$a"
 
     global $CFG, $USER;
 
@@ -1153,20 +1156,6 @@ function get_string($identifier, $module="", $a="", $b="", $c="") {
 }
 
 
-function get_string_variable_list($string) {
-// This function is only used from get_string_from_file().
-    if (empty ($string))
-        return;
-
-    // Match on all variables in $string
-    $count = preg_match_all("/\\\$[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/",
-                            $string, $matches);
-
-    // Return array of matches ($matches[0] is most useful)
-    return $matches;
-}
-
-
 function get_string_from_file($identifier, $langfile, $destination) {
 // This function is only used from get_string().
     include ($langfile);
@@ -1175,18 +1164,7 @@ function get_string_from_file($identifier, $langfile, $destination) {
         return false;
     }
 
-    $value = "sprintf(\"".$string[$identifier]."\");";
-    $variables = get_string_variable_list($value);
-    if (empty($variables[0]))
-        return "$destination = $value";
-    else {
-        foreach ($variables[0] as $variable) {
-            $variablecheck .= "if (!isset ($variable))\n" .
-                "die (\"Variable specified in translation " .
-                "not set.\");\n";
-        }
-        return "$variablecheck $destination = $value";
-    }
+    return "$destination = sprintf(\"".$string[$identifier]."\");";
 }