diff --git a/apply.php b/apply.php index d0fe2df..df7fd4a 100644 --- a/apply.php +++ b/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 '
'; echo ''; echo ''; @@ -61,7 +64,12 @@ echo ''; foreach ( $enrols as $enrol ) { $picture = get_user_picture($enrol->userid); - echo ''; + if ($enrol->status == 2) { + echo ''; + } else { + echo ''; + } + echo ''; echo ''; echo ''; echo ''; @@ -69,9 +77,16 @@ foreach ( $enrols as $enrol ) { echo ''; } echo '
' . get_string ( 'applydate', 'enrol_apply' echo '
' . format_string($enrol->course) . '' . $OUTPUT->render($picture) . ''.$enrol->firstname . ' ' . $enrol->lastname.'' . date ( "Y-m-d", $enrol->timecreated ) . '
'; -echo '

  

'; +echo '

'; +echo ''; +echo ''; +echo ''; +echo '

'; echo '
'; -echo ''; +echo ''; echo $OUTPUT->footer (); diff --git a/lang/de/enrol_apply.php b/lang/de/enrol_apply.php index 244dd3a..e2c331c 100644 --- a/lang/de/enrol_apply.php +++ b/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.
{firstname}:Registrierungsname; {content}:Kursname'; +$string['waitmailcontent_desc'] = 'Bitte benutzen Sie die Spezialmarkierungen, um den gewünschten Mailinhalt zu ersetzen.
{firstname}:Registrierungsname; {content}:Kursname'; $string['cancelmailcontent_desc'] = 'Bitte benutzen Sie die Spezialmarkierungen, um den gewünschten Mailinhalt zu ersetzen.
{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'; diff --git a/lang/en/enrol_apply.php b/lang/en/enrol_apply.php index bd22069..371e691 100644 --- a/lang/en/enrol_apply.php +++ b/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.
{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['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'; diff --git a/lib.php b/lib.php index 65b73f1..2ee7744 100644 --- a/lib.php +++ b/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; diff --git a/settings.php b/settings.php index c672475..de61af9 100644 --- a/settings.php +++ b/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')));