From 5dce3ed4886effd2190e60dd66a95f4152519991 Mon Sep 17 00:00:00 2001 From: Nihaal Shaikh Date: Tue, 3 Mar 2026 13:26:17 +0100 Subject: [PATCH 1/2] Update #86c8jzuvd - upgraded plugin to support Moodle 5.1, moved changelog to separate file --- CHANGELOG.md | 25 +++++++++++++++++++++++++ README.md | 9 ++------- version.php | 6 +++--- 3 files changed, 30 insertions(+), 10 deletions(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..7492a5d --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,25 @@ +# Changelog + +## 5.1.0 (2026030300) +- Tested and verified on Moodle 5.1 + +## 5.0.2 (2025080401) +- Added support for pre-configuring IP ranges by admins + +## 5.0.1 (2025052200) +- Tested on Moodle 5.0 + +## 4.5.0 (2025040400) +- Tested on Moodle 4.5 + +## 4.4.0 (2024072000) +- Tested on Moodle 4.4 + +## 4.0.3 (2022052801) +- Test in Moodle 4.0 @[hamzatamyachte](https://github.com/hamzatamyachte) + +## 4.0.2 (2022052800) +- Fixed the [issue 6](https://github.com/ldesignmediaNL/moodle-availability_ipaddress/issues/6) @[hamzatamyachte](https://github.com/hamzatamyachte) + +## 4.0.1 (2022021100) +- Thanks for adding ip-range support @[juacas](https://github.com/juacas) diff --git a/README.md b/README.md index 0c7784d..2b9b60f 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ activity, making it accessible only to users from specified IP addresses. ![Moodle404](https://img.shields.io/badge/moodle-4.4-F98012.svg?logo=moodle) ![Moodle405](https://img.shields.io/badge/moodle-4.5-F98012.svg?logo=moodle) ![Moodle500](https://img.shields.io/badge/moodle-5.0-F98012.svg?logo=moodle) +![Moodle501](https://img.shields.io/badge/moodle-5.1-F98012.svg?logo=moodle) ![PHP7.4](https://img.shields.io/badge/PHP-7.4-777BB4.svg?logo=php) ![PHP8.0](https://img.shields.io/badge/PHP-8.0-777BB4.svg?logo=php) @@ -64,10 +65,4 @@ Contributions are welcome and will be fully credited. We accept contributions vi ## Changelog -- 2024080401 Added support for pre-configuring IP ranges by admins -- 2025052200 Tested on Moodle 5.0 -- 2025040400 Tested on Moodle 4.5 -- 2024072000 Tested on Moodle 4.4 -- 2022021100 Thanks for adding ip-range support @[juacas](https://github.com/juacas) -- 2022052800 Fixed the [issue 6](https://github.com/ldesignmediaNL/moodle-availability_ipaddress/issues/6) @[hamzatamyachte](https://github.com/hamzatamyachte) -- 2022052801 Test in Moodle 4.0 @[hamzatamyachte](https://github.com/hamzatamyachte) +See [CHANGELOG.md](CHANGELOG.md) for a full list of changes. diff --git a/version.php b/version.php index d764e5d..75516ed 100644 --- a/version.php +++ b/version.php @@ -27,8 +27,8 @@ defined('MOODLE_INTERNAL') || die(); $plugin->component = 'availability_ipaddress'; -$plugin->version = 2025080401; -$plugin->release = '5.0.2'; +$plugin->version = 2026030300; +$plugin->release = '5.1.0'; $plugin->requires = 2016120500; $plugin->maturity = MATURITY_STABLE; -$plugin->supported = [400, 500]; +$plugin->supported = [400, 501]; From 3f5f4ee6cbde9349c2355c92b91e80aa18328d83 Mon Sep 17 00:00:00 2001 From: Nihaal Shaikh Date: Mon, 16 Mar 2026 13:09:05 +0100 Subject: [PATCH 2/2] Update #86c8jzuvd - Moodle code style followed --- classes/condition.php | 2 -- classes/form/range_form.php | 10 ++++---- classes/frontend.php | 2 -- classes/helper.php | 3 --- classes/privacy/provider.php | 2 -- classes/table/ipranges_table.php | 35 ++++++++++++++++++---------- manage_ranges.php | 40 ++++++++++++++++++++++++-------- settings.php | 4 ++-- 8 files changed, 61 insertions(+), 37 deletions(-) diff --git a/classes/condition.php b/classes/condition.php index 50a202c..0c0d6f2 100644 --- a/classes/condition.php +++ b/classes/condition.php @@ -36,7 +36,6 @@ use core_availability\info; * @copyright 2019-05-14 Mfreak.nl | LdesignMedia.nl - Luuk Verhoeven */ class condition extends \core_availability\condition { - /** * Manual provided IP addresses. * @@ -213,5 +212,4 @@ class condition extends \core_availability\condition { return $result; } - } diff --git a/classes/form/range_form.php b/classes/form/range_form.php index 5d4ff2a..d890246 100644 --- a/classes/form/range_form.php +++ b/classes/form/range_form.php @@ -39,7 +39,6 @@ require_once($CFG->libdir . '/formslib.php'); * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class range_form extends \moodleform { - /** * Define the form. * @@ -72,8 +71,12 @@ class range_form extends \moodleform { $mform->addHelpButton('ipaddresses', 'ipaddresses_help', 'availability_ipaddress'); // Description field. - $mform->addElement('textarea', 'description', get_string('description'), - ['rows' => 3, 'cols' => 60]); + $mform->addElement( + 'textarea', + 'description', + get_string('description'), + ['rows' => 3, 'cols' => 60] + ); $mform->setType('description', PARAM_TEXT); // Enabled field. @@ -147,5 +150,4 @@ class range_form extends \moodleform { return false; } - } diff --git a/classes/frontend.php b/classes/frontend.php index 4d826b1..8d844e7 100644 --- a/classes/frontend.php +++ b/classes/frontend.php @@ -34,7 +34,6 @@ namespace availability_ipaddress; * @copyright 2019-05-14 Mfreak.nl | LdesignMedia.nl - Luuk Verhoeven */ class frontend extends \core_availability\frontend { - /** * get_javascript_strings * @@ -81,5 +80,4 @@ class frontend extends \core_availability\frontend { return [$rangedata]; } - } diff --git a/classes/helper.php b/classes/helper.php index 804dc33..ad16d63 100644 --- a/classes/helper.php +++ b/classes/helper.php @@ -34,7 +34,6 @@ namespace availability_ipaddress; * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class helper { - /** * Check if a predefined range is in use. * @@ -296,7 +295,6 @@ class helper { // Process nested conditions. return self::process_nested_conditions($availability, $rangeid) || $modified; - } /** @@ -361,5 +359,4 @@ class helper { return $modified; } - } diff --git a/classes/privacy/provider.php b/classes/privacy/provider.php index 3587f26..ee58551 100644 --- a/classes/privacy/provider.php +++ b/classes/privacy/provider.php @@ -33,7 +33,6 @@ namespace availability_ipaddress\privacy; * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class provider implements \core_privacy\local\metadata\null_provider { - /** * Get the language string identifier with the component's language * file to explain why this plugin stores no data. @@ -43,5 +42,4 @@ class provider implements \core_privacy\local\metadata\null_provider { public static function get_reason(): string { return 'privacy:metadata'; } - } diff --git a/classes/table/ipranges_table.php b/classes/table/ipranges_table.php index b7f232e..69e2451 100644 --- a/classes/table/ipranges_table.php +++ b/classes/table/ipranges_table.php @@ -45,7 +45,6 @@ use confirm_action; * @author Vincent Cornelis */ class ipranges_table extends table_sql { - /** * @var moodle_url The base URL for the page. */ @@ -185,8 +184,10 @@ class ipranges_table extends table_sql { // Edit action. $editurl = new moodle_url($this->baseurl, ['action' => 'edit', 'id' => $range->id]); - $actions[] = $OUTPUT->action_icon($editurl, - new pix_icon('t/edit', get_string('edit'))); + $actions[] = $OUTPUT->action_icon( + $editurl, + new pix_icon('t/edit', get_string('edit')) + ); // Toggle action. $toggleurl = new moodle_url($this->baseurl, ['action' => 'toggle', 'id' => $range->id, 'sesskey' => sesskey()]); @@ -199,10 +200,16 @@ class ipranges_table extends table_sql { if ($usage['inuse']) { // Create confirmation message with usage details. $message = \availability_ipaddress\helper::get_range_usage_html($range->id); - $message .= \html_writer::tag('p', get_string('confirm_disable_range', 'availability_ipaddress'), - ['class' => 'font-weight-bold']); - $actions[] = $OUTPUT->action_icon($toggleurl, new pix_icon($toggleicon, $togglestring), - new confirm_action($message)); + $message .= \html_writer::tag( + 'p', + get_string('confirm_disable_range', 'availability_ipaddress'), + ['class' => 'font-weight-bold'] + ); + $actions[] = $OUTPUT->action_icon( + $toggleurl, + new pix_icon($toggleicon, $togglestring), + new confirm_action($message) + ); } else { $actions[] = $OUTPUT->action_icon($toggleurl, new pix_icon($toggleicon, $togglestring)); } @@ -222,17 +229,21 @@ class ipranges_table extends table_sql { $usage = \availability_ipaddress\helper::is_range_in_use($range->id); if ($usage['inuse']) { $message = \availability_ipaddress\helper::get_range_usage_html($range->id); - $message .= \html_writer::tag('p', get_string('confirm_delete_range', 'availability_ipaddress'), - ['class' => 'font-weight-bold']); + $message .= \html_writer::tag( + 'p', + get_string('confirm_delete_range', 'availability_ipaddress'), + ['class' => 'font-weight-bold'] + ); } else { $message = get_string('confirm_delete_range', 'availability_ipaddress'); } - $actions[] = $OUTPUT->action_icon($deleteurl, + $actions[] = $OUTPUT->action_icon( + $deleteurl, new pix_icon('t/delete', get_string('delete')), - new confirm_action($message)); + new confirm_action($message) + ); return implode(' ', $actions); } - } diff --git a/manage_ranges.php b/manage_ranges.php index 75f5649..6f2f050 100644 --- a/manage_ranges.php +++ b/manage_ranges.php @@ -44,11 +44,19 @@ if ($action === 'delete' && confirm_sesskey()) { $DB->delete_records('availability_ipaddress_pre', ['id' => $id]); if ($removed > 0) { - redirect($PAGE->url, get_string('range_deleted_and_removed', 'availability_ipaddress', $removed), - null, \core\output\notification::NOTIFY_SUCCESS); + redirect( + $PAGE->url, + get_string('range_deleted_and_removed', 'availability_ipaddress', $removed), + null, + \core\output\notification::NOTIFY_SUCCESS + ); } else { - redirect($PAGE->url, get_string('range_deleted', 'availability_ipaddress'), null, - \core\output\notification::NOTIFY_SUCCESS); + redirect( + $PAGE->url, + get_string('range_deleted', 'availability_ipaddress'), + null, + \core\output\notification::NOTIFY_SUCCESS + ); } } @@ -63,8 +71,12 @@ if ($action === 'toggle' && confirm_sesskey()) { if (!$record->enabled) { $removed = \availability_ipaddress\helper::remove_range_from_restrictions($id); if ($removed > 0) { - redirect($PAGE->url, get_string('range_disabled_and_removed', 'availability_ipaddress', $removed), - null, \core\output\notification::NOTIFY_SUCCESS); + redirect( + $PAGE->url, + get_string('range_disabled_and_removed', 'availability_ipaddress', $removed), + null, + \core\output\notification::NOTIFY_SUCCESS + ); } } @@ -85,15 +97,23 @@ if ($action === 'add' || $action === 'edit') { // Update existing. $data->timemodified = time(); $DB->update_record('availability_ipaddress_pre', $data); - redirect($PAGE->url, get_string('range_updated', 'availability_ipaddress'), null, - \core\output\notification::NOTIFY_SUCCESS); + redirect( + $PAGE->url, + get_string('range_updated', 'availability_ipaddress'), + null, + \core\output\notification::NOTIFY_SUCCESS + ); } else { // Create new. $data->timecreated = time(); $data->timemodified = time(); $DB->insert_record('availability_ipaddress_pre', $data); - redirect($PAGE->url, get_string('range_created', 'availability_ipaddress'), null, - \core\output\notification::NOTIFY_SUCCESS); + redirect( + $PAGE->url, + get_string('range_created', 'availability_ipaddress'), + null, + \core\output\notification::NOTIFY_SUCCESS + ); } } diff --git a/settings.php b/settings.php index 88a4cc0..7cd5087 100644 --- a/settings.php +++ b/settings.php @@ -29,7 +29,6 @@ defined('MOODLE_INTERNAL') || die(); global $ADMIN; if ($hassiteconfig) { - // Add external page for managing IP ranges. $ADMIN->add( 'availabilitysettings', @@ -38,7 +37,8 @@ if ($hassiteconfig) { get_string('setting:manage_predefined_ranges', 'availability_ipaddress'), new moodle_url('/availability/condition/ipaddress/manage_ranges.php'), 'moodle/site:config' - )); + ) + ); } // Set the visible name of auto generated settings page to empty string,