Skip to content

Commit 6b44961

Browse files
author
Kordan
committed
few insecure fixes
1 parent 0656ae6 commit 6b44961

File tree

9 files changed

+139
-126
lines changed

9 files changed

+139
-126
lines changed

classes/observer.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,13 @@ public static function user_unenroled(\core\event\user_enrolment_deleted $event)
7777
}
7878
}
7979
if (!empty($enrol) && $instanceenabled) {
80-
$activeunenrolalert = $enrol->customint4;
80+
$activeunenrolalert = $enrol->customint2;
8181
}
8282

8383
if ($activeglobal == 1 && $activeunenrolalert == 1) {
84-
$notificationeabc->enviarmail($user, $course, 2);
84+
$notificationeabc->send_email($user, $course, 2);
8585
} else if (!empty($enrol) && !empty($activeunenrolalert) && $instanceenabled) {
86-
$notificationeabc->enviarmail($user, $course, 2);
86+
$notificationeabc->send_email($user, $course, 2);
8787
}
8888
}
8989
}
@@ -127,13 +127,13 @@ public static function user_updated(\core\event\user_enrolment_updated $event) {
127127
}
128128
}
129129
if (!empty($enrol) && $instanceenabled) {
130-
$activeenrolupdatedalert = $enrol->customint5;
130+
$activeenrolupdatedalert = $enrol->customint3;
131131
}
132132

133133
if ($activeglobal == 1 && $activeenrolupdatedalert == 1) {
134-
$notificationeabc->enviarmail($user, $course, 3);
134+
$notificationeabc->send_email($user, $course, 3);
135135
} else if (!empty($enrol) && !empty($activeenrolupdatedalert) && $instanceenabled) {
136-
$notificationeabc->enviarmail($user, $course, 3);
136+
$notificationeabc->send_email($user, $course, 3);
137137
}
138138
}
139139
}
@@ -160,7 +160,7 @@ public static function user_enroled(\core\event\user_enrolment_created $event) {
160160

161161
$notificationeabc = new enrol_notificationeabc_plugin();
162162

163-
$activeglobal = $notificationeabc->get_config('activarglobal');
163+
$activeglobal = $notificationeabc->get_config('activarglobalenrolalert');
164164
$activeenrolalert = $notificationeabc->get_config('activeenrolalert');
165165

166166
$enrol = $DB->get_record('enrol', array('enrol' => 'notificationeabc', 'courseid' => $event->courseid));
@@ -177,13 +177,13 @@ public static function user_enroled(\core\event\user_enrolment_created $event) {
177177
}
178178

179179
if (!empty($enrol) && $instanceenabled) {
180-
$activeenrolalert = $enrol->customint3;
180+
$activeenrolalert = $enrol->customint1;
181181
}
182182

183183
if ($activeglobal == 1 && $activeenrolalert == 1) {
184-
$notificationeabc->enviarmail($user, $course, 1);
184+
$notificationeabc->send_email($user, $course, 1);
185185
} else if (!empty($enrol) && !empty($activeenrolalert) && $instanceenabled) {
186-
$notificationeabc->enviarmail($user, $course, 1);
186+
$notificationeabc->send_email($user, $course, 1);
187187
}
188188
}
189189
}

db/access.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,12 @@
3838
'manager' => CAP_ALLOW,
3939
)
4040
),
41+
'enrol/notificationeabc:config' => array(
42+
'captype' => 'write',
43+
'contextlevel' => CONTEXT_COURSE,
44+
'archetypes' => array(
45+
'manager' => CAP_ALLOW,
46+
'editingteacher' => CAP_ALLOW,
47+
)
48+
),
4149
);

edit.php

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,13 @@
8080

8181
$instance->status = $data->status;
8282
$instance->name = $data->name;
83-
$instance->customint1 = $data->customint1;
83+
84+
if (isset($data->customint1)) {
85+
$instance->customint1 = $data->customint1;
86+
} else {
87+
$instance->customint1 = 0;
88+
}
89+
8490
if (isset($data->customint2)) {
8591
$instance->customint2 = $data->customint2;
8692
} else {
@@ -93,18 +99,6 @@
9399
$instance->customint3 = 0;
94100
}
95101

96-
if (isset($data->customint4)) {
97-
$instance->customint4 = $data->customint4;
98-
} else {
99-
$instance->customint4 = 0;
100-
}
101-
102-
if (isset($data->customint5)) {
103-
$instance->customint5 = $data->customint5;
104-
} else {
105-
$instance->customint5 = 0;
106-
}
107-
108102
$instance->customtext1 = $data->customtext1['text'];
109103
$instance->customtext2 = $data->customtext2['text'];
110104
$instance->customtext3 = $data->customtext3['text'];
@@ -124,8 +118,6 @@
124118
'customint1' => $data->customint1,
125119
'customint2' => $data->customint2,
126120
'customint3' => $data->customint3,
127-
'customint4' => $data->customint4,
128-
'customint5' => $data->customint5,
129121
'customtext1' => $data->customtext1['text'],
130122
'customtext2' => $data->customtext2['text'],
131123
'customtext3' => $data->customtext3['text'],

edit_form.php

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,30 +49,30 @@ public function definition() {
4949

5050
$mform->addElement('header', 'header', get_string('pluginname', 'enrol_notificationeabc'));
5151
$mform->addElement('text', 'name', get_string('custominstancename', 'enrol'));
52+
$mform->setType('name', PARAM_RAW);
5253

53-
$options = array(ENROL_INSTANCE_ENABLED => get_string('yes'),
54-
ENROL_INSTANCE_DISABLED => get_string('no'));
54+
$options = array(ENROL_INSTANCE_ENABLED => get_string('yes'), ENROL_INSTANCE_DISABLED => get_string('no'));
5555
$mform->addElement('select', 'status', get_string('status', 'enrol_notificationeabc'), $options);
5656

5757
// Enrol notifications.
58-
$mform->addElement('advcheckbox', 'customint3', get_string('activeenrolalert', 'enrol_notificationeabc'));
59-
$mform->addHelpButton('customint3', 'activeenrolalert', 'enrol_notificationeabc');
58+
$mform->addElement('advcheckbox', 'customint1', get_string('activeenrolalert', 'enrol_notificationeabc'));
59+
$mform->addHelpButton('customint1', 'activeenrolalert', 'enrol_notificationeabc');
6060

61-
$mform->addElement('editor', 'customtext1', get_string('location', 'enrol_notificationeabc'), null);
61+
$mform->addElement('editor', 'customtext1', get_string('enrolmessage', 'enrol_notificationeabc'), null);
6262
$mform->setType('customtext1', PARAM_RAW);
63-
$mform->addHelpButton('customtext1', 'location', 'enrol_notificationeabc');
63+
$mform->addHelpButton('customtext1', 'enrolmessage', 'enrol_notificationeabc');
6464

6565
// Unenrol notifications.
66-
$mform->addElement('advcheckbox', 'customint4', get_string('activeunenrolalert', 'enrol_notificationeabc'));
67-
$mform->addHelpButton('customint4', 'activeunenrolalert', 'enrol_notificationeabc');
66+
$mform->addElement('advcheckbox', 'customint2', get_string('activeunenrolalert', 'enrol_notificationeabc'));
67+
$mform->addHelpButton('customint2', 'activeunenrolalert', 'enrol_notificationeabc');
6868

6969
$mform->addElement('editor', 'customtext2', get_string('unenrolmessage', 'enrol_notificationeabc'), null);
7070
$mform->setType('customtext2', PARAM_RAW);
7171
$mform->addHelpButton('customtext2', 'unenrolmessage', 'enrol_notificationeabc');
7272

7373
// Update enrolment notifications.
74-
$mform->addElement('advcheckbox', 'customint5', get_string('activeenrolupdatedalert', 'enrol_notificationeabc'));
75-
$mform->addHelpButton('customint5', 'activeenrolupdatedalert', 'enrol_notificationeabc');
74+
$mform->addElement('advcheckbox', 'customint3', get_string('activeenrolupdatedalert', 'enrol_notificationeabc'));
75+
$mform->addHelpButton('customint3', 'activeenrolupdatedalert', 'enrol_notificationeabc');
7676

7777
$mform->addElement('editor', 'customtext3', get_string('updatedenrolmessage', 'enrol_notificationeabc'), null);
7878
$mform->setType('customtext3', PARAM_RAW);
@@ -81,9 +81,11 @@ public function definition() {
8181
// Email y nombre del remitente.
8282
$mform->addElement('text', 'customchar1', get_string('emailsender', 'enrol_notificationeabc'));
8383
$mform->addHelpButton('customchar1', 'emailsender', 'enrol_notificationeabc');
84+
$mform->setType('customchar1', PARAM_RAW);
8485

8586
$mform->addElement('text', 'customchar2', get_string('namesender', 'enrol_notificationeabc'));
8687
$mform->addHelpButton('customchar2', 'namesender', 'enrol_notificationeabc');
88+
$mform->setType('customchar2', PARAM_RAW);
8789

8890
$this->add_action_buttons(true, ($instance->id ? null : get_string('addinstance', 'enrol')));
8991

@@ -103,9 +105,9 @@ public function definition() {
103105
$mform->setDefault('customtext3', array('text' => $instance->customtext3));
104106
$mform->setDefault('customchar1', $instance->customchar1);
105107
$mform->setDefault('customchar2', $instance->customchar2);
108+
$mform->setDefault('customint1', $instance->customint1);
109+
$mform->setDefault('customint2', $instance->customint2);
106110
$mform->setDefault('customint3', $instance->customint3);
107-
$mform->setDefault('customint4', $instance->customint4);
108-
$mform->setDefault('customint5', $instance->customint5);
109111
if (!empty($instance->name)) {
110112
$mform->setDefault('name', $instance->name);
111113
} else {

lang/en/enrol_notificationeabc.php

Lines changed: 38 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -25,63 +25,68 @@
2525
* @author Osvaldo Arriola <osvaldo@e-abclearning.com>
2626
*/
2727

28-
$string['filelockedmail'] = 'You has been enroled in {$a->fullname} ({$a->url})';
29-
$string['location'] = 'Message';
30-
$string['messageprovider:notificationeabc_enrolment'] = 'Enrol notification messages';
31-
$string['notificationeabc:manage'] = 'Manage notificationeabc';
32-
$string['pluginname'] = 'Enrol Notification';
28+
$string['activar_help'] = 'When activated will be verified by the immediate execution of cron later, users who were enrolled for the period specified above';
29+
$string['activar'] = 'Enable initial verification';
30+
$string['emailsender_help'] = 'By default set to take the email user support ';
31+
$string['emailsender'] = 'Email sender ';
32+
$string['failsend'] = 'WARNING: it has no been able to notify the {$a->username} user about his enrollment in the {$a->coursename} course'."\n";
33+
$string['fecha_help'] = 'Place the period for which you want to perform the first virificación';
34+
$string['fecha'] = 'Period for verification of users enrolled courses';
35+
$string['messageprovider:notificationeabc_enrolment'] = 'Enrol email notification messages';
36+
$string['namesender_help'] = 'By default it takes the name set to the user support';
37+
$string['namesender'] = 'Name sender ';
38+
$string['notificationeabc:config'] = 'Configure email notificationeabc instances';
39+
$string['notificationeabc:manage'] = 'Manage email notificationeabc';
3340
$string['pluginname_desc'] = 'Enrol notifications via mail';
34-
$string['location_help'] = 'Personalize the message that users will come to be enrolled. This field accepts the following markers which then will be replaced by the corresponding values ​​dynamically
41+
$string['pluginname'] = 'Enrol Notification';
42+
$string['status'] = 'Active enrol email notification';
43+
$string['subject'] = 'Enrolment email notification';
44+
$string['succefullsend'] = 'The user {$a->username} has been notified about his enrollment in the {$a->coursename} course'."\n";
45+
46+
// Unenrol notifications.
47+
$string['activeenrolalert'] = 'Active enrol alert';
48+
$string['activeenrolalert_help'] = 'Active enrol alert';
49+
$string['activarglobalenrolalert'] = 'Active global';
50+
$string['activarglobalenrolalert_help'] = 'Active enrol email notification for all site';
51+
$string['enrolmessage'] = 'Message';
52+
$string['enrolmessage_help'] = 'Personalize the message that users will come to be enrolled. This field accepts the following markers which then will be replaced by the corresponding values ​​dynamically
3553
<pre>
3654
{COURSENAME} = course fullname
3755
{USERNAME} = username
38-
{NOMBRE} = firstname
39-
{APELLIDO} = lastname
56+
{FIRSTNAME} = firstname
57+
{LASTNAME} = lastname
4058
{URL} = course url
4159
</pre>';
42-
$string['fecha_help'] = 'Place the period for which you want to perform the first virificación';
43-
$string['fecha'] = 'Period for verification of users enrolled courses';
44-
$string['activar'] = 'Enable initial verification';
45-
$string['activar_help'] = 'When activated will be verified by the immediate execution of cron later, users who were enrolled for the period specified above';
46-
$string['activarglobal'] = 'Active global';
47-
$string['activarglobal_help'] = 'Active enrol notification for all site';
48-
$string['emailsender'] = 'Email sender ';
49-
$string['emailsender_help'] = 'By default set to take the email user support ';
50-
$string['namesender'] = 'Name sender ';
51-
$string['namesender_help'] = 'By default it takes the name set to the user support';
52-
$string['status'] = 'Active enrol notification';
53-
$string['subject'] = 'Enrolment notification';
54-
$string['activeenrolalert'] = 'Active enrol alert';
55-
$string['activeenrolalert_help'] = 'Active enrol alert';
60+
$string['enrolmessagedefault'] = 'You has been enroled in {$a->fullname} ({$a->url})';
61+
5662
// Unenrol notifications.
57-
$string['activeunenrolalert'] = 'Active unenrol notifications';
63+
$string['activeunenrolalert'] = 'Active unenrol email notifications';
5864
$string['activeunenrolalert_help'] = 'Active unenrol alert';
5965
$string['activarglobalunenrolalert'] = 'Active global';
60-
$string['activarglobalunenrolalert_help'] = 'Active enrol notifications for all site';
66+
$string['activarglobalunenrolalert_help'] = 'Active enrol email notifications for all site';
6167
$string['unenrolmessage'] = 'Custom Message';
6268
$string['unenrolmessage_help'] = 'Personalize the message that users will come to be unenrolled. This field accepts the following markers which then will be replaced by the corresponding values ​​dynamically
6369
<pre>
6470
{COURSENAME} = course fullname
6571
{USERNAME} = username
66-
{NOMBRE} = firstname
67-
{APELLIDO} = lastname
72+
{FIRSTNAME} = firstname
73+
{LASTNAME} = lastname
6874
{URL} = course url
6975
</pre>';
7076
$string['unenrolmessagedefault'] = 'You has been unenrolled from {$a->fullname} ({$a->url})';
77+
7178
// Update enrol notifications.
72-
$string['activeenrolupdatedalert'] = 'Active update enrol notifications';
73-
$string['activeenrolupdatedalert_help'] = 'Active update enrol notifications';
79+
$string['activeenrolupdatedalert'] = 'Active update enrol email notifications';
80+
$string['activeenrolupdatedalert_help'] = 'Active update enrol email notifications';
7481
$string['activarglobalenrolupdated'] = 'Active global';
75-
$string['activarglobalenrolupdated_help'] = 'Active enrol updated notifications for all site';
82+
$string['activarglobalenrolupdated_help'] = 'Active enrol updated email notifications for all site';
7683
$string['updatedenrolmessage'] = 'Custom message';
7784
$string['updatedenrolmessage_help'] = 'Personalize the message that users will come to be updated. This field accepts the following markers which then will be replaced by the corresponding values ​​dynamically
7885
<pre>
7986
{COURSENAME} = course fullname
8087
{USERNAME} = username
81-
{NOMBRE} = firstname
82-
{APELLIDO} = lastname
88+
{FIRSTNAME} = firstname
89+
{LASTNAME} = lastname
8390
{URL} = course url
8491
</pre>';
8592
$string['updatedenrolmessagedefault'] = 'Your enrolment from {$a->fullname} has been updated ({$a->url})';
86-
$string['succefullsend'] = 'The user {$a->username} has been notified about his enrollment in the {$a->coursename} course'."\n";
87-
$string['failsend'] = 'WARNING: it has no been able to notify the {$a->username} user about his enrollment in the {$a->coursename} course'."\n";

lang/es/enrol_notificationeabc.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
* @author Osvaldo Arriola <osvaldo@e-abclearning.com>
2626
*/
2727

28-
$string['filelockedmail'] = 'Ud ha sido matriculado en el curso {$a->fullname} ({$a->url})';
29-
$string['location'] = 'Mensaje personalizado';
28+
$string['enrolmessagedefault'] = 'Ud ha sido matriculado en el curso {$a->fullname} ({$a->url})';
29+
$string['enrolmessage'] = 'Mensaje personalizado';
3030
$string['messageprovider:notificationeabc_enrolment'] = 'Enrol notification messages';
3131
$string['notificationeabc:manage'] = 'Gestionar notificaciones de matriculación';
3232
$string['pluginname'] = 'Notificación de Matriculación';
@@ -35,16 +35,16 @@
3535
<pre>
3636
{COURSENAME} = Nombre completo del curso
3737
{USERNAME} = Nombre de usuario
38-
{NOMBRE} = Nombre
39-
{APELLIDO} = Apellido
38+
{FIRSTNAME} = Nombre
39+
{LASTNAME} = Apellido
4040
{URL} = Url del curso
4141
</pre>';
4242
$string['fecha_help'] = 'Coloque el periodo por el cual desea que se realice la virificación inicial de usuarios matriculados';
4343
$string['fecha'] = 'Período para realizar la verificación de usuarios que se matricularon a cursos';
4444
$string['activar'] = 'Activar verificación inicial';
4545
$string['activar_help'] = 'Al activarse se verificará, mediante la ejecucion del cron inmediata posterior, los usuarios que fueron matriculados en el periodo establecido arriba';
46-
$string['activarglobal'] = 'Activar para todo el sitio';
47-
$string['activarglobal_help'] = 'Activa la notificacion de matriculacion para todo los cursos';
46+
$string['activarglobalenrolalert'] = 'Activar para todo el sitio';
47+
$string['activarglobalenrolalert_help'] = 'Activa la notificacion de matriculacion para todo los cursos';
4848
$string['emailsender'] = 'Email del remitente ';
4949
$string['emailsender_help'] = 'Por defecto toma el email configurado como el usuario de soporte ';
5050
$string['namesender'] = 'Nombre del remitente ';
@@ -63,8 +63,8 @@
6363
<pre>
6464
{COURSENAME} = Nombre completo del curso
6565
{USERNAME} = Nombre de usuario
66-
{NOMBRE} = Nombre
67-
{APELLIDO} = Apellido
66+
{FIRSTNAME} = Nombre
67+
{LASTNAME} = Apellido
6868
{URL} = Url del curso
6969
</pre>';
7070
$string['unenrolmessagedefault'] = 'Ud ha sido desmatriculado del curso {$a->fullname} ({$a->url})';
@@ -78,8 +78,8 @@
7878
<pre>
7979
{COURSENAME} = Nombre completo del curso
8080
{USERNAME} = Nombre de usuario
81-
{NOMBRE} = Nombre
82-
{APELLIDO} = Apellido
81+
{FIRSTNAME} = Nombre
82+
{LASTNAME} = Apellido
8383
{URL} = Url del curso
8484
</pre>';
8585
$string['updatedenrolmessagedefault'] = 'Su matriculacion en el curso {$a->fullname} ha sido actualizada ({$a->url})';

0 commit comments

Comments
 (0)