]> git.mjollnir.org Git - moodle.git/commitdiff
Here finally is an admin interface for controlling the new enrolment plugins.
authormoodler <moodler>
Sat, 21 Aug 2004 17:15:07 +0000 (17:15 +0000)
committermoodler <moodler>
Sat, 21 Aug 2004 17:15:07 +0000 (17:15 +0000)
It's not at all well-tested yet (I made a lot of changes to it just tonight)
but it's late and I am literally sick (with flu) and tired so I'm checking
this in and going to bed.

Please fix all the bugs for me.   ;-)

17 files changed:
admin/enrol.php
admin/users.php
enrol/database/config.html [new file with mode: 0644]
enrol/database/enrol.php
enrol/enrol.class.php
enrol/flatfile/config.html [new file with mode: 0644]
enrol/flatfile/enrol.php
enrol/paypal/config.html [new file with mode: 0644]
enrol/paypal/enrol.html
enrol/paypal/enrol.php
enrol/paypal/ipn.php
lang/en/enrol_database.php [new file with mode: 0755]
lang/en/enrol_flatfile.php
lang/en/enrol_internal.php
lang/en/enrol_paypal.php
lang/en/install.php
lang/en/moodle.php

index d95d8fe36e4c971947e0443dc282f65f1ecb5d54..c43986c11045e72164f0e301390fe77efab0b1c4 100644 (file)
@@ -4,6 +4,7 @@
 
     include("../config.php");
     require_login();
+    optional_variable($enrol, $CFG->enrol);
 
     if (!$site = get_site()) {
         redirect("index.php");
         error("Only the admin can use this page");
     }
 
-       if (isset($_GET['enrolment'])) {
-           $enrolname = $_GET['enrol'];
-       } else {
-        $enrolname = $CFG->enrol;
-       } 
-    
-    require_once("$CFG->dirroot/enrol/$enrolname/enrol.php");   /// Open the class
+    require_once("$CFG->dirroot/enrol/$enrol/enrol.php");   /// Open the class
 
     $enrolment = new enrolment_plugin();
 
 
 /// If data submitted, then process and store.
 
-       if ($config = data_submitted()) {
-        if ($enrolment->process_config($config)) {
+       if ($frm = data_submitted()) {
+        if ($enrolment->process_config($frm)) {
+            set_config('enrol', $frm->enrol);
             redirect("enrol.php", get_string("changessaved"), 1);
         }
-       }
+       } else {
+        $frm = $CFG;
+    }
 
 /// Otherwise fill and print the form.
 
-    $str = get_strings(array('enrolments', 'users', 'administration'));
+    /// get language strings
+    $str = get_strings(array('enrolments', 'users', 'administration', 'settings'));
 
-    if (empty($config)) {
-        $page->config = $CFG;
-    } else {
-        $page->config = $config;
-    }
 
     $modules = get_list_of_plugins("enrol");
     foreach ($modules as $module) {
-        $page->options[$module] = get_string("enrolname", "enrol_$module");
+        $options[$module] = get_string("enrolname", "enrol_$module");
     }
-    asort($page->options);
-
-    $form = $enrolment->config_form($page);
+    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_heading($page->options[$CFG->enrol]);
+    echo "<form target=\"{$CFG->framename}\" name=\"enrolmenu\" method=\"post\" action=\"enrol.php\">";
+    echo "<div align=\"center\"><p><b>";
+
 
-    echo "<CENTER><P><B>";
-    echo "NOT COMPLETE";
-    echo "<P><B>";
-    echo "<form TARGET=\"{$CFG->framename}\" NAME=\"authmenu\" method=\"post\" action=\"auth.php\">";
-    print_string("chooseauthmethod","auth");
+/// Choose an enrolment method
+    echo get_string('chooseenrolmethod').': ';
+       choose_from_menu ($options, "enrol", $enrol, "",
+                      "document.location='enrol.php?enrol='+document.enrolmenu.enrol.options[document.enrolmenu.enrol.selectedIndex].value", "");
 
-       choose_from_menu ($options, "auth", $auth, "","document.location='auth.php?auth='+document.authmenu.auth.options[document.authmenu.auth.selectedIndex].value", "");
+    echo "</b></p></div>";
+    
+/// Print current enrolment type description    
+    print_simple_box_start("center", "80%", "$THEME->cellheading");
+    print_heading($options[$enrol]);
 
-    echo "</B></P></CENTER>";
-        
+    print_simple_box_start("center", "60%", "$THEME->cellcontent");
+    print_string("description", "enrol_$enrol");
+    print_simple_box_end();
 
+    echo "<hr>";
+   // print_heading($str->settings);
     
+    $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();
 
index ade66ef70f5e9a47860e50a2ddf5b59b685e7355..a7b29f1d415f7bac51a0f90bf3530b8209ce6adb 100644 (file)
@@ -33,7 +33,7 @@
         $table->data[] = array("<b><a href=\"$CFG->wwwroot/$CFG->admin/uploaduser.php\">".get_string("uploadusers")."</a></b>",
                                get_string("adminhelpuploadusers"));
     }
-    $table->data[] = array('', '');
+    $table->data[] = array('', '<hr />');
     $table->data[] = array("<b><a href=\"enrol.php\">".get_string("enrolments")."</a></b>",
                            get_string("adminhelpenrolments"));
     $table->data[] = array("<b><a href=\"../course/index.php?edit=off\">".get_string("assignstudents")."</a></b>",
diff --git a/enrol/database/config.html b/enrol/database/config.html
new file mode 100644 (file)
index 0000000..847f827
--- /dev/null
@@ -0,0 +1,118 @@
+<table cellspacing="0" cellpadding="5" border="0" align="center">
+<tr valign="top">
+       <td align="right"><p>enrol_dbtype:</p></td>
+       <td>
+    <?php  $dbtypes = array("access","ado_access", "ado", "ado_mssql", "borland_ibase", "csv", "db2", "fbsql", "firebird", "ibase", "informix72", "informix", "mssql", "mysql", "mysqlt", "oci805", "oci8", "oci8po", "odbc", "odbc_mssql", "odbc_oracle", "oracle", "postgres64", "postgres7", "postgres", "proxy", "sqlanywhere", "sybase", "vfp");
+       foreach ($dbtypes as $dbtype) {
+           $dboptions[$dbtype] = $dbtype;
+       }
+       choose_from_menu($dboptions, "enrol_dbtype", $frm->enrol_dbtype, '', '', '');
+    ?>
+      
+    </td>
+    <td>
+    <?php  print_string("dbtype","enrol_database") ?>
+    </td>
+</tr>
+
+<tr valign="top">
+       <td align="right"><p>enrol_dbhost:</p></td>
+       <td>
+        <input size="15" type="text" name="enrol_dbhost" value="<?php echo $frm->enrol_dbhost ?>" />
+    </td>
+    <td>
+    <?php  print_string("dbhost","enrol_database") ?>
+    </td>
+</tr>
+
+<tr valign="top">
+       <td align="right"><p>enrol_dbuser:</p></td>
+       <td>
+        <input size="15" type="text" name="enrol_dbuser" value="<?php echo $frm->enrol_dbuser ?>" />
+    </td>
+    <td>
+    <?php  print_string("dbuser","enrol_database") ?>
+    </td>
+</tr>
+
+<tr valign="top">
+       <td align="right"><p>enrol_dbpass:</p></td>
+       <td>
+        <input size="15" type="text" name="enrol_dbpass" value="<?php echo $frm->enrol_dbpass ?>" />
+    </td>
+    <td>
+    <?php  print_string("dbpass","enrol_database") ?>
+    </td>
+</tr>
+
+<tr valign="top">
+       <td align="right"><p>enrol_dbname:</p></td>
+       <td>
+        <input size="15" type="text" name="enrol_dbname" value="<?php echo $frm->enrol_dbname ?>" />
+    </td>
+    <td>
+    <?php  print_string("dbname","enrol_database") ?>
+    </td>
+</tr>
+
+<tr valign="top">
+       <td align="right"><p>enrol_dbtable:</p></td>
+       <td>
+        <input size="15" type="text" name="enrol_dbtable" value="<?php echo $frm->enrol_dbtable ?>" />
+    </td>
+    <td>
+    <?php  print_string("dbtable","enrol_database") ?>
+    </td>
+</tr>
+
+<tr valign="top">
+       <td align="right"><p>enrol_localcoursefield:</p></td>
+       <td>
+        <input size="15" type="text" name="enrol_localcoursefield" value="<?php echo $frm->enrol_localcoursefield ?>" />
+    </td>
+    <td>
+    <?php  print_string("localcoursefield","enrol_database") ?>
+    </td>
+</tr>
+
+<tr valign="top">
+       <td align="right"><p>enrol_localuserfield:</p></td>
+       <td>
+        <input size="15" type="text" name="enrol_localuserfield" value="<?php echo $frm->enrol_localuserfield ?>" />
+    </td>
+    <td>
+    <?php  print_string("localuserfield","enrol_database") ?>
+    </td>
+</tr>
+
+<tr valign="top">
+       <td align="right"><p>enrol_remotecoursefield:</p></td>
+       <td>
+        <input size="15" type="text" name="enrol_remotecoursefield" value="<?php echo $frm->enrol_remotecoursefield ?>" />
+    </td>
+    <td>
+    <?php  print_string("remotecoursefield","enrol_database") ?>
+    </td>
+</tr>
+
+<tr valign="top">
+       <td align="right"><p>enrol_remoteuserfield:</p></td>
+       <td>
+        <input size="15" type="text" name="enrol_remoteuserfield" value="<?php echo $frm->enrol_remoteuserfield ?>" />
+    </td>
+    <td>
+    <?php  print_string("remoteuserfield","enrol_database") ?>
+    </td>
+</tr>
+
+<tr valign="top">
+       <td align="right"><p>enrol_allowinternal:</p></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 608bb561a532569a16b2de55b3bbfbfb45c8f0b5..8cf26caea5bdc99d75ac21c101cafeb514c47d50 100644 (file)
@@ -1,23 +1,6 @@
-<?php
-require_once("$CFG->dirroot/enrol/enrol.class.php");
-
-/**
- *
- * $CFG->enrol_dbtype
- * $CFG->enrol_dbhost
- * $CFG->enrol_dbname
- * $CFG->enrol_dbuser
- * $CFG->enrol_dbpass
- * $CFG->enrol_dbtable
- * $CFG->enrol_localcoursefield
- * $CFG->enrol_localuserfield
- * $CFG->enrol_remotecoursefield
- * $CFG->enrol_remoteuserfield
- */
-
-
-
+<?php  // $Id$
 
+require_once("$CFG->dirroot/enrol/enrol.class.php");
 
 class enrolment_plugin extends enrolment_base {
 
@@ -59,7 +42,7 @@ function get_student_courses(&$user) {
             /// to the respective remote fields
             $rs = $enroldb->Execute("SELECT * FROM $CFG->enrol_dbtable 
                                      WHERE $CFG->enrol_remotecoursefield = '$localcoursevalue' 
-                                     AND $CFG->enrol_remoteuserfield = '$user->{$CFG->enrol_localuserfield}' ");
+                                     AND $CFG->enrol_remoteuserfield = '{$user->$CFG->enrol_localuserfield}' ");
 
             /// If no records existed then student has been unenrolled externally.
             /// Unenrol locally and remove entry from the $user->student array
@@ -80,7 +63,7 @@ function get_student_courses(&$user) {
 function print_entry($course) {
     global $CFG;
 
-    if (! empty($CFG->enrol_flatfileallowinternal) ) {
+    if (! empty($CFG->enrol_allowinternal) ) {
         parent::print_entry($course);
     } else {
         print_header();
@@ -93,7 +76,7 @@ function print_entry($course) {
 function check_entry($form, $course) {
     global $CFG;
 
-    if (! empty($CFG->enrol_flatfileallowinternal) ) {
+    if (! empty($CFG->enrol_allowinternal) ) {
         parent::check_entry($form, $course);
     }
 }
@@ -104,8 +87,73 @@ function get_access_icons($course) {
 }
 
 
+/// Overrise the base config_form() function
+function config_form($frm) {
+    global $CFG;
+    include("$CFG->dirroot/enrol/database/config.html");
+}
+
+/// Override the base process_config() function
+function process_config($config) {
+
+    if (!isset($config->enrol_dbtype)) {
+        $config->enrol_dbtype = 'mysql';
+    }
+    set_config('enrol_dbtype', $config->enrol_dbtype);
+
+    if (!isset($config->enrol_dbhost)) {
+        $config->enrol_dbhost = '';
+    }
+    set_config('enrol_dbhost', $config->enrol_dbhost);
+
+    if (!isset($config->enrol_dbuser)) {
+        $config->enrol_dbuser = '';
+    }
+    set_config('enrol_dbuser', $config->enrol_dbuser);
 
+    if (!isset($config->enrol_dbpass)) {
+        $config->enrol_dbpass = '';
+    }
+    set_config('enrol_dbpass', $config->enrol_dbpass);
 
+    if (!isset($config->enrol_dbname)) {
+        $config->enrol_dbname = '';
+    }
+    set_config('enrol_dbname', $config->enrol_dbname);
+
+    if (!isset($config->enrol_dbtable)) {
+        $config->enrol_dbtable = '';
+    }
+    set_config('enrol_dbtable', $config->enrol_dbtable);
+
+    if (!isset($config->enrol_localcoursefield)) {
+        $config->enrol_localcoursefield = '';
+    }
+    set_config('enrol_localcoursefield', $config->enrol_localcoursefield);
+
+    if (!isset($config->enrol_localuserfield)) {
+        $config->enrol_localuserfield = '';
+    }
+    set_config('enrol_localuserfield', $config->enrol_localuserfield);
+
+    if (!isset($config->enrol_remotecoursefield)) {
+        $config->enrol_remotecoursefield = '';
+    }
+    set_config('enrol_remotecoursefield', $config->enrol_remotecoursefield);
+
+    if (!isset($config->enrol_remoteuserfield)) {
+        $config->enrol_remoteuserfield = '';
+    }
+    set_config('enrol_remoteuserfield', $config->enrol_remoteuserfield);
+
+    if (!isset($config->enrol_allowinternal)) {
+        $config->enrol_allowinternal = '';
+    }
+    set_config('enrol_allowinternal', $config->enrol_allowinternal);
+    
+    return true;
+
+}
 
 
 } // end of class
index 602f25a93bbd7693f1f218c2912df36d3c0fce17..2576510383d256b5c08b19de76407133dae32a29 100644 (file)
@@ -246,9 +246,7 @@ function check_entry($form, $course) {
 * @param    page  an object containing all the data for this page
 */
 function config_form($page) {
-
-    return "";
-
+    
 }
 
 
@@ -261,8 +259,17 @@ function config_form($page) {
 */
 function process_config($config) {
 
-    return true;
+    $return = true;
+
+    print_object($config);
+
+    foreach ($config as $name => $value) {
+        if (!set_config($name, $value)) {
+            $return = false;
+        }
+    }
 
+    return $return;
 }
 
 
diff --git a/enrol/flatfile/config.html b/enrol/flatfile/config.html
new file mode 100644 (file)
index 0000000..2002d0b
--- /dev/null
@@ -0,0 +1,53 @@
+<table cellspacing="0" cellpadding="5" border="0" align="center">
+
+<tr valign="top">
+       <td align="right"><p>enrol_flatfilelocation:</p></td>
+       <td>
+        <input type="text" size="20" name="enrol_flatfilelocation" value="<?php echo $frm->enrol_flatfilelocation ?>" />
+    </td>
+    <td>
+    <?php  print_string("location", "enrol_flatfile") ?>
+    </td>
+</tr>
+
+<tr valign="top">
+       <td align="right"><p>enrol_mailstudents:</p></td>
+       <td>
+        <input type="checkbox" value=1 name="enrol_mailstudents" <?php if ($frm->enrol_mailstudents) echo "checked=\"true\"" ?> />
+    </td>
+    <td>
+    <?php  print_string("mailstudents") ?>
+    </td>
+</tr>
+
+<tr valign="top">
+       <td align="right"><p>enrol_mailteachers:</p></td>
+       <td>
+        <input type="checkbox" value=1 name="enrol_mailteachers" <?php if ($frm->enrol_mailteachers) echo "checked=\"true\"" ?> />
+    </td>
+    <td>
+    <?php  print_string("mailteachers") ?>
+    </td>
+</tr>
+
+<tr valign="top">
+       <td align="right"><p>enrol_mailadmins:</p></td>
+       <td>
+        <input type="checkbox" value=1 name="enrol_mailadmins" <?php if ($frm->enrol_mailadmins) echo "checked=\"true\"" ?> />
+    </td>
+    <td>
+    <?php  print_string("mailadmins") ?>
+    </td>
+</tr>
+
+<tr valign="top">
+       <td align="right"><p>enrol_allowinternal:</p></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 73f58f7ddb5e7b5c4d21934eb402142a86c3425b..e26cef732ea565836cf91621b28d3bcf3189f196 100644 (file)
@@ -3,10 +3,10 @@ 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_flatfilemailusers:      send email to users when they are enrolled in a course
-// $CFG->enrol_flatfilemailadmin:      email the log from the cron job to the admin
-// $CFG->enrol_flatfileallowinternal:  allow internal enrolment in courses
-
+// $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
 
 
 
@@ -18,7 +18,7 @@ class enrolment_plugin extends enrolment_base {
 function print_entry($course) {
     global $CFG;
 
-    if (! empty($CFG->enrol_flatfileallowinternal) ) {
+    if (! empty($CFG->enrol_allowinternal) ) {
         parent::print_entry($course);
     } else {
         print_header();
@@ -31,12 +31,50 @@ function print_entry($course) {
 function check_entry($form, $course) {
     global $CFG;
 
-    if (! empty($CFG->enrol_flatfileallowinternal) ) {
+    if (! empty($CFG->enrol_allowinternal) ) {
         parent::check_entry($form, $course);
     }
 }
 
 
+/// Override the base config_form() function
+function config_form($frm) {
+    global $CFG;
+    include ("$CFG->dirroot/enrol/flatfile/config.html");    
+}
+
+
+/// Override the base process_config() function
+function process_config($config) {
+
+    if (!isset($config->enrol_flatfilelocation)) {
+        $config->enrol_flatfilelocation = '';
+    }
+    set_config('enrol_flatfilelocation', $config->enrol_flatfilelocation);
+
+    if (!isset($config->enrol_mailstudents)) {
+        $config->enrol_mailstudents = '';
+    }
+    set_config('enrol_mailstudents', $config->enrol_mailstudents);
+
+    if (!isset($config->enrol_mailteachers)) {
+        $config->enrol_mailteachers = '';
+    }
+    set_config('enrol_mailteachers', $config->enrol_mailteachers);
+
+    if (!isset($config->enrol_mailadmins)) {
+        $config->enrol_mailadmins = '';
+    }
+    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 base cron() function to read in a file
@@ -181,12 +219,8 @@ function check_entry($form, $course) {
 
 
 
-                    if ( (! empty($CFG->enrol_flatfilemailusers)) and empty($elog) and ($fields[0] == "add") ) {
-                        $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 ( empty($elog) and ($fields[0] == "add") ) {
+   
                         if ($fields[1] == "student") {
                             if (! $teacher = get_teacher($course->id)) {
                                 $teacher = get_admin();
@@ -195,9 +229,20 @@ function check_entry($form, $course) {
                             $teacher = get_admin();
                         }
 
-                        email_to_user($user, $teacher, $subject, $message);
-                    }
+                        if (!empty($CFG->enrol_mailstudents)) {
+                            $a->coursename = "$course->fullname";
+                            $a->profileurl = "$CFG->wwwroot/user/view.php?id=$user->id&course=$course->id";
+                            email_to_user($user, $teacher, get_string("enrolmentnew", '', $course->shortname), 
+                                          get_string('welcometocoursetext', '', $a));
+                        }
 
+                        if (!empty($CFG->enrol_mailteachers)) {
+                            $a->course = "$course->fullname";
+                            $a->user = fullname($user);
+                            email_to_user($teacher, $user, get_string("enrolmentnew", '', $course->shortname), 
+                                          get_string('enrolmentnewuser', '', $a));
+                        }
+                    }
 
 
                     if (empty($elog)) {
@@ -215,7 +260,7 @@ function check_entry($form, $course) {
                 $this->log .= "Error unlinking file $filename\n";
             }
 
-            if (! empty($CFG->enrol_flatfilemailadmin)) {
+            if (!empty($CFG->enrol_mailadmins)) {
                 email_to_user(get_admin(), get_admin(), "Flatfile Enrolment Log", $this->log);
             }
 
diff --git a/enrol/paypal/config.html b/enrol/paypal/config.html
new file mode 100644 (file)
index 0000000..5e72888
--- /dev/null
@@ -0,0 +1,63 @@
+<table cellspacing="0" cellpadding="5" border="0" align="center">
+
+<tr valign="top">
+       <td align="right"><p>enrol_cost:</p></td>
+       <td>
+        <input type="text" size="5" name="enrol_cost" value="<?php echo $frm->enrol_cost ?>" />
+    </td>
+    <td>
+    <?php  print_string("costdefault") ?>
+    </td>
+</tr>
+
+<tr valign="top">
+       <td align="right"><p>enrol_currency:</p></td>
+       <td>
+    <?php choose_from_menu ($paypalcurrencies, "enrol_currency", $frm->enrol_currency, "","", "") ?>
+    </td>
+    <td>
+    <?php  print_string("currency") ?>
+    </td>
+</tr>
+
+<tr valign="top">
+       <td align="right"><p>enrol_paypalbusiness:</p></td>
+       <td>
+        <input type="text" name="enrol_paypalbusiness" value="<?php echo $frm->enrol_paypalbusiness ?>" />
+    </td>
+    <td>
+    <?php  print_string("business", "enrol_paypal") ?>
+    </td>
+</tr>
+
+<tr valign="top">
+       <td align="right"><p>enrol_mailstudents:</p></td>
+       <td>
+        <input type="checkbox" value=1 name="enrol_mailstudents" <?php if ($frm->enrol_mailstudents) echo "checked=\"true\"" ?> />
+    </td>
+    <td>
+    <?php  print_string("mailstudents") ?>
+    </td>
+</tr>
+
+<tr valign="top">
+       <td align="right"><p>enrol_mailteachers:</p></td>
+       <td>
+        <input type="checkbox" value=1 name="enrol_mailteachers" <?php if ($frm->enrol_mailteachers) echo "checked=\"true\"" ?> />
+    </td>
+    <td>
+    <?php  print_string("mailteachers") ?>
+    </td>
+</tr>
+
+<tr valign="top">
+       <td align="right"><p>enrol_mailadmins:</p></td>
+       <td>
+        <input type="checkbox" value=1 name="enrol_mailadmins" <?php if ($frm->enrol_mailadmins) echo "checked=\"true\"" ?> />
+    </td>
+    <td>
+    <?php  print_string("mailadmins") ?>
+    </td>
+</tr>
+
+</table>
index 7d59f3ad2dd911fdf7985115a65a41877dbd1b05..71dcd939981d352386ee443be882e25907103840 100644 (file)
@@ -1,7 +1,7 @@
 <div align="center">
 
 <p><?php print_string("paymentrequired") ?></p>
-<p><b><?php echo get_string("cost").": $CFG->enrol_paypalcurrency $cost"; ?></b></p>
+<p><b><?php echo get_string("cost").": $CFG->enrol_currency $cost"; ?></b></p>
 <p><?php print_string("paymentinstant") ?></p>
         
 <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
@@ -15,7 +15,7 @@
 <input type="hidden" name="os0" value="<?php echo fullname($USER) ?>">
 <input type="hidden" name="custom" value="<?php echo "$USER->id-$course->id" ?>">
 
-<input type="hidden" name="currency_code" value="<?php p($CFG->enrol_paypalcurrency) ?>">
+<input type="hidden" name="currency_code" value="<?php p($CFG->enrol_currency) ?>">
 <input type="hidden" name="amount" value="<?php p($cost) ?>">
 
 <input type="hidden" name="for_auction" value="false">
index 5c0790f762b7266845a978b1c498b341f5c646d5..a322f930637e50a427373a179a008b032d80b346 100644 (file)
@@ -1,4 +1,5 @@
-<?php
+<?php  // $Id$
+       // Implements all the main code for the Paypal plugin
 
 require_once("$CFG->dirroot/enrol/enrol.class.php");
 
@@ -40,7 +41,6 @@ function print_entry($course) {
 
 
         include("$CFG->dirroot/enrol/paypal/enrol.html");
-        echo "</div>";
 
         print_simple_box_end();
         print_footer();
@@ -78,11 +78,11 @@ function get_access_icons($course) {
         $strrequirespayment = get_string("requirespayment");
         $strcost = get_string("cost");
 
-        if (empty($CFG->enrol_paypalcurrency)) {
-            $CFG->enrol_paypalcurrency = 'USD';
+        if (empty($CFG->enrol_currency)) {
+            set_config('enrol_currency', 'USD');
         }
 
-        switch ($CFG->enrol_paypalcurrency) {
+        switch ($CFG->enrol_currency) {
            case 'EUR': $currency = '&euro;'; break;
            case 'CAD': $currency = '$'; break;
            case 'GBP': $currency = '&pound;'; break;
@@ -90,7 +90,8 @@ function get_access_icons($course) {
            default:    $currency = '$'; break;
         }
         
-        $str .= "<p>$strcost: <a title=\"$strrequirespayment\" href=\"$CFG->wwwroot/course/view.php?id=$course->id\">";
+        $str .= "<p class=\"coursecost\"><font size=-1>$strcost: ".
+                "<a title=\"$strrequirespayment\" href=\"$CFG->wwwroot/course/view.php?id=$course->id\"></a>";
         $str .= "$currency".format_float($cost,2).'</a></p>';
         
     }
@@ -99,5 +100,55 @@ function get_access_icons($course) {
 }
 
 
+/// Override the base class config_form() function
+function config_form($frm) {
+    global $CFG;
+
+    $paypalcurrencies = array(  'USD' => 'US Dollars',
+                                'EUR' => 'Euros',
+                                'JPY' => 'Japanese Yen',
+                                'GBP' => 'British Pounds',
+                                'CAD' => 'Canadian Dollars'
+                             );
+
+    include("$CFG->dirroot/enrol/paypal/config.html");
+}
+
+function process_config($config) {
+
+    if (!isset($config->enrol_cost)) {
+        $config->enrol_cost = 0;
+    }
+    set_config('enrol_cost', $config->enrol_cost);
+
+    if (!isset($config->enrol_currency)) {
+        $config->enrol_currency = 'USD';
+    }
+    set_config('enrol_currency', $config->enrol_currency);
+
+    if (!isset($config->enrol_paypalbusiness)) {
+        $config->enrol_paypalbusiness = '';
+    }
+    set_config('enrol_paypalbusiness', $config->enrol_paypalbusiness);
+
+    if (!isset($config->enrol_mailstudents)) {
+        $config->enrol_mailstudents = '';
+    }
+    set_config('enrol_mailstudents', $config->enrol_mailstudents);
+
+    if (!isset($config->enrol_mailteachers)) {
+        $config->enrol_mailteachers = '';
+    }
+    set_config('enrol_mailteachers', $config->enrol_mailteachers);
+
+    if (!isset($config->enrol_mailadmins)) {
+        $config->enrol_mailadmins = '';
+    }
+    set_config('enrol_mailadmins', $config->enrol_mailadmins);
+    
+    return true;
+
+}
+
 
 } // end of class definition
index f12609f2e77a75ffa88f0a02727a2126964ef88a..1212bed72bd4ff2d0d348fb4d473c33f99d6e799 100644 (file)
             } else {
                 $teacher = get_teacher($course->id);
 
-                if (!empty($CFG->enrol_paypalmailstudents)) {
+                if (!empty($CFG->enrol_mailstudents)) {
                     $a->coursename = "$course->fullname";
                     $a->profileurl = "$CFG->wwwroot/user/view.php?id=$user->id";
-                    email_to_user($user, $teacher, get_string("enrolmentnew", '', $course->shortname), get_string('welcometocoursetext', '', $a));
+                    email_to_user($user, $teacher, get_string("enrolmentnew", '', $course->shortname), 
+                                  get_string('welcometocoursetext', '', $a));
                 }
 
-                if (!empty($CFG->enrol_paypalmailteachers)) {
-                    email_to_user($teacher, $user, get_string("enrolmentnew", '', $course->shortname), "I have enrolled in your class via Paypal");
+                if (!empty($CFG->enrol_mailteachers)) {
+                    $a->course = "$course->fullname";
+                    $a->user = fullname($user);
+                    email_to_user($teacher, $user, get_string("enrolmentnew", '', $course->shortname), 
+                                  get_string('enrolmentnewuser', '', $a));
                 }
+
+                if (!empty($CFG->enrol_mailadmins)) {
+                    $a->course = "$course->fullname";
+                    $a->user = fullname($user);
+                    $admins = get_admins();
+                    foreach ($admins as $admin) {
+                        email_to_user($admin, $user, get_string("enrolmentnew", '', $course->shortname), 
+                                      get_string('enrolmentnewuser', '', $a));
+                    }
+                }
+
             }
 
 
diff --git a/lang/en/enrol_database.php b/lang/en/enrol_database.php
new file mode 100755 (executable)
index 0000000..9576a38
--- /dev/null
@@ -0,0 +1,17 @@
+<?PHP // $Id$ 
+
+$string['enrolname'] = 'External Database';
+
+$string['description'] = 'You can use a external database (of nearly any kind) to control your enrolments.  It is assumed your external database contains a field containing a course ID, and a field containing a user ID.  These are compared against fields that you choose in the local course and user tables.';
+$string['dbtype'] = 'Database server type';
+$string['dbhost'] = 'Database server hostname ';
+$string['dbuser'] = 'Username to access the server';
+$string['dbpass'] = 'Password to access the server';
+$string['dbname'] = 'The specific database to use';
+$string['dbtable'] = 'The table in that database';
+$string['localcoursefield'] = 'The name of the field in the course table that we are using to match entries in the remote database (eg idnumber)';
+$string['localuserfield'] = 'The name of the field in the local user table that we use to match the user to a remote record (eg idnumber)';
+$string['remotecoursefield'] = 'The field in the remote database we expect to find the course ID in';
+$string['remoteuserfield'] = 'The field in the remote database we expect to find the user ID in';
+
+?>
index 0f42669fe943683182aa537a759d2b4a90e98d6a..c026da664bf4ddd8a77f3555d957fb38138d5b0e 100644 (file)
@@ -1,7 +1,22 @@
 <?PHP // $Id$ 
 
 $string['enrolname'] = 'Flat file';
+
+$string['description'] = 'This method will repeatedly check for and process a specially-formatted text file in the location that you specify.  The file can look something like this: 
+<pre>
+   add, student, 5, CF101
+   add, teacher, 6, CF101
+   add, teacheredit, 7, CF101
+   del, student, 8, CF101
+   del, student, 17, CF101
+   add, student, 21, CF101, 1091115000, 1091215000
+</pre>
+';
+
 $string['filelockedmailsubject'] = 'Important error: Enrolment file';
 $string['filelockedmail'] = 'The text file you are using for file-based enrolments ($a) can not be deleted by the cron process.  This usually means the permissions are wrong on it.  Please fix the permissions so that Moodle can delete the file, otherwise it might be processed repeatedly.';
+$string['location'] = 'File location';
+$string['mailusers'] = 'Notify users by email';
+$string['mailadmin'] = 'Notify admin by email';
 
 ?>
index ad7139c42c8e99433d2f4b6936a9ce7e716b6fac..0f992b0ced16acdc5c66127593f831ad1c3942cb 100644 (file)
@@ -2,4 +2,12 @@
 
 $string['enrolname'] = 'Internal Enrolment';
 
+$string['description'] = 'This is the default form of enrolment. There are two main ways a student can be enrolled in a particular course.
+<ul>
+<li>A teacher or admin can enrol them manually using the link in the Course Administration menu 
+    within the course.</li>
+<li>A course can have a password defined, known as an \"enrolment key\".  Anyone who knows this key is 
+    able to add themselves to a course.</li>
+</ul>';
+
 ?>
index 71baabb6dfd058ba0525670ea873c335cf7e10ee..95fe7d67862694e3eda6c9c3da73d0c36a012c5e 100644 (file)
@@ -1,6 +1,10 @@
 <?PHP // $Id$ 
 
 $string['enrolname'] = 'Paypal';
+$string['description'] = 'The Paypal module allows you to set up paid courses.  If the cost for any course is zero, then students are not asked to pay for entry.  There is a site-wide cost that you set here as a default for the whole site and then a course setting that you can set for each course individually. The course cost overrides the site cost.';
+$string['business'] = 'The email address of your business Paypal account';
 $string['sendpaymentbutton'] = 'Send payment via Paypal';
 
+
+
 ?>
index 6baf2f1b53a6a2b8f1be853cc37cebc69392cf5a..ba5a815ec017acda14aa4375b59dc67f5ca7268c 100755 (executable)
@@ -12,7 +12,7 @@ $string['admindirsetting'] = "
 $string['caution'] = 'Caution';\r
 $string['chooselanguage'] = 'Choose a language';\r
 $string['compatibilitysettings'] = 'Checking your PHP settings ...';\r
-$string['configfilenotwritten'] = "The installer script was not able to automatically create a config.php file containing your chosen settings. Please copy the following code into a file named config.php within the root directory of Moodle.";\r
+$string['configfilenotwritten'] = "The installer script was not able to automatically create a config.php file containing your chosen settings, probably because the Moodle directory is not writeable. You can manually copy the following code into a file named config.php within the root directory of Moodle.";\r
 $string['configfilewritten'] = "config.php has been successfully created";\r
 $string['configurationcomplete'] = 'Configuration completed';\r
 \r
index 8dda36bc33a14e95c2f765e32f1141f5d23a2d36..46e39bdc14288a2d96847321c53ac4c63c12e972 100644 (file)
@@ -69,6 +69,7 @@ $string['allgroups'] = 'All groups';
 $string['alllogs'] = 'All logs';
 $string['allow'] = 'Allow';
 $string['allowguests'] = 'This course allows guest users to enter';
+$string['allowinternal'] = 'Allow internal methods as well';
 $string['allownot'] = 'Do not allow';
 $string['allparticipants'] = 'All participants';
 $string['alphabet'] = 'A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z';
@@ -132,6 +133,7 @@ $string['checkingsections'] = 'Checking sections';
 $string['checklanguage'] = 'Check language';
 $string['choose'] = 'Choose';
 $string['choosecourse'] = 'Choose a course';
+$string['chooseenrolmethod'] = 'Primary method of enrolment';
 $string['chooselivelogs'] = 'Or watch current activity';
 $string['chooselogs'] = 'Choose which logs you want to see';
 $string['choosereportfilter'] = 'Choose a filter for the report';
@@ -205,6 +207,7 @@ $string['copyinguserfiles'] = 'Copying user files';
 $string['copyingzipfile'] = 'Copying zip file';
 $string['copyrightnotice'] = 'Copyright notice';
 $string['cost'] = 'Cost';
+$string['costdefault'] = 'Default cost';
 $string['country'] = 'Country';
 $string['course'] = 'Course';
 $string['courseavailable'] = 'This course is available to students';
@@ -237,6 +240,7 @@ $string['creatingsections'] = 'Creating sections';
 $string['creatingtemporarystructures'] = 'Creating temporary structures';
 $string['creatingusers'] = 'Creating users';
 $string['creatingxmlfile'] = 'Creating XML file';
+$string['currency'] = 'Currency';
 $string['currentcourseadding'] = 'Current course, adding data to it';
 $string['currentcoursedeleting'] = 'Current course, deleting it first';
 $string['currentlanguage'] = 'Current language';
@@ -381,6 +385,7 @@ password that you should have received from $a';
 $string['enrolmentkeyhint'] = 'That enrolment key was incorrect, please try again<BR>
 (Here\'s a hint - it starts with \'$a\')';
 $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['enrolments'] = 'Enrolments';
@@ -590,6 +595,9 @@ $string['loginto'] = 'Login to $a';
 $string['loginusing'] = 'Login here using your username and password';
 $string['logout'] = 'Logout';
 $string['logs'] = 'Logs';
+$string['mailstudents'] = 'Inform students';
+$string['mailteachers'] = 'Inform teachers';
+$string['mailadmins'] = 'Inform admins';
 $string['mainmenu'] = 'Main menu';
 $string['makeafolder'] = 'Make a folder';
 $string['makeeditable'] = 'If you make \'$a\' editable by the web server process (eg apache) then you could edit this file directly from this page';