From 6b44961d99daab78b2f2c632f8db21fab9a08b6a Mon Sep 17 00:00:00 2001 From: Kordan Date: Tue, 20 Feb 2018 13:38:01 +0100 Subject: [PATCH] few insecure fixes --- classes/observer.php | 20 +++---- db/access.php | 8 +++ edit.php | 22 +++---- edit_form.php | 26 +++++---- lang/en/enrol_notificationeabc.php | 71 ++++++++++++----------- lang/es/enrol_notificationeabc.php | 20 +++---- lib.php | 92 ++++++++++++++++-------------- settings.php | 4 +- version.php | 2 +- 9 files changed, 139 insertions(+), 126 deletions(-) diff --git a/classes/observer.php b/classes/observer.php index 86c2f64..093416e 100644 --- a/classes/observer.php +++ b/classes/observer.php @@ -77,13 +77,13 @@ public static function user_unenroled(\core\event\user_enrolment_deleted $event) } } if (!empty($enrol) && $instanceenabled) { - $activeunenrolalert = $enrol->customint4; + $activeunenrolalert = $enrol->customint2; } if ($activeglobal == 1 && $activeunenrolalert == 1) { - $notificationeabc->enviarmail($user, $course, 2); + $notificationeabc->send_email($user, $course, 2); } else if (!empty($enrol) && !empty($activeunenrolalert) && $instanceenabled) { - $notificationeabc->enviarmail($user, $course, 2); + $notificationeabc->send_email($user, $course, 2); } } } @@ -127,13 +127,13 @@ public static function user_updated(\core\event\user_enrolment_updated $event) { } } if (!empty($enrol) && $instanceenabled) { - $activeenrolupdatedalert = $enrol->customint5; + $activeenrolupdatedalert = $enrol->customint3; } if ($activeglobal == 1 && $activeenrolupdatedalert == 1) { - $notificationeabc->enviarmail($user, $course, 3); + $notificationeabc->send_email($user, $course, 3); } else if (!empty($enrol) && !empty($activeenrolupdatedalert) && $instanceenabled) { - $notificationeabc->enviarmail($user, $course, 3); + $notificationeabc->send_email($user, $course, 3); } } } @@ -160,7 +160,7 @@ public static function user_enroled(\core\event\user_enrolment_created $event) { $notificationeabc = new enrol_notificationeabc_plugin(); - $activeglobal = $notificationeabc->get_config('activarglobal'); + $activeglobal = $notificationeabc->get_config('activarglobalenrolalert'); $activeenrolalert = $notificationeabc->get_config('activeenrolalert'); $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) { } if (!empty($enrol) && $instanceenabled) { - $activeenrolalert = $enrol->customint3; + $activeenrolalert = $enrol->customint1; } if ($activeglobal == 1 && $activeenrolalert == 1) { - $notificationeabc->enviarmail($user, $course, 1); + $notificationeabc->send_email($user, $course, 1); } else if (!empty($enrol) && !empty($activeenrolalert) && $instanceenabled) { - $notificationeabc->enviarmail($user, $course, 1); + $notificationeabc->send_email($user, $course, 1); } } } diff --git a/db/access.php b/db/access.php index f0fd586..2f6b7a6 100644 --- a/db/access.php +++ b/db/access.php @@ -38,4 +38,12 @@ 'manager' => CAP_ALLOW, ) ), + 'enrol/notificationeabc:config' => array( + 'captype' => 'write', + 'contextlevel' => CONTEXT_COURSE, + 'archetypes' => array( + 'manager' => CAP_ALLOW, + 'editingteacher' => CAP_ALLOW, + ) + ), ); diff --git a/edit.php b/edit.php index aab3b4c..9e03072 100644 --- a/edit.php +++ b/edit.php @@ -80,7 +80,13 @@ $instance->status = $data->status; $instance->name = $data->name; - $instance->customint1 = $data->customint1; + + if (isset($data->customint1)) { + $instance->customint1 = $data->customint1; + } else { + $instance->customint1 = 0; + } + if (isset($data->customint2)) { $instance->customint2 = $data->customint2; } else { @@ -93,18 +99,6 @@ $instance->customint3 = 0; } - if (isset($data->customint4)) { - $instance->customint4 = $data->customint4; - } else { - $instance->customint4 = 0; - } - - if (isset($data->customint5)) { - $instance->customint5 = $data->customint5; - } else { - $instance->customint5 = 0; - } - $instance->customtext1 = $data->customtext1['text']; $instance->customtext2 = $data->customtext2['text']; $instance->customtext3 = $data->customtext3['text']; @@ -124,8 +118,6 @@ 'customint1' => $data->customint1, 'customint2' => $data->customint2, 'customint3' => $data->customint3, - 'customint4' => $data->customint4, - 'customint5' => $data->customint5, 'customtext1' => $data->customtext1['text'], 'customtext2' => $data->customtext2['text'], 'customtext3' => $data->customtext3['text'], diff --git a/edit_form.php b/edit_form.php index 3f75793..2d2f31c 100644 --- a/edit_form.php +++ b/edit_form.php @@ -49,30 +49,30 @@ public function definition() { $mform->addElement('header', 'header', get_string('pluginname', 'enrol_notificationeabc')); $mform->addElement('text', 'name', get_string('custominstancename', 'enrol')); + $mform->setType('name', PARAM_RAW); - $options = array(ENROL_INSTANCE_ENABLED => get_string('yes'), - ENROL_INSTANCE_DISABLED => get_string('no')); + $options = array(ENROL_INSTANCE_ENABLED => get_string('yes'), ENROL_INSTANCE_DISABLED => get_string('no')); $mform->addElement('select', 'status', get_string('status', 'enrol_notificationeabc'), $options); // Enrol notifications. - $mform->addElement('advcheckbox', 'customint3', get_string('activeenrolalert', 'enrol_notificationeabc')); - $mform->addHelpButton('customint3', 'activeenrolalert', 'enrol_notificationeabc'); + $mform->addElement('advcheckbox', 'customint1', get_string('activeenrolalert', 'enrol_notificationeabc')); + $mform->addHelpButton('customint1', 'activeenrolalert', 'enrol_notificationeabc'); - $mform->addElement('editor', 'customtext1', get_string('location', 'enrol_notificationeabc'), null); + $mform->addElement('editor', 'customtext1', get_string('enrolmessage', 'enrol_notificationeabc'), null); $mform->setType('customtext1', PARAM_RAW); - $mform->addHelpButton('customtext1', 'location', 'enrol_notificationeabc'); + $mform->addHelpButton('customtext1', 'enrolmessage', 'enrol_notificationeabc'); // Unenrol notifications. - $mform->addElement('advcheckbox', 'customint4', get_string('activeunenrolalert', 'enrol_notificationeabc')); - $mform->addHelpButton('customint4', 'activeunenrolalert', 'enrol_notificationeabc'); + $mform->addElement('advcheckbox', 'customint2', get_string('activeunenrolalert', 'enrol_notificationeabc')); + $mform->addHelpButton('customint2', 'activeunenrolalert', 'enrol_notificationeabc'); $mform->addElement('editor', 'customtext2', get_string('unenrolmessage', 'enrol_notificationeabc'), null); $mform->setType('customtext2', PARAM_RAW); $mform->addHelpButton('customtext2', 'unenrolmessage', 'enrol_notificationeabc'); // Update enrolment notifications. - $mform->addElement('advcheckbox', 'customint5', get_string('activeenrolupdatedalert', 'enrol_notificationeabc')); - $mform->addHelpButton('customint5', 'activeenrolupdatedalert', 'enrol_notificationeabc'); + $mform->addElement('advcheckbox', 'customint3', get_string('activeenrolupdatedalert', 'enrol_notificationeabc')); + $mform->addHelpButton('customint3', 'activeenrolupdatedalert', 'enrol_notificationeabc'); $mform->addElement('editor', 'customtext3', get_string('updatedenrolmessage', 'enrol_notificationeabc'), null); $mform->setType('customtext3', PARAM_RAW); @@ -81,9 +81,11 @@ public function definition() { // Email y nombre del remitente. $mform->addElement('text', 'customchar1', get_string('emailsender', 'enrol_notificationeabc')); $mform->addHelpButton('customchar1', 'emailsender', 'enrol_notificationeabc'); + $mform->setType('customchar1', PARAM_RAW); $mform->addElement('text', 'customchar2', get_string('namesender', 'enrol_notificationeabc')); $mform->addHelpButton('customchar2', 'namesender', 'enrol_notificationeabc'); + $mform->setType('customchar2', PARAM_RAW); $this->add_action_buttons(true, ($instance->id ? null : get_string('addinstance', 'enrol'))); @@ -103,9 +105,9 @@ public function definition() { $mform->setDefault('customtext3', array('text' => $instance->customtext3)); $mform->setDefault('customchar1', $instance->customchar1); $mform->setDefault('customchar2', $instance->customchar2); + $mform->setDefault('customint1', $instance->customint1); + $mform->setDefault('customint2', $instance->customint2); $mform->setDefault('customint3', $instance->customint3); - $mform->setDefault('customint4', $instance->customint4); - $mform->setDefault('customint5', $instance->customint5); if (!empty($instance->name)) { $mform->setDefault('name', $instance->name); } else { diff --git a/lang/en/enrol_notificationeabc.php b/lang/en/enrol_notificationeabc.php index e8e0d2c..b8c5cf4 100644 --- a/lang/en/enrol_notificationeabc.php +++ b/lang/en/enrol_notificationeabc.php @@ -25,63 +25,68 @@ * @author Osvaldo Arriola */ -$string['filelockedmail'] = 'You has been enroled in {$a->fullname} ({$a->url})'; -$string['location'] = 'Message'; -$string['messageprovider:notificationeabc_enrolment'] = 'Enrol notification messages'; -$string['notificationeabc:manage'] = 'Manage notificationeabc'; -$string['pluginname'] = 'Enrol Notification'; +$string['activar_help'] = 'When activated will be verified by the immediate execution of cron later, users who were enrolled for the period specified above'; +$string['activar'] = 'Enable initial verification'; +$string['emailsender_help'] = 'By default set to take the email user support '; +$string['emailsender'] = 'Email sender '; +$string['failsend'] = 'WARNING: it has no been able to notify the {$a->username} user about his enrollment in the {$a->coursename} course'."\n"; +$string['fecha_help'] = 'Place the period for which you want to perform the first virificación'; +$string['fecha'] = 'Period for verification of users enrolled courses'; +$string['messageprovider:notificationeabc_enrolment'] = 'Enrol email notification messages'; +$string['namesender_help'] = 'By default it takes the name set to the user support'; +$string['namesender'] = 'Name sender '; +$string['notificationeabc:config'] = 'Configure email notificationeabc instances'; +$string['notificationeabc:manage'] = 'Manage email notificationeabc'; $string['pluginname_desc'] = 'Enrol notifications via mail'; -$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 +$string['pluginname'] = 'Enrol Notification'; +$string['status'] = 'Active enrol email notification'; +$string['subject'] = 'Enrolment email notification'; +$string['succefullsend'] = 'The user {$a->username} has been notified about his enrollment in the {$a->coursename} course'."\n"; + +// Unenrol notifications. +$string['activeenrolalert'] = 'Active enrol alert'; +$string['activeenrolalert_help'] = 'Active enrol alert'; +$string['activarglobalenrolalert'] = 'Active global'; +$string['activarglobalenrolalert_help'] = 'Active enrol email notification for all site'; +$string['enrolmessage'] = 'Message'; +$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
 {COURSENAME} = course fullname
 {USERNAME} = username
-{NOMBRE} = firstname
-{APELLIDO} = lastname
+{FIRSTNAME} = firstname
+{LASTNAME} = lastname
 {URL} = course url
 
'; -$string['fecha_help'] = 'Place the period for which you want to perform the first virificación'; -$string['fecha'] = 'Period for verification of users enrolled courses'; -$string['activar'] = 'Enable initial verification'; -$string['activar_help'] = 'When activated will be verified by the immediate execution of cron later, users who were enrolled for the period specified above'; -$string['activarglobal'] = 'Active global'; -$string['activarglobal_help'] = 'Active enrol notification for all site'; -$string['emailsender'] = 'Email sender '; -$string['emailsender_help'] = 'By default set to take the email user support '; -$string['namesender'] = 'Name sender '; -$string['namesender_help'] = 'By default it takes the name set to the user support'; -$string['status'] = 'Active enrol notification'; -$string['subject'] = 'Enrolment notification'; -$string['activeenrolalert'] = 'Active enrol alert'; -$string['activeenrolalert_help'] = 'Active enrol alert'; +$string['enrolmessagedefault'] = 'You has been enroled in {$a->fullname} ({$a->url})'; + // Unenrol notifications. -$string['activeunenrolalert'] = 'Active unenrol notifications'; +$string['activeunenrolalert'] = 'Active unenrol email notifications'; $string['activeunenrolalert_help'] = 'Active unenrol alert'; $string['activarglobalunenrolalert'] = 'Active global'; -$string['activarglobalunenrolalert_help'] = 'Active enrol notifications for all site'; +$string['activarglobalunenrolalert_help'] = 'Active enrol email notifications for all site'; $string['unenrolmessage'] = 'Custom Message'; $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
 {COURSENAME} = course fullname
 {USERNAME} = username
-{NOMBRE} = firstname
-{APELLIDO} = lastname
+{FIRSTNAME} = firstname
+{LASTNAME} = lastname
 {URL} = course url
 
'; $string['unenrolmessagedefault'] = 'You has been unenrolled from {$a->fullname} ({$a->url})'; + // Update enrol notifications. -$string['activeenrolupdatedalert'] = 'Active update enrol notifications'; -$string['activeenrolupdatedalert_help'] = 'Active update enrol notifications'; +$string['activeenrolupdatedalert'] = 'Active update enrol email notifications'; +$string['activeenrolupdatedalert_help'] = 'Active update enrol email notifications'; $string['activarglobalenrolupdated'] = 'Active global'; -$string['activarglobalenrolupdated_help'] = 'Active enrol updated notifications for all site'; +$string['activarglobalenrolupdated_help'] = 'Active enrol updated email notifications for all site'; $string['updatedenrolmessage'] = 'Custom message'; $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
 {COURSENAME} = course fullname
 {USERNAME} = username
-{NOMBRE} = firstname
-{APELLIDO} = lastname
+{FIRSTNAME} = firstname
+{LASTNAME} = lastname
 {URL} = course url
 
'; $string['updatedenrolmessagedefault'] = 'Your enrolment from {$a->fullname} has been updated ({$a->url})'; -$string['succefullsend'] = 'The user {$a->username} has been notified about his enrollment in the {$a->coursename} course'."\n"; -$string['failsend'] = 'WARNING: it has no been able to notify the {$a->username} user about his enrollment in the {$a->coursename} course'."\n"; \ No newline at end of file diff --git a/lang/es/enrol_notificationeabc.php b/lang/es/enrol_notificationeabc.php index a185d74..034c2fe 100644 --- a/lang/es/enrol_notificationeabc.php +++ b/lang/es/enrol_notificationeabc.php @@ -25,8 +25,8 @@ * @author Osvaldo Arriola */ -$string['filelockedmail'] = 'Ud ha sido matriculado en el curso {$a->fullname} ({$a->url})'; -$string['location'] = 'Mensaje personalizado'; +$string['enrolmessagedefault'] = 'Ud ha sido matriculado en el curso {$a->fullname} ({$a->url})'; +$string['enrolmessage'] = 'Mensaje personalizado'; $string['messageprovider:notificationeabc_enrolment'] = 'Enrol notification messages'; $string['notificationeabc:manage'] = 'Gestionar notificaciones de matriculación'; $string['pluginname'] = 'Notificación de Matriculación'; @@ -35,16 +35,16 @@
 {COURSENAME} = Nombre completo del curso
 {USERNAME} = Nombre de usuario
-{NOMBRE} = Nombre
-{APELLIDO} = Apellido
+{FIRSTNAME} = Nombre
+{LASTNAME} = Apellido
 {URL} = Url del curso
 
'; $string['fecha_help'] = 'Coloque el periodo por el cual desea que se realice la virificación inicial de usuarios matriculados'; $string['fecha'] = 'Período para realizar la verificación de usuarios que se matricularon a cursos'; $string['activar'] = 'Activar verificación inicial'; $string['activar_help'] = 'Al activarse se verificará, mediante la ejecucion del cron inmediata posterior, los usuarios que fueron matriculados en el periodo establecido arriba'; -$string['activarglobal'] = 'Activar para todo el sitio'; -$string['activarglobal_help'] = 'Activa la notificacion de matriculacion para todo los cursos'; +$string['activarglobalenrolalert'] = 'Activar para todo el sitio'; +$string['activarglobalenrolalert_help'] = 'Activa la notificacion de matriculacion para todo los cursos'; $string['emailsender'] = 'Email del remitente '; $string['emailsender_help'] = 'Por defecto toma el email configurado como el usuario de soporte '; $string['namesender'] = 'Nombre del remitente '; @@ -63,8 +63,8 @@
 {COURSENAME} = Nombre completo del curso
 {USERNAME} = Nombre de usuario
-{NOMBRE} = Nombre
-{APELLIDO} = Apellido
+{FIRSTNAME} = Nombre
+{LASTNAME} = Apellido
 {URL} = Url del curso
 
'; $string['unenrolmessagedefault'] = 'Ud ha sido desmatriculado del curso {$a->fullname} ({$a->url})'; @@ -78,8 +78,8 @@
 {COURSENAME} = Nombre completo del curso
 {USERNAME} = Nombre de usuario
-{NOMBRE} = Nombre
-{APELLIDO} = Apellido
+{FIRSTNAME} = Nombre
+{LASTNAME} = Apellido
 {URL} = Url del curso
 
'; $string['updatedenrolmessagedefault'] = 'Su matriculacion en el curso {$a->fullname} ha sido actualizada ({$a->url})'; diff --git a/lib.php b/lib.php index 0e68872..66d346e 100644 --- a/lib.php +++ b/lib.php @@ -51,69 +51,67 @@ class enrol_notificationeabc_plugin extends enrol_plugin * @param int $type aviso matriculacion, actualizacion o desmatriculacion * @return bool */ - public function enviarmail(stdClass $user, stdClass $course, $type) { + public function send_email(stdClass $user, stdClass $course, $type) { global $CFG, $DB, $COURSE; $course->url = $CFG->wwwroot . '/course/view.php?id=' . $course->id; $enrol = $DB->get_record('enrol', array('enrol' => 'notificationeabc', 'courseid' => $course->id, 'status' => 0)); - $activeglobalenrol = $this->get_config('activarglobal'); + $activeglobalenrol = $this->get_config('activarglobalenrolalert'); $activarglobalunenrolalert = $this->get_config('activarglobalunenrolalert'); $activarglobalenrolupdated = $this->get_config('activarglobalenrolupdated'); - $mensajeenrol = $this->get_config('location'); - $plainmensajeenrol = strip_tags($mensajeenrol); - $mensajeunenrol = $this->get_config('unenrolmessage'); - $plainmensajeunenrol = strip_tags($mensajeunenrol); - $mensajeupdateenrol = $this->get_config('updatedenrolmessage'); - $plainmensajeupdateenrol = strip_tags($mensajeupdateenrol); + $enrolmessage = $this->get_config('enrolmessage'); + $plainmensajeenrol = strip_tags($enrolmessage); + $unenrolmessage = $this->get_config('unenrolmessage'); + $plainmensajeunenrol = strip_tags($unenrolmessage); + $updatedenrolmessage = $this->get_config('updatedenrolmessage'); + $plainmensajeupdateenrol = strip_tags($updatedenrolmessage); switch ((int)$type) { case 1: // Si no se configuro un mensaje personalizado se envia uno por defecto basico. if (!empty($enrol) && !empty($enrol->customtext1)) { - $texto = strip_tags($enrol->customtext1); - if (!empty($texto)) { - $mensaje = $this->process_mensaje($enrol->customtext1, $user, $course); + $customtext = strip_tags($enrol->customtext1); + if (!empty($customtext)) { + $message = $this->get_message($enrol->customtext1, $user, $course); } else { - $mensaje = get_string("filelockedmail", "enrol_notificationeabc", $course); + $message = get_string('enrolmessagedefault', 'enrol_notificationeabc', $course); } } else if (!empty($activeglobalenrol) && !empty($plainmensajeenrol)) { - $mensaje = $this->process_mensaje($mensajeenrol, $user, $course); + $message = $this->get_message($enrolmessage, $user, $course); } else { - $mensaje = get_string("filelockedmail", "enrol_notificationeabc", $course); + $message = get_string('enrolmessagedefault', 'enrol_notificationeabc', $course); } break; case 2: - if (!empty($enrol) && !empty($enrol->customtext2)) { - $texto = strip_tags($enrol->customtext2); - if (!empty($texto)) { - $mensaje = $this->process_mensaje($enrol->customtext2, $user, $course); + $customtext = strip_tags($enrol->customtext2); + if (!empty($customtext)) { + $message = $this->get_message($enrol->customtext2, $user, $course); } else { - $mensaje = get_string("unenrolmessagedefault", "enrol_notificationeabc", $course); + $message = get_string('unenrolmessagedefault', 'enrol_notificationeabc', $course); } } else if (!empty($activarglobalunenrolalert) && !empty($plainmensajeunenrol)) { - $mensaje = $this->process_mensaje($mensajeunenrol, $user, $course); + $message = $this->get_message($unenrolmessage, $user, $course); } else { - $mensaje = get_string("unenrolmessagedefault", "enrol_notificationeabc", $course); + $message = get_string('unenrolmessagedefault', 'enrol_notificationeabc', $course); } break; case 3: - if (!empty($enrol) && !empty($enrol->customtext3)) { - $texto = strip_tags($enrol->customtext3); - if (!empty($texto)) { - $mensaje = $this->process_mensaje($enrol->customtext3, $user, $course); + $customtext = strip_tags($enrol->customtext3); + if (!empty($customtext)) { + $message = $this->get_message($enrol->customtext3, $user, $course); } else { - $mensaje = get_string("updatedenrolmessagedefault", "enrol_notificationeabc", $course); + $message = get_string('updatedenrolmessagedefault', 'enrol_notificationeabc', $course); } } else if (!empty($activarglobalenrolupdated) && !empty($plainmensajeupdateenrol)) { - $mensaje = $this->process_mensaje($mensajeupdateenrol, $user, $course); + $message = $this->get_message($updatedenrolmessage, $user, $course); } else { - $mensaje = get_string("updatedenrolmessagedefault", "enrol_notificationeabc", $course); + $message = get_string('updatedenrolmessagedefault', 'enrol_notificationeabc', $course); } break; @@ -149,7 +147,7 @@ public function enviarmail(stdClass $user, stdClass $course, $type) { $eventdata->subject = get_string('subject', 'enrol_notificationeabc'); $eventdata->fullmessage = ''; $eventdata->fullmessageformat = FORMAT_HTML; - $eventdata->fullmessagehtml = $mensaje; + $eventdata->fullmessagehtml = $message; $eventdata->smallmessage = ''; $strdata = new stdClass(); $strdata->username = $user->username; @@ -166,19 +164,19 @@ public function enviarmail(stdClass $user, stdClass $course, $type) { // Procesa el mensaje para aceptar marcadores. /** * Proccess message method - * @param String $mensaje el mensaje en bruto + * @param String $message el mensaje en bruto * @param stdClass $user instancia usuario * @param stdClass $course instancia curso * @return String el mensaje procesado */ - public function process_mensaje($mensaje, stdClass $user, stdClass $course) { + public function get_message($message, stdClass $user, stdClass $course) { global $CFG; - $m = $mensaje; + $m = $message; $url = new moodle_url($CFG->wwwroot . '/course/view.php', array('id' => $course->id)); $m = str_replace('{COURSENAME}', $course->fullname, $m); $m = str_replace('{USERNAME}', $user->username, $m); - $m = str_replace('{NOMBRE}', $user->firstname, $m); - $m = str_replace('{APELLIDO}', $user->lastname, $m); + $m = str_replace('{FIRSTNAME}', $user->firstname, $m); + $m = str_replace('{LASTNAME}', $user->lastname, $m); $m = str_replace('{URL}', $url, $m); return $m; } @@ -208,15 +206,13 @@ public function get_newinstance_link($courseid) { public function get_instance_defaults() { $fields = array(); - $fields['customtext1'] = $this->get_config('location'); + $fields['customtext1'] = $this->get_config('enrolmessage'); $fields['customtext2'] = $this->get_config('unenrolmessage'); $fields['customtext3'] = $this->get_config('updatedenrolmessage'); $fields['status'] = 1; - $fields['customint1'] = 0; - $fields['customint2'] = 0; - $fields['customint3'] = $this->get_config('activeenrolalert'); - $fields['customint4'] = $this->get_config('activeunenrolalert'); - $fields['customint5'] = $this->get_config('activeenrolupdatedalert'); + $fields['customint1'] = $this->get_config('activeenrolalert'); + $fields['customint2'] = $this->get_config('activeunenrolalert'); + $fields['customint3'] = $this->get_config('activeenrolupdatedalert'); $fields['customchar1'] = $this->get_config('emailsender'); $fields['customchar2'] = $this->get_config('namesender'); @@ -241,16 +237,16 @@ public function get_action_icons(stdClass $instance) { if (has_capability('enrol/notificationeabc:manage', $context)) { $editlink = new moodle_url( - "/enrol/notificationeabc/edit.php", + '/enrol/notificationeabc/edit.php', array('courseid' => $instance->courseid, 'id' => $instance->id) ); $icons[] = $OUTPUT->action_icon( $editlink, new pix_icon( - 'i/edit', + 't/edit', get_string('edit'), 'core', - array('class' => 'icon') + array('class' => 'icon iconsmall') ) ); } @@ -270,5 +266,15 @@ public function get_info_icons(array $instances) { 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/notificationeabc:config', $context); + } } // End of class. diff --git a/settings.php b/settings.php index 4d2c738..5e281e7 100644 --- a/settings.php +++ b/settings.php @@ -42,8 +42,8 @@ ); $settings->add(new admin_setting_configcheckbox( 'enrol_notificationeabc/activarglobal', - get_string('activarglobal', 'enrol_notificationeabc'), - get_string('activarglobal_help', 'enrol_notificationeabc'), + get_string('activarglobalenrolalert', 'enrol_notificationeabc'), + get_string('activarglobalenrolalert_help', 'enrol_notificationeabc'), '') ); $settings->add(new admin_setting_heading( diff --git a/version.php b/version.php index c67dd02..88e163f 100644 --- a/version.php +++ b/version.php @@ -26,7 +26,7 @@ */ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2017111700; +$plugin->version = 2018022001; $plugin->requires = 2016120503; $plugin->component = 'enrol_notificationeabc'; $plugin->maturity = MATURITY_STABLE;