diff --git a/lib.php b/lib.php index 7f44c01..3acf6f8 100644 --- a/lib.php +++ b/lib.php @@ -238,36 +238,6 @@ 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,ue.status - 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 != 0 - 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,ue.status - 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 != 0 - AND e.enrol = ?'; - $userenrolments = $DB->get_records_sql($sql, array('apply')); - } - return $userenrolments; -} - function confirmEnrolment($enrols){ global $DB; global $CFG; diff --git a/manage.php b/manage.php index 00a8d1a..2995525 100644 --- a/manage.php +++ b/manage.php @@ -12,6 +12,7 @@ require_once ('../../config.php'); require_once($CFG->dirroot.'/enrol/apply/lib.php'); +require_once($CFG->dirroot.'/enrol/apply/manage_table.php'); $id = optional_param('id', null, PARAM_INT); $userenrolments = optional_param_array('userenrolments', null, PARAM_INT); @@ -41,6 +42,7 @@ $PAGE->set_pagelayout('admin'); $PAGE->set_heading($pageheading); $PAGE->navbar->add(get_string('confirmusers', 'enrol_apply')); $PAGE->set_title(get_string('confirmusers', 'enrol_apply')); +$PAGE->requires->css('/enrol/apply/style.css'); if ($userenrolments != null) { $action = required_param('type', PARAM_TEXT); @@ -61,59 +63,37 @@ if ($userenrolments != null) { redirect($manageurl); } -$enrols = getAllEnrolment($id); -if ($id == null) { - $applicationinfo = $DB->get_records_sql(' - SELECT userenrolmentid, comment - FROM {enrol_apply_applicationinfo} - WHERE userenrolmentid IN ( - SELECT id - FROM {user_enrolments} - WHERE enrolid IN ( - SELECT id - FROM {enrol} - WHERE enrol = ?))', array('apply')); -} else { - $applicationinfo = $DB->get_records_sql(' - SELECT userenrolmentid, comment - FROM {enrol_apply_applicationinfo} - WHERE userenrolmentid IN ( - SELECT id - FROM {user_enrolments} - WHERE enrolid = ?)', array($instance->id)); -} - echo $OUTPUT->header (); echo $OUTPUT->heading ( get_string ( 'confirmusers', 'enrol_apply' ) ); echo get_string('confirmusers_desc', 'enrol_apply'); + +$table = new enrol_apply_manage_table($id); +$table->define_baseurl($manageurl); +$columns = array( + 'checkboxcolumn', + 'course', + 'fullname', // Magic happens here: The column heading will automatically be set. + 'email', + 'applydate', + 'applycomment'); +$headers = array( + '', + get_string('course'), + 'fullname', // Magic happens here: The column heading will automatically be set due to column name 'fullname'. + get_string('email'), + get_string('applydate', 'enrol_apply'), + get_string('comment', 'enrol_apply')); +$table->define_columns($columns); +$table->define_headers($headers); + +$table->sortable(true, 'id'); + + echo '