Browse Source

Merge pull request #49 from sudile/dev-waitinglist

Add waiting list feature.
SABERES_37_STABLE
Flotter Totte 9 years ago
parent
commit
900a5eb142
  1. 21
      apply.php
  2. 5
      lang/de/enrol_apply.php
  3. 5
      lang/en/enrol_apply.php
  4. 35
      lib.php
  5. 5
      settings.php

21
apply.php

@ -39,6 +39,8 @@ $userenrolments = optional_param_array('userenrolments', null, PARAM_INT);
if ($userenrolments != null) {
if ($_POST ['type'] == 'confirm') {
confirmEnrolment($userenrolments);
} elseif ($_POST ['type'] == 'wait') {
waitEnrolment ($userenrolments);
} elseif ($_POST ['type'] == 'cancel') {
cancelEnrolment($userenrolments);
}
@ -49,6 +51,7 @@ $enrols = getAllEnrolment ($enrolid);
echo $OUTPUT->header ();
echo $OUTPUT->heading ( get_string ( 'confirmusers', 'enrol_apply' ) );
echo get_string('confirmusers_desc', 'enrol_apply');
echo '<form id="frmenrol" method="post" action="apply.php?id=' . $id . '&enrolid=' . $enrolid . '">';
echo '<input type="hidden" id="type" name="type" value="confirm">';
echo '<table class="generalbox editcourse boxaligncenter"><tr class="header">';
@ -61,7 +64,12 @@ echo '<th class="header" scope="col">' . get_string ( 'applydate', 'enrol_apply'
echo '</tr>';
foreach ( $enrols as $enrol ) {
$picture = get_user_picture($enrol->userid);
echo '<tr><td><input type="checkbox" name="userenrolments[]" value="' . $enrol->id . '"></td>';
if ($enrol->status == 2) {
echo '<tr style="vertical-align: top; background-color: #ccc;">';
} else {
echo '<tr style="vertical-align: top;">';
}
echo '<td><input type="checkbox" name="userenrolments[]" value="' . $enrol->id . '"></td>';
echo '<td>' . format_string($enrol->course) . '</td>';
echo '<td>' . $OUTPUT->render($picture) . '</td>';
echo '<td>'.$enrol->firstname . ' ' . $enrol->lastname.'</td>';
@ -69,9 +77,16 @@ foreach ( $enrols as $enrol ) {
echo '<td>' . date ( "Y-m-d", $enrol->timecreated ) . '</td></tr>';
}
echo '</table>';
echo '<p align="center"><input type="button" value="' . get_string ( 'btnconfirm', 'enrol_apply' ) . '" onclick="doSubmit(\'confrim\');">&nbsp;&nbsp;<input type="button" value="' . get_string ( 'btncancel', 'enrol_apply' ) . '" onclick="doSubmit(\'cancel\');"></p>';
echo '<p align="center">';
echo '<input type="button" value="' . get_string ( 'btnconfirm', 'enrol_apply' ) . '" onclick="doSubmit(\'confirm\');">';
echo '<input type="button" value="' . get_string ( 'btnwait', 'enrol_apply' ) . '" onclick="doSubmit(\'wait\');">';
echo '<input type="button" value="' . get_string ( 'btncancel', 'enrol_apply' ) . '" onclick="doSubmit(\'cancel\');">';
echo '</p>';
echo '</form>';
echo '<script>function doSubmit(type){if(type=="cancel"){document.getElementById("type").value=type;}document.getElementById("frmenrol").submit();}</script>';
echo '<script>function doSubmit(type){
document.getElementById("type").value=type;
document.getElementById("frmenrol").submit();
}</script>';
echo $OUTPUT->footer ();

5
lang/de/enrol_apply.php

@ -16,18 +16,23 @@ $string['pluginname_desc'] = 'With this plugin users can apply to a course and a
$string['confirmmailsubject'] = 'E-Mail-Betreff für Bestätigung der Einschreibung';
$string['confirmmailcontent'] = 'E-Mail für Bestätigung der Einschreibung';
$string['waitmailsubject'] = 'E-Mail-Betreff für Benachrichtigung über das setzen auf Warteliste';
$string['waitmailcontent'] = 'E-Mail für Benachrichtigung über das setzen auf Warteliste';
$string['cancelmailsubject'] = 'Mail-Betreff für Verwerfen der Einschreibung';
$string['cancelmailcontent'] = 'Mail für Verwerfen der Einschreibung';
$string['confirmmailcontent_desc'] = 'Bitte benutzen Sie die Spezialmarkierungen, um den gewünschten Mailinhalt zu ersetzen.<br>{firstname}:Registrierungsname; {content}:Kursname';
$string['waitmailcontent_desc'] = 'Bitte benutzen Sie die Spezialmarkierungen, um den gewünschten Mailinhalt zu ersetzen.<br>{firstname}:Registrierungsname; {content}:Kursname';
$string['cancelmailcontent_desc'] = 'Bitte benutzen Sie die Spezialmarkierungen, um den gewünschten Mailinhalt zu ersetzen.<br>{firstname}:Registrierungsname; {content}:Kursname';
$string['confirmusers'] = 'Einschreibung bestätigen';
$string['confirmusers_desc'] = 'Nutzer in grau hinterlegten Zeilen befinden sich auf der Warteliste und können noch nachträglich dem Kurs hinzugefügt oder gelöscht werden.';
$string['coursename'] = 'Kurs';
$string['applyuser'] = 'Voname / Nachname';
$string['applyusermail'] = 'Email';
$string['applydate'] = 'Einschreibungsdatum';
$string['btnconfirm'] = 'Einschreibungsanfragen bestätigen';
$string['btnwait'] = 'markierte Nutzer auf die Warteliste setzen';
$string['btncancel'] = ' Einschreibungsanfragen ablehnen';
$string['enrolusers'] = 'Benutzer manuell einschreiben';

5
lang/en/enrol_apply.php

@ -16,18 +16,23 @@ $string['pluginname_desc'] = 'With this plug-in users can apply to be enrolled i
$string['confirmmailsubject'] = 'Confirmation email subject';
$string['confirmmailcontent'] = 'Confirmation email content';
$string['waitmailsubject'] = 'Waiting list mail subject';
$string['waitmailcontent'] = 'Waiting list mail content';
$string['cancelmailsubject'] = 'Cancelation email subject';
$string['cancelmailcontent'] = 'Cancelation email content';
$string['confirmmailcontent_desc'] = 'Please use the following special marks to replace email content with data from Moodle.<br/>{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.<br/>{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.<br/>{firstname}:The first name of the user; {content}:The course name;{lastname}:The last name of the user;{username}:The users registration username';
$string['confirmusers'] = 'Enrol Confirm';
$string['confirmusers_desc'] = 'Users in gray colored rows are on the waiting list.';
$string['coursename'] = 'Course';
$string['applyuser'] = 'First name / Surname';
$string['applyusermail'] = 'Email';
$string['applydate'] = 'Enrol date';
$string['btnconfirm'] = 'Confirm requests';
$string['btnwait'] = 'put marked users on waiting list';
$string['btncancel'] = 'Cancel requests';
$string['enrolusers'] = 'Enrol users';

35
lib.php

@ -240,7 +240,7 @@ class enrol_apply_plugin extends enrol_plugin {
function getAllEnrolment($id = null) {
global $DB;
if ($id) {
$sql = 'SELECT ue.userid,ue.id,u.firstname,u.lastname,u.email,u.picture,c.fullname as course,ue.timecreated
$sql = 'SELECT ue.userid,ue.id,u.firstname,u.lastname,u.email,u.picture,c.fullname as course,ue.timecreated,ue.status
FROM {course} c
JOIN {enrol} e
ON e.courseid = c.id
@ -248,7 +248,7 @@ function getAllEnrolment($id = null) {
ON ue.enrolid = e.id
JOIN {user} u
ON ue.userid = u.id
WHERE ue.status = 1
WHERE ue.status != 0
AND e.id = ?';
$userenrolments = $DB->get_records_sql($sql, array($id));
} else {
@ -260,7 +260,7 @@ function getAllEnrolment($id = null) {
ON ue.enrolid = e.id
LEFT JOIN {course} c
ON e.courseid = c.id
WHERE ue.status = 1
WHERE ue.status != 0
AND e.enrol = ?';
$userenrolments = $DB->get_records_sql($sql, array('apply'));
}
@ -289,6 +289,20 @@ function confirmEnrolment($enrols){
}
}
function waitEnrolment($enrols){
global $DB;
global $CFG;
foreach ($enrols as $enrol){
@$enroluser->id = $enrol;
@$enroluser->status = 2;
if($DB->update_record('user_enrolments',$enroluser)){
$info = getRelatedInfo($enrol);
sendWaitMail($info);
}
}
}
function cancelEnrolment($enrols){
global $DB;
foreach ($enrols as $enrol){
@ -323,6 +337,21 @@ function sendConfirmMail($info){
email_to_user($info, $contact, $apply_setting['confirmmailsubject']->value, html_to_text($body), $body);
}
function sendWaitMail($info){
global $DB;
global $CFG;
//global $USER;
$apply_setting = $DB->get_records_sql("select name,value from ".$CFG->prefix."config_plugins where plugin='enrol_apply'");
$replace = array('firstname'=>$info->firstname,'content'=>format_string($info->coursename),'lastname'=>$info->lastname,'username'=>$info->username);
$body = get_config('enrol_apply', 'waitmailcontent');
$body = updateMailContent($body,$replace);
$contact = get_admin();
//confirm mail will sent by the admin
//$contact = $USER;
email_to_user($info, $contact, get_config('enrol_apply', 'waitmailsubject'), html_to_text($body), $body);
}
function sendConfirmMailToTeachers($instance,$info,$applydescription){
global $DB;
global $CFG;

5
settings.php

@ -21,6 +21,11 @@ if ($ADMIN->fulltree) {
$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));
$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',''));
$settings->add(new admin_setting_configtext('enrol_apply/cancelmailsubject','',get_string('cancelmailsubject', 'enrol_apply'),null,PARAM_TEXT,60));
$settings->add(new admin_setting_heading('enrol_apply_cancelmailcontent', '', get_string('cancelmailcontent_desc', 'enrol_apply')));

Loading…
Cancel
Save