From f4bb716a64873af5f1b98e56519b415544c77749 Mon Sep 17 00:00:00 2001 From: Johannes Burk Date: Tue, 12 Apr 2016 10:20:10 +0200 Subject: [PATCH] Indention convert to spaces --- apply.php | 68 ++-- db/access.php | 3 - db/install.php | 41 --- edit.php | 2 +- edit_form.php | 4 +- enroluser.php | 18 +- lib.php | 866 ++++++++++++++++++++++++------------------------ locallib.php | 4 +- manage.php | 28 +- settings.php | 4 +- unenrolself.php | 8 +- unenroluser.php | 4 +- version.php | 3 +- 13 files changed, 505 insertions(+), 548 deletions(-) delete mode 100644 db/install.php diff --git a/apply.php b/apply.php index 9910698..ba13992 100644 --- a/apply.php +++ b/apply.php @@ -1,7 +1,7 @@ set_title ( "$site->shortname: " . get_string ( 'confirmusers', 'enrol_ap $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); - } - redirect ( "$CFG->wwwroot/enrol/apply/apply.php?id=" . $id . "&enrolid=" . $enrolid ); + if ($_POST ['type'] == 'confirm') { + confirmEnrolment($userenrolments); + } elseif ($_POST ['type'] == 'wait') { + waitEnrolment ($userenrolments); + } elseif ($_POST ['type'] == 'cancel') { + cancelEnrolment($userenrolments); + } + redirect ( "$CFG->wwwroot/enrol/apply/apply.php?id=" . $id . "&enrolid=" . $enrolid ); } $enrols = getAllEnrolment ($enrolid); $applicationinfo = $DB->get_records_sql(' - SELECT userenrolmentid, comment - FROM {enrol_apply_applicationinfo} - WHERE userenrolmentid IN ( - SELECT id - FROM {user_enrolments} - WHERE enrolid = ?)', array($enrolid)); + SELECT userenrolmentid, comment + FROM {enrol_apply_applicationinfo} + WHERE userenrolmentid IN ( + SELECT id + FROM {user_enrolments} + WHERE enrolid = ?)', array($enrolid)); echo $OUTPUT->header (); echo $OUTPUT->heading ( get_string ( 'confirmusers', 'enrol_apply' ) ); @@ -71,20 +71,20 @@ echo '' . get_string ( 'applydate', 'enrol_apply' echo '' . get_string ( 'comment', 'enrol_apply' ) . ''; echo ''; foreach ( $enrols as $enrol ) { - $picture = get_user_picture($enrol->userid); - if ($enrol->status == 2) { - echo ''; - } else { - echo ''; - } - echo ''; - echo '' . format_string($enrol->course) . ''; - echo '' . $OUTPUT->render($picture) . ''; - echo ''.$enrol->firstname . ' ' . $enrol->lastname.''; - echo '' . $enrol->email . ''; - echo '' . date ( "Y-m-d", $enrol->timecreated ) . ''; - echo '' . htmlspecialchars($applicationinfo[$enrol->id]->comment) . ''; - echo ''; + $picture = get_user_picture($enrol->userid); + if ($enrol->status == 2) { + echo ''; + } else { + echo ''; + } + echo ''; + echo '' . format_string($enrol->course) . ''; + echo '' . $OUTPUT->render($picture) . ''; + echo ''.$enrol->firstname . ' ' . $enrol->lastname.''; + echo '' . $enrol->email . ''; + echo '' . date ( "Y-m-d", $enrol->timecreated ) . ''; + echo '' . htmlspecialchars($applicationinfo[$enrol->id]->comment) . ''; + echo ''; } echo ''; echo '

'; @@ -94,19 +94,19 @@ echo ''; echo $OUTPUT->footer (); function get_user_picture($userid){ - global $DB; + global $DB; $extrafields[] = 'lastaccess'; $ufields = user_picture::fields('u', $extrafields); - $sql = "SELECT DISTINCT $ufields FROM {user} u where u.id=$userid"; + $sql = "SELECT DISTINCT $ufields FROM {user} u where u.id=$userid"; $user = $DB->get_record_sql($sql); - return new user_picture($user); + return new user_picture($user); } \ No newline at end of file diff --git a/db/access.php b/db/access.php index 0263294..bb8818d 100644 --- a/db/access.php +++ b/db/access.php @@ -78,7 +78,4 @@ $capabilities = array( 'student' => CAP_ALLOW, ) ), - ); - - diff --git a/db/install.php b/db/install.php deleted file mode 100644 index 7ecd509..0000000 --- a/db/install.php +++ /dev/null @@ -1,41 +0,0 @@ -sendcoursewelcomemessage)) { - set_config('sendcoursewelcomemessage', $CFG->sendcoursewelcomemessage, 'enrol_apply'); // new course default - $DB->set_field('enrol', 'customint4', $CFG->sendcoursewelcomemessage, array('enrol'=>'apply')); // each instance has different setting now - unset_config('sendcoursewelcomemessage'); - } - - // migrate long-time-no-see feature settings - if (isset($CFG->longtimenosee)) { - $nosee = $CFG->longtimenosee * 3600 * 24; - set_config('longtimenosee', $nosee, 'enrol_apply'); - $DB->set_field('enrol', 'customint2', $nosee, array('enrol'=>'apply')); - unset_config('longtimenosee'); - } -} diff --git a/edit.php b/edit.php index 126ef35..d8b9626 100644 --- a/edit.php +++ b/edit.php @@ -2,7 +2,7 @@ /** * ************************************************************************* - * * Apply Enrol ** + * * Apply Enrol ** * ************************************************************************* * @copyright emeneo.com ** * @link emeneo.com ** diff --git a/edit_form.php b/edit_form.php index cdaaa4d..07b7466 100644 --- a/edit_form.php +++ b/edit_form.php @@ -2,7 +2,7 @@ /** * ************************************************************************* - * * Apply Enrol ** + * * Apply Enrol ** * ************************************************************************* * @copyright emeneo.com ** * @link emeneo.com ** @@ -40,7 +40,7 @@ class enrol_self_edit_form extends moodleform { $mform->addElement('select', 'roleid', get_string('defaultrole', 'role'), $roles); $mform->setDefault('roleid', $plugin->get_config('roleid')); - $mform->addElement('textarea', 'customtext1', get_string('editdescription', 'enrol_apply')); + $mform->addElement('textarea', 'customtext1', get_string('editdescription', 'enrol_apply')); $mform->addElement('select', 'customint1', get_string('show_standard_user_profile', 'enrol_apply'), $options); $mform->setDefault('customint1', $plugin->get_config('customint1')); diff --git a/enroluser.php b/enroluser.php index a7e9c7a..901f135 100644 --- a/enroluser.php +++ b/enroluser.php @@ -1,7 +1,7 @@ ";print_r($instance);exit(); $enrol_manual->enrol_user($instance, $adduser->id, $roleid, $timestart, $timeend); - // Deprecated fixed by Shiro - //add_to_log($course->id, 'course', 'enrol', '../enrol/users.php?id='.$course->id, $course->id); //there should be userid somewhere! - $context = context_course::instance($course->id); - \core\event\user_enrolment_created::create(array('context' => $context))->trigger(); + // Deprecated fixed by Shiro + //add_to_log($course->id, 'course', 'enrol', '../enrol/users.php?id='.$course->id, $course->id); //there should be userid somewhere! + $context = context_course::instance($course->id); + \core\event\user_enrolment_created::create(array('context' => $context))->trigger(); } $potentialuserselector->invalidate_selected_users(); @@ -125,10 +125,10 @@ if (optional_param('remove', false, PARAM_BOOL) && confirm_sesskey()) { foreach($userstounassign as $removeuser) { $enrol_manual->unenrol_user($instance, $removeuser->id); - // Deprecated fixed by Shiro - //add_to_log($course->id, 'course', 'unenrol', '../enrol/users.php?id='.$course->id, $course->id); //there should be userid somewhere! - $context = context_course::instance($course->id); - \core\event\user_enrolment_deleted::delete(array('context' => $context))->trigger(); + // Deprecated fixed by Shiro + //add_to_log($course->id, 'course', 'unenrol', '../enrol/users.php?id='.$course->id, $course->id); //there should be userid somewhere! + $context = context_course::instance($course->id); + \core\event\user_enrolment_deleted::delete(array('context' => $context))->trigger(); } $potentialuserselector->invalidate_selected_users(); diff --git a/lib.php b/lib.php index 5a370a9..aa27236 100644 --- a/lib.php +++ b/lib.php @@ -1,7 +1,7 @@ get_instance_defaults(); - return $this->add_instance($course, $fields); - } - - public function allow_unenrol(stdClass $instance) { - // users with unenrol cap may unenrol other users manually manually - return true; - } - - public function get_newinstance_link($courseid) { - $context = context_course::instance($courseid, MUST_EXIST); - - if (!has_capability('moodle/course:enrolconfig', $context) or !has_capability('enrol/apply:config', $context)) { - return NULL; - } - // multiple instances supported - different roles with different password - return new moodle_url('/enrol/apply/edit.php', array('courseid'=>$courseid)); - } - - public function enrol_page_hook(stdClass $instance) { - global $CFG, $OUTPUT, $SESSION, $USER, $DB; - - if (isguestuser()) { - // can not enrol guest!! - return null; - } - if ($DB->record_exists('user_enrolments', array('userid'=>$USER->id, 'enrolid'=>$instance->id))) { - //TODO: maybe we should tell them they are already enrolled, but can not access the course - //return null; - return $OUTPUT->notification(get_string('notification', 'enrol_apply'), 'notifysuccess'); - } + /** + * Add new instance of enrol plugin with default settings. + * @param object $course + * @return int id of new instance + */ + public function add_default_instance($course) { + $fields = $this->get_instance_defaults(); + return $this->add_instance($course, $fields); + } + + public function allow_unenrol(stdClass $instance) { + // users with unenrol cap may unenrol other users manually manually + return true; + } + + public function get_newinstance_link($courseid) { + $context = context_course::instance($courseid, MUST_EXIST); + + if (!has_capability('moodle/course:enrolconfig', $context) or !has_capability('enrol/apply:config', $context)) { + return NULL; + } + // multiple instances supported - different roles with different password + return new moodle_url('/enrol/apply/edit.php', array('courseid'=>$courseid)); + } + + public function enrol_page_hook(stdClass $instance) { + global $CFG, $OUTPUT, $SESSION, $USER, $DB; + + if (isguestuser()) { + // can not enrol guest!! + return null; + } + if ($DB->record_exists('user_enrolments', array('userid'=>$USER->id, 'enrolid'=>$instance->id))) { + //TODO: maybe we should tell them they are already enrolled, but can not access the course + //return null; + return $OUTPUT->notification(get_string('notification', 'enrol_apply'), 'notifysuccess'); + } require_once("$CFG->dirroot/enrol/apply/locallib.php"); - $form = new enrol_apply_enrol_form(NULL, $instance); - - $instanceid = optional_param('instance', 0, PARAM_INT); - if ($instance->id == $instanceid) { - if ($data = $form->get_data()) { - $userInfo = $data; - $applydescription = $userInfo->applydescription; - unset($userInfo->applydescription); - $userInfo->id = $USER->id; - - $apply_setting = $DB->get_records_sql("select name,value from ".$CFG->prefix."config_plugins where plugin='enrol_apply'"); - - $show_standard_user_profile = $show_extra_user_profile = false; - if($instance->customint1 != ''){ - ($instance->customint1 == 0)?$show_standard_user_profile = true:$show_standard_user_profile = false; - }else{ - ($apply_setting['show_standard_user_profile']->value == 0)?$show_standard_user_profile = true:$show_standard_user_profile = false; - } - - if($instance->customint2 != ''){ - ($instance->customint2 == 0)?$show_extra_user_profile = true:$show_extra_user_profile = false; - }else{ - ($apply_setting['show_extra_user_profile']->value == 0)?$show_extra_user_profile = true:$show_extra_user_profile = false; - } - - if(!$show_standard_user_profile && $show_extra_user_profile){ - profile_save_data($userInfo); - $res = $DB->update_record('user',$userInfoProfile); - //$res = $DB->update_record('user',$userInfo); - } - /*elseif($show_standard_user_profile && $show_extra_user_profile){ - profile_save_data($userInfo); - $res = $DB->update_record('user',$userInfo); - }*/ - - $enrol = enrol_get_plugin('self'); - $timestart = time(); - if ($instance->enrolperiod) { - $timeend = $timestart + $instance->enrolperiod; - } else { - $timeend = 0; - } - - $roleid = $instance->roleid; - if(!$roleid){ - $role = $DB->get_record_sql("select * from ".$CFG->prefix."role where archetype='student' limit 1"); - $roleid = $role->id; - } - - $this->enrol_user($instance, $USER->id, $roleid, $timestart, $timeend,1); - $userenrolment = $DB->get_record('user_enrolments', array('userid' => $USER->id, 'enrolid' => $instance->id), 'id', MUST_EXIST); - $applicationinfo = new stdClass(); - $applicationinfo->userenrolmentid = $userenrolment->id; - $applicationinfo->comment = $applydescription; - $DB->insert_record('enrol_apply_applicationinfo', $applicationinfo, false); - sendConfirmMailToTeachers($instance, $data, $applydescription); - sendConfirmMailToManagers($instance, $data, $applydescription); - - // Deprecated fixed by Shiro - //add_to_log($instance->courseid, 'course', 'enrol', '../enrol/users.php?id='.$instance->courseid, $instance->courseid); //there should be userid somewhere! - $context = context_course::instance($instance->courseid); - \core\event\user_enrolment_created::create( - array( - 'objectid' => $instance->id, - 'courseid' => $instance->courseid, - 'context' => $context, - 'relateduserid' => $USER->id, - 'other' => array('enrol' => 'apply') - ))->trigger(); - - redirect("$CFG->wwwroot/course/view.php?id=$instance->courseid"); - } - } - //exit; - ob_start(); - $form->display(); - $output = ob_get_clean(); - - return $OUTPUT->box($output); - - } - - public function get_action_icons(stdClass $instance) { - global $OUTPUT; - - if ($instance->enrol !== 'apply') { - throw new coding_exception('invalid enrol instance!'); - } - $context = context_course::instance($instance->courseid); - - $icons = array(); - - if (has_capability('enrol/apply:config', $context)) { + $form = new enrol_apply_enrol_form(NULL, $instance); + + $instanceid = optional_param('instance', 0, PARAM_INT); + if ($instance->id == $instanceid) { + if ($data = $form->get_data()) { + $userInfo = $data; + $applydescription = $userInfo->applydescription; + unset($userInfo->applydescription); + $userInfo->id = $USER->id; + + $apply_setting = $DB->get_records_sql("select name,value from ".$CFG->prefix."config_plugins where plugin='enrol_apply'"); + + $show_standard_user_profile = $show_extra_user_profile = false; + if($instance->customint1 != ''){ + ($instance->customint1 == 0)?$show_standard_user_profile = true:$show_standard_user_profile = false; + }else{ + ($apply_setting['show_standard_user_profile']->value == 0)?$show_standard_user_profile = true:$show_standard_user_profile = false; + } + + if($instance->customint2 != ''){ + ($instance->customint2 == 0)?$show_extra_user_profile = true:$show_extra_user_profile = false; + }else{ + ($apply_setting['show_extra_user_profile']->value == 0)?$show_extra_user_profile = true:$show_extra_user_profile = false; + } + + if(!$show_standard_user_profile && $show_extra_user_profile){ + profile_save_data($userInfo); + $res = $DB->update_record('user',$userInfoProfile); + //$res = $DB->update_record('user',$userInfo); + } + /*elseif($show_standard_user_profile && $show_extra_user_profile){ + profile_save_data($userInfo); + $res = $DB->update_record('user',$userInfo); + }*/ + + $enrol = enrol_get_plugin('self'); + $timestart = time(); + if ($instance->enrolperiod) { + $timeend = $timestart + $instance->enrolperiod; + } else { + $timeend = 0; + } + + $roleid = $instance->roleid; + if(!$roleid){ + $role = $DB->get_record_sql("select * from ".$CFG->prefix."role where archetype='student' limit 1"); + $roleid = $role->id; + } + + $this->enrol_user($instance, $USER->id, $roleid, $timestart, $timeend,1); + $userenrolment = $DB->get_record('user_enrolments', array('userid' => $USER->id, 'enrolid' => $instance->id), 'id', MUST_EXIST); + $applicationinfo = new stdClass(); + $applicationinfo->userenrolmentid = $userenrolment->id; + $applicationinfo->comment = $applydescription; + $DB->insert_record('enrol_apply_applicationinfo', $applicationinfo, false); + sendConfirmMailToTeachers($instance, $data, $applydescription); + sendConfirmMailToManagers($instance, $data, $applydescription); + + // Deprecated fixed by Shiro + //add_to_log($instance->courseid, 'course', 'enrol', '../enrol/users.php?id='.$instance->courseid, $instance->courseid); //there should be userid somewhere! + $context = context_course::instance($instance->courseid); + \core\event\user_enrolment_created::create( + array( + 'objectid' => $instance->id, + 'courseid' => $instance->courseid, + 'context' => $context, + 'relateduserid' => $USER->id, + 'other' => array('enrol' => 'apply') + ))->trigger(); + + redirect("$CFG->wwwroot/course/view.php?id=$instance->courseid"); + } + } + //exit; + ob_start(); + $form->display(); + $output = ob_get_clean(); + + return $OUTPUT->box($output); + + } + + public function get_action_icons(stdClass $instance) { + global $OUTPUT; + + if ($instance->enrol !== 'apply') { + throw new coding_exception('invalid enrol instance!'); + } + $context = context_course::instance($instance->courseid); + + $icons = array(); + + if (has_capability('enrol/apply:config', $context)) { $editlink = new moodle_url("/enrol/apply/edit.php", array('courseid'=>$instance->courseid, 'id'=>$instance->id)); $icons[] = $OUTPUT->action_icon($editlink, new pix_icon('t/edit', get_string('edit'), 'core', array('class' => 'iconsmall'))); } - if (has_capability('enrol/apply:manage', $context)) { - $managelink = new moodle_url("/enrol/apply/apply.php", array('id'=>$_GET['id'],'enrolid'=>$instance->id)); - $icons[] = $OUTPUT->action_icon($managelink, new pix_icon('i/users', get_string('confirmenrol', 'enrol_apply'), 'core', array('class'=>'iconsmall'))); - } + if (has_capability('enrol/apply:manage', $context)) { + $managelink = new moodle_url("/enrol/apply/apply.php", array('id'=>$_GET['id'],'enrolid'=>$instance->id)); + $icons[] = $OUTPUT->action_icon($managelink, new pix_icon('i/users', get_string('confirmenrol', 'enrol_apply'), 'core', array('class'=>'iconsmall'))); + } - if (has_capability("enrol/apply:enrol", $context)) { - $enrollink = new moodle_url("/enrol/apply/enroluser.php", array('enrolid'=>$instance->id)); - $icons[] = $OUTPUT->action_icon($enrollink, new pix_icon('t/enrolusers', get_string('enrolusers', 'enrol_apply'), 'core', array('class'=>'iconsmall'))); - } - - return $icons; - } + if (has_capability("enrol/apply:enrol", $context)) { + $enrollink = new moodle_url("/enrol/apply/enroluser.php", array('enrolid'=>$instance->id)); + $icons[] = $OUTPUT->action_icon($enrollink, new pix_icon('t/enrolusers', get_string('enrolusers', 'enrol_apply'), 'core', array('class'=>'iconsmall'))); + } + + return $icons; + } /** - * Is it possible to hide/show enrol instance via standard UI? - * - * @param stdClass $instance - * @return bool - */ - public function can_hide_show_instance($instance) { - $context = context_course::instance($instance->courseid); - return has_capability('enrol/apply:config', $context); - } - - /** - * Is it possible to delete enrol instance via standard UI? - * - * @param stdClass $instance - * @return bool - */ - - public function can_delete_instance($instance) { - $context = context_course::instance($instance->courseid); - return has_capability('enrol/apply:config', $context); - } - - - /** - * Sets up navigation entries. - * - * @param stdClass $instancesnode - * @param stdClass $instance - * @return void - */ - public function add_course_navigation($instancesnode, stdClass $instance) { + * Is it possible to hide/show enrol instance via standard UI? + * + * @param stdClass $instance + * @return bool + */ + public function can_hide_show_instance($instance) { + $context = context_course::instance($instance->courseid); + return has_capability('enrol/apply:config', $context); + } + + /** + * Is it possible to delete enrol instance via standard UI? + * + * @param stdClass $instance + * @return bool + */ + + public function can_delete_instance($instance) { + $context = context_course::instance($instance->courseid); + return has_capability('enrol/apply:config', $context); + } + + + /** + * Sets up navigation entries. + * + * @param stdClass $instancesnode + * @param stdClass $instance + * @return void + */ + public function add_course_navigation($instancesnode, stdClass $instance) { if ($instance->enrol !== 'apply') { throw new coding_exception('Invalid enrol instance type!'); } @@ -204,43 +204,43 @@ class enrol_apply_plugin extends enrol_plugin { } } - public function get_user_enrolment_actions(course_enrolment_manager $manager, $ue) { - $actions = array(); - $context = $manager->get_context(); - $instance = $ue->enrolmentinstance; - $params = $manager->get_moodlepage()->url->params(); - $params['ue'] = $ue->id; - if ($this->allow_unenrol($instance) && has_capability("enrol/apply:unenrol", $context)) { - $url = new moodle_url('/enrol/apply/unenroluser.php', $params); - $actions[] = new user_enrolment_action(new pix_icon('t/delete', ''), get_string('unenrol', 'enrol'), $url, array('class'=>'unenrollink', 'rel'=>$ue->id)); - } - if ($this->allow_manage($instance) && has_capability("enrol/apply:manage", $context)) { - $url = new moodle_url('/enrol/apply/editenrolment.php', $params); - $actions[] = new user_enrolment_action(new pix_icon('t/edit', ''), get_string('edit'), $url, array('class'=>'editenrollink', 'rel'=>$ue->id)); - } - return $actions; - } - - /** - * Returns defaults for new instances. - * @return array - */ - public function get_instance_defaults() { - $fields = array(); - $fields['status'] = $this->get_config('status'); - $fields['roleid'] = $this->get_config('roleid', 0); - $fields['customint1'] = $this->get_config('show_standard_user_profile'); - $fields['customint2'] = $this->get_config('show_extra_user_profile'); - $fields['customint3'] = $this->get_config('sendmailtoteacher'); - $fields['customint4'] = $this->get_config('sendmailtomanager'); - - return $fields; - } + public function get_user_enrolment_actions(course_enrolment_manager $manager, $ue) { + $actions = array(); + $context = $manager->get_context(); + $instance = $ue->enrolmentinstance; + $params = $manager->get_moodlepage()->url->params(); + $params['ue'] = $ue->id; + if ($this->allow_unenrol($instance) && has_capability("enrol/apply:unenrol", $context)) { + $url = new moodle_url('/enrol/apply/unenroluser.php', $params); + $actions[] = new user_enrolment_action(new pix_icon('t/delete', ''), get_string('unenrol', 'enrol'), $url, array('class'=>'unenrollink', 'rel'=>$ue->id)); + } + if ($this->allow_manage($instance) && has_capability("enrol/apply:manage", $context)) { + $url = new moodle_url('/enrol/apply/editenrolment.php', $params); + $actions[] = new user_enrolment_action(new pix_icon('t/edit', ''), get_string('edit'), $url, array('class'=>'editenrollink', 'rel'=>$ue->id)); + } + return $actions; + } + + /** + * Returns defaults for new instances. + * @return array + */ + public function get_instance_defaults() { + $fields = array(); + $fields['status'] = $this->get_config('status'); + $fields['roleid'] = $this->get_config('roleid', 0); + $fields['customint1'] = $this->get_config('show_standard_user_profile'); + $fields['customint2'] = $this->get_config('show_extra_user_profile'); + $fields['customint3'] = $this->get_config('sendmailtoteacher'); + $fields['customint4'] = $this->get_config('sendmailtomanager'); + + return $fields; + } } function getAllEnrolment($id = null) { - global $DB; - if ($id) { + 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 @@ -252,7 +252,7 @@ function getAllEnrolment($id = null) { WHERE ue.status != 0 AND e.id = ?'; $userenrolments = $DB->get_records_sql($sql, array($id)); - } else { + } 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 @@ -264,263 +264,263 @@ function getAllEnrolment($id = null) { WHERE ue.status != 0 AND e.enrol = ?'; $userenrolments = $DB->get_records_sql($sql, array('apply')); - } - return $userenrolments; + } + return $userenrolments; } function confirmEnrolment($enrols){ - global $DB; - global $CFG; - foreach ($enrols as $enrol){ - @$enroluser->id = $enrol; - @$enroluser->status = 0; - - if($DB->update_record('user_enrolments',$enroluser)){ - $userenrolments = $DB->get_record_sql('select * from '.$CFG->prefix.'user_enrolments where id='.$enrol); - $role = $DB->get_record_sql("select * from ".$CFG->prefix."role where archetype='student' limit 1"); - @$roleAssignments->userid = $userenrolments->userid; - @$roleAssignments->roleid = $role->id; - @$roleAssignments->contextid = 3; - @$roleAssignments->timemodified = time(); - @$roleAssignments->modifierid = 2; - $DB->insert_record('role_assignments',$roleAssignments); - $info = getRelatedInfo($enrol); - $DB->delete_records('enrol_apply_applicationinfo', array('userenrolmentid' => $enrol)); - sendConfirmMail($info); - } - } + global $DB; + global $CFG; + foreach ($enrols as $enrol){ + @$enroluser->id = $enrol; + @$enroluser->status = 0; + + if($DB->update_record('user_enrolments',$enroluser)){ + $userenrolments = $DB->get_record_sql('select * from '.$CFG->prefix.'user_enrolments where id='.$enrol); + $role = $DB->get_record_sql("select * from ".$CFG->prefix."role where archetype='student' limit 1"); + @$roleAssignments->userid = $userenrolments->userid; + @$roleAssignments->roleid = $role->id; + @$roleAssignments->contextid = 3; + @$roleAssignments->timemodified = time(); + @$roleAssignments->modifierid = 2; + $DB->insert_record('role_assignments',$roleAssignments); + $info = getRelatedInfo($enrol); + $DB->delete_records('enrol_apply_applicationinfo', array('userenrolmentid' => $enrol)); + sendConfirmMail($info); + } + } } 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); - } - } + 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){ - $info = getRelatedInfo($enrol); - if($DB->delete_records('user_enrolments',array('id'=>$enrol))){ - $DB->delete_records('enrol_apply_applicationinfo', array('userenrolmentid' => $enrol)); - sendCancelMail($info); - } - } + global $DB; + foreach ($enrols as $enrol){ + $info = getRelatedInfo($enrol); + if($DB->delete_records('user_enrolments',array('id'=>$enrol))){ + $DB->delete_records('enrol_apply_applicationinfo', array('userenrolmentid' => $enrol)); + sendCancelMail($info); + } + } } function sendCancelMail($info){ - global $DB; - global $CFG; - $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 = $apply_setting['cancelmailcontent']->value; - $body = updateMailContent($body,$replace); - $contact = core_user::get_support_user(); - email_to_user($info, $contact, $apply_setting['cancelmailsubject']->value, html_to_text($body), $body); + global $DB; + global $CFG; + $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 = $apply_setting['cancelmailcontent']->value; + $body = updateMailContent($body,$replace); + $contact = core_user::get_support_user(); + email_to_user($info, $contact, $apply_setting['cancelmailsubject']->value, html_to_text($body), $body); } function sendConfirmMail($info){ - global $DB; - global $CFG; - $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 = $apply_setting['confirmmailcontent']->value; - $body = updateMailContent($body,$replace); - $contact = core_user::get_support_user(); - email_to_user($info, $contact, $apply_setting['confirmmailsubject']->value, html_to_text($body), $body); + global $DB; + global $CFG; + $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 = $apply_setting['confirmmailcontent']->value; + $body = updateMailContent($body,$replace); + $contact = core_user::get_support_user(); + email_to_user($info, $contact, $apply_setting['confirmmailsubject']->value, html_to_text($body), $body); } function sendWaitMail($info){ - global $DB; - global $CFG; + global $DB; + global $CFG; //global $USER; - $apply_setting = $DB->get_records_sql("select name,value from ".$CFG->prefix."config_plugins where plugin='enrol_apply'"); + $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(); + $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); + email_to_user($info, $contact, get_config('enrol_apply', 'waitmailsubject'), html_to_text($body), $body); } function sendConfirmMailToTeachers($instance,$info,$applydescription){ - global $DB; - global $CFG; - global $USER; - - $courseid = $instance->courseid; - $instanceid = $instance->id; - $apply_setting = $DB->get_records_sql("select name,value from ".$CFG->prefix."config_plugins where plugin='enrol_apply'"); - - $show_standard_user_profile = $show_extra_user_profile = false; - if($instance->customint1 != ''){ - ($instance->customint1 == 0)?$show_standard_user_profile = true:$show_standard_user_profile = false; - }else{ - ($apply_setting['show_standard_user_profile']->value == 0)?$show_standard_user_profile = true:$show_standard_user_profile = false; - } - - if($instance->customint2 != ''){ - ($instance->customint2 == 0)?$show_extra_user_profile = true:$show_extra_user_profile = false; - }else{ - ($apply_setting['show_extra_user_profile']->value == 0)?$show_extra_user_profile = true:$show_extra_user_profile = false; - } - - if($instance->customint3 == 1){ - $course = get_course($courseid); - $context = context_course::instance($courseid, MUST_EXIST); - $teacherType = $DB->get_record('role',array("shortname"=>"editingteacher")); - $teachers = $DB->get_records('role_assignments', array('contextid'=>$context->id,'roleid'=>$teacherType->id)); - foreach($teachers as $teacher){ - $editTeacher = $DB->get_record('user',array('id'=>$teacher->userid)); - $body = '

'. get_string('coursename', 'enrol_apply') .': '.format_string($course->fullname).'

'; - $body .= '

'. get_string('applyuser', 'enrol_apply') .': '.$USER->firstname.' '.$USER->lastname.'

'; - $body .= '

'. get_string('comment', 'enrol_apply') .': '.$applydescription.'

'; - - if($show_standard_user_profile){ - $body .= '

'. get_string('user_profile', 'enrol_apply').'

'; - $body .= '

'. get_string('firstname') .': '.$info->firstname.'

'; - $body .= '

'. get_string('lastname') .': '.$info->lastname.'

'; - $body .= '

'. get_string('email') .': '.$info->email.'

'; - $body .= '

'. get_string('city') .': '.$info->city.'

'; - $body .= '

'. get_string('country') .': '.$info->country.'

'; - $body .= '

'. get_string('preferredlanguage') .': '.$info->lang.'

'; - $body .= '

'. get_string('description') .': '.$info->description_editor['text'].'

'; - - $body .= '

'. get_string('firstnamephonetic') .': '.$info->firstnamephonetic.'

'; - $body .= '

'. get_string('lastnamephonetic') .': '.$info->lastnamephonetic.'

'; - $body .= '

'. get_string('middlename') .': '.$info->middlename.'

'; - $body .= '

'. get_string('alternatename') .': '.$info->alternatename.'

'; - $body .= '

'. get_string('url') .': '.$info->url.'

'; - $body .= '

'. get_string('icqnumber') .': '.$info->icq.'

'; - $body .= '

'. get_string('skypeid') .': '.$info->skype.'

'; - $body .= '

'. get_string('aimid') .': '.$info->aim.'

'; - $body .= '

'. get_string('yahooid') .': '.$info->yahoo.'

'; - $body .= '

'. get_string('msnid') .': '.$info->msn.'

'; - $body .= '

'. get_string('idnumber') .': '.$info->idnumber.'

'; - $body .= '

'. get_string('institution') .': '.$info->institution.'

'; - $body .= '

'. get_string('department') .': '.$info->department.'

'; - $body .= '

'. get_string('phone') .': '.$info->phone1.'

'; - $body .= '

'. get_string('phone2') .': '.$info->phone2.'

'; - $body .= '

'. get_string('address') .': '.$info->address.'

'; - } - - if($show_extra_user_profile){ - require_once($CFG->dirroot.'/user/profile/lib.php'); - $user = $DB->get_record('user',array('id'=>$USER->id)); - profile_load_custom_fields($user); - foreach ($user->profile as $key => $value) { - $body .= '

'. $key .': '.$value.'

'; - } - } - - $body .= '

'. html_writer::link(new moodle_url("/enrol/apply/apply.php", array('id'=>$courseid,'enrolid'=>$instanceid)), get_string('applymanage', 'enrol_apply')).'

'; - $contact = core_user::get_support_user(); - $info = $editTeacher; - $info->coursename = $course->fullname; - email_to_user($info, $contact, get_string('mailtoteacher_suject', 'enrol_apply'), html_to_text($body), $body); - } - } + global $DB; + global $CFG; + global $USER; + + $courseid = $instance->courseid; + $instanceid = $instance->id; + $apply_setting = $DB->get_records_sql("select name,value from ".$CFG->prefix."config_plugins where plugin='enrol_apply'"); + + $show_standard_user_profile = $show_extra_user_profile = false; + if($instance->customint1 != ''){ + ($instance->customint1 == 0)?$show_standard_user_profile = true:$show_standard_user_profile = false; + }else{ + ($apply_setting['show_standard_user_profile']->value == 0)?$show_standard_user_profile = true:$show_standard_user_profile = false; + } + + if($instance->customint2 != ''){ + ($instance->customint2 == 0)?$show_extra_user_profile = true:$show_extra_user_profile = false; + }else{ + ($apply_setting['show_extra_user_profile']->value == 0)?$show_extra_user_profile = true:$show_extra_user_profile = false; + } + + if($instance->customint3 == 1){ + $course = get_course($courseid); + $context = context_course::instance($courseid, MUST_EXIST); + $teacherType = $DB->get_record('role',array("shortname"=>"editingteacher")); + $teachers = $DB->get_records('role_assignments', array('contextid'=>$context->id,'roleid'=>$teacherType->id)); + foreach($teachers as $teacher){ + $editTeacher = $DB->get_record('user',array('id'=>$teacher->userid)); + $body = '

'. get_string('coursename', 'enrol_apply') .': '.format_string($course->fullname).'

'; + $body .= '

'. get_string('applyuser', 'enrol_apply') .': '.$USER->firstname.' '.$USER->lastname.'

'; + $body .= '

'. get_string('comment', 'enrol_apply') .': '.$applydescription.'

'; + + if($show_standard_user_profile){ + $body .= '

'. get_string('user_profile', 'enrol_apply').'

'; + $body .= '

'. get_string('firstname') .': '.$info->firstname.'

'; + $body .= '

'. get_string('lastname') .': '.$info->lastname.'

'; + $body .= '

'. get_string('email') .': '.$info->email.'

'; + $body .= '

'. get_string('city') .': '.$info->city.'

'; + $body .= '

'. get_string('country') .': '.$info->country.'

'; + $body .= '

'. get_string('preferredlanguage') .': '.$info->lang.'

'; + $body .= '

'. get_string('description') .': '.$info->description_editor['text'].'

'; + + $body .= '

'. get_string('firstnamephonetic') .': '.$info->firstnamephonetic.'

'; + $body .= '

'. get_string('lastnamephonetic') .': '.$info->lastnamephonetic.'

'; + $body .= '

'. get_string('middlename') .': '.$info->middlename.'

'; + $body .= '

'. get_string('alternatename') .': '.$info->alternatename.'

'; + $body .= '

'. get_string('url') .': '.$info->url.'

'; + $body .= '

'. get_string('icqnumber') .': '.$info->icq.'

'; + $body .= '

'. get_string('skypeid') .': '.$info->skype.'

'; + $body .= '

'. get_string('aimid') .': '.$info->aim.'

'; + $body .= '

'. get_string('yahooid') .': '.$info->yahoo.'

'; + $body .= '

'. get_string('msnid') .': '.$info->msn.'

'; + $body .= '

'. get_string('idnumber') .': '.$info->idnumber.'

'; + $body .= '

'. get_string('institution') .': '.$info->institution.'

'; + $body .= '

'. get_string('department') .': '.$info->department.'

'; + $body .= '

'. get_string('phone') .': '.$info->phone1.'

'; + $body .= '

'. get_string('phone2') .': '.$info->phone2.'

'; + $body .= '

'. get_string('address') .': '.$info->address.'

'; + } + + if($show_extra_user_profile){ + require_once($CFG->dirroot.'/user/profile/lib.php'); + $user = $DB->get_record('user',array('id'=>$USER->id)); + profile_load_custom_fields($user); + foreach ($user->profile as $key => $value) { + $body .= '

'. $key .': '.$value.'

'; + } + } + + $body .= '

'. html_writer::link(new moodle_url("/enrol/apply/apply.php", array('id'=>$courseid,'enrolid'=>$instanceid)), get_string('applymanage', 'enrol_apply')).'

'; + $contact = core_user::get_support_user(); + $info = $editTeacher; + $info->coursename = $course->fullname; + email_to_user($info, $contact, get_string('mailtoteacher_suject', 'enrol_apply'), html_to_text($body), $body); + } + } } function sendConfirmMailToManagers($instance,$info,$applydescription){ - global $DB; - global $CFG; - global $USER; - - $courseid = $instance->courseid; - $apply_setting = $DB->get_records_sql("select name,value from ".$CFG->prefix."config_plugins where plugin='enrol_apply'"); - - $show_standard_user_profile = $show_extra_user_profile = false; - if($instance->customint1 != ''){ - ($instance->customint1 == 0)?$show_standard_user_profile = true:$show_standard_user_profile = false; - }else{ - ($apply_setting['show_standard_user_profile']->value == 0)?$show_standard_user_profile = true:$show_standard_user_profile = false; - } - - if($instance->customint2 != ''){ - ($instance->customint2 == 0)?$show_extra_user_profile = true:$show_extra_user_profile = false; - }else{ - ($apply_setting['show_extra_user_profile']->value == 0)?$show_extra_user_profile = true:$show_extra_user_profile = false; - } - - if($apply_setting['sendmailtomanager']->value == 1){ - $course = get_course($courseid); - $context = context_system::instance(); - $managerType = $DB->get_record('role',array("shortname"=>"manager")); - $managers = $DB->get_records('role_assignments', array('contextid'=>$context->id,'roleid'=>$managerType->id)); - foreach($managers as $manager){ - $userWithManagerRole = $DB->get_record('user',array('id'=>$manager->userid)); - $body = '

'. get_string('coursename', 'enrol_apply') .': '.format_string($course->fullname).'

'; - $body .= '

'. get_string('applyuser', 'enrol_apply') .': '.$USER->firstname.' '.$USER->lastname.'

'; - $body .= '

'. get_string('comment', 'enrol_apply') .': '.$applydescription.'

'; - if($show_standard_user_profile){ - $body .= '

'. get_string('user_profile', 'enrol_apply').'

'; - $body .= '

'. get_string('firstname') .': '.$info->firstname.'

'; - $body .= '

'. get_string('lastname') .': '.$info->lastname.'

'; - $body .= '

'. get_string('email') .': '.$info->email.'

'; - $body .= '

'. get_string('city') .': '.$info->city.'

'; - $body .= '

'. get_string('country') .': '.$info->country.'

'; - $body .= '

'. get_string('preferredlanguage') .': '.$info->lang.'

'; - $body .= '

'. get_string('description') .': '.$info->description_editor['text'].'

'; - - $body .= '

'. get_string('firstnamephonetic') .': '.$info->firstnamephonetic.'

'; - $body .= '

'. get_string('lastnamephonetic') .': '.$info->lastnamephonetic.'

'; - $body .= '

'. get_string('middlename') .': '.$info->middlename.'

'; - $body .= '

'. get_string('alternatename') .': '.$info->alternatename.'

'; - $body .= '

'. get_string('url') .': '.$info->url.'

'; - $body .= '

'. get_string('icqnumber') .': '.$info->icq.'

'; - $body .= '

'. get_string('skypeid') .': '.$info->skype.'

'; - $body .= '

'. get_string('aimid') .': '.$info->aim.'

'; - $body .= '

'. get_string('yahooid') .': '.$info->yahoo.'

'; - $body .= '

'. get_string('msnid') .': '.$info->msn.'

'; - $body .= '

'. get_string('idnumber') .': '.$info->idnumber.'

'; - $body .= '

'. get_string('institution') .': '.$info->institution.'

'; - $body .= '

'. get_string('department') .': '.$info->department.'

'; - $body .= '

'. get_string('phone') .': '.$info->phone1.'

'; - $body .= '

'. get_string('phone2') .': '.$info->phone2.'

'; - $body .= '

'. get_string('address') .': '.$info->address.'

'; - } - - if($show_extra_user_profile){ - require_once($CFG->dirroot.'/user/profile/lib.php'); - $user = $DB->get_record('user',array('id'=>$USER->id)); - profile_load_custom_fields($user); - foreach ($user->profile as $key => $value) { - $body .= '

'. $key .': '.$value.'

'; - } - } - - $body .= '

'. html_writer::link(new moodle_url('/enrol/apply/manage.php'), get_string('applymanage', 'enrol_apply')).'

'; - $contact = core_user::get_support_user(); - $info = $userWithManagerRole; - $info->coursename = $course->fullname; - email_to_user($info, $contact, get_string('mailtoteacher_suject', 'enrol_apply'), html_to_text($body), $body); - } - } + global $DB; + global $CFG; + global $USER; + + $courseid = $instance->courseid; + $apply_setting = $DB->get_records_sql("select name,value from ".$CFG->prefix."config_plugins where plugin='enrol_apply'"); + + $show_standard_user_profile = $show_extra_user_profile = false; + if($instance->customint1 != ''){ + ($instance->customint1 == 0)?$show_standard_user_profile = true:$show_standard_user_profile = false; + }else{ + ($apply_setting['show_standard_user_profile']->value == 0)?$show_standard_user_profile = true:$show_standard_user_profile = false; + } + + if($instance->customint2 != ''){ + ($instance->customint2 == 0)?$show_extra_user_profile = true:$show_extra_user_profile = false; + }else{ + ($apply_setting['show_extra_user_profile']->value == 0)?$show_extra_user_profile = true:$show_extra_user_profile = false; + } + + if($apply_setting['sendmailtomanager']->value == 1){ + $course = get_course($courseid); + $context = context_system::instance(); + $managerType = $DB->get_record('role',array("shortname"=>"manager")); + $managers = $DB->get_records('role_assignments', array('contextid'=>$context->id,'roleid'=>$managerType->id)); + foreach($managers as $manager){ + $userWithManagerRole = $DB->get_record('user',array('id'=>$manager->userid)); + $body = '

'. get_string('coursename', 'enrol_apply') .': '.format_string($course->fullname).'

'; + $body .= '

'. get_string('applyuser', 'enrol_apply') .': '.$USER->firstname.' '.$USER->lastname.'

'; + $body .= '

'. get_string('comment', 'enrol_apply') .': '.$applydescription.'

'; + if($show_standard_user_profile){ + $body .= '

'. get_string('user_profile', 'enrol_apply').'

'; + $body .= '

'. get_string('firstname') .': '.$info->firstname.'

'; + $body .= '

'. get_string('lastname') .': '.$info->lastname.'

'; + $body .= '

'. get_string('email') .': '.$info->email.'

'; + $body .= '

'. get_string('city') .': '.$info->city.'

'; + $body .= '

'. get_string('country') .': '.$info->country.'

'; + $body .= '

'. get_string('preferredlanguage') .': '.$info->lang.'

'; + $body .= '

'. get_string('description') .': '.$info->description_editor['text'].'

'; + + $body .= '

'. get_string('firstnamephonetic') .': '.$info->firstnamephonetic.'

'; + $body .= '

'. get_string('lastnamephonetic') .': '.$info->lastnamephonetic.'

'; + $body .= '

'. get_string('middlename') .': '.$info->middlename.'

'; + $body .= '

'. get_string('alternatename') .': '.$info->alternatename.'

'; + $body .= '

'. get_string('url') .': '.$info->url.'

'; + $body .= '

'. get_string('icqnumber') .': '.$info->icq.'

'; + $body .= '

'. get_string('skypeid') .': '.$info->skype.'

'; + $body .= '

'. get_string('aimid') .': '.$info->aim.'

'; + $body .= '

'. get_string('yahooid') .': '.$info->yahoo.'

'; + $body .= '

'. get_string('msnid') .': '.$info->msn.'

'; + $body .= '

'. get_string('idnumber') .': '.$info->idnumber.'

'; + $body .= '

'. get_string('institution') .': '.$info->institution.'

'; + $body .= '

'. get_string('department') .': '.$info->department.'

'; + $body .= '

'. get_string('phone') .': '.$info->phone1.'

'; + $body .= '

'. get_string('phone2') .': '.$info->phone2.'

'; + $body .= '

'. get_string('address') .': '.$info->address.'

'; + } + + if($show_extra_user_profile){ + require_once($CFG->dirroot.'/user/profile/lib.php'); + $user = $DB->get_record('user',array('id'=>$USER->id)); + profile_load_custom_fields($user); + foreach ($user->profile as $key => $value) { + $body .= '

'. $key .': '.$value.'

'; + } + } + + $body .= '

'. html_writer::link(new moodle_url('/enrol/apply/manage.php'), get_string('applymanage', 'enrol_apply')).'

'; + $contact = core_user::get_support_user(); + $info = $userWithManagerRole; + $info->coursename = $course->fullname; + email_to_user($info, $contact, get_string('mailtoteacher_suject', 'enrol_apply'), html_to_text($body), $body); + } + } } function getRelatedInfo($enrolid){ - global $DB; - global $CFG; - return $DB->get_record_sql('select u.*,c.fullname as coursename 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.id='.$enrolid); + global $DB; + global $CFG; + return $DB->get_record_sql('select u.*,c.fullname as coursename 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.id='.$enrolid); } function updateMailContent($content,$replace){ - foreach ($replace as $key=>$val) { - $content = str_replace("{".$key."}",$val,$content); - } - return $content; + foreach ($replace as $key=>$val) { + $content = str_replace("{".$key."}",$val,$content); + } + return $content; } diff --git a/locallib.php b/locallib.php index b84fda8..4ee596a 100644 --- a/locallib.php +++ b/locallib.php @@ -2,7 +2,7 @@ /** * ************************************************************************* - * * Apply Enrol ** + * * Apply Enrol ** * ************************************************************************* * @copyright emeneo.com ** * @link emeneo.com ** @@ -56,7 +56,7 @@ class enrol_apply_enrol_form extends moodleform { // nothing? } - $mform->addElement('html', '

'.$instance->customtext1.'

'); + $mform->addElement('html', '

'.$instance->customtext1.'

'); $mform->addElement('textarea', 'applydescription', get_string('comment', 'enrol_apply'),'cols="80"'); //user profile diff --git a/manage.php b/manage.php index 26050ba..5da4902 100644 --- a/manage.php +++ b/manage.php @@ -1,7 +1,7 @@ navbar->add ( get_string ( 'confirmusers', 'enrol_apply' ) ); $PAGE->set_title ( "$site->shortname: " . get_string ( 'confirmusers', 'enrol_apply' ) ); if (isset ( $_POST ['enrolid'] )) { - if ($_POST ['enrolid']) { - if ($_POST ['type'] == 'confirm') { - confirmEnrolment ( $_POST ['enrolid'] ); - } elseif ($_POST ['type'] == 'cancel') { - cancelEnrolment ( $_POST ['enrolid'] ); - } - redirect ( "$CFG->wwwroot/enrol/apply/manage.php" ); - } + if ($_POST ['enrolid']) { + if ($_POST ['type'] == 'confirm') { + confirmEnrolment ( $_POST ['enrolid'] ); + } elseif ($_POST ['type'] == 'cancel') { + cancelEnrolment ( $_POST ['enrolid'] ); + } + redirect ( "$CFG->wwwroot/enrol/apply/manage.php" ); + } } $enrols = getAllEnrolment(); @@ -49,11 +49,11 @@ echo '' . get_string ( 'applyusermail', 'enrol_ap echo '' . get_string ( 'applydate', 'enrol_apply' ) . ''; echo ''; foreach ( $enrols as $enrol ) { - echo ''; - echo '' . format_string($enrol->course) . ''; - echo '' . $enrol->firstname . ' ' . $enrol->lastname . ''; - echo '' . $enrol->email . ''; - echo '' . date ( "Y-m-d", $enrol->timecreated ) . ''; + echo ''; + echo '' . format_string($enrol->course) . ''; + echo '' . $enrol->firstname . ' ' . $enrol->lastname . ''; + echo '' . $enrol->email . ''; + echo '' . date ( "Y-m-d", $enrol->timecreated ) . ''; } echo ''; echo '

  

'; diff --git a/settings.php b/settings.php index de61af9..ed85bbb 100644 --- a/settings.php +++ b/settings.php @@ -1,7 +1,7 @@ fulltree) { $settings->add(new admin_setting_heading('enrol_apply_cancelmailcontent', '', get_string('cancelmailcontent_desc', 'enrol_apply'))); $settings->add(new admin_setting_confightmleditor('enrol_apply/cancelmailcontent', get_string('cancelmailcontent', 'enrol_apply'),'utf-8','')); - $settings->add(new admin_setting_configcheckbox('enrol_apply/sendmailtoteacher', get_string('sendmailtoteacher', 'enrol_apply'), '', 0)); + $settings->add(new admin_setting_configcheckbox('enrol_apply/sendmailtoteacher', get_string('sendmailtoteacher', 'enrol_apply'), '', 0)); $settings->add(new admin_setting_configcheckbox('enrol_apply/sendmailtomanager', get_string('sendmailtomanager', 'enrol_apply'), '', 0)); //--- enrol instance defaults ---------------------------------------------------------------------------- diff --git a/unenrolself.php b/unenrolself.php index 942014c..cf92998 100644 --- a/unenrolself.php +++ b/unenrolself.php @@ -49,11 +49,11 @@ $PAGE->set_title($plugin->get_instance_name($instance)); if ($confirm and confirm_sesskey()) { $plugin->unenrol_user($instance, $USER->id); - - // Deprecated fixed by Shiro + + // Deprecated fixed by Shiro //add_to_log($course->id, 'course', 'unenrol', '../enrol/users.php?id='.$course->id, $course->id); //TODO: there should be userid somewhere! - $context = context_course::instance($course->id); - \core\event\user_enrolment_deleted::delete(array('context' => $context))->trigger(); + $context = context_course::instance($course->id); + \core\event\user_enrolment_deleted::delete(array('context' => $context))->trigger(); redirect(new moodle_url('/index.php')); } diff --git a/unenroluser.php b/unenroluser.php index 9d423e4..dd2f7f1 100644 --- a/unenroluser.php +++ b/unenroluser.php @@ -1,7 +1,7 @@ $ue->enrolid, 'contextcourse' => CONTEXT_COURSE); $course = $DB->get_record_sql($sql, $params, MUST_EXIST); diff --git a/version.php b/version.php index 9d68c8b..373640b 100644 --- a/version.php +++ b/version.php @@ -1,7 +1,7 @@ version = 2016042201;