From a1450c16a5f4088908c69435d4afc8f50afce01b Mon Sep 17 00:00:00 2001 From: Daniel Neis Date: Wed, 7 Oct 2015 13:36:46 -0300 Subject: [PATCH 1/3] adding composer.json --- composer.json | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 composer.json diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..0d4625c --- /dev/null +++ b/composer.json @@ -0,0 +1,12 @@ +{ + "name": "emeneo/moodle-enrol_apply", + "description": "An enrol plugin for Moodle that adds an approval step into the course enrolment process.", + "type": "moodle-enrol", + "license": "GPLv3", + "require": { + "composer/installers": "*" + }, + "extra": { + "installer-name": "apply" + } +} From bd03f5001f3d9320bdf5fe3318ab84f8326a0140 Mon Sep 17 00:00:00 2001 From: Daniel Neis Araujo Date: Mon, 22 Feb 2016 10:52:43 -0300 Subject: [PATCH 2/3] filter by enrolid/enrol plugin on getAllEnrolment --- apply.php | 8 +++++--- db/access.php | 9 +++++++++ lib.php | 31 +++++++++++++++++++++++++------ 3 files changed, 39 insertions(+), 9 deletions(-) diff --git a/apply.php b/apply.php index 7197c8c..3c6e748 100644 --- a/apply.php +++ b/apply.php @@ -22,6 +22,8 @@ $id = required_param ( 'id', PARAM_INT ); // course id $course = $DB->get_record ( 'course', array ('id' => $id ), '*', MUST_EXIST ); $context = context_course::instance($course->id, MUST_EXIST); +$enrolid = optional_param('enrolid', 0, PARAM_INT); + require_login ( $course ); require_capability ( 'moodle/course:enrolreview', $context ); @@ -40,15 +42,15 @@ if (isset ( $_POST ['enrolid'] )) { } elseif ($_POST ['type'] == 'cancel') { cancelEnrolment ( $_POST ['enrolid'] ); } - redirect ( "$CFG->wwwroot/enrol/apply/apply.php?id=" . $id . "&enrolid=" . $_GET ['enrolid'] ); + redirect ( "$CFG->wwwroot/enrol/apply/apply.php?id=" . $id . "&enrolid=" . $enrolid ); } } -$enrols = getAllEnrolment ($id); +$enrols = getAllEnrolment ($enrolid); echo $OUTPUT->header (); echo $OUTPUT->heading ( get_string ( 'confirmusers', 'enrol_apply' ) ); -echo '
'; +echo ''; echo ''; echo ''; echo ''; diff --git a/db/access.php b/db/access.php index e5bc9e5..0263294 100644 --- a/db/access.php +++ b/db/access.php @@ -53,6 +53,15 @@ $capabilities = array( ) ), + 'enrol/apply:enrol' => array( + 'captype' => 'write', + 'contextlevel' => CONTEXT_COURSE, + 'archetypes' => array( + 'editingteacher' => CAP_ALLOW, + 'manager' => CAP_ALLOW, + ) + ), + 'enrol/apply:unenrol' => array( 'captype' => 'write', 'contextlevel' => CONTEXT_COURSE, diff --git a/lib.php b/lib.php index 2012d0b..65b73f1 100644 --- a/lib.php +++ b/lib.php @@ -237,13 +237,32 @@ class enrol_apply_plugin extends enrol_plugin { } } -function getAllEnrolment($id = null){ +function getAllEnrolment($id = null) { global $DB; - global $CFG; - if($id){ - $userenrolments = $DB->get_records_sql('select ue.userid,ue.id,u.firstname,u.lastname,u.email,u.picture,c.fullname as course,ue.timecreated from '.$CFG->prefix.'user_enrolments as ue left join '.$CFG->prefix.'user as u on ue.userid=u.id left join '.$CFG->prefix.'enrol as e on ue.enrolid=e.id left join '.$CFG->prefix.'course as c on e.courseid=c.id where ue.status=1 and e.courseid='.$id); - }else{ - $userenrolments = $DB->get_records_sql('select ue.id,ue.userid,u.firstname,u.lastname,u.email,u.picture,c.fullname as course,ue.timecreated from '.$CFG->prefix.'user_enrolments as ue left join '.$CFG->prefix.'user as u on ue.userid=u.id left join '.$CFG->prefix.'enrol as e on ue.enrolid=e.id left join '.$CFG->prefix.'course as c on e.courseid=c.id where ue.status=1'); + if ($id) { + $sql = 'SELECT ue.userid,ue.id,u.firstname,u.lastname,u.email,u.picture,c.fullname as course,ue.timecreated + FROM {course} c + JOIN {enrol} e + ON e.courseid = c.id + JOIN {user_enrolments} ue + ON ue.enrolid = e.id + JOIN {user} u + ON ue.userid = u.id + WHERE ue.status = 1 + AND e.id = ?'; + $userenrolments = $DB->get_records_sql($sql, array($id)); + } else { + $sql = 'SELECT ue.id,ue.userid,u.firstname,u.lastname,u.email,u.picture,c.fullname as course,ue.timecreated + FROM {user_enrolments} ue + LEFT JOIN {user} u + ON ue.userid = u.id + LEFT JOIN {enrol} e + ON ue.enrolid = e.id + LEFT JOIN {course} c + ON e.courseid = c.id + WHERE ue.status = 1 + AND e.enrol = ?'; + $userenrolments = $DB->get_records_sql($sql, array('apply')); } return $userenrolments; } From ee16239cf34712dc19773f58fbef3f10776c4ddf Mon Sep 17 00:00:00 2001 From: Daniel Neis Araujo Date: Mon, 29 Feb 2016 13:36:58 -0300 Subject: [PATCH 3/3] add missing string --- lang/en/enrol_apply.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lang/en/enrol_apply.php b/lang/en/enrol_apply.php index b76d535..8a919fa 100644 --- a/lang/en/enrol_apply.php +++ b/lang/en/enrol_apply.php @@ -35,6 +35,7 @@ $string['status'] = 'Allow Course enrol confirmation'; $string['confirmenrol'] = 'Manage application'; $string['apply:config'] = 'Configure apply enrol instances'; +$string['apply:enrol'] = 'Enrol users'; $string['apply:manage'] = 'Manage apply enrolment'; $string['apply:unenrol'] = 'Cancel users from the course'; $string['apply:unenrolapply'] = 'Cancel self from the course'; // is this necessary now? @@ -55,4 +56,4 @@ $string['user_profile'] = 'User Profile'; $string['show_standard_user_profile'] = 'Show standard user profile fields on enrolment screen'; $string['show_extra_user_profile'] = 'Show extra user profile fields on enrolment screen'; -?> \ No newline at end of file +?>