]> git.mjollnir.org Git - moodle.git/commitdiff
[multienrol]Initial commit for multi enrolment plugin feature
authormartinlanghoff <martinlanghoff>
Thu, 9 Mar 2006 02:48:29 +0000 (02:48 +0000)
committermartinlanghoff <martinlanghoff>
Thu, 9 Mar 2006 02:48:29 +0000 (02:48 +0000)
29 files changed:
admin/cron.php
admin/enrol.php
admin/enrol_config.php [new file with mode: 0644]
admin/index.php
admin/users.php
course/edit.html
course/edit.php
course/enrol.php
course/lib.php
enrol/authorize/enrol.php
enrol/database/config.html
enrol/database/enrol.php
enrol/flatfile/config.html
enrol/flatfile/enrol.php
enrol/internal/enrol.php
enrol/ldap/config.html
enrol/ldap/enrol.php
enrol/ldap/enrol_ldap_sync.php
enrol/paypal/enrol.php
enrol/paypal/return.php
lang/en/help/courseenrolmentplugins.html [new file with mode: 0644]
lang/en_utf8/help/courseenrolmentplugins.html [new file with mode: 0644]
lang/en_utf8/moodle.php
lib/db/mysql.php
lib/db/mysql.sql
lib/db/postgres7.php
lib/db/postgres7.sql
lib/moodlelib.php
version.php

index 5932eec72b2cce944bc165cfaf87539f95fbba52..06ee75d929496a5d3f06ded83aae28e886121634 100644 (file)
     }
 
 /// Run the enrolment cron, if any
