MDL-17457 migrated all modules to new db/install.php; added upgrade.txt file for...
[moodle.git] / enrol / enrol.class.php
1 <?php // $Id$
3 /**
4 * enrolment_factory is used to "manufacture" an instance of required enrolment plugin.
5 */
7 class enrolment_factory {
8     function factory($enrol = '') {
9         global $CFG;
10         if (!$enrol) {
11             $enrol = $CFG->enrol;
12         }
13         if (file_exists("$CFG->dirroot/enrol/$enrol/enrol.php")) {
14             require_once("$CFG->dirroot/enrol/$enrol/enrol.php");
15             $class = "enrolment_plugin_$enrol";
16             return new $class;
17         } else {
18             trigger_error("$CFG->dirroot/enrol/$enrol/enrol.php does not exist");
19             notify("Enrolment file $enrol/enrol.php does not exist");
20         }
21     }
22 }
24 ?>