MDL-15916 teachers now control course welcome messages in each course separately, you can also specify custom message
AMOS BEGIN MOV [sendcoursewelcomemessage_desc,enrol_self],[sendcoursewelcomemessage_help,enrol_self] AMOS END
This commit is contained in:
@@ -30,7 +30,8 @@ function xmldb_enrol_self_install() {
|
||||
|
||||
// migrate welcome message
|
||||
if (isset($CFG->sendcoursewelcomemessage)) {
|
||||
set_config('sendcoursewelcomemessage', $CFG->sendcoursewelcomemessage, 'enrol_self');
|
||||
set_config('sendcoursewelcomemessage', $CFG->sendcoursewelcomemessage, 'enrol_self'); // new course default
|
||||
$DB->set_field('enrol', 'customint4', $CFG->sendcoursewelcomemessage, array('enrol'=>'self')); // each instance has different setting now
|
||||
unset_config('sendcoursewelcomemessage');
|
||||
}
|
||||
|
||||
|
||||
+4
-1
@@ -71,6 +71,8 @@ if ($mform->is_cancelled()) {
|
||||
$instance->customint1 = $data->customint1;
|
||||
$instance->customint2 = $data->customint2;
|
||||
$instance->customint3 = $data->customint3;
|
||||
$instance->customint4 = $data->customint4;
|
||||
$instance->customtext1 = $data->customtext1;
|
||||
$instance->roleid = $data->roleid;
|
||||
$instance->enrolperiod = $data->enrolperiod;
|
||||
$instance->enrolstartdate = $data->enrolstartdate;
|
||||
@@ -79,7 +81,8 @@ if ($mform->is_cancelled()) {
|
||||
$DB->update_record('enrol', $instance);
|
||||
|
||||
} else {
|
||||
$fields = array('status'=>$data->status, 'name'=>$data->name, 'password'=>$data->password, 'customint1'=>$data->customint1, 'customint2'=>$data->customint2, 'customint3'=>$data->customint3,
|
||||
$fields = array('status'=>$data->status, 'name'=>$data->name, 'password'=>$data->password, 'customint1'=>$data->customint1, 'customint2'=>$data->customint2,
|
||||
'customint3'=>$data->customint3, 'customint4'=>$data->customint4, 'customtext1'=>$data->customtext1,
|
||||
'roleid'=>$data->roleid, 'enrolperiod'=>$data->enrolperiod, 'enrolstartdate'=>$data->enrolstartdate, 'enrolenddate'=>$data->enrolenddate);
|
||||
$plugin->add_instance($course, $fields);
|
||||
}
|
||||
|
||||
@@ -97,6 +97,12 @@ class enrol_self_edit_form extends moodleform {
|
||||
$mform->addHelpButton('customint3', 'maxenrolled', 'enrol_self');
|
||||
$mform->setType('customint3', PARAM_INT);
|
||||
|
||||
$mform->addElement('advcheckbox', 'customint4', get_string('sendcoursewelcomemessage', 'enrol_self'));
|
||||
$mform->setDefault('customint4', $plugin->get_config('sendcoursewelcomemessage'));
|
||||
$mform->addHelpButton('customint4', 'sendcoursewelcomemessage', 'enrol_self');
|
||||
|
||||
$mform->addElement('textarea', 'customtext1', get_string('customwelcomemessage', 'enrol_self'), array('cols'=>'60', 'rows'=>'8'));
|
||||
|
||||
$mform->addElement('hidden', 'id');
|
||||
$mform->setType('id', PARAM_INT);
|
||||
$mform->addElement('hidden', 'courseid');
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
$string['customwelcomemessage'] = 'Custom welcome message';
|
||||
$string['defaultrole'] = 'Default role assignment';
|
||||
$string['defaultrole_desc'] = 'Select role which should be assigned to users during self enrolment';
|
||||
$string['enrolenddate'] = 'End date';
|
||||
@@ -61,7 +62,7 @@ $string['self:manage'] = 'Manage enrolled users';
|
||||
$string['self:unenrol'] = 'Unenrol users from course';
|
||||
$string['self:unenrolself'] = 'Unenrol self from the course';
|
||||
$string['sendcoursewelcomemessage'] = 'Send course welcome message';
|
||||
$string['sendcoursewelcomemessage_desc'] = 'If enabled, users receive a welcome message via email when they self-enrol in a course.';
|
||||
$string['sendcoursewelcomemessage_help'] = 'If enabled, users receive a welcome message via email when they self-enrol in a course.';
|
||||
$string['showhint'] = 'Show hint';
|
||||
$string['showhint_desc'] = 'Show first letter of the guest access key.';
|
||||
$string['status'] = 'Allow self enrolments';
|
||||
|
||||
+12
-9
@@ -204,7 +204,7 @@ class enrol_self_plugin extends enrol_plugin {
|
||||
}
|
||||
}
|
||||
// send welcome
|
||||
if ($this->get_config('sendcoursewelcomemessage')) {
|
||||
if ($instance->customint4) {
|
||||
$this->email_welcome_message($instance, $USER);
|
||||
}
|
||||
}
|
||||
@@ -228,6 +228,7 @@ class enrol_self_plugin extends enrol_plugin {
|
||||
$fields = array('customint1' => $this->get_config('groupkey'),
|
||||
'customint2' => $this->get_config('longtimenosee'),
|
||||
'customint3' => $this->get_config('maxenrolled'),
|
||||
'customint4' => $this->get_config('sendcoursewelcomemessage'),
|
||||
'enrolperiod' => $this->get_config('enrolperiod', 0),
|
||||
'status' => $this->get_config('status'),
|
||||
'roleid' => $this->get_config('roleid', 0));
|
||||
@@ -251,20 +252,22 @@ class enrol_self_plugin extends enrol_plugin {
|
||||
|
||||
$course = $DB->get_record('course', array('id'=>$instance->courseid), '*', MUST_EXIST);
|
||||
|
||||
if (!empty($instance->customtext1)) {
|
||||
//note: there is no gui for this yet, do we really need it?
|
||||
$message = formaat_string($instance->customtext1);
|
||||
$a = new object();
|
||||
$a->coursename = format_string($course->fullname);
|
||||
$a->profileurl = "$CFG->wwwroot/user/view.php?id=$user->id&course=$course->id";
|
||||
|
||||
if (trim($instance->customtext1) !== '') {
|
||||
$message = $instance->customtext1;
|
||||
$message = str_replace('{$a->coursename}', $a->coursename, $message);
|
||||
$message = str_replace('{$a->profileurl}', $a->profileurl, $message);
|
||||
} else {
|
||||
$a = new object();
|
||||
$a->coursename = format_string($course->fullname);
|
||||
$a->profileurl = "$CFG->wwwroot/user/view.php?id=$user->id&course=$course->id";
|
||||
$message = get_string("welcometocoursetext", 'enrol_self', $a);
|
||||
$message = get_string('welcometocoursetext', 'enrol_self', $a);
|
||||
}
|
||||
|
||||
$subject = get_string('welcometocourse', 'enrol_self', format_string($course->fullname));
|
||||
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$rusers = null;
|
||||
$rusers = array();
|
||||
if (!empty($CFG->coursecontact)) {
|
||||
$croles = explode(',', $CFG->coursecontact);
|
||||
$rusers = get_role_users($croles, $context, true, '', 'r.sortorder ASC, u.lastname ASC');
|
||||
|
||||
@@ -40,10 +40,6 @@ if ($ADMIN->fulltree) {
|
||||
$settings->add(new admin_setting_configcheckbox('enrol_self/showhint',
|
||||
get_string('showhint', 'enrol_self'), get_string('showhint_desc', 'enrol_self'), 0));
|
||||
|
||||
$settings->add(new admin_setting_configcheckbox('enrol_self/sendcoursewelcomemessage',
|
||||
get_string('sendcoursewelcomemessage', 'enrol_self'), get_string('sendcoursewelcomemessage_desc', 'enrol_self'), 1));
|
||||
|
||||
|
||||
//--- enrol instance defaults ----------------------------------------------------------------------------
|
||||
$settings->add(new admin_setting_heading('enrol_self_defaults',
|
||||
get_string('enrolinstancedefaults', 'admin'), get_string('enrolinstancedefaults_desc', 'admin')));
|
||||
@@ -90,4 +86,7 @@ if ($ADMIN->fulltree) {
|
||||
|
||||
$settings->add(new admin_setting_configtext('enrol_self/maxenrolled',
|
||||
get_string('maxenrolled', 'enrol_self'), get_string('maxenrolled_help', 'enrol_self'), 0, PARAM_INT));
|
||||
|
||||
$settings->add(new admin_setting_configcheckbox('enrol_self/sendcoursewelcomemessage',
|
||||
get_string('sendcoursewelcomemessage', 'enrol_self'), get_string('sendcoursewelcomemessage_desc', 'enrol_self'), 1));
|
||||
}
|
||||
|
||||
@@ -26,5 +26,5 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->version = 2010090500;
|
||||
$plugin->version = 2010090501;
|
||||
$plugin->cron = 180;
|
||||
Reference in New Issue
Block a user