-    require_once("$CFG->dirroot/enrol/$CFG->enrol/enrol.php");
-    $enrol = new enrolment_plugin();
-    $enrol->cron();
-    if (!empty($enrol->log)) {
-        mtrace($enrol->log);
+    if (!($plugins = explode(',', $CFG->enrol_plugins_enabled))) {
+        $plugins = array($CFG->enrol);
+    }
+    require_once($CFG->dirroot .'/enrol/enrol.class.php');
+    foreach ($plugins as $p) {
+        $enrol = enrolment_factory::factory($p);
+        if (method_exists($enrol, 'cron')) {
+            $enrol->cron();
+        }
+        if (!empty($enrol->log)) {
+            mtrace($enrol->log);
+        }
+        unset($enrol);
     }
 
     if (!empty($CFG->enablestats)) {
index 92404f0923563faa980cf1b54d7ad7fae8fe154c..6d97c63e8466588c54e36b94e8a696b675a14377 100644 (file)
         error(get_string('confirmsesskeybad', 'error'));
     }
 
-    require_once("$CFG->dirroot/enrol/$enrol/enrol.php");   /// Open the class
+    require_once("$CFG->dirroot/enrol/enrol.class.php");   /// Open the factory class
 
-    $enrolment = new enrolment_plugin();
-
-
-/// If data submitted, then process and store.
+/// Save settings
 
     if ($frm = data_submitted()) {
-        if ($enrolment->process_config($frm)) {
-            set_config('enrol', $frm->enrol);
-            redirect("enrol.php?sesskey=$USER->sesskey", get_string("changessaved"), 1);
+        if (empty($frm->enable)) {
+            $frm->enable = array();
+        }
+        if (empty($frm->default)) {
+            $frm->default = '';
+        }
+        if ($frm->default && !in_array($frm->default, $frm->enable)) {
+            $frm->enable[] = $frm->default;
         }
-    } else {
-        $frm = $CFG;
+        asort($frm->enable);
+        set_config('enrol_plugins_enabled', implode(',', $frm->enable));
+        set_config('enrol', $frm->default);
+        redirect("enrol.php?sesskey=$USER->sesskey", get_string("changessaved"), 1);
     }
 
-/// Otherwise fill and print the form.
+/// Print the form
 
-    /// get language strings
-    $str = get_strings(array('enrolments', 'users', 'administration', 'settings'));
+    $str = get_strings(array('enrolmentplugins', 'users', 'administration', 'settings', 'edit'));
 
+    print_header("$site->shortname: $str->enrolmentplugins", "$site->fullname",
+                  "<a href=\"index.php\">$str->administration</a> -> 
+                   <a href=\"users.php\">$str->users</a> -> $str->enrolmentplugins");
 
     $modules = get_list_of_plugins("enrol");
     $options = array();
     }
     asort($options);
 
-    print_header("$site->shortname: $str->enrolments", "$site->fullname",
-                  "<a href=\"index.php\">$str->administration</a> -> 
-                   <a href=\"users.php\">$str->users</a> -> $str->enrolments");
+    print_simple_box("blah", 'center', '700');
 
     echo "<form target=\"{$CFG->framename}\" name=\"enrolmenu\" method=\"post\" action=\"enrol.php\">";
     echo "<input type=\"hidden\" name=\"sesskey\" value=\"".$USER->sesskey."\">";
-    echo "<div align=\"center\"><p><b>";
-
-
-/// Choose an enrolment method
-    echo get_string('chooseenrolmethod').': ';
-    choose_from_menu ($options, "enrol", $enrol, "",
-                      "document.location='enrol.php?sesskey=$USER->sesskey&enrol='+document.enrolmenu.enrol.options[document.enrolmenu.enrol.selectedIndex].value", "");
 
-    echo "</b></p></div>";
-    
-/// Print current enrolment type description    
-    print_simple_box_start("center", "80%");
-    print_heading($options[$enrol]);
+    $table = new stdClass();
+    $table->head = array(get_string('name'), get_string('enable'), get_string('default'), $str->settings);
+    $table->align = array('left', 'center', 'center', 'center');
+    $table->size = array('60%', '', '', '15%');
+    $table->width = '700';
+    $table->data = array();
 
-    print_simple_box_start("center", "60%", '', 5, 'informationbox');
-    print_string("description", "enrol_$enrol");
-    print_simple_box_end();
+    $modules = get_list_of_plugins("enrol");
+    foreach ($modules as $module) {
+        $name = get_string("enrolname", "enrol_$module");
+        $plugin = enrolment_factory::factory($module);
+        $enable = '<input type="checkbox" name="enable[]" value="'.$module.'"';
+        if (stristr($CFG->enrol_plugins_enabled, $module) !== false) {
+            $enable .= ' checked="checked"';
+        }
+        if ($module == 'internal') {
+            $enable .= ' disabled="disabled" /><input type="hidden" name="enable[]" value="'.$module.'"';
+        }
+        $enable .= ' />';
+        if (method_exists($plugin, 'print_entry')) {
+            $default = '<input type="radio" name="default" value="'.$module.'"';
+            if ($CFG->enrol == $module) {
+                $default .= ' checked="checked"';
+            }
+            $default .= ' />';
+        } else {
+            $default = '';
+        }
+        $table->data[$name] = array($name, $enable, $default,
+                                '<a href="enrol_config.php?sesskey='.$USER->sesskey.'&amp;enrol='.$module.'">'.$str->edit.'</a>');
+    }
+    asort($table->data);
 
-    echo "<hr />";
-   // print_heading($str->settings);
-    
-    $enrolment->config_form($frm);
+    print_table($table);
 
-    echo "<center><p><input type=\"submit\" value=\"".get_string("savechanges")."\"></p></center>\n";
+    echo "<center><input type=\"submit\" value=\"".get_string("savechanges")."\"></center>\n";
     echo "</form>";
 
-    print_simple_box_end();
-
     print_footer();
 
-    exit;
-?>
+?>
\ No newline at end of file
diff --git a/admin/enrol_config.php b/admin/enrol_config.php
new file mode 100644 (file)
index 0000000..7148f6c
--- /dev/null
@@ -0,0 +1,87 @@
+<?PHP  // $Id$
+       // enrol_config.php - allows admin to edit all enrollment variables
+       //                    Yes, enrol is correct English spelling.
+
+    include("../config.php");
+
+    $enrol = required_param('enrol', PARAM_ALPHA);
+
+    require_login();
+
+    if (!$site = get_site()) {
+        redirect("index.php");
+    }
+
+    if (!isadmin()) {
+        error("Only the admin can use this page");
+    }
+
+    if (!confirm_sesskey()) {
+        error(get_string('confirmsesskeybad', 'error'));
+    }
+
+    require_once("$CFG->dirroot/enrol/enrol.class.php");   /// Open the factory class
+
+    $enrolment = enrolment_factory::factory($enrol);
+
+/// If data submitted, then process and store.
+
+    if ($frm = data_submitted()) {
+        if ($enrolment->process_config($frm)) {
+            redirect("enrol.php?sesskey=$USER->sesskey", get_string("changessaved"), 1);
+        }
+    } else {
+        $frm = $CFG;
+    }
+
+/// Otherwise fill and print the form.
+
+    /// get language strings
+    $str = get_strings(array('enrolmentplugins', 'configuration', 'users', 'administration'));
+
+
+    $modules = get_list_of_plugins("enrol");
+    foreach ($modules as $module) {
+        $options[$module] = get_string("enrolname", "enrol_$module");
+    }
+    asort($options);
+
+    print_header("$site->shortname: $str->enrolmentplugins", "$site->fullname",
+                  "<a href=\"index.php\">$str->administration</a> -> 
+                   <a href=\"users.php\">$str->users</a> -> 
+                   <a href=\"enrol.php\">$str->enrolmentplugins</a> -> 
+                   $str->configuration");
+
+    echo "<form target=\"{$CFG->framename}\" name=\"enrolmenu\" method=\"post\" action=\"enrol_config.php\">";
+    echo "<input type=\"hidden\" name=\"sesskey\" value=\"".$USER->sesskey."\">";
+    echo "<div align=\"center\"><p><b>";
+
+
+/// Choose an enrolment method
+    echo get_string('chooseenrolmethod').': ';
+    choose_from_menu ($options, "enrol", $enrol, "",
+                      "document.location='enrol_config.php?sesskey=$USER->sesskey&enrol='+document.enrolmenu.enrol.options[document.enrolmenu.enrol.selectedIndex].value", "");
+
+    echo "</b></p></div>";
+    
+/// Print current enrolment type description    
+    print_simple_box_start("center", "80%");
+    print_heading($options[$enrol]);
+
+    print_simple_box_start("center", "60%", '', 5, 'informationbox');
+    print_string("description", "enrol_$enrol");
+    print_simple_box_end();
+
+    echo "<hr />";
+    
+    $enrolment->config_form($frm);
+
+    echo "<center><p><input type=\"submit\" value=\"".get_string("savechanges")."\"></p></center>\n";
+    echo "</form>";
+
+    print_simple_box_end();
+
+    print_footer();
+
+    exit;
+?>
index 2967841e15698fa091eaae3a62a4ef94d9c4316d..b36b8288f9ab5cfd351f4432e8967216a351e8a9 100644 (file)
     $userdata .= '<div class="adminlink"><a href="'.$CFG->wwwroot.'/'.$CFG->admin.'/uploaduser.php?sesskey='.$USER->sesskey.'">'.
                  get_string('uploadusers').'</a> - <span class="explanation">'.get_string('adminhelpuploadusers').'</span></div>';
 
-    $userdata .= '<hr /><div class="adminlink"><a href="enrol.php?sesskey='.$USER->sesskey.'">'.get_string('enrolments').
+    $userdata .= '<hr /><div class="adminlink"><a href="enrol.php?sesskey='.$USER->sesskey.'">'.get_string('enrolmentplugins').
                  '</a> - <span class="explanation">'.get_string('adminhelpenrolments').'</span></div>';
     $userdata .= '<div class="adminlink"><a href="../course/index.php?edit=off&amp;sesskey='.$USER->sesskey.'">'.
                  get_string('assignstudents').'</a> - <span class="explanation">'.get_string('adminhelpassignstudents').'</span></div>';
     }
     $table->data[] = array('<strong><a href="environment.php">'.get_string('environment','admin').'</a></strong>',
                            '<div class="explanation">'.get_string('adminhelpenvironment').'</div>');
+
     if (file_exists("$CFG->dirroot/$CFG->admin/$CFG->dbtype")) {
         $table->data[] = array("<strong><a href=\"$CFG->dbtype/frame.php\">".get_string('managedatabase').'</a></strong>',
                                get_string('adminhelpmanagedatabase'));
index 2f00a1a980c42a8486762a2e93a6699ca436d2e3..607a14a6955944387e0be1a3997d0c91e27f1559 100644 (file)
@@ -32,7 +32,7 @@
     $table->data[] = array("<b><a href=\"$CFG->wwwroot/$CFG->admin/uploaduser.php?sesskey=$USER->sesskey\">".get_string("uploadusers")."</a></b>",
                                get_string("adminhelpuploadusers"));
     $table->data[] = array('', '<hr />');
-    $table->data[] = array("<b><a href=\"enrol.php?sesskey=$USER->sesskey\">".get_string("enrolments")."</a></b>",
+    $table->data[] = array("<b><a href=\"enrol.php?sesskey=$USER->sesskey\">".get_string("enrolmentplugins")."</a></b>",
                            get_string("adminhelpenrolments"));
     $table->data[] = array("<b><a href=\"../course/index.php?edit=off&amp;sesskey=$USER->sesskey\">".get_string("assignstudents")."</a></b>",
                            get_string("adminhelpassignstudents"));
index 179a2bac5785b00ec392aefa1061f6d5bff242c9..5ad997cc7756d5ee04a32fd02af611b940504d8f 100644 (file)
@@ -15,6 +15,9 @@
     if (!isset($form->theme)) {
         $form->theme = '';
     }
+    if (!isset($form->enrol)) {
+        $form->enrol = '';
+    }
     if (!isset($form->enrollable)) {
         $form->enrollable = 1;
     }
            helpbutton("coursestartdate", get_string("startdate"));
     ?></td>
 </tr>
+<tr valign="top">
+    <td align="right"><?php  print_string("enrolmentplugins") ?>:</td>
+    <td><?php
+            unset($choices);
+            $modules = get_list_of_plugins("enrol");
+            foreach ($modules as $module) {
+                $name = get_string("enrolname", "enrol_$module");
+                $plugin = enrolment_factory::factory($module);
+                if (method_exists($plugin, 'print_entry')) {
+                    $choices[$name] = $module;
+                }
+            }
+            asort($choices);
+            $choices = array_flip($choices);
+            $choices = array_merge(array('' => get_string('sitedefault')), $choices);
+            choose_from_menu ($choices, "enrol", "$form->enrol", "");
+            helpbutton("courseenrolmentplugins", get_string("enrolmentplugins"));
+    ?></td>
+</tr>
 <tr valign="top">
     <td align="right"><?php  print_string("enrollable") ?>:</td>
     <td><?php
     </td>
 </tr>
 <?php
-    if ($CFG->enrol != 'internal') {
+    if (method_exists(enrolment_factory::factory($course->enrol), 'print_entry') && $course->enrol != 'internal') {
 ?>
 <tr valign="top">
     <td align="right"><?php  print_string("cost") ?>:</td>
index d196164e3181ba76380fa65df88c924d81ebaf76..9c22c070a245d582d3f6d6054a3b2f63b486b156 100644 (file)
@@ -4,6 +4,7 @@
     require_once("../config.php");
     require_once("lib.php");
     require_once("$CFG->libdir/blocklib.php");
+    require_once("$CFG->dirroot/enrol/enrol.class.php");
 
     $id       = optional_param('id', 0, PARAM_INT); // course id
     $category = optional_param('category', 0, PARAM_INT); // possible default category
index 91fd039fff4bf5d9daf2bdf7422ee3b5ce7fe825..f62ff9b8429e875e07154ae70be8a453223af0ea 100644 (file)
@@ -5,7 +5,7 @@
 
     require_once("../config.php");
     require_once("lib.php");
-    require_once("$CFG->dirroot/enrol/$CFG->enrol/enrol.php");
+    require_once("$CFG->dirroot/enrol/enrol.class.php");
 
     $id = required_param('id',PARAM_INT);
 
 
     check_for_restricted_user($USER->username);
 
-    $enrol = new enrolment_plugin();
-
 /// Refreshing enrolment data in the USER session
-    $enrol->get_student_courses($USER);
-    $enrol->get_teacher_courses($USER);
+    if (!($plugins = explode(',', $CFG->enrol_plugins_enabled))) {
+        $plugins = array($CFG->enrol);
+    }
+    require_once($CFG->dirroot .'/enrol/enrol.class.php');
+    foreach ($plugins as $p) {
+        $enrol = enrolment_factory::factory($p);
+        if (method_exists($enrol, 'get_student_courses')) {
+            $enrol->get_student_courses($USER);
+        }
+        if (method_exists($enrol, 'get_teacher_courses')) {
+            $enrol->get_teacher_courses($USER);
+        }
+        unset($enrol);
+    }
 
+    $enrol = enrolment_factory::factory($course->enrol);
 
 /// Double check just in case they are actually enrolled already 
 /// This might occur if they were enrolled during this session
     }
 
 /// Check if the course is enrollable
+    if (!method_exists($enrol, 'print_entry')) {
+        print_header_simple();
+        notice(get_string('enrolmentnointernal'), $CFG->wwwroot);
+    }
+
     if (!$course->enrollable ||
             ($course->enrollable == 2 && $course->enrolstartdate > 0 && $course->enrolstartdate > time()) ||
             ($course->enrollable == 2 && $course->enrolenddate > 0 && $course->enrolenddate <= time())
index 4f6903e79e548587a807e2e3a287bc6a6a70273e..cfc889a2b1d7f84fc1fb1cccaf895beec7269002 100644 (file)
@@ -1401,14 +1401,7 @@ function print_courses($category, $width="100%", $hidesitecourse = false) {
             print_course($course, $width);
         }
     } else {
-        print_heading(get_string('nocoursesyet'));
-        if (iscreator()) {
-            $options = array();
-            $options['category'] = $category->id;
-            echo '<div class="addcoursebutton" align="center">';
-            print_single_button($CFG->wwwroot.'/course/edit.php', $options, get_string('addnewcourse'));
-            echo '</div>';
-        }
+        print_heading(get_string("nocoursesyet"));
     }
 
 }
@@ -1418,12 +1411,9 @@ function print_course($course, $width="100%") {
 
     global $CFG, $USER;
 
-    static $enrol;
+    require_once("$CFG->dirroot/enrol/enrol.class.php");
 
-    if (empty($enrol)) {
-        require_once("$CFG->dirroot/enrol/$CFG->enrol/enrol.php");
-        $enrol = new enrolment_plugin;
-    }
+    $enrol = enrolment_factory::factory($course->enrol);
 
     print_simple_box_start("center", "$width", '', 5, "coursebox");
 
index a6d16f57e4b484e2c39b548bff2d9378e1f6e151..c82c8199b11e1935f37ae3cf64e9b2cc61b4a7f6 100755 (executable)
@@ -7,7 +7,7 @@ require_once $CFG->dirroot.'/enrol/authorize/const.php';
  * enrolment_plugin_authorize
  *
  */
-class enrolment_plugin extends enrolment_base
+class enrolment_plugin_authorize 
 {
     /**
      * Credit card error messages.
@@ -36,9 +36,10 @@ class enrolment_plugin extends enrolment_base
     {
         global $CFG, $USER, $form;
 
-        if ($this->zero_cost($course) || isguest()) {
-            parent::print_entry($course);
-            return; // No money for guests ;)
+        if ($this->zero_cost($course) || isguest()) { // No money for guests ;)
+            $internal = enrolment_factory::factory('internal');
+            $internal->print_entry($course);
+            return;
         }
 
         $this->prevent_double_paid($course);
@@ -82,8 +83,9 @@ class enrolment_plugin extends enrolment_base
      * @access public
      */
     function check_entry($form, $course) {
-        if ((!empty($form->password)) || isguest() || $this->zero_cost($course)) {
-            parent::check_entry($form, $course);
+        if ($this->zero_cost($course) || isguest() || (!empty($form->password))) {
+            $internal = enrolment_factory::factory('internal');
+            $internal->print_entry($course);
         } elseif ((!empty($form->ccsubmit)) && $this->validate_enrol_form($form)) {
             $this->cc_submit($form, $course);
         }
@@ -371,7 +373,9 @@ class enrolment_plugin extends enrolment_base
      */
     function get_access_icons($course) {
 
-        $str = parent::get_access_icons($course);
+
+        $internal = enrolment_factory::factory('internal');
+        $str = $internal->get_access_icons($course);
         $curcost = $this->get_course_cost($course);
 
         if (abs($curcost['cost']) > 0.00) {
@@ -570,7 +574,8 @@ class enrolment_plugin extends enrolment_base
     function cron()
     {
         global $CFG;
-        parent::cron();
+        $internal = enrolment_factory::factory('internal');
+        $internal->cron();
         require_once $CFG->dirroot.'/enrol/authorize/action.php';
 
         $oneday = 86400;
index 0a9ad32735b5b16a1370206965299b41666428c6..1de83de10392ca43baa995e95eafaf3669c0ed56 100644 (file)
 <th colspan="2">
     <?php print_string("general_options", "enrol_database") ?>
 </td>
-<tr valign="top">
-    <td align="right">enrol_allowinternal:</td>
-    <td>
-        <input type="checkbox" name="enrol_allowinternal" <?php if ($frm->enrol_allowinternal) echo "checked=\"true\"" ?> />
-    </td>
-    <td>
-    <?php  print_string('allowinternal') ?>
-    </td>
-</tr>
 
 </table>
index dda6b6a7bd925fc6ba1a1b23b2501f07fe866218..0b8f3bc9adc74b7542d915dc3809794abd5d88d8 100644 (file)
@@ -5,24 +5,14 @@ require_once("$CFG->dirroot/course/lib.php");
 require_once("$CFG->dirroot/lib/blocklib.php");
 require_once("$CFG->dirroot/lib/pagelib.php");
 
-class enrolment_plugin extends enrolment_base {
+class enrolment_plugin_database {
 
     var $log;    
 
-/// Leave get_teacher_courses() function unchanged for the time being
-
-
-/// Leave cron() function unchanged
-
-
-
 /// Overide the base get_student_courses() function
 function get_student_courses(&$user) {
     global $CFG;
 
-    parent::get_student_courses($user);  /// Start with the list of known enrolments
-                                         /// If the database fails we can at least use this
-
     // NOTE: if $this->enrol_connect() succeeds you MUST remember to call
     // $this->enrol_disconnect() as it is doing some nasty vodoo with $CFG->prefix
     if ($enroldb = $this->enrol_connect()) {
@@ -282,30 +272,6 @@ function sync_enrolments($type='student') {
     return true;
 }
 
-
-/// Override the base print_entry() function
-function print_entry($course) {
-    global $CFG;
-
-    if (! empty($CFG->enrol_allowinternal) ) {
-        parent::print_entry($course);
-    } else {
-        print_header();
-        notice(get_string("enrolmentnointernal"), $CFG->wwwroot);
-    }
-}
-
-
-/// Override the base check_entry() function
-function check_entry($form, $course) {
-    global $CFG;
-
-    if (! empty($CFG->enrol_allowinternal) ) {
-        parent::check_entry($form, $course);
-    }
-}
-
-
 /// Overide the get_access_icons() function
 function get_access_icons($course) {
 }
@@ -320,7 +286,8 @@ function config_form($frm) {
                   'enrol_localcoursefield', 'enrol_localuserfield', 
                   'enrol_remotecoursefield', 'enrol_remoteuserfield',
                   'enrol_db_autocreate', 'enrol_db_category', 'enrol_db_template', 
-                  'enrol_allowinternal');
+                  'enrol_remotecoursefield', 'enrol_remoteuserfield');
+
     foreach ($vars as $var) {
         if (!isset($frm->$var)) {
             $frm->$var = '';
@@ -396,11 +363,6 @@ function process_config($config) {
         $config->enrol_db_template = '';
     }
     set_config('enrol_db_template', $config->enrol_db_template);
-
-    if (!isset($config->enrol_allowinternal)) {
-        $config->enrol_allowinternal = '';
-    }
-    set_config('enrol_allowinternal', $config->enrol_allowinternal);
     return true;
 
 }
@@ -510,7 +472,6 @@ function enrol_connect() {
     }
 
     // Try to connect to the external database
-
     $enroldb = &ADONewConnection($CFG->enrol_dbtype);
     if ($enroldb->PConnect($CFG->enrol_dbhost,$CFG->enrol_dbuser,$CFG->enrol_dbpass,$CFG->enrol_dbname)) {
         return $enroldb;
index 19d3aa0ea28f9ee6145482de8f429b58f18e54c7..cac3ba271c6234f3f97768f30cf7954295df5158 100644 (file)
     </td>
 </tr>
 
-<tr valign="top">
-    <td align="right">enrol_allowinternal:</td>
-    <td>
-        <input type="checkbox" value="1" name="enrol_allowinternal" <?php if ($frm->enrol_allowinternal) echo "checked=\"true\"" ?> />
-    </td>
-    <td>
-    <?php  print_string('allowinternal') ?>
-    </td>
-</tr>
-
 </table>
index 8b51a767e5057cc79e0b0706a724642f83dcc38f..e4c0f261464cf5b44f0de4428f7153a951359d71 100644 (file)
@@ -1,42 +1,16 @@
 <?php
-require_once("$CFG->dirroot/enrol/enrol.class.php");
-
 // The following flags are set in the configuration
 // $CFG->enrol_flatfilelocation:       where is the file we are looking for?
-// $CFG->enrol_allowinternal:          allow internal enrolment in courses
 // $CFG->enrol_emailstudents:          send email to students when they are enrolled in a course
 // $CFG->enrol_emailteachers:          send email to teachers when they are enrolled in a course
 // $CFG->enrol_emailadmins:            email the log from the cron job to the admin
 
 
 
-class enrolment_plugin extends enrolment_base {
+class enrolment_plugin_flatfile {
 
     var $log;    
 
-/// Override the base print_entry() function
-function print_entry($course) {
-    global $CFG;
-
-    if (! empty($CFG->enrol_allowinternal) ) {
-        parent::print_entry($course);
-    } else {
-        print_header();
-        notice(get_string("enrolmentnointernal"), $CFG->wwwroot);
-    }
-}
-
-
-/// Override the base check_entry() function
-function check_entry($form, $course) {
-    global $CFG;
-
-    if (! empty($CFG->enrol_allowinternal) ) {
-        parent::check_entry($form, $course);
-    }
-}
-
-
 /// Override the base config_form() function
 function config_form($frm) {
     global $CFG;
@@ -74,15 +48,14 @@ function process_config($config) {
     }
     set_config('enrol_mailadmins', $config->enrol_mailadmins);
 
-    if (!isset($config->enrol_allowinternal)) {
-        $config->enrol_allowinternal = '';
-    }
-    set_config('enrol_allowinternal', $config->enrol_allowinternal);
-    
     return true;
 
 }
 
+/// Override the get_access_icons() function
+function get_access_icons($course) {
+}
+
 /**
 * Override the base cron() function to read in a file
 *
@@ -99,9 +72,6 @@ function process_config($config) {
     function cron() {
         global $CFG;
 
-        /// call the base class
-        parent::cron();
-
         if (empty($CFG->enrol_flatfilelocation)) {
             $filename = "$CFG->dataroot/1/enrolments.txt";  // Default location
         } else {
index 038393c97130a66e1a1ddc157eafc08611927444..0800229539b93ad4b82cc58a8f8b3227376a5dcd 100644 (file)
@@ -1,8 +1,432 @@
-<?php
-require_once("$CFG->dirroot/enrol/enrol.class.php");
+<?php   /// $Id$
+///////////////////////////////////////////////////////////////////////////
+//                                                                       //
+// NOTICE OF COPYRIGHT                                                   //
+//                                                                       //
+// Moodle - Modular Object-Oriented Dynamic Learning Environment         //
+//          http://moodle.org                                            //
+//                                                                       //
+// Copyright (C) 2004  Martin Dougiamas  http://moodle.com               //
+//                                                                       //
+// This program is free software; you can redistribute it and/or modify  //
+// it under the terms of the GNU General Public License as published by  //
+// the Free Software Foundation; either version 2 of the License, or     //
+// (at your option) any later version.                                   //
+//                                                                       //
+// This program is distributed in the hope that it will be useful,       //
+// but WITHOUT ANY WARRANTY; without even the implied warranty of        //
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         //
+// GNU General Public License for more details:                          //
+//                                                                       //
+//          http://www.gnu.org/copyleft/gpl.html                         //
+//                                                                       //
+///////////////////////////////////////////////////////////////////////////
 
-class enrolment_plugin extends enrolment_base {
-    /// nothing to do - it's already perfect!
+
+/**
+* enrolment_plugin_internal is the default enrolment plugin
+*
+* This class provides all the functionality for an enrolment plugin
+* In fact it includes all the code for the default, "internal" method
+* so that other plugins can override these as necessary.
+*/
+
+class enrolment_plugin_internal {
+
+var $errormsg;
+
+
+
+/**
+* Returns information about the courses a student has access to
+*
+* Set the $user->student course array
+* Set the $user->timeaccess course array
+*
+* @param    user  referenced object, must contain $user->id already set
+*/
+function get_student_courses(&$user) {
+
+    if ($students = get_records("user_students", "userid", $user->id)) {
+        $currenttime = time();
+        foreach ($students as $student) {
+
+        /// Is course visible?
+
+            if (get_field("course", "visible", "id", $student->course)) {
+
+            /// Is the student enrolment active right now?
+
+                if ( ( $student->timestart == 0 or ( $currenttime > $student->timestart )) and 
+                     ( $student->timeend   == 0 or ( $currenttime < $student->timeend )) ) {
+                    $user->student[$student->course] = true;
+                    $user->timeaccess[$student->course] = $student->timeaccess;
+                }
+            }
+        }
+    }   
+}
+
+
+
+/**
+* Returns information about the courses a student has access to
+*
+* Set the $user->teacher course array
+* Set the $user->teacheredit course array
+* Set the $user->timeaccess course array
+*
+* @param    user  referenced object, must contain $user->id already set
+*/
+function get_teacher_courses(&$user) {
+
+    if ($teachers = get_records("user_teachers", "userid", $user->id)) {
+        $currenttime = time();
+        foreach ($teachers as $teacher) {
+
+        /// Is teacher only teaching this course for a specific time period?
+
+            if ( ( $teacher->timestart == 0 or ( $currenttime > $teacher->timestart )) and 
+                 ( $teacher->timeend   == 0 or ( $currenttime < $teacher->timeend )) ) {
+
+                $user->teacher[$teacher->course] = true;
+
+                if ($teacher->editall) {
+                    $user->teacheredit[$teacher->course] = true;
+                }   
+
+                $user->timeaccess[$teacher->course] = $teacher->timeaccess;
+            }
+        }   
+    }
+}
+
+
+
+
+/**
+* Prints the entry form/page for this enrolment
+*
+* This is only called from course/enrol.php
+* Most plugins will probably override this to print payment 
+* forms etc, or even just a notice to say that manual enrolment 
+* is disabled
+*
+* @param    course  current course object
+*/
+function print_entry($course) {
+    global $CFG, $USER, $SESSION, $THEME;
+
+    $strloginto = get_string("loginto", "", $course->shortname);
+    $strcourses = get_string("courses");
+
+
+
+/// Automatically enrol into courses without password
+
+    if ($course->password == "") {   // no password, so enrol
+
+        if (isguest()) {
+            add_to_log($course->id, "course", "guest", "view.php?id=$course->id", "$USER->id");
+
+        } else if (empty($_GET['confirm']) && empty($_GET['cancel'])) {
+
+            print_header($strloginto, $course->fullname, "<a href=\".\">$strcourses</a> -> $strloginto");
+            echo "<br />";
+            notice_yesno(get_string("enrolmentconfirmation"), "enrol.php?id=$course->id&amp;confirm=1", "enrol.php?id=$course->id&amp;cancel=1");
+            print_footer();
+            exit;
+
+        } elseif (!empty($_GET['confirm'])) {
+            if ($course->enrolperiod) {
+                $timestart = time();
+                $timeend = time() + $course->enrolperiod;
+            } else {
+                $timestart = $timeend = 0;
+            }
+
+            if (! enrol_student($USER->id, $course->id, $timestart, $timeend, 'manual')) {
+                error("An error occurred while trying to enrol you.");
+            }
+
+            $subject = get_string("welcometocourse", "", $course->fullname);
+            $a->coursename = $course->fullname;
+            $a->profileurl = "$CFG->wwwroot/user/view.php?id=$USER->id&course=$course->id";
+            $message = get_string("welcometocoursetext", "", $a);
+            if (! $teacher = get_teacher($course->id)) {
+                $teacher = get_admin();
+            }
+            email_to_user($USER, $teacher, $subject, $message);
+
+            add_to_log($course->id, "course", "enrol", "view.php?id=$course->id", "$USER->id");
+
+            $USER->student[$course->id] = true;
+
+            if ($SESSION->wantsurl) {
+                $destination = $SESSION->wantsurl;
+                unset($SESSION->wantsurl);
+            } else {
+                $destination = "$CFG->wwwroot/course/view.php?id=$course->id";
+            }
+
+            redirect($destination);
+        } elseif (!empty($_GET['cancel'])) {
+            unset($SESSION->wantsurl);
+            redirect($CFG->wwwroot);
+        }
+    }
+
+    $teacher = get_teacher($course->id);
+    if (!isset($password)) {
+        $password = "";
+    }
+
+
+    print_header($strloginto, $course->fullname, "<a href=\".\">$strcourses</a> -> $strloginto", "form.password");
+
+    print_course($course, "80%");
+
+    include("$CFG->dirroot/enrol/internal/enrol.html");
+
+    print_footer();
+
+}
+
+
+
+/**
+* The other half to print_entry, this checks the form data
+*
+* This function checks that the user has completed the task on the 
+* enrolment entry page and then enrolls them.
+*
+* @param    form    the form data submitted, as an object
+* @param    course  the current course, as an object
+*/
+function check_entry($form, $course) {
+    global $CFG, $USER, $SESSION, $THEME;
+
+    if (empty($form->password)) {
+        $form->password = '';
+    }
+
+    $groupid = $this->check_group_entry($course->id, $form->password);
+    if (($form->password == $course->password) or ($groupid !== false) ) {
+
+        if (isguest()) {
+        
+            add_to_log($course->id, "course", "guest", "view.php?id=$course->id", $_SERVER['REMOTE_ADDR']);
+            
+        } else {  /// Update or add new enrolment
+
+            if ($course->enrolperiod) {
+                $timestart = time();
+                $timeend   = $timestart + $course->enrolperiod;
+            } else {
+                $timestart = $timeend = 0;
+            }
+
+            if (! enrol_student($USER->id, $course->id, $timestart, $timeend, 'manual')) {
+                error("An error occurred while trying to enrol you.");
+            }
+
+            if ($groupid !== false) {
+                if (add_user_to_group($groupid, $USER->id)) {
+                    $USER->groupmember[$course->id] = $groupid;
+                } else {
+                    error("An error occurred while trying to add you to a group");
+                }
+            }
+
+            $subject = get_string("welcometocourse", "", $course->fullname);
+            $a->coursename = $course->fullname;
+            $a->profileurl = "$CFG->wwwroot/user/view.php?id=$USER->id&amp;course=$course->id";
+            $message = get_string("welcometocoursetext", "", $a);
+            
+            if (! $teacher = get_teacher($course->id)) {
+                $teacher = get_admin();
+            }
+            
+            email_to_user($USER, $teacher, $subject, $message);
+            add_to_log($course->id, "course", "enrol", "view.php?id=$course->id", "$USER->id");
+        }
+        
+        $USER->student[$course->id] = true;
+        
+        if ($SESSION->wantsurl) {
+            $destination = $SESSION->wantsurl;
+            unset($SESSION->wantsurl);
+        } else {
+            $destination = "$CFG->wwwroot/course/view.php?id=$course->id";
+        }
+        
+        redirect($destination);
+
+    } else {
+        $this->errormsg = get_string("enrolmentkeyhint", "", substr($course->password,0,1));
+    }
+                        
+}
+
+
+/**
+* Check if the given enrolment key matches a group enrolment key for the given course
+*
+* Check if the given enrolment key matches a group enrolment key for the given course
+*
+* @param    courseid  the current course id
+* @param    password  the submitted enrolment key
+*/
+function check_group_entry ($courseid, $password) {
+    $ingroup = false;
+    if ( ($groups = get_groups($courseid)) !== false ) {
+        foreach ($groups as $group) 
+            if ( !empty($group->password) and ($password == $group->password) )
+                $ingroup = $group->id;
+    }
+    return $ingroup;
 }
 
+
+/**
+* Prints a form for configuring the current enrolment plugin
+*
+* This function is called from admin/enrol.php, and outputs a 
+* full page with a form for defining the current enrolment plugin.
+*
+* @param    page  an object containing all the data for this page
+*/
+function config_form($page) {
+    
+}
+
+
+/**
+* Processes and stored configuration data for the enrolment plugin
+*
+* Processes and stored configuration data for the enrolment plugin
+*
+* @param    config  all the configuration data as entered by the admin
+*/
+function process_config($config) {
+
+    $return = true;
+
+    foreach ($config as $name => $value) {
+        if (!set_config($name, $value)) {
+            $return = false;
+        }
+    }
+
+    return $return;
+}
+
+
+/**
+* This function is run by admin/cron.php every time 
+*
+* The cron function can perform regular checks for the current 
+* enrollment plugin.  For example it can check a foreign database,
+* all look for a file to pull data in from
+*
+*/
+function cron() {
+    // Delete students from all courses where their enrolment period has expired
+    
+    $select = "timeend > '0' AND timeend < '" . time() . "'";
+    
+    if ($students = get_records_select('user_students', $select)) {
+        foreach ($students as $student) {
+            if ($course = get_record('course', 'id', $student->course)) {
+                if (empty($course->enrolperiod)) {   // This overrides student timeend
+                    continue;
+                }
+            }
+            unenrol_student($student->userid, $student->course);
+        }
+    }
+    if ($teachers = get_records_select('user_teachers', $select)) {
+        foreach ($teachers as $teacher) {
+            remove_teacher($teacher->userid, $teacher->course);
+        }
+    }
+
+    // Notify teachers/students about students who's enrolment are going to expire
+    global $CFG;
+    if ($CFG->lastexpirynotify < date('Ymd') && ($courses = get_records_select('course', 'enrolperiod > 0 AND expirynotify > 0 AND expirythreshold > 0'))) {
+        $site = get_site();
+        $admin = get_admin();
+        $strexpirynotify = get_string('expirynotify');
+        foreach ($courses as $course) {
+            $a = new stdClass();
+            $a->course = $course->shortname .' '. $course->fullname;
+            $a->threshold = $course->expirythreshold / 86400;
+            $a->extendurl = $CFG->wwwroot . '/user/index.php?id=' . $course->id;
+            $a->current = array();
+            $a->past = array();
+            $a->current = $a->past = array();
+            $expiry = time() + $course->expirythreshold;
+            $sql = "SELECT * FROM {$CFG->prefix}user u INNER JOIN {$CFG->prefix}user_students s ON u.id=s.userid WHERE s.course = $course->id AND s.timeend > 0 AND s.timeend <= $expiry";
+            if ($students = get_records_sql($sql)) {
+                $teacher = get_teacher($course->id);
+                $strexpirynotifystudentsemail = get_string('expirynotifystudentsemail', '', $a);
+                foreach ($students as $student) {
+                    if ($student->timeend < ($expiry - 86400)) {
+                        $a->past[] = fullname($student) . " <$student->email>";
+                    } else {
+                        $a->current[] = fullname($student) . " <$student->email>";
+                        if ($course->notifystudents) {
+                            // Send this guy notice
+                            email_to_user($student, $teacher, $site->fullname .' '. $strexpirynotify, $strexpirynotifystudentsemail);
+                        }
+                    }
+                }
+            }
+            $a->current = implode("\n", $a->current);
+            $a->past = implode("\n", $a->past);
+            $strexpirynotifyemail = get_string('expirynotifyemail', '', $a);
+            if ($a->current || $a->past) {
+                $sql = "SELECT u.* FROM {$CFG->prefix}user u INNER JOIN {$CFG->prefix}user_teachers t ON u.id=t.userid WHERE t.course = $course->id";
+                if ($teachers = get_records_sql($sql)) {
+                    foreach ($teachers as $teacher) {
+                        email_to_user($teacher, $admin, $a->course .' '. $strexpirynotify, $strexpirynotifyemail);
+                    }
+                }
+            }
+            set_config('lastexpirynotify', date('Ymd'));
+        }
+    }
+}
+
+
+/**
+* Returns the relevant icons for a course
+*
+* Returns the relevant icons for a course
+*
+* @param    course  the current course, as an object
+*/
+function get_access_icons($course) {
+    global $CFG;
+
+    $str = '';
+
+    if (!empty($course->guest)) {
+        $strallowguests = get_string("allowguests");
+        $str .= '<a title="'.$strallowguests.'" href="'.$CFG->wwwroot.'/course/view.php?id='.$course->id.'">';
+        $str .= '<img vspace="4" alt="'.$strallowguests.'" height="16" width="16" border="0" '.
+                'src="'.$CFG->pixpath.'/i/guest.gif" /></a>&nbsp;&nbsp;';
+    }
+    if (!empty($course->password)) {
+        $strrequireskey = get_string("requireskey");
+        $str .= '<a title="'.$strrequireskey.'" href="'.$CFG->wwwroot.'/course/view.php?id='.$course->id.'">';
+        $str .= '<img vspace="4" alt="'.$strrequireskey.'" height="16" width="16" border="0" src="'.$CFG->pixpath.'/i/key.gif" /></a>';
+    }
+
+    return $str;
+}
+
+
+} /// end of class
+
 ?>
index 3a94e5ea23dc34caf4bddee2f2646f6a16069da2..464b2990f64216c6de04f7ceaf7704d4753d35f3 100755 (executable)
@@ -73,19 +73,10 @@ if (!isset ($frm->enrol_ldap_course_summary_editlock)) {
     $frm->enrol_ldap_course_summary_editlock = false;
 }
 // autocreate
-if (!isset ($frm->enrol_ldap_autocreate)) {
-    $frm->enrol_ldap_autocreate = false;
-}
-if (!isset ($frm->enrol_ldap_category)) {
-    $frm->enrol_ldap_category = 1;
-}
-if (!isset ($frm->enrol_ldap_template)) {
-    $frm->enrol_ldap_template = '';
-}
-// general options
-if (!isset ($frm->enrol_allowinternal)) {
-    $frm->enrol_allowinternal = false;
-}
+optional_variable($frm->enrol_ldap_autocreate, false);
+optional_variable($frm->enrol_ldap_category, 1);
+optional_variable($frm->enrol_ldap_template, '');
+
 ?>
 
 <table cellspacing="0" cellpadding="5" border="0" align="center">
@@ -367,14 +358,4 @@ if (!isset ($frm->enrol_allowinternal)) {
    </td>
 </tr>
 
-<tr valign="top">
-       <td align="right">enrol_allowinternal:</td>
-       <td>
-        <input type="checkbox" name="enrol_allowinternal" <?php if ($frm->enrol_allowinternal) echo "checked=\"true\"" ?> />
-    </td>
-    <td>
-    <?php  print_string('allowinternal') ?>
-    </td>
-</tr>
-
 </table>
index aa4c1d43431e5c39ebaa4f0b0558abdca8cd9031..01fe56361931e1e8849176c33f6aa763774819f4 100755 (executable)
@@ -3,34 +3,24 @@
 require_once("$CFG->dirroot/enrol/enrol.class.php");
 require_once("$CFG->dirroot/course/lib.php");
 require_once("$CFG->dirroot/lib/blocklib.php");
-require_once("$CFG->dirroot//lib/pagelib.php");
+require_once("$CFG->dirroot/lib/pagelib.php");
 
 $CFG->enrol_localcoursefield = 'idnumber';
 
-class enrolment_plugin extends enrolment_base {
+class enrolment_plugin_ldap {
 
     var $log;    
 
-/// Leave get_teacher_courses() function unchanged for the time being
-
-
-/// Leave cron() function unchanged
-
-
 /// Overide the base get_student_courses() function
 function get_student_courses(&$user) {
     global $CFG;
-    parent::get_student_courses($user); // populate known enrolments
-    $this->get_user_courses($user, 'student');
-    return parent::get_student_courses($user);    
+    return $this->get_user_courses($user, 'student');
 }
 
 /// Overide the base get_teacher_courses() function
 function get_teacher_courses(&$user) {
     global $CFG;
-    parent::get_teacher_courses($user); // populate known enrolments
-    $this->get_user_courses($user, 'teacher');
-    return parent::get_teacher_courses($user);
+    return $this->get_user_courses($user, 'teacher');
 }
 
 /// Overide the base get_student_courses() function
@@ -327,28 +317,6 @@ function sync_enrolments($type, $enrol) {
 }
 
 
-/// Override the base print_entry() function
-function print_entry($course) {
-    global $CFG;
-
-    if (! empty($CFG->enrol_allowinternal) ) {
-        parent::print_entry($course);
-    } else {
-        print_header();
-        notice(get_string("enrolmentnointernal"), $CFG->wwwroot);
-    }
-}
-
-/// Override the base check_entry() function
-function check_entry($form, $course) {
-    global $CFG;
-
-    if (! empty($CFG->enrol_allowinternal) ) {
-        parent::check_entry($form, $course);
-    }
-}
-
-
 /// Overide the get_access_icons() function
 function get_access_icons($course) {
 }
@@ -455,12 +423,7 @@ function process_config($config) {
         $config->enrol_ldap_autocreate = '0';
     }
     set_config('enrol_ldap_autocreate', $config->enrol_ldap_autocreate);                 
-   
-    if (!isset($config->enrol_allowinternal)) {
-        $config->enrol_allowinternal = '';
-    }
-    set_config('enrol_allowinternal', $config->enrol_allowinternal);
-    
+
     return true;
 
 }
index 31d0a5af2381116bda363e6f9b6ee7c58a3419f9..a8a5621e39a962f2bb2fd9818d85d2e99b7a0b5e 100755 (executable)
     require_once($CFG->dirroot . '/course/lib.php');
     require_once($CFG->dirroot . '/lib/moodlelib.php');
     require_once($CFG->dirroot . '/lib/datalib.php');
-    require_once($CFG->dirroot . "/enrol/" . $CFG->enrol . "/enrol.php");
+    require_once($CFG->dirroot . "/enrol/ldap/enrol.php");
 
     // ensure errors are well explained
     $CFG->debug=10;
     // update enrolments -- these handlers should autocreate courses if required
-    $enrol = new enrolment_plugin();
+    $enrol = new enrolment_plugin_ldap();
     $enrol->enrol_ldap_connect();    
     $enrol->sync_enrolments('student', true);
     $enrol->sync_enrolments('teacher', true);
index 1a902f68bfae187f8c45ade9edd9eab19430d402..1ce836c713e8e19dca45841ad99ed4d6fa879aaa 100644 (file)
@@ -4,7 +4,7 @@
 require_once("$CFG->dirroot/enrol/enrol.class.php");
 
 
-class enrolment_plugin extends enrolment_base {
+class enrolment_plugin_paypal {
 
 
 /// Override the base print_entry() function
@@ -29,8 +29,8 @@ function print_entry($course) {
 
     if (abs($cost) < 0.01) { // no cost, default to base class entry to course
 
-
-        parent::print_entry($course);
+        $internal = enrolment_factory::factory('internal');
+        $internal->print_entry($course);
 
     } else {
 
@@ -83,7 +83,8 @@ function get_access_icons($course) {
     }
 
     if (abs($cost) < 0.01) {
-        $str = parent::get_access_icons($course);
+        $internal = enrolment_factory::factory('internal');
+        $str = $internal->get_access_icons($course);
 
     } else {
     
@@ -178,20 +179,20 @@ function sanitise_for_paypal($text) {
     if (!empty($CFG->sanitise_for_paypal)) {
         //Array of characters to replace (not allowed by PayPal)
         //Can be expanded as necessary to add other diacritics
-        $replace = array('á' => 'a',        //Spanish characters
-                         'é' => 'e',
-                         'í' => 'i',
-                         'ó' => 'o',
-                         'ú' => 'u',
-                         'Á' => 'A',
-                         'É' => 'E',
-                         'Í' => 'I',
-                         'Ó' => 'O',
-                         'Ú' => 'U',
-                         'ñ' => 'n',
-                         'Ñ' => 'N',
-                         'ü' => 'u',
-                         'Ü' => 'U');
+        $replace = array('' => 'a',        //Spanish characters
+                         '' => 'e',
+                         '' => 'i',
+                         '' => 'o',
+                         '' => 'u',
+                         '' => 'A',
+                         '' => 'E',
+                         '' => 'I',
+                         '' => 'O',
+                         '' => 'U',
+                         '' => 'n',
+                         '' => 'N',
+                         '' => 'u',
+                         '' => 'U');
         $text = strtr($text, $replace);
     
         //Make here other sanities if necessary
index 4ee264e7e5dcdbe84bfc50ea9cb80f25a8676a42..e6d5ebecf81cfecd753dcdc08904db912d091af5 100644 (file)
@@ -1,7 +1,7 @@
 <?php  // $Id$
 
     require("../../config.php");
-    require_once("$CFG->dirroot/enrol/$CFG->enrol/enrol.php");
+    require_once("$CFG->dirroot/enrol/paypal/enrol.php");
 
     require_variable($id);
 
@@ -12,7 +12,7 @@
     require_login();
 
 /// Refreshing enrolment data in the USER session
-    $enrol = new enrolment_plugin();
+    $enrol = new enrolment_plugin_paypal();
     $enrol->get_student_courses($USER);
 
     if ($SESSION->wantsurl) {
diff --git a/lang/en/help/courseenrolmentplugins.html b/lang/en/help/courseenrolmentplugins.html
new file mode 100644 (file)
index 0000000..b3d6e44
--- /dev/null
@@ -0,0 +1 @@
+<p>Choose default interactive enrolment plugin used in this course</p>
diff --git a/lang/en_utf8/help/courseenrolmentplugins.html b/lang/en_utf8/help/courseenrolmentplugins.html
new file mode 100644 (file)
index 0000000..b3d6e44
--- /dev/null
@@ -0,0 +1 @@
+<p>Choose default interactive enrolment plugin used in this course</p>
index f67e4aaf8a301b7aebb117f59c82fc5bf04f5a51..f4d7a1f1b07c1579612fa953fbda45a2b3666147 100644 (file)
@@ -161,17 +161,19 @@ $string['changedpassword'] = 'Changed password';
 $string['changepassword'] = 'Change password';
 $string['changessaved'] = 'Changes saved';
 $string['check'] = 'Check';
+$string['checkall'] = 'Check all';
 $string['checkingbackup'] = 'Checking backup';
 $string['checkingcourse'] = 'Checking course';
 $string['checkingforbbexport'] = 'Checking for BlackBoard export';
 $string['checkinginstances'] = 'Checking instances';
 $string['checkingsections'] = 'Checking sections';
 $string['checklanguage'] = 'Check language';
+$string['checknone'] = 'Check none';
 $string['childcourses'] = 'Child courses';
 $string['childcoursenotfound'] = 'Child course not found!';
 $string['choose'] = 'Choose';
 $string['choosecourse'] = 'Choose a course';
-$string['chooseenrolmethod'] = 'Primary method of enrolment';
+$string['chooseenrolmethod'] = 'Choose enrolment plugin';
 $string['chooselivelogs'] = 'Or watch current activity';
 $string['chooselogs'] = 'Choose which logs you want to see';
 $string['choosereportfilter'] = 'Choose a filter for the report';
@@ -456,6 +458,7 @@ $string['enrolmentnew'] = 'New enrolment in $a';
 $string['enrolmentnewuser'] = '$a->user has enrolled in course \"$a->course\"';
 $string['enrolmentnointernal'] = 'Manual enrolments are currently not enabled';
 $string['enrolmentnotyet'] = 'Sorry, you can not access this course until <br /> $a';
+$string['enrolmentplugins'] = 'Enrolment Plugins';
 $string['enrolments'] = 'Enrolments';
 $string['enrolmentstart'] = 'Enrolment Started';
 $string['enrolperiod'] = 'Enrolment duration';
@@ -527,7 +530,6 @@ $string['forcepasswordchangehelp'] = 'Prompt user to change it on their next log
 $string['forcepasswordchangenotice'] = 'You must change your password to proceed.';
 $string['forcetheme'] = 'Force theme';
 $string['forgotten'] = 'Forgotten your username or password?';
-$string['forgottenduplicate'] = 'Automatic password recovery can not be completed as your email address appears in the database more than once. Please contact your administrator <a href=\"mailto:$a->email\">$a->firstname $a->lastname</a> .';
 $string['forgotaccount'] = 'Lost password?';
 $string['format'] = 'Format';
 $string['formathtml'] = 'HTML format';
index d89721bdfd0b6c001f71f21a8f30f8a17cf3318e..6c473825f76fc9b88f4ca0b5ef26a6ebd3fd18d0 100644 (file)
@@ -1649,7 +1649,7 @@ function main_upgrade($oldversion=0) {
         table_column('course','','enrolenddate','int');
     }
 
-    if ($oldversion < 2005101200) { # add enrolment key to course_request.
+    if ($oldversion < 2005101200) { // add enrolment key to course_request.
         table_column('course_request','','password','varchar',50);
     }
 
@@ -1658,6 +1658,10 @@ function main_upgrade($oldversion=0) {
         modify_database('',"ALTER TABLE prefix_log ADD INDEX info (info);");
     }
 
+    if ($oldversion < 2006030900) {
+        table_column('course','','enrol','varchar','20','','');
+    }
+
     return $result;
 }
 
index 38e0d7797aa9f9abc48830ef6ca5dfe54599f684..de3b7dd92647fff3ff611edfacea92ce1ec9b4bb 100644 (file)
@@ -85,6 +85,7 @@ CREATE TABLE `prefix_course` (
   `enrollable` tinyint(1) unsigned NOT NULL default '1',
   `enrolstartdate` int(10) unsigned NOT NULL default '0',
   `enrolenddate` int(10) unsigned NOT NULL default '0',
+  `enrol` varchar(20) NOT NULL default '',
   PRIMARY KEY  (`id`),
   KEY `category` (`category`),
   KEY `idnumber` (`idnumber`),
index eb2a07e89066bb61a5448f4f160206853e5a8111..603537d62c390a5f5e208a5813cacae4edf8e5c4 100644 (file)
@@ -1391,7 +1391,8 @@ function main_upgrade($oldversion=0) {
         table_column('course','','enrolenddate','integer');
     }
 
-    if ($oldversion < 2005101200) { # add enrolment key to course_request.
+
+    if ($oldversion < 2005101200) { // add enrolment key to course_request.
         table_column('course_request','','password','text');
     }
 
@@ -1399,6 +1400,10 @@ function main_upgrade($oldversion=0) {
         modify_database('',"CREATE INDEX prefix_log_userid_idx ON prefix_log (userid);");
         modify_database('',"CREATE INDEX prefix_log_info_idx ON prefix_log (info);");
     }
+
+    if ($oldversion < 2006030900) {
+        table_column('course','','enrol','varchar','20','','');
+    }
     
     return $result;
 }
index 43993851c98dadd334469b8306d4f65288e91400..0314d20bf8125f30c4e40a94b9adb36a2b7f2dd4 100644 (file)
@@ -55,7 +55,8 @@ CREATE TABLE prefix_course (
    notifystudents integer NOT NULL default '0',
    enrollable integer NOT NULL default '1',
    enrolstartdate integer NOT NULL default '0',
-   enrolenddate integer NOT NULL default '0'
+   enrolenddate integer NOT NULL default '0',
+   enrol varchar(20) NOT NULL default ''
 );
 
 CREATE UNIQUE INDEX prefix_course_category_sortorder_uk ON prefix_course (category,sortorder);
index a714d54f0794d4692e5f862c8ac4dd928953a18e..3cd275b0d35e17d4b50ac0cf681660f39d637f35 100644 (file)
@@ -2674,12 +2674,22 @@ function get_complete_user_data($field, $value) {
 
     $user->student[SITEID] = isstudent(SITEID, $user->id);
 
-/// Determine enrolments based on current enrolment module
+/// Load the list of enrolment plugin enabled
 
-    require_once($CFG->dirroot .'/enrol/'. $CFG->enrol .'/enrol.php');
-    $enrol = new enrolment_plugin();
-    $enrol->get_student_courses($user);
-    $enrol->get_teacher_courses($user);
+    if (!($plugins = explode(',', $CFG->enrol_plugins_enabled))) {
+        $plugins = array($CFG->enrol);
+    }
+    require_once($CFG->dirroot .'/enrol/enrol.class.php');
+    foreach ($plugins as $p) {
+        $enrol = enrolment_factory::factory($p);
+        if (method_exists($enrol, 'get_student_courses')) {
+            $enrol->get_student_courses($user);
+        }
+        if (method_exists($enrol, 'get_teacher_courses')) {
+            $enrol->get_teacher_courses($user);
+        }
+        unset($enrol);
+    }
 
 /// Get various settings and preferences
 
index d5716cc3b20504f7b9464eac2347569c085bde6c..06e809f3b6f4c638a4f00e31c49dcfc465ba32e9 100644 (file)
@@ -6,7 +6,7 @@
 // This is compared against the values stored in the database to determine
 // whether upgrades should be performed (see lib/db/*.php)
 
-   $version = 2006030800;  // YYYYMMDD = date
+   $version = 2006030900;  // YYYYMMDD = date
                            //       XY = increments within a single day
 
    $release = '1.6 development';    // Human-friendly version name