Update #86c8jzuvd - Moodle code style followed

This commit is contained in:
Nihaal Shaikh
2026-03-16 13:09:05 +01:00
parent 5dce3ed488
commit 3f5f4ee6cb
8 changed files with 61 additions and 37 deletions

View File

@@ -36,7 +36,6 @@ use core_availability\info;
* @copyright 2019-05-14 Mfreak.nl | LdesignMedia.nl - Luuk Verhoeven * @copyright 2019-05-14 Mfreak.nl | LdesignMedia.nl - Luuk Verhoeven
*/ */
class condition extends \core_availability\condition { class condition extends \core_availability\condition {
/** /**
* Manual provided IP addresses. * Manual provided IP addresses.
* *
@@ -213,5 +212,4 @@ class condition extends \core_availability\condition {
return $result; return $result;
} }
} }

View File

@@ -39,7 +39,6 @@ require_once($CFG->libdir . '/formslib.php');
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/ */
class range_form extends \moodleform { class range_form extends \moodleform {
/** /**
* Define the form. * Define the form.
* *
@@ -72,8 +71,12 @@ class range_form extends \moodleform {
$mform->addHelpButton('ipaddresses', 'ipaddresses_help', 'availability_ipaddress'); $mform->addHelpButton('ipaddresses', 'ipaddresses_help', 'availability_ipaddress');
// Description field. // Description field.
$mform->addElement('textarea', 'description', get_string('description'), $mform->addElement(
['rows' => 3, 'cols' => 60]); 'textarea',
'description',
get_string('description'),
['rows' => 3, 'cols' => 60]
);
$mform->setType('description', PARAM_TEXT); $mform->setType('description', PARAM_TEXT);
// Enabled field. // Enabled field.
@@ -147,5 +150,4 @@ class range_form extends \moodleform {
return false; return false;
} }
} }

View File

@@ -34,7 +34,6 @@ namespace availability_ipaddress;
* @copyright 2019-05-14 Mfreak.nl | LdesignMedia.nl - Luuk Verhoeven * @copyright 2019-05-14 Mfreak.nl | LdesignMedia.nl - Luuk Verhoeven
*/ */
class frontend extends \core_availability\frontend { class frontend extends \core_availability\frontend {
/** /**
* get_javascript_strings * get_javascript_strings
* *
@@ -81,5 +80,4 @@ class frontend extends \core_availability\frontend {
return [$rangedata]; return [$rangedata];
} }
} }

View File

@@ -34,7 +34,6 @@ namespace availability_ipaddress;
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/ */
class helper { class helper {
/** /**
* Check if a predefined range is in use. * Check if a predefined range is in use.
* *
@@ -296,7 +295,6 @@ class helper {
// Process nested conditions. // Process nested conditions.
return self::process_nested_conditions($availability, $rangeid) || $modified; return self::process_nested_conditions($availability, $rangeid) || $modified;
} }
/** /**
@@ -361,5 +359,4 @@ class helper {
return $modified; return $modified;
} }
} }

View File

@@ -33,7 +33,6 @@ namespace availability_ipaddress\privacy;
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/ */
class provider implements \core_privacy\local\metadata\null_provider { class provider implements \core_privacy\local\metadata\null_provider {
/** /**
* Get the language string identifier with the component's language * Get the language string identifier with the component's language
* file to explain why this plugin stores no data. * 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 { public static function get_reason(): string {
return 'privacy:metadata'; return 'privacy:metadata';
} }
} }

View File

@@ -45,7 +45,6 @@ use confirm_action;
* @author Vincent Cornelis * @author Vincent Cornelis
*/ */
class ipranges_table extends table_sql { class ipranges_table extends table_sql {
/** /**
* @var moodle_url The base URL for the page. * @var moodle_url The base URL for the page.
*/ */
@@ -185,8 +184,10 @@ class ipranges_table extends table_sql {
// Edit action. // Edit action.
$editurl = new moodle_url($this->baseurl, ['action' => 'edit', 'id' => $range->id]); $editurl = new moodle_url($this->baseurl, ['action' => 'edit', 'id' => $range->id]);
$actions[] = $OUTPUT->action_icon($editurl, $actions[] = $OUTPUT->action_icon(
new pix_icon('t/edit', get_string('edit'))); $editurl,
new pix_icon('t/edit', get_string('edit'))
);
// Toggle action. // Toggle action.
$toggleurl = new moodle_url($this->baseurl, ['action' => 'toggle', 'id' => $range->id, 'sesskey' => sesskey()]); $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']) { if ($usage['inuse']) {
// Create confirmation message with usage details. // Create confirmation message with usage details.
$message = \availability_ipaddress\helper::get_range_usage_html($range->id); $message = \availability_ipaddress\helper::get_range_usage_html($range->id);
$message .= \html_writer::tag('p', get_string('confirm_disable_range', 'availability_ipaddress'), $message .= \html_writer::tag(
['class' => 'font-weight-bold']); 'p',
$actions[] = $OUTPUT->action_icon($toggleurl, new pix_icon($toggleicon, $togglestring), get_string('confirm_disable_range', 'availability_ipaddress'),
new confirm_action($message)); ['class' => 'font-weight-bold']
);
$actions[] = $OUTPUT->action_icon(
$toggleurl,
new pix_icon($toggleicon, $togglestring),
new confirm_action($message)
);
} else { } else {
$actions[] = $OUTPUT->action_icon($toggleurl, new pix_icon($toggleicon, $togglestring)); $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); $usage = \availability_ipaddress\helper::is_range_in_use($range->id);
if ($usage['inuse']) { if ($usage['inuse']) {
$message = \availability_ipaddress\helper::get_range_usage_html($range->id); $message = \availability_ipaddress\helper::get_range_usage_html($range->id);
$message .= \html_writer::tag('p', get_string('confirm_delete_range', 'availability_ipaddress'), $message .= \html_writer::tag(
['class' => 'font-weight-bold']); 'p',
get_string('confirm_delete_range', 'availability_ipaddress'),
['class' => 'font-weight-bold']
);
} else { } else {
$message = get_string('confirm_delete_range', 'availability_ipaddress'); $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 pix_icon('t/delete', get_string('delete')),
new confirm_action($message)); new confirm_action($message)
);
return implode(' ', $actions); return implode(' ', $actions);
} }
} }

View File

@@ -44,11 +44,19 @@ if ($action === 'delete' && confirm_sesskey()) {
$DB->delete_records('availability_ipaddress_pre', ['id' => $id]); $DB->delete_records('availability_ipaddress_pre', ['id' => $id]);
if ($removed > 0) { if ($removed > 0) {
redirect($PAGE->url, get_string('range_deleted_and_removed', 'availability_ipaddress', $removed), redirect(
null, \core\output\notification::NOTIFY_SUCCESS); $PAGE->url,
get_string('range_deleted_and_removed', 'availability_ipaddress', $removed),
null,
\core\output\notification::NOTIFY_SUCCESS
);
} else { } else {
redirect($PAGE->url, get_string('range_deleted', 'availability_ipaddress'), null, redirect(
\core\output\notification::NOTIFY_SUCCESS); $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) { if (!$record->enabled) {
$removed = \availability_ipaddress\helper::remove_range_from_restrictions($id); $removed = \availability_ipaddress\helper::remove_range_from_restrictions($id);
if ($removed > 0) { if ($removed > 0) {
redirect($PAGE->url, get_string('range_disabled_and_removed', 'availability_ipaddress', $removed), redirect(
null, \core\output\notification::NOTIFY_SUCCESS); $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. // Update existing.
$data->timemodified = time(); $data->timemodified = time();
$DB->update_record('availability_ipaddress_pre', $data); $DB->update_record('availability_ipaddress_pre', $data);
redirect($PAGE->url, get_string('range_updated', 'availability_ipaddress'), null, redirect(
\core\output\notification::NOTIFY_SUCCESS); $PAGE->url,
get_string('range_updated', 'availability_ipaddress'),
null,
\core\output\notification::NOTIFY_SUCCESS
);
} else { } else {
// Create new. // Create new.
$data->timecreated = time(); $data->timecreated = time();
$data->timemodified = time(); $data->timemodified = time();
$DB->insert_record('availability_ipaddress_pre', $data); $DB->insert_record('availability_ipaddress_pre', $data);
redirect($PAGE->url, get_string('range_created', 'availability_ipaddress'), null, redirect(
\core\output\notification::NOTIFY_SUCCESS); $PAGE->url,
get_string('range_created', 'availability_ipaddress'),
null,
\core\output\notification::NOTIFY_SUCCESS
);
} }
} }

View File

@@ -29,7 +29,6 @@ defined('MOODLE_INTERNAL') || die();
global $ADMIN; global $ADMIN;
if ($hassiteconfig) { if ($hassiteconfig) {
// Add external page for managing IP ranges. // Add external page for managing IP ranges.
$ADMIN->add( $ADMIN->add(
'availabilitysettings', 'availabilitysettings',
@@ -38,7 +37,8 @@ if ($hassiteconfig) {
get_string('setting:manage_predefined_ranges', 'availability_ipaddress'), get_string('setting:manage_predefined_ranges', 'availability_ipaddress'),
new moodle_url('/availability/condition/ipaddress/manage_ranges.php'), new moodle_url('/availability/condition/ipaddress/manage_ranges.php'),
'moodle/site:config' 'moodle/site:config'
)); )
);
} }
// Set the visible name of auto generated settings page to empty string, // Set the visible name of auto generated settings page to empty string,