]> git.mjollnir.org Git - moodle.git/commitdiff
Changes to make makeClassFromFile() in makeclass.php work better
authormoodler <moodler>
Mon, 9 Dec 2002 02:12:37 +0000 (02:12 +0000)
committermoodler <moodler>
Mon, 9 Dec 2002 02:12:37 +0000 (02:12 +0000)
lib/makeclass.php
lib/setup.php

index 35768d6dfdc1079912c1a54f604eab3c9ddc9619..29bcf4abb3d3e761d2f0fb1a06ca4868866061ad 100644 (file)
@@ -5,18 +5,26 @@
 // It exists to provide a more object-oriented interface to some of 
 // Moodle's main library functions, for use by external programs.
 // 
-// Thanks to Greg Barnett from Crown College for this code
+// Thanks to Greg Barnett from Crown College for ideas and code
 
 // Usage example (from an external program):
 // 
-//     require("blah/moodle/lib/makeclass.php"); 
-//     makeClassFromFile("blah/moodle/lib/moodlelib.php", "moodlelib"); 
-//
-//     moodle::isteacher($courseID);    // for example ... 
+// /// Set things up
+//     $external_moodle_access = true;                   // Affects setup.php
+//     require_once("moodle/lib/makeclass.php");         // This file
+//     makeClassFromFile("moodlelib.php", "moodlelib");  // File in $CFG->libdir
 //
+// /// Call moodle functions like this
+//     moodle::isteacher($courseID); 
+
 
+require_once("../config.php");
 
 function makeClassFromFile($file, $classname) {
+    global $CFG;
+
+    $file = "$CFG->libdir/$file";
+
     # sanity checks
     assert('is_file($file)');
     assert('!class_exists($classname)');
index 856499324c5d0ad62098613a84d25acb116fdc13..ab9c5db0c5ed5deb101de4d1bbb3e18f4c901b6d 100644 (file)
 
 /// Load up standard libraries 
 
-    require("$CFG->libdir/weblib.php");          // Standard web page functions
-    require("$CFG->libdir/moodlelib.php");       // Various Moodle functions
+    if (!isset($external_moodle_access)) {           // See lib/makeclass.php
+        require("$CFG->libdir/weblib.php");          // Standard web page functions
+        require("$CFG->libdir/moodlelib.php");       // Various Moodle functions
+    }
 
 
 /// Set error reporting back to normal