diff --git a/apply_form.php b/apply_form.php index 93a6f1e..33c2029 100644 --- a/apply_form.php +++ b/apply_form.php @@ -53,22 +53,22 @@ class enrol_apply_apply_form extends moodleform { $mform->addElement('header', 'selfheader', $heading); $mform->addElement('html', '
'.$instance->customtext1.'
'); - $mform->addElement('textarea', 'applydescription', get_string('comment', 'enrol_apply'),'cols="80"'); + $mform->addElement('textarea', 'applydescription', get_string('comment', 'enrol_apply'), 'cols="80"'); $mform->setType('applydescription', PARAM_TEXT); - //user profile + // User profile... $editoroptions = $filemanageroptions = null; - if($instance->customint1){ + if ($instance->customint1) { useredit_shared_definition($mform, $editoroptions, $filemanageroptions, $USER); } - if($instance->customint2){ + if ($instance->customint2) { profile_definition($mform, $USER->id); } $mform->setDefaults((array)$USER); - + $this->add_action_buttons(false, get_string('enrolme', 'enrol_self')); $mform->addElement('hidden', 'id'); diff --git a/db/access.php b/db/access.php index d3c75d9..364b4a4 100644 --- a/db/access.php +++ b/db/access.php @@ -36,8 +36,7 @@ $capabilities = array( ) ), - /** - * Enrolment approval. + /* Enrolment approval. * If granted on CONTEXT_SYSTEM level it allows approval for all courses * at Site Administration -> Courses -> Manage enrolment applications. */ diff --git a/edit.php b/edit.php index 2875f27..1cf82c2 100644 --- a/edit.php +++ b/edit.php @@ -26,18 +26,18 @@ require('../../config.php'); require_once('edit_form.php'); $courseid = required_param('courseid', PARAM_INT); -$instanceid = optional_param('id', 0, PARAM_INT); // instanceid +$instanceid = optional_param('id', 0, PARAM_INT); -$course = $DB->get_record('course', array('id'=>$courseid), '*', MUST_EXIST); -$context = context_course::instance($course->id, MUST_EXIST); +$course = get_course($courseid); +$context = context_course::instance($course->id, MUST_EXIST); require_login($course); require_capability('enrol/apply:config', $context); -$PAGE->set_url('/enrol/apply/edit.php', array('courseid'=>$course->id, 'id'=>$instanceid)); +$PAGE->set_url('/enrol/apply/edit.php', array('courseid' => $course->id, 'id' => $instanceid)); $PAGE->set_pagelayout('admin'); -$return = new moodle_url('/enrol/instances.php', array('id'=>$course->id)); +$return = new moodle_url('/enrol/instances.php', array('id' => $course->id)); if (!enrol_is_enabled('apply')) { redirect($return); } @@ -45,42 +45,48 @@ if (!enrol_is_enabled('apply')) { $plugin = enrol_get_plugin('apply'); if ($instanceid) { - $instance = $DB->get_record('enrol', array('courseid'=>$course->id, 'enrol'=>'apply', 'id'=>$instanceid), '*', MUST_EXIST); + $instance = $DB->get_record( + 'enrol', + array( + 'courseid' => $course->id, + 'enrol' => 'apply', + 'id' => $instanceid), + '*', MUST_EXIST); } else { require_capability('moodle/course:enrolconfig', $context); - // no instance yet, we have to add new instance - navigation_node::override_active_url(new moodle_url('/enrol/instances.php', array('id'=>$course->id))); + // No instance yet, we have to add new instance. + navigation_node::override_active_url(new moodle_url('/enrol/instances.php', array('id' => $course->id))); $instance = (object)$plugin->get_instance_defaults(); $instance->id = null; $instance->courseid = $course->id; } -$mform = new enrol_apply_edit_form(NULL, array($instance, $plugin, $context)); +$mform = new enrol_apply_edit_form(null, array($instance, $plugin, $context)); if ($mform->is_cancelled()) { redirect($return); } else if ($data = $mform->get_data()) { if ($instance->id) { - $instance->status = $data->status; - $instance->name = $data->name; - $instance->customtext1 = $data->customtext1; - $instance->customint1 = $data->customint1; - $instance->customint2 = $data->customint2; - $instance->customint3 = $data->customint3; - $instance->roleid = $data->roleid; - $instance->timemodified = time(); + $instance->status = $data->status; + $instance->name = $data->name; + $instance->customtext1 = $data->customtext1; + $instance->customint1 = $data->customint1; + $instance->customint2 = $data->customint2; + $instance->customint3 = $data->customint3; + $instance->roleid = $data->roleid; + $instance->timemodified = time(); $DB->update_record('enrol', $instance); } else { $fields = array( - 'status' =>$data->status, - 'name' =>$data->name, - 'roleid' =>$data->roleid, - 'customint1' =>$data->customint1, - 'customint2' =>$data->customint2, - 'customint3' =>$data->customint3, - 'customtext1' =>$data->customtext1); + 'status' => $data->status, + 'name' => $data->name, + 'roleid' => $data->roleid, + 'customint1' => $data->customint1, + 'customint2' => $data->customint2, + 'customint3' => $data->customint3, + 'customtext1' => $data->customtext1); $plugin->add_instance($course, $fields); } diff --git a/edit_form.php b/edit_form.php index 0572c74..649a100 100644 --- a/edit_form.php +++ b/edit_form.php @@ -28,7 +28,7 @@ require_once($CFG->libdir.'/formslib.php'); class enrol_apply_edit_form extends moodleform { - function definition() { + protected function definition() { $mform = $this->_form; list($instance, $plugin, $context) = $this->_customdata; diff --git a/lang/ca/enrol_apply.php b/lang/ca/enrol_apply.php index 5c2a903..88151dd 100644 --- a/lang/ca/enrol_apply.php +++ b/lang/ca/enrol_apply.php @@ -1,14 +1,25 @@ . + +/** + * @package enrol_apply + * @copyright emeneo.com (http://emeneo.com/) + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + // The name of your plugin. Displayed on admin menus. $string['enrolname'] = 'Inscripció prèvia aprovació'; $string['pluginname'] = 'Inscripció prèvia aprovació'; @@ -26,7 +37,7 @@ $string['confirmusers'] = 'Confirmar inscripcions'; $string['coursename'] = 'Curs'; $string['applyuser'] = 'Nom / Cognom'; $string['applyusermail'] = 'Correu electrònic'; -$string['applydate'] = 'Data d\'inscripció'; +$string['applydate'] = 'Data d\'inscripció'; $string['btnconfirm'] = 'Confirmar'; $string['btncancel'] = 'Cancel·lar'; $string['enrolusers'] = 'Inscriure usuaris'; @@ -34,10 +45,10 @@ $string['enrolusers'] = 'Inscriure usuaris'; $string['status'] = 'Permet inscripció prèvia aprovació'; $string['confirmenrol'] = 'Gestionar sol·licituds'; -$string['apply:config'] = 'Configurar instàncies d\'Inscripció prèvia aprovació'; // Needs more insight -$string['apply:manageapplications'] = 'Gestionar la Inscripció prèvia aprovació'; // Needs more insight -$string['apply:unenrol'] = 'Cancel·lar usuaris del curs'; // Needs more insight - +$string['apply:config'] = 'Configurar instàncies d\'Inscripció prèvia aprovació'; // Needs more insight. +$string['apply:manageapplications'] = 'Gestionar la Inscripció prèvia aprovació'; // Needs more insight. +$string['apply:unenrol'] = 'Cancel·lar usuaris del curs'; // Needs more insight. + $string['notification'] = 'Sol·licitud d\'inscripció enviada correctament.'. 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($standarduserfields){ + if ($standarduserfields) { $body .= ''. get_string('user_profile', 'enrol_apply').'
'; $body .= ''. get_string('firstname') .': '.$standarduserfields->firstname.'
'; $body .= ''. get_string('lastname') .': '.$standarduserfields->lastname.'
'; @@ -110,7 +124,7 @@ class enrol_apply_renderer extends plugin_renderer_base { $body .= ''. get_string('address') .': '.$standarduserfields->address.'
'; } - if($extrauserfields){ + if ($extrauserfields) { foreach ($extrauserfields as $key => $value) { $body .= ''. $key .': '.$value.'
'; } @@ -120,4 +134,4 @@ class enrol_apply_renderer extends plugin_renderer_base { return $body; } -} \ No newline at end of file +} diff --git a/settings.php b/settings.php index cbe9ae2..f58eb01 100644 --- a/settings.php +++ b/settings.php @@ -26,9 +26,9 @@ defined('MOODLE_INTERNAL') || die(); if ($ADMIN->fulltree) { - $settings->add(new admin_setting_heading('enrol_apply_enrolname','',get_string('pluginname_desc', 'enrol_apply'))); - - // Confirm mail settings. + $settings->add(new admin_setting_heading('enrol_apply_enrolname', '', get_string('pluginname_desc', 'enrol_apply'))); + + // Confirm mail settings... $settings->add(new admin_setting_heading( 'enrol_apply_confirmmail', get_string('confirmmail_heading', 'enrol_apply'), @@ -66,7 +66,7 @@ if ($ADMIN->fulltree) { null, PARAM_RAW)); - // Cancel mail settings + // Cancel mail settings... $settings->add(new admin_setting_heading( 'enrol_apply_cancelmail', get_string('cancelmail_heading', 'enrol_apply'), @@ -85,7 +85,7 @@ if ($ADMIN->fulltree) { null, PARAM_RAW)); - // Notification settings. + // Notification settings... $settings->add(new admin_setting_heading( 'enrol_apply_notify', get_string('notify_heading', 'enrol_apply'), @@ -101,7 +101,7 @@ if ($ADMIN->fulltree) { '', 0)); - // Enrol instance defaults. + // Enrol instance defaults... $settings->add(new admin_setting_heading('enrol_manual_defaults', get_string('enrolinstancedefaults', 'admin'), get_string('enrolinstancedefaults_desc', 'admin'))); @@ -132,7 +132,7 @@ if ($ADMIN->fulltree) { } } -if ($hassiteconfig) { // needs this condition or there is error on login page +if ($hassiteconfig) { // Needs this condition or there is error on login page. $ADMIN->add('courses', new admin_externalpage('enrol_apply', get_string('applymanage', 'enrol_apply'), new moodle_url('/enrol/apply/manage.php'))); diff --git a/unenrolself.php b/unenrolself.php index 77a875e..4cf6021 100644 --- a/unenrolself.php +++ b/unenrolself.php @@ -30,8 +30,8 @@ require('../../config.php'); $enrolid = required_param('enrolid', PARAM_INT); $confirm = optional_param('confirm', 0, PARAM_BOOL); -$instance = $DB->get_record('enrol', array('id'=>$enrolid, 'enrol'=>'apply'), '*', MUST_EXIST); -$course = $DB->get_record('course', array('id'=>$instance->courseid), '*', MUST_EXIST); +$instance = $DB->get_record('enrol', array('id' => $enrolid, 'enrol' => 'apply'), '*', MUST_EXIST); +$course = $DB->get_record('course', array('id' => $instance->courseid), '*', MUST_EXIST); $context = context_course::instance($course->id, MUST_EXIST); require_login(); @@ -44,10 +44,10 @@ $plugin = enrol_get_plugin('apply'); // Security defined inside following function. if (!$plugin->get_unenrolself_link($instance)) { - redirect(new moodle_url('/course/view.php', array('id'=>$course->id))); + redirect(new moodle_url('/course/view.php', array('id' => $course->id))); } -$PAGE->set_url('/enrol/apply/unenrolself.php', array('enrolid'=>$instance->id)); +$PAGE->set_url('/enrol/apply/unenrolself.php', array('enrolid' => $instance->id)); $PAGE->set_title($plugin->get_instance_name($instance)); if ($confirm and confirm_sesskey()) { @@ -57,8 +57,9 @@ if ($confirm and confirm_sesskey()) { } echo $OUTPUT->header(); -$yesurl = new moodle_url($PAGE->url, array('confirm'=>1, 'sesskey'=>sesskey())); -$nourl = new moodle_url('/course/view.php', array('id'=>$course->id)); -$message = get_string('unenrolselfconfirm', 'enrol_self', format_string($course->fullname)); //I leave the unenrolselfconfirm message because it fits perfectly +$yesurl = new moodle_url($PAGE->url, array('confirm' => 1, 'sesskey' => sesskey())); +$nourl = new moodle_url('/course/view.php', array('id' => $course->id)); +// I leave the unenrolselfconfirm message because it fits perfectly. +$message = get_string('unenrolselfconfirm', 'enrol_self', format_string($course->fullname)); echo $OUTPUT->confirm($message, $yesurl, $nourl); echo $OUTPUT->footer();