Merge branch 'w32_MDL-34635_m24_selfwelcommultilang' of git://github.com/skodak/moodle

This commit is contained in:
Dan Poltawski 2012-08-06 11:29:16 +08:00
commit e447150153
3 changed files with 22 additions and 5 deletions

View File

@ -105,6 +105,7 @@ class enrol_self_edit_form extends moodleform {
$mform->addHelpButton('customint4', 'sendcoursewelcomemessage', 'enrol_self');
$mform->addElement('textarea', 'customtext1', get_string('customwelcomemessage', 'enrol_self'), array('cols'=>'60', 'rows'=>'8'));
$mform->addHelpButton('customtext1', 'customwelcomemessage', 'enrol_self');
$mform->addElement('hidden', 'id');
$mform->setType('id', PARAM_INT);

View File

@ -25,6 +25,12 @@
*/
$string['customwelcomemessage'] = 'Custom welcome message';
$string['customwelcomemessage_help'] = 'A custom welcome message may be added as plain text or Moodle-auto format, including HTML tags and multi-lang tags.
The following placeholders may be included in the message:
* Course name {$a->coursename}
* Link to user\'s profile page {$a->profileurl}';
$string['defaultrole'] = 'Default role assignment';
$string['defaultrole_desc'] = 'Select role which should be assigned to users during self enrolment';
$string['editenrolment'] = 'Edit enrolment';

View File

@ -267,22 +267,32 @@ class enrol_self_plugin extends enrol_plugin {
global $CFG, $DB;
$course = $DB->get_record('course', array('id'=>$instance->courseid), '*', MUST_EXIST);
$context = context_course::instance($course->id);
$a = new stdClass();
$a->coursename = format_string($course->fullname);
$a->coursename = format_string($course->fullname, true, array('context'=>$context));
$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);
if (strpos($message, '<') === false) {
// Plain text only.
$messagetext = $message;
$messagehtml = text_to_html($messagetext, null, false, true);
} else {
// This is most probably the tag/newline soup known as FORMAT_MOODLE.
$messagehtml = format_text($message, FORMAT_MOODLE, array('context'=>$context, 'para'=>false, 'newlines'=>true, 'filter'=>true));
$messagetext = html_to_text($messagehtml);
}
} else {
$message = get_string('welcometocoursetext', 'enrol_self', $a);
$messagetext = get_string('welcometocoursetext', 'enrol_self', $a);
$messagehtml = text_to_html($messagetext, null, false, true);
}
$subject = get_string('welcometocourse', 'enrol_self', format_string($course->fullname));
$subject = get_string('welcometocourse', 'enrol_self', format_string($course->fullname, true, array('context'=>$context)));
$context = context_course::instance($course->id);
$rusers = array();
if (!empty($CFG->coursecontact)) {
$croles = explode(',', $CFG->coursecontact);
@ -295,7 +305,7 @@ class enrol_self_plugin extends enrol_plugin {
}
//directly emailing welcome message rather than using messaging
email_to_user($user, $contact, $subject, $message);
email_to_user($user, $contact, $subject, $messagetext, $messagehtml);
}
/**