1 |
efrain |
1 |
<?php
|
|
|
2 |
// This file is part of Moodle - http://moodle.org/
|
|
|
3 |
//
|
|
|
4 |
// Moodle is free software: you can redistribute it and/or modify
|
|
|
5 |
// it under the terms of the GNU General Public License as published by
|
|
|
6 |
// the Free Software Foundation, either version 3 of the License, or
|
|
|
7 |
// (at your option) any later version.
|
|
|
8 |
//
|
|
|
9 |
// Moodle is distributed in the hope that it will be useful,
|
|
|
10 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
11 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
12 |
// GNU General Public License for more details.
|
|
|
13 |
//
|
|
|
14 |
// You should have received a copy of the GNU General Public License
|
|
|
15 |
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
|
16 |
|
|
|
17 |
/**
|
|
|
18 |
* Notificationeabc enrolment plugin.
|
|
|
19 |
*
|
|
|
20 |
* This plugin notifies users when an event occurs on their enrolments (enrol, unenrol, update enrolment)
|
|
|
21 |
*
|
|
|
22 |
* @package enrol_notificationeabc
|
|
|
23 |
* @copyright 2017 e-ABC Learning
|
|
|
24 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
25 |
* @author Osvaldo Arriola <osvaldo@e-abclearning.com>
|
|
|
26 |
*/
|
|
|
27 |
|
|
|
28 |
defined('MOODLE_INTERNAL') || die();
|
|
|
29 |
|
|
|
30 |
require_once($CFG->libdir . '/formslib.php');
|
|
|
31 |
|
|
|
32 |
/**
|
|
|
33 |
* Edit form class
|
|
|
34 |
*
|
|
|
35 |
* @package enrol_notificationeabc
|
|
|
36 |
* @copyright 2016 e-ABC Learning
|
|
|
37 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
38 |
*/
|
|
|
39 |
class enrol_notificationeabc_edit_form extends moodleform
|
|
|
40 |
{
|
|
|
41 |
/**
|
|
|
42 |
* Main definition
|
|
|
43 |
*/
|
|
|
44 |
public function definition() {
|
|
|
45 |
|
|
|
46 |
$mform = $this->_form;
|
|
|
47 |
|
|
|
48 |
list($instance, $plugin, $context) = $this->_customdata;
|
|
|
49 |
|
|
|
50 |
$mform->addElement('header', 'header', get_string('pluginname', 'enrol_notificationeabc'));
|
|
|
51 |
$mform->addElement('text', 'name', get_string('custominstancename', 'enrol'));
|
|
|
52 |
|
|
|
53 |
$options = array(ENROL_INSTANCE_ENABLED => get_string('yes'),
|
|
|
54 |
ENROL_INSTANCE_DISABLED => get_string('no'));
|
|
|
55 |
$mform->addElement('select', 'status', get_string('status', 'enrol_notificationeabc'), $options);
|
|
|
56 |
|
|
|
57 |
// Enrol notifications.
|
|
|
58 |
$mform->addElement('advcheckbox', 'customint3', get_string('activeenrolalert', 'enrol_notificationeabc'));
|
|
|
59 |
$mform->addHelpButton('customint3', 'activeenrolalert', 'enrol_notificationeabc');
|
|
|
60 |
|
|
|
61 |
$mform->addElement('editor', 'customtext1', get_string('location', 'enrol_notificationeabc'), null);
|
|
|
62 |
$mform->setType('customtext1', PARAM_RAW);
|
|
|
63 |
$mform->addHelpButton('customtext1', 'location', 'enrol_notificationeabc');
|
|
|
64 |
|
|
|
65 |
// Unenrol notifications.
|
|
|
66 |
$mform->addElement('advcheckbox', 'customint4', get_string('activeunenrolalert', 'enrol_notificationeabc'));
|
|
|
67 |
$mform->addHelpButton('customint4', 'activeunenrolalert', 'enrol_notificationeabc');
|
|
|
68 |
|
|
|
69 |
$mform->addElement('editor', 'customtext2', get_string('unenrolmessage', 'enrol_notificationeabc'), null);
|
|
|
70 |
$mform->setType('customtext2', PARAM_RAW);
|
|
|
71 |
$mform->addHelpButton('customtext2', 'unenrolmessage', 'enrol_notificationeabc');
|
|
|
72 |
|
|
|
73 |
// Update enrolment notifications.
|
|
|
74 |
$mform->addElement('advcheckbox', 'customint5', get_string('activeenrolupdatedalert', 'enrol_notificationeabc'));
|
|
|
75 |
$mform->addHelpButton('customint5', 'activeenrolupdatedalert', 'enrol_notificationeabc');
|
|
|
76 |
|
|
|
77 |
$mform->addElement('editor', 'customtext3', get_string('updatedenrolmessage', 'enrol_notificationeabc'), null);
|
|
|
78 |
$mform->setType('customtext3', PARAM_RAW);
|
|
|
79 |
$mform->addHelpButton('customtext3', 'updatedenrolmessage', 'enrol_notificationeabc');
|
|
|
80 |
|
|
|
81 |
// Email y nombre del remitente.
|
|
|
82 |
$mform->addElement('text', 'customchar1', get_string('emailsender', 'enrol_notificationeabc'));
|
|
|
83 |
$mform->addHelpButton('customchar1', 'emailsender', 'enrol_notificationeabc');
|
|
|
84 |
|
|
|
85 |
$mform->addElement('text', 'customchar2', get_string('namesender', 'enrol_notificationeabc'));
|
|
|
86 |
$mform->addHelpButton('customchar2', 'namesender', 'enrol_notificationeabc');
|
|
|
87 |
|
|
|
88 |
$this->add_action_buttons(true, ($instance->id ? null : get_string('addinstance', 'enrol')));
|
|
|
89 |
|
|
|
90 |
if (!empty($instance->courseid)) {
|
|
|
91 |
$mform->addElement('hidden', 'courseid', $instance->courseid);
|
|
|
92 |
$mform->setType('courseid', PARAM_INT);
|
|
|
93 |
}
|
|
|
94 |
|
|
|
95 |
if (!empty($instance->id)) {
|
|
|
96 |
$mform->addElement('hidden', 'id', $instance->id);
|
|
|
97 |
$mform->setType('id', PARAM_INT);
|
|
|
98 |
}
|
|
|
99 |
|
|
|
100 |
if (!empty($instance)) {
|
|
|
101 |
$mform->setDefault('customtext1', array('text' => $instance->customtext1));
|
|
|
102 |
$mform->setDefault('customtext2', array('text' => $instance->customtext2));
|
|
|
103 |
$mform->setDefault('customtext3', array('text' => $instance->customtext3));
|
|
|
104 |
$mform->setDefault('customchar1', $instance->customchar1);
|
|
|
105 |
$mform->setDefault('customchar2', $instance->customchar2);
|
|
|
106 |
$mform->setDefault('customint3', $instance->customint3);
|
|
|
107 |
$mform->setDefault('customint4', $instance->customint4);
|
|
|
108 |
$mform->setDefault('customint5', $instance->customint5);
|
|
|
109 |
if (!empty($instance->name)) {
|
|
|
110 |
$mform->setDefault('name', $instance->name);
|
|
|
111 |
} else {
|
|
|
112 |
$mform->setDefault('name', 'notificationeabc');
|
|
|
113 |
}
|
|
|
114 |
}
|
|
|
115 |
$this->set_data($instance);
|
|
|
116 |
|
|
|
117 |
}
|
|
|
118 |
|
|
|
119 |
|
|
|
120 |
}
|