diff --git a/apply_form.php b/apply_form.php
index 553d09c..77bc667 100644
--- a/apply_form.php
+++ b/apply_form.php
@@ -72,14 +72,11 @@ class enrol_apply_apply_form extends moodleform {
$apply_setting = $DB->get_records_sql("select name,value from ".$CFG->prefix."config_plugins where plugin='enrol_apply'");
- ($instance->customint1 == 0)?$show_standard_user_profile = true:$show_standard_user_profile = false;
- ($instance->customint2 == 0)?$show_extra_user_profile = true:$show_extra_user_profile = false;
-
- if($show_standard_user_profile){
+ if($instance->customint1){
useredit_shared_definition($mform, $editoroptions, $filemanageroptions,$user);
}
- if($show_extra_user_profile){
+ if($instance->customint2){
profile_definition($mform, $user->id);
}
diff --git a/db/upgrade.php b/db/upgrade.php
index 93b7df0..c402af8 100644
--- a/db/upgrade.php
+++ b/db/upgrade.php
@@ -51,6 +51,22 @@ function xmldb_enrol_apply_upgrade($oldversion) {
upgrade_plugin_savepoint(true, 2016012801, 'enrol', 'apply');
}
+ if ($oldversion < 2016042202) {
+ // Invert settings for showing standard and extra user profile fields.
+ $enrolapply = enrol_get_plugin('apply');
+ $showstandarduserprofile = $enrolapply->get_config('show_standard_user_profile') == 0 ? true : false;
+ $enrolapply->set_config('show_standard_user_profile', $showstandarduserprofile);
+ $showextrauserprofile = $enrolapply->get_config('show_extra_user_profile') == 0 ? true : false;
+ $enrolapply->set_config('show_extra_user_profile', $showextrauserprofile);
+
+ $instances = $DB->get_records('enrol', array('enrol' => 'apply'));
+ foreach ($instances as $instance) {
+ $instance->customint1 = !$instance->customint1;
+ $instance->customint2 = !$instance->customint2;
+ $DB->update_record('enrol', $instance, true);
+ }
+ }
+
return true;
}
\ No newline at end of file
diff --git a/edit_form.php b/edit_form.php
index 07b7466..ed97deb 100644
--- a/edit_form.php
+++ b/edit_form.php
@@ -26,8 +26,8 @@ class enrol_self_edit_form extends moodleform {
$mform->addElement('text', 'name', get_string('custominstancename', 'enrol'));
$mform->setType('name', PARAM_TEXT);
- $options = array(ENROL_INSTANCE_ENABLED => get_string('yes'),
- ENROL_INSTANCE_DISABLED => get_string('no'));
+ $options = array(1 => get_string('yes'),
+ 0 => get_string('no'));
$mform->addElement('select', 'status', get_string('status', 'enrol_apply'), $options);
//$mform->addHelpButton('status', 'status', 'enrol_apply');
$mform->setDefault('status', $plugin->get_config('status'));
diff --git a/lang/en/enrol_apply.php b/lang/en/enrol_apply.php
index 371e691..d71d897 100644
--- a/lang/en/enrol_apply.php
+++ b/lang/en/enrol_apply.php
@@ -14,16 +14,32 @@ $string['enrolname'] = 'Course enrol confirmation';
$string['pluginname'] = 'Course enrol confirmation';
$string['pluginname_desc'] = 'With this plug-in users can apply to be enrolled in a course. A teacher or site manager will then have to approve the enrolment before the user gets enroled.';
+$string['confirmmail_heading'] = 'Confirmation email';
+$string['confirmmail_desc'] = '';
$string['confirmmailsubject'] = 'Confirmation email subject';
+$string['confirmmailsubject_desc'] = '';
$string['confirmmailcontent'] = 'Confirmation email content';
+$string['confirmmailcontent_desc'] = 'Please use the following special marks to replace email content with data from Moodle.
{firstname}:The first name of the user; {content}:The course name;{lastname}:The last name of the user;{username}:The users registration username';
+
+$string['waitmail_heading'] = 'Waiting list email';
+$string['waitmail_desc'] = '';
$string['waitmailsubject'] = 'Waiting list mail subject';
+$string['waitmailsubject_desc'] = '';
$string['waitmailcontent'] = 'Waiting list mail content';
+$string['waitmailcontent_desc'] = 'Please use the following special marks to replace email content with data from Moodle.
{firstname}:The first name of the user; {content}:The course name;{lastname}:The last name of the user;{username}:The users registration username';
+
+$string['cancelmail_heading'] = 'Cancelation email';
+$string['cancelmail_desc'] = '';
$string['cancelmailsubject'] = 'Cancelation email subject';
+$string['cancelmailsubject_desc'] = '';
$string['cancelmailcontent'] = 'Cancelation email content';
-$string['confirmmailcontent_desc'] = 'Please use the following special marks to replace email content with data from Moodle.
{firstname}:The first name of the user; {content}:The course name;{lastname}:The last name of the user;{username}:The users registration username';
-$string['waitmailcontent_desc'] = 'Please use the following special marks to replace email content with data from Moodle.
{firstname}:The first name of the user; {content}:The course name;{lastname}:The last name of the user;{username}:The users registration username';
$string['cancelmailcontent_desc'] = 'Please use the following special marks to replace email content with data from Moodle.
{firstname}:The first name of the user; {content}:The course name;{lastname}:The last name of the user;{username}:The users registration username';
+$string['notify_heading'] = 'Notification settings';
+$string['notify_desc'] = 'Define who gets notified about new enrolment applications.';
+$string['sendmailtoteacher'] = 'Send email notification to teachers';
+$string['sendmailtomanager'] = 'Send email notification to managers';
+
$string['confirmusers'] = 'Enrol Confirm';
$string['confirmusers_desc'] = 'Users in gray colored rows are on the waiting list.';
@@ -49,8 +65,7 @@ $string['apply:unenrolself'] = 'Cancel self from the course';
$string['notification'] = 'Enrolment application successfully sent.
You will be informed by email when your enrolment has been confirmed.';
-$string['sendmailtoteacher'] = 'Send email notification to teachers';
-$string['sendmailtomanager'] = 'Send email notification to managers';
+
$string['mailtoteacher_suject'] = 'New Enrolment request!';
$string['editdescription'] = 'Textarea description';
$string['comment'] = 'Comment';
diff --git a/lib.php b/lib.php
index 3a4bdbe..f68076d 100644
--- a/lib.php
+++ b/lib.php
@@ -295,9 +295,6 @@ function sendConfirmMailToTeachers($instance,$info,$applydescription){
$courseid = $instance->courseid;
$instanceid = $instance->id;
- ($instance->customint1 == 0)?$show_standard_user_profile = true:$show_standard_user_profile = false;
- ($instance->customint2 == 0)?$show_extra_user_profile = true:$show_extra_user_profile = false;
-
if($instance->customint3 == 1){
$course = get_course($courseid);
$context = context_course::instance($courseid, MUST_EXIST);
@@ -309,7 +306,7 @@ function sendConfirmMailToTeachers($instance,$info,$applydescription){
$body .= '
'. get_string('applyuser', 'enrol_apply') .': '.$USER->firstname.' '.$USER->lastname.'
'; $body .= ''. get_string('comment', 'enrol_apply') .': '.$applydescription.'
'; - if($show_standard_user_profile){ + if($instance->customint1){ $body .= ''. get_string('user_profile', 'enrol_apply').'
'; $body .= ''. get_string('firstname') .': '.$info->firstname.'
'; $body .= ''. get_string('lastname') .': '.$info->lastname.'
'; @@ -337,7 +334,7 @@ function sendConfirmMailToTeachers($instance,$info,$applydescription){ $body .= ''. get_string('address') .': '.$info->address.'
'; } - if($show_extra_user_profile){ + if($instance->customint2){ require_once($CFG->dirroot.'/user/profile/lib.php'); $user = $DB->get_record('user',array('id'=>$USER->id)); profile_load_custom_fields($user); @@ -362,9 +359,6 @@ function sendConfirmMailToManagers($instance,$info,$applydescription){ $courseid = $instance->courseid; - ($instance->customint1 == 0)?$show_standard_user_profile = true:$show_standard_user_profile = false; - ($instance->customint2 == 0)?$show_extra_user_profile = true:$show_extra_user_profile = false; - if(get_config('enrol_apply', 'sendmailtomanager') == 1){ $course = get_course($courseid); $context = context_system::instance(); @@ -375,7 +369,7 @@ function sendConfirmMailToManagers($instance,$info,$applydescription){ $body = ''. get_string('coursename', 'enrol_apply') .': '.format_string($course->fullname).'
'; $body .= ''. get_string('applyuser', 'enrol_apply') .': '.$USER->firstname.' '.$USER->lastname.'
'; $body .= ''. get_string('comment', 'enrol_apply') .': '.$applydescription.'
'; - if($show_standard_user_profile){ + if($instance->customint1){ $body .= ''. get_string('user_profile', 'enrol_apply').'
'; $body .= ''. get_string('firstname') .': '.$info->firstname.'
'; $body .= ''. get_string('lastname') .': '.$info->lastname.'
'; @@ -403,7 +397,7 @@ function sendConfirmMailToManagers($instance,$info,$applydescription){ $body .= ''. get_string('address') .': '.$info->address.'
'; } - if($show_extra_user_profile){ + if($instance->customint2){ require_once($CFG->dirroot.'/user/profile/lib.php'); $user = $DB->get_record('user',array('id'=>$USER->id)); profile_load_custom_fields($user); diff --git a/settings.php b/settings.php index ed85bbb..33a0836 100644 --- a/settings.php +++ b/settings.php @@ -13,48 +13,102 @@ defined('MOODLE_INTERNAL') || die(); if ($ADMIN->fulltree) { - //--- general settings ----------------------------------------------------------------------------------- $settings->add(new admin_setting_heading('enrol_apply_enrolname','',get_string('pluginname_desc', 'enrol_apply'))); - $settings->add(new admin_setting_configtext('enrol_apply/confirmmailsubject','',get_string('confirmmailsubject', 'enrol_apply'),null,PARAM_TEXT,60)); + // Confirm mail settings. + $settings->add(new admin_setting_heading( + 'enrol_apply_confirmmail', + get_string('confirmmail_heading', 'enrol_apply'), + get_string('confirmmail_desc', 'enrol_apply'))); + $settings->add(new admin_setting_configtext( + 'enrol_apply/confirmmailsubject', + get_string('confirmmailsubject', 'enrol_apply'), + get_string('confirmmailsubject_desc', 'enrol_apply'), + null, + PARAM_TEXT, + 60)); + $settings->add(new admin_setting_confightmleditor( + 'enrol_apply/confirmmailcontent', + get_string('confirmmailcontent', 'enrol_apply'), + get_string('confirmmailcontent_desc', 'enrol_apply'), + null, + PARAM_TEXT)); - $settings->add(new admin_setting_heading('enrol_apply_confirmmailcontent', '', get_string('confirmmailcontent_desc', 'enrol_apply'))); - $settings->add(new admin_setting_confightmleditor('enrol_apply/confirmmailcontent', get_string('confirmmailcontent', 'enrol_apply'),'utf-8','')); - - $settings->add(new admin_setting_configtext('enrol_apply/waitmailsubject','',get_string('waitmailsubject', 'enrol_apply'),null,PARAM_TEXT,60)); + // Wait mail settings. + $settings->add(new admin_setting_heading( + 'enrol_apply_waitmail', + get_string('waitmail_heading', 'enrol_apply'), + get_string('waitmail_desc', 'enrol_apply'))); + $settings->add(new admin_setting_configtext( + 'enrol_apply/waitmailsubject', + get_string('waitmailsubject', 'enrol_apply'), + get_string('waitmailsubject_desc', 'enrol_apply'), + null, + PARAM_TEXT, + 60)); + $settings->add(new admin_setting_confightmleditor( + 'enrol_apply/waitmailcontent', + get_string('waitmailcontent', 'enrol_apply'), + get_string('waitmailcontent_desc', 'enrol_apply'), + null, + PARAM_TEXT)); - $settings->add(new admin_setting_heading('enrol_apply_waitmailcontent', '', get_string('waitmailcontent_desc', 'enrol_apply'))); - $settings->add(new admin_setting_confightmleditor('enrol_apply/waitmailcontent', get_string('waitmailcontent', 'enrol_apply'),'utf-8','')); + // Cancel mail settings + $settings->add(new admin_setting_heading( + 'enrol_apply_cancelmail', + get_string('cancelmail_heading', 'enrol_apply'), + get_string('cancelmail_desc', 'enrol_apply'))); + $settings->add(new admin_setting_configtext( + 'enrol_apply/cancelmailsubject', + get_string('cancelmailsubject', 'enrol_apply'), + get_string('cancelmailsubject_desc', 'enrol_apply'), + null, + PARAM_TEXT, + 60)); + $settings->add(new admin_setting_confightmleditor( + 'enrol_apply/cancelmailcontent', + get_string('cancelmailcontent', 'enrol_apply'), + get_string('cancelmailcontent_desc', 'enrol_apply'), + null, + PARAM_TEXT)); - $settings->add(new admin_setting_configtext('enrol_apply/cancelmailsubject','',get_string('cancelmailsubject', 'enrol_apply'),null,PARAM_TEXT,60)); + // Notification settings. + $settings->add(new admin_setting_heading( + 'enrol_apply_notify', + get_string('notify_heading', 'enrol_apply'), + get_string('notify_desc', 'enrol_apply'))); + $settings->add(new admin_setting_configcheckbox( + 'enrol_apply/sendmailtoteacher', + get_string('sendmailtoteacher', 'enrol_apply'), + '', + 0)); + $settings->add(new admin_setting_configcheckbox( + 'enrol_apply/sendmailtomanager', + get_string('sendmailtomanager', 'enrol_apply'), + '', + 0)); - $settings->add(new admin_setting_heading('enrol_apply_cancelmailcontent', '', get_string('cancelmailcontent_desc', 'enrol_apply'))); - $settings->add(new admin_setting_confightmleditor('enrol_apply/cancelmailcontent', get_string('cancelmailcontent', 'enrol_apply'),'utf-8','')); - - $settings->add(new admin_setting_configcheckbox('enrol_apply/sendmailtoteacher', get_string('sendmailtoteacher', 'enrol_apply'), '', 0)); - $settings->add(new admin_setting_configcheckbox('enrol_apply/sendmailtomanager', get_string('sendmailtomanager', 'enrol_apply'), '', 0)); - - //--- enrol instance defaults ---------------------------------------------------------------------------- + // Enrol instance defaults. $settings->add(new admin_setting_heading('enrol_manual_defaults', get_string('enrolinstancedefaults', 'admin'), get_string('enrolinstancedefaults_desc', 'admin'))); - + $settings->add(new admin_setting_configcheckbox('enrol_apply/defaultenrol', get_string('defaultenrol', 'enrol'), get_string('defaultenrol_desc', 'enrol'), 0)); - + $options = array(ENROL_INSTANCE_ENABLED => get_string('yes'), ENROL_INSTANCE_DISABLED => get_string('no')); $settings->add(new admin_setting_configselect('enrol_apply/status', get_string('status', 'enrol_apply'), get_string('status_desc', 'enrol_apply'), ENROL_INSTANCE_ENABLED, $options)); - $options = array(ENROL_INSTANCE_ENABLED => get_string('yes'), - ENROL_INSTANCE_DISABLED => get_string('no')); + $options = array(1 => get_string('yes'), + 0 => get_string('no')); $settings->add(new admin_setting_configselect('enrol_apply/show_standard_user_profile', - get_string('show_standard_user_profile', 'enrol_apply'), '', ENROL_INSTANCE_ENABLED, $options)); + get_string('show_standard_user_profile', 'enrol_apply'), '', 1, $options)); - $options = array(ENROL_INSTANCE_ENABLED => get_string('yes'), - ENROL_INSTANCE_DISABLED => get_string('no')); + $options = array(1 => get_string('yes'), + 0 => get_string('no')); $settings->add(new admin_setting_configselect('enrol_apply/show_extra_user_profile', - get_string('show_extra_user_profile', 'enrol_apply'), '', ENROL_INSTANCE_ENABLED, $options)); + get_string('show_extra_user_profile', 'enrol_apply'), '', 1, $options)); if (!during_initial_install()) { $options = get_default_enrol_roles(context_system::instance()); diff --git a/version.php b/version.php index 373640b..46fca18 100644 --- a/version.php +++ b/version.php @@ -19,7 +19,7 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2016042201; +$plugin->version = 2016042202; $plugin->requires = 2011080100; $plugin->maturity = MATURITY_STABLE; $plugin->release = 'Enrolment upon approval plugin Version 3.0-d';