Browse Source

Format code (code checker)

SABERES_37_STABLE
Johannes Burk 9 years ago
parent
commit
fbb31ec2a0
  1. 10
      apply_form.php
  2. 3
      db/access.php
  3. 54
      edit.php
  4. 2
      edit_form.php
  5. 43
      lang/ca/enrol_apply.php
  6. 32
      lang/de/enrol_apply.php
  7. 34
      lang/en/enrol_apply.php
  8. 32
      lang/en_us/en_us_enrol_apply.php
  9. 47
      lang/es/enrol_apply.php
  10. 33
      lang/it/enrol_apply.php
  11. 51
      lang/pt_br/enrol_apply.php
  12. 31
      lang/zh_cn/enrol_apply.php
  13. 133
      lib.php
  14. 10
      manage.php
  15. 17
      manage_table.php
  16. 30
      renderer.php
  17. 14
      settings.php
  18. 15
      unenrolself.php

10
apply_form.php

@ -53,22 +53,22 @@ class enrol_apply_apply_form extends moodleform {
$mform->addElement('header', 'selfheader', $heading);
$mform->addElement('html', '<p>'.$instance->customtext1.'</p>');
$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');

3
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.
*/

54
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);
}

2
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;

43
lang/ca/enrol_apply.php

@ -1,14 +1,25 @@
<?php
/**
* *************************************************************************
* * Apply Enrol **
* *************************************************************************
* @copyright emeneo.com **
* @link emeneo.com **
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later **
* *************************************************************************
* ************************************************************************
*/
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* @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'] = '<b>Sol·licitud d\'inscripció enviada correctament</b>. <br/><br/>Rebràs una notificació per correu electrònic un cop estigui confirmada la inscripció.';
$string['sendmailtoteacher'] = 'Enviar notificacions per correu als professors';
@ -48,5 +59,3 @@ $string['comment'] = 'Comentari';
$string['applymanage'] = 'Gestionar inscripcions';
$string['status_desc'] = 'Allow course access of internally enrolled users.';
?>

32
lang/de/enrol_apply.php

@ -1,14 +1,25 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* *************************************************************************
* * Apply Enrol **
* *************************************************************************
* @copyright emeneo.com **
* @link emeneo.com **
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later **
* *************************************************************************
* ************************************************************************
*/
* @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'] = 'Bestätigung der Kurseinschreibung';
$string['pluginname'] = 'Bestätigung der Kurseinschreibung';
@ -42,7 +53,7 @@ $string['confirmenrol'] = 'Einschreibeanfragen bearbeiten';
$string['apply:config'] = 'Einschreibungsbelegstellen anlegen';
$string['apply:manageapplications'] = 'Einschreibungsanfragen verwalten';
$string['apply:unenrol'] = 'Benutzer aus dem Kurs entfernen';
$string['notification'] = '<b>Einschreibungsantrag wurde erfolgreich gesendet.</b>. <br/><br/>Sie werden via Mail informiert, sobald Ihre Einschreibung bestätigt wurde.';
$string['sendmailtoteacher'] = 'Sende eine Hinweis-E-Mail an den Trainer';
@ -51,4 +62,3 @@ $string['editdescription'] = 'Beschreibung anpassen';
$string['applymanage'] = 'Manage enrolment applications';
$string['status_desc'] = 'Kurszugriff für intern eingeschriebene Nutzer/innen erlauben.';
?>

34
lang/en/enrol_apply.php

@ -1,14 +1,27 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* *************************************************************************
* * Apply Enrol **
* *************************************************************************
* @copyright emeneo.com **
* @link emeneo.com **
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later **
* *************************************************************************
* ************************************************************************
*/
* @package enrol_apply
* @copyright emeneo.com (http://emeneo.com/)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @author emeneo.com (http://emeneo.com/)
* @author Johannes Burk <johannes.burk@sudile.com>
*/
// The name of your plug-in. Displayed on admin menus.
$string['enrolname'] = 'Course enrol confirmation';
$string['pluginname'] = 'Course enrol confirmation';
@ -60,10 +73,8 @@ $string['apply:manageapplications'] = 'Manage apply enrolment';
$string['apply:unenrol'] = 'Cancel users from the course';
$string['apply:unenrolself'] = 'Cancel self from the course';
$string['notification'] = '<b>Enrolment application successfully sent</b>. <br/><br/>You will be informed by email when your enrolment has been confirmed.';
$string['mailtoteacher_suject'] = 'New Enrolment request!';
$string['editdescription'] = 'Textarea description';
$string['comment'] = 'Comment';
@ -74,4 +85,3 @@ $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';
?>

32
lang/en_us/en_us_enrol_apply.php

@ -1,14 +1,25 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* *************************************************************************
* * Apply enrol **
* *************************************************************************
* @copyright emeneo.com **
* @link emeneo.com **
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later **
* *************************************************************************
* ************************************************************************
*/
* @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 plug-in. Displayed on admin menus.
$string['enrollname'] = 'Course enrollment confirmation';
$string['pluginname'] = 'Course enrollment confirmation';
@ -38,7 +49,7 @@ $string['apply:config'] = 'Configure apply enroll instances';
$string['apply:manageapplications'] = 'Manage apply enrollment';
$string['apply:unenroll'] = 'Cancel users from the course';
$string['apply:unenrollapply'] = 'Cancel self from the course';
$string['notification'] = '<b>Enrolllment application successfully sent</b>. <br/><br/>You will be informed by email when your enrollment has been confirmed.';
$string['sendmailtoteacher'] = 'Send email notification to teachers';
@ -49,4 +60,3 @@ $string['comment'] = 'Comment';
$string['applymanage'] = 'Manage enrollment applications';
$string['status_desc'] = 'Allow course access of internally enrolled users.';
?>

47
lang/es/enrol_apply.php

@ -1,18 +1,29 @@
<?php
/**
* *************************************************************************
* * Apply Enrol **
* *************************************************************************
* @copyright emeneo.com **
* @link emeneo.com **
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later **
* *************************************************************************
* ************************************************************************
*/
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* @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'] = 'Matrículas solicitadas';
$string['pluginname'] = 'Matrículas solicitadas';
$string['pluginname_desc'] = 'With this plugin users can apply to a course and a teacher have to comfirm before the user gets enroled.'; // needs to be translated
$string['pluginname_desc'] = 'With this plugin users can apply to a course and a teacher have to comfirm before the user gets enroled.'; // Needs to be translated.
$string['confirmmailsubject'] = 'Asunto del correo de confirmación';
$string['confirmmailcontent'] = 'Contenido del correo de confirmación';
@ -26,7 +37,7 @@ $string['confirmusers'] = 'Confirmar matrículas';
$string['coursename'] = 'Curso';
$string['applyuser'] = 'Nombre / Apellido';
$string['applyusermail'] = 'Correo electrónico';
$string['applydate'] = 'Fecha de solicitud'; // Enrol date -> Fecha de matriculación
$string['applydate'] = 'Fecha de solicitud'; // Enrol date -> Fecha de matriculación.
$string['btnconfirm'] = 'Confirmar';
$string['btncancel'] = 'Cancelar';
$string['enrolusers'] = 'Matricular usuarios';
@ -34,10 +45,10 @@ $string['enrolusers'] = 'Matricular usuarios';
$string['status'] = 'Aceptar matriculación tras aprobación';
$string['confirmenrol'] = 'Gestionar solicitudes';
$string['apply:config'] = 'Configurar instancias de matrículas solicitadas'; // Needs more insight
$string['apply:manageapplications'] = 'Gestionar matrículas solicitadas'; // Needs more insight
$string['apply:unenrol'] = 'Cancelar usuarios del curso'; // Needs more insight
$string['apply:config'] = 'Configurar instancias de matrículas solicitadas'; // Needs more insight.
$string['apply:manageapplications'] = 'Gestionar matrículas solicitadas'; // Needs more insight.
$string['apply:unenrol'] = 'Cancelar usuarios del curso'; // Needs more insight.
$string['notification'] = '<b>Solicitud de matriculación enviada correctamente</b>. <br/><br/>Será notificado por correo electrónico en cuanto se confirme su matriculación.';
$string['sendmailtoteacher'] = 'Enviar notificaciones por correo a los profesores';
@ -47,6 +58,4 @@ $string['editdescription'] = 'Descripción del área de texto';
$string['comment'] = 'Comentario';
$string['applymanage'] = 'Gestionar matrículas';
$string['status_desc'] = 'Allow course access of internally enrolled users.'; // needs to be translated
?>
$string['status_desc'] = 'Allow course access of internally enrolled users.'; // Needs to be translated.

33
lang/it/enrol_apply.php

@ -1,14 +1,25 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* *************************************************************************
* * Apply Enrol **
* *************************************************************************
* @copyright emeneo.com **
* @link emeneo.com **
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later **
* *************************************************************************
* ************************************************************************
*/
* @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'] = 'Conferma di iscrizione al corso';
$string['pluginname'] = 'Conferma di iscrizione al corso';
@ -38,7 +49,7 @@ $string['apply:config'] = 'Configura le istanze del plugin';
$string['apply:manageapplications'] = 'Gestisci le richieste di iscrizione';
$string['apply:unenrol'] = 'Cancella gli utenti dal corso';
$string['apply:unenrolself'] = 'Permetti all\'utente di disiscriversi dal corso';
$string['notification'] = '<b>Richiesta di iscrizione al corso correttamente inviata</b>. <br/><br/>Verrai informato via email appena la tua richiesta di iscrizione viene confermata. Se vuoi iscriverti ad altri corsi, premi sul "catalogo dei corsi" sul top menu.';
$string['sendmailtoteacher'] = 'Manda email di notifica agli insegnanti';
@ -49,5 +60,3 @@ $string['comment'] = 'Commento';
$string['applymanage'] = 'Gestisci richieste di iscrizione';
$string['status_desc'] = 'Permette l\'accesso al corso agli utenti iscritti internamente.';
?>

51
lang/pt_br/enrol_apply.php

@ -1,18 +1,29 @@
<?php
/**
* *************************************************************************
* * Apply Enrol **
* *************************************************************************
* @copyright emeneo.com **
* @link emeneo.com **
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later **
* *************************************************************************
* ************************************************************************
*/
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* @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'] = 'Matrículas solicitadas';
$string['pluginname'] = 'Matrículas solicitadas';
$string['pluginname_desc'] = 'With this plugin users can apply to a course and a teacher have to comfirm before the user gets enroled.'; // needs to be translated
$string['pluginname_desc'] = 'With this plugin users can apply to a course and a teacher have to comfirm before the user gets enroled.'; // Needs to be translated.
$string['confirmmailsubject'] = 'Assunto do e-mail de confirmação';
$string['confirmmailcontent'] = 'Conteúdo do e-mail de confirmação';
@ -26,7 +37,7 @@ $string['confirmusers'] = 'Confirmar matrículas';
$string['coursename'] = 'Curso';
$string['applyuser'] = 'Nome / Sobrenome';
$string['applyusermail'] = 'E-mail';
$string['applydate'] = 'Data de solicitação'; // Enrol date -> Fecha de matriculación
$string['applydate'] = 'Data de solicitação'; // Enrol date -> Fecha de matriculación.
$string['btnconfirm'] = 'Confirmar';
$string['btncancel'] = 'Cancelar';
$string['enrolusers'] = 'Matricular usuários';
@ -34,17 +45,15 @@ $string['enrolusers'] = 'Matricular usuários';
$string['status'] = 'Aceitar matrícula após aprovação';
$string['confirmenrol'] = 'Gerenciar solicitações';
$string['apply:config'] = 'Configurar instâncias de matrículas solicitadas'; // Needs more insight
$string['apply:manageapplications'] = 'Gerenciar matrículas solicitadas'; // Needs more insight
$string['apply:unenrol'] = 'Cancelar usuários do curso'; // Needs more insight
$string['apply:config'] = 'Configurar instâncias de matrículas solicitadas'; // Needs more insight.
$string['apply:manageapplications'] = 'Gerenciar matrículas solicitadas'; // Needs more insight.
$string['apply:unenrol'] = 'Cancelar usuários do curso'; // Needs more insight.
$string['notification'] = '<b>Solicitação de matrícula enviada com sucesso</b>. <br/><br/>Você será notificado por e-mail quando a sua matrícula for confirmada.';
$string['sendmailtoteacher'] = 'Enviar e-mail de notificação para professores';
$string['mailtoteacher_suject'] = 'Nova solicitação de inscrição!';
$string['editdescription'] = 'Descrição';
$string['applymanage'] = 'Manage enrolment applications'; // needs to be translated
$string['status_desc'] = 'Allow course access of internally enrolled users.'; // needs to be translated
$string['editdescription'] = 'Descrição';
$string['applymanage'] = 'Manage enrolment applications'; // Needs to be translated.
?>
$string['status_desc'] = 'Allow course access of internally enrolled users.'; // Needs to be translated.

31
lang/zh_cn/enrol_apply.php

@ -1,14 +1,25 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* *************************************************************************
* * Apply Enrol **
* *************************************************************************
* @copyright emeneo.com **
* @link emeneo.com **
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later **
* *************************************************************************
* ************************************************************************
*/
* @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 plug-in. Displayed on admin menus.
$string['enrolname'] = '选课确认';
$string['pluginname'] = '选课确认';
@ -39,7 +50,6 @@ $string['apply:manageapplications'] = '管理选课申请';
$string['apply:unenrol'] = '从课程中取消用户的选课';
$string['apply:unenrolself'] = '从课程中取消自身的选课';
$string['notification'] = '<b>选课申请已发送成功</b><br/><br/>申请通过后您会收到邮件通知。';
$string['sendmailtoteacher'] = '向教师发送邮件通知';
@ -50,4 +60,3 @@ $string['comment'] = '评论';
$string['applymanage'] = '管理选课申请';
$string['status_desc'] = '允许内部选课的用户进入课程';
?>

133
lib.php

@ -26,11 +26,12 @@
define('ENROL_APPLY_USER_WAIT', 2);
class enrol_apply_plugin extends enrol_plugin {
/**
* Add new instance of enrol plugin with default settings.
* @param object $course
* @return int id of new instance
*/
* 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);
@ -48,28 +49,28 @@ class enrol_apply_plugin extends enrol_plugin {
* @return moodle_url page url
*/
public function get_newinstance_link($courseid) {
$context = context_course::instance($courseid, MUST_EXIST);
$context = context_course::instance($courseid, MUST_EXIST);
if (!has_capability('moodle/course:enrolconfig', $context) or !has_capability('enrol/apply:config', $context)) {
return NULL;
return null;
}
return new moodle_url('/enrol/apply/edit.php', array('courseid'=>$courseid));
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!!
// Can not enrol guest!
return null;
}
if ($DB->record_exists('user_enrolments', array('userid'=>$USER->id, 'enrolid'=>$instance->id))) {
if ($DB->record_exists('user_enrolments', array('userid' => $USER->id, 'enrolid' => $instance->id))) {
return $OUTPUT->notification(get_string('notification', 'enrol_apply'), 'notifysuccess');
}
require_once("$CFG->dirroot/enrol/apply/apply_form.php");
$form = new enrol_apply_apply_form(NULL, $instance);
$form = new enrol_apply_apply_form(null, $instance);
if ($data = $form->get_data()) {
// Only process when form submission is for this instance (multi instance support).
@ -79,7 +80,12 @@ class enrol_apply_plugin extends enrol_plugin {
$roleid = $instance->roleid;
$this->enrol_user($instance, $USER->id, $roleid, $timestart, $timeend, ENROL_USER_SUSPENDED);
$userenrolment = $DB->get_record('user_enrolments', array('userid' => $USER->id, 'enrolid' => $instance->id), 'id', MUST_EXIST);
$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 = $data->applydescription;
@ -102,54 +108,59 @@ class enrol_apply_plugin extends enrol_plugin {
if ($instance->enrol !== 'apply') {
throw new coding_exception('invalid enrol instance!');
}
$context = context_course::instance($instance->courseid);
$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')));
$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:manageapplications', $context)) {
$managelink = new moodle_url("/enrol/apply/manage.php", array('id'=>$instance->id));
$icons[] = $OUTPUT->action_icon($managelink, new pix_icon('i/users', get_string('confirmenrol', 'enrol_apply'), 'core', array('class'=>'iconsmall')));
$managelink = new moodle_url("/enrol/apply/manage.php", array('id' => $instance->id));
$icons[] = $OUTPUT->action_icon($managelink, new pix_icon(
'i/users',
get_string('confirmenrol', 'enrol_apply'),
'core',
array('class' => 'iconsmall')));
}
return $icons;
}
/**
* Is it possible to hide/show enrol instance via standard UI?
*
* @param stdClass $instance
* @return bool
*/
/**
* 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
*/
* 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
*/
* 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!');
@ -157,7 +168,7 @@ class enrol_apply_plugin extends enrol_plugin {
$context = context_course::instance($instance->courseid);
if (has_capability('enrol/apply:config', $context)) {
$managelink = new moodle_url('/enrol/apply/edit.php', array('courseid'=>$instance->courseid, 'id'=>$instance->id));
$managelink = new moodle_url('/enrol/apply/edit.php', array('courseid' => $instance->courseid, 'id' => $instance->id));
$instancesnode->add($this->get_instance_name($instance), $managelink, navigation_node::TYPE_SETTING);
}
}
@ -195,10 +206,9 @@ class enrol_apply_plugin extends enrol_plugin {
return $fields;
}
function confirmEnrolment($enrols){
public function confirm_enrolment($enrols) {
global $DB;
foreach ($enrols as $enrol){
// $userenrolment = $DB->get_record('user_enrolments', array('id' => $enrol), '*', MUST_EXIST);
foreach ($enrols as $enrol) {
$userenrolment = $DB->get_record_select(
'user_enrolments',
'id = :id AND (status = :enrolusersuspended OR status = :enrolapplyuserwait)',
@ -226,10 +236,13 @@ class enrol_apply_plugin extends enrol_plugin {
}
}
function waitEnrolment($enrols){
public function wait_enrolment($enrols) {
global $DB;
foreach ($enrols as $enrol){
$userenrolment = $DB->get_record('user_enrolments', array('id' => $enrol, 'status' => ENROL_USER_SUSPENDED), '*', IGNORE_MISSING);
foreach ($enrols as $enrol) {
$userenrolment = $DB->get_record(
'user_enrolments',
array('id' => $enrol, 'status' => ENROL_USER_SUSPENDED),
'*', IGNORE_MISSING);
if ($userenrolment != null) {
$instance = $DB->get_record('enrol', array('id' => $userenrolment->enrolid, 'enrol' => 'apply'), '*', MUST_EXIST);
@ -249,9 +262,9 @@ class enrol_apply_plugin extends enrol_plugin {
}
}
function cancelEnrolment($enrols){
public function cancel_enrolment($enrols) {
global $DB;
foreach ($enrols as $enrol){
foreach ($enrols as $enrol) {
$userenrolment = $DB->get_record_select(
'user_enrolments',
'id = :id AND (status = :enrolusersuspended OR status = :enrolapplyuserwait)',
@ -279,19 +292,19 @@ class enrol_apply_plugin extends enrol_plugin {
}
}
function send_mail_to_applicant($instance, $userid, $subject, $body) {
private function send_mail_to_applicant($instance, $userid, $subject, $body) {
global $DB;
global $CFG;
$course = get_course($instance->courseid);
$user = core_user::get_user($userid);
$body = $this->updateMailContent($body, $course, $user);
$body = $this->update_mail_content($body, $course, $user);
$contact = core_user::get_support_user();
email_to_user($user, $contact, $subject, html_to_text($body), $body);
}
function send_application_notification($instance, $userid, $data) {
private function send_application_notification($instance, $userid, $data) {
global $CFG, $PAGE;
$renderer = $PAGE->get_renderer('enrol_apply');
@ -323,7 +336,13 @@ class enrol_apply_plugin extends enrol_plugin {
$teachers = get_role_users($editingteacherrole->id, $context);
$manageurl = new moodle_url("/enrol/apply/manage.php", array('id' => $instance->id));
$body = $renderer->application_notification_mail_body($course, $user, $manageurl, $data->applydescription, $standarduserfields, $extrauserfields);
$body = $renderer->application_notification_mail_body(
$course,
$user,
$manageurl,
$data->applydescription,
$standarduserfields,
$extrauserfields);
foreach ($teachers as $teacher) {
email_to_user($teacher, $contact, get_string('mailtoteacher_suject', 'enrol_apply'), html_to_text($body), $body);
}
@ -337,21 +356,27 @@ class enrol_apply_plugin extends enrol_plugin {
$managers = get_role_users($managerrole->id, $context);
$manageurl = new moodle_url('/enrol/apply/manage.php');
$body = $renderer->application_notification_mail_body($course, $user, $manageurl, $data->applydescription, $standarduserfields, $extrauserfields);
$body = $renderer->application_notification_mail_body(
$course,
$user,
$manageurl,
$data->applydescription,
$standarduserfields,
$extrauserfields);
foreach ($managers as $manager) {
email_to_user($manager, $contact, get_string('mailtoteacher_suject', 'enrol_apply'), html_to_text($body), $body);
}
}
}
function updateMailContent($content, $course, $user) {
private function update_mail_content($content, $course, $user) {
$replace = array(
'firstname' => $user->firstname,
'content' => format_string($course->fullname),
'lastname' => $user->lastname,
'username' => $user->username);
foreach ($replace as $key=>$val) {
$content = str_replace("{".$key."}",$val,$content);
foreach ($replace as $key => $val) {
$content = str_replace('{' . $key . '}', $val, $content);
}
return $content;
}

10
manage.php

@ -22,7 +22,7 @@
* @author Johannes Burk <johannes.burk@sudile.com>
*/
require_once ('../../config.php');
require_once('../../config.php');
require_once($CFG->dirroot.'/enrol/apply/lib.php');
require_once($CFG->dirroot.'/enrol/apply/manage_table.php');
require_once($CFG->dirroot.'/enrol/apply/renderer.php');
@ -38,7 +38,7 @@ if ($id == null) {
require_capability('enrol/apply:manageapplications', $context);
$pageheading = get_string('confirmusers', 'enrol_apply');
} else {
$instance = $DB->get_record('enrol', array('id'=>$id, 'enrol'=>'apply'), '*', MUST_EXIST);
$instance = $DB->get_record('enrol', array('id' => $id, 'enrol' => 'apply'), '*', MUST_EXIST);
require_course_login($instance->courseid);
$course = get_course($instance->courseid);
$context = context_course::instance($course->id, MUST_EXIST);
@ -60,11 +60,11 @@ $PAGE->requires->css('/enrol/apply/style.css');
if ($userenrolments != null) {
$enrolapply = enrol_get_plugin('apply');
if (optional_param('confirm', false, PARAM_BOOL)) {
$enrolapply->confirmEnrolment($userenrolments);
$enrolapply->confirm_enrolment($userenrolments);
} else if (optional_param('wait', false, PARAM_BOOL)) {
$enrolapply->waitEnrolment($userenrolments);
$enrolapply->wait_enrolment($userenrolments);
} else if (optional_param('cancel', false, PARAM_BOOL)) {
$enrolapply->cancelEnrolment($userenrolments);
$enrolapply->cancel_enrolment($userenrolments);
}
redirect($manageurl);
}

17
manage_table.php

@ -46,12 +46,13 @@ class enrol_apply_manage_table extends table_sql {
}
$this->set_sql(
'ue.id AS userenrolmentid, ue.userid, ue.status AS enrolstatus, ue.timecreated AS applydate, ai.comment AS applycomment, u.*, c.fullname as course',
'ue.id AS userenrolmentid, ue.userid, ue.status AS enrolstatus, ue.timecreated AS applydate,
ai.comment AS applycomment, u.*, c.fullname as course',
"{user_enrolments} AS ue
LEFT JOIN {enrol_apply_applicationinfo} AS ai ON ai.userenrolmentid = ue.id
JOIN {user} AS u ON u.id = ue.userid
JOIN {enrol} AS e ON e.id = ue.enrolid
JOIN {course} AS c ON c.id = e.courseid",
LEFT JOIN {enrol_apply_applicationinfo} ai ON ai.userenrolmentid = ue.id
JOIN {user} u ON u.id = ue.userid
JOIN {enrol} e ON e.id = ue.enrolid
JOIN {course} c ON c.id = e.courseid",
$sqlwhere,
$sqlparams);
}
@ -61,7 +62,7 @@ class enrol_apply_manage_table extends table_sql {
* @param $row array the data for this row. Note (Johannes): this is actually an object with all sql columns.
* @return string added to the class="" attribute of the tr.
*/
function get_row_class($row) {
public function get_row_class($row) {
if ($row->enrolstatus == 2) {
return 'enrol_apply_waitinglist_highlight';
}
@ -73,9 +74,9 @@ class enrol_apply_manage_table extends table_sql {
}
public function col_fullname($row) {
// $row contains all user fields, see sql query.
// The $row variable contains all user fields, see sql query.
global $OUTPUT;
$col = $OUTPUT->user_picture($row, array('popup'=>true));
$col = $OUTPUT->user_picture($row, array('popup' => true));
$col .= fullname($row);
return $col;
}

30
renderer.php

@ -41,15 +41,27 @@ class enrol_apply_renderer extends plugin_renderer_base {
}
public function manage_form($table, $manageurl) {
echo html_writer::start_tag('form', array('id' => 'enrol_apply_manage_form', 'method' => 'post', 'action' => $manageurl->out()));
echo html_writer::start_tag('form', array(
'id' => 'enrol_apply_manage_form',
'method' => 'post',
'action' => $manageurl->out()));
$this->manage_table($table);
echo html_writer::start_tag('p', array('align' => 'center'));
echo html_writer::empty_tag('input', array('type' => 'submit', 'name' => 'confirm', 'value' => get_string('btnconfirm', 'enrol_apply')));
echo html_writer::empty_tag('input', array('type' => 'submit', 'name' => 'wait', 'value' => get_string('btnwait', 'enrol_apply')));
echo html_writer::empty_tag('input', array('type' => 'submit', 'name' => 'cancel', 'value' => get_string('btncancel', 'enrol_apply')));
echo html_writer::empty_tag('input', array(
'type' => 'submit',
'name' => 'confirm',
'value' => get_string('btnconfirm', 'enrol_apply')));
echo html_writer::empty_tag('input', array(
'type' => 'submit',
'name' => 'wait',
'value' => get_string('btnwait', 'enrol_apply')));
echo html_writer::empty_tag('input', array(
'type' => 'submit',
'name' => 'cancel',
'value' => get_string('btncancel', 'enrol_apply')));
echo html_writer::end_tag('p');
echo html_writer::end_tag('form');
@ -78,11 +90,13 @@ class enrol_apply_renderer extends plugin_renderer_base {
$table->out(50, true);
}
public function application_notification_mail_body($course, $user, $manageurl, $applydescription, $standarduserfields = null, $extrauserfields = null) {
public function application_notification_mail_body(
$course, $user, $manageurl, $applydescription, $standarduserfields = null, $extrauserfields = null) {
$body = '<p>'. get_string('coursename', 'enrol_apply') .': '.format_string($course->fullname).'</p>';
$body .= '<p>'. get_string('applyuser', 'enrol_apply') .': '.$user->firstname.' '.$user->lastname.'</p>';
$body .= '<p>'. get_string('comment', 'enrol_apply') .': '.$applydescription.'</p>';
if($standarduserfields){
if ($standarduserfields) {
$body .= '<p><strong>'. get_string('user_profile', 'enrol_apply').'</strong></p>';
$body .= '<p>'. get_string('firstname') .': '.$standarduserfields->firstname.'</p>';
$body .= '<p>'. get_string('lastname') .': '.$standarduserfields->lastname.'</p>';
@ -110,7 +124,7 @@ class enrol_apply_renderer extends plugin_renderer_base {
$body .= '<p>'. get_string('address') .': '.$standarduserfields->address.'</p>';
}
if($extrauserfields){
if ($extrauserfields) {
foreach ($extrauserfields as $key => $value) {
$body .= '<p>'. $key .': '.$value.'</p>';
}
@ -120,4 +134,4 @@ class enrol_apply_renderer extends plugin_renderer_base {
return $body;
}
}
}

14
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')));

15
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();

Loading…
Cancel
Save