From 866b2cef95b95c69484965711dc8b4717d472159 Mon Sep 17 00:00:00 2001 From: Gareth Barnard <1058419+gjb2048@users.noreply.github.com> Date: Sat, 7 Oct 2023 18:27:43 +0100 Subject: [PATCH] Code checker --- block_theme_selector.php | 45 ++++++++++++++++++++-------------------- db/access.php | 28 ++++++++++++------------- db/upgrade.php | 2 -- settings.php | 14 ++++++------- version.php | 2 +- 5 files changed, 44 insertions(+), 47 deletions(-) diff --git a/block_theme_selector.php b/block_theme_selector.php index fe72376..20d1606 100644 --- a/block_theme_selector.php +++ b/block_theme_selector.php @@ -24,7 +24,6 @@ * @author G J Barnard - {@link http://moodle.org/user/profile.php?id=442195} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -defined('MOODLE_INTERNAL') || die; /** * Theme selector block class. @@ -76,8 +75,8 @@ public function get_content() { if (((has_capability('moodle/site:config', $coursecontext)) && ($CFG->block_theme_selector_urlswitch == 1)) || (($CFG->block_theme_selector_urlswitch == 2) && ($allowthemechangeonurl))) { - $selectdataarray = array('data-sesskey' => sesskey(), 'data-device' => 'default', - 'data-urlswitch' => $CFG->block_theme_selector_urlswitch); + $selectdataarray = ['data-sesskey' => sesskey(), 'data-device' => 'default', + 'data-urlswitch' => $CFG->block_theme_selector_urlswitch, ]; if ($CFG->block_theme_selector_urlswitch == 2) { $pageurl = $this->page->url->out(false); $selectdataarray['data-url'] = $pageurl; @@ -85,7 +84,7 @@ public function get_content() { } $selectdataarray['aria-labelledby'] = 'themeselectorselectlabel'; $selectdataarray['id'] = 'themeselectorselect'; - $this->page->requires->js_call_amd('block_theme_selector/block_theme_selector', 'init', array()); + $this->page->requires->js_call_amd('block_theme_selector/block_theme_selector', 'init', []); // Add a dropdown to switch themes. if (!empty($CFG->block_theme_selector_excludedthemes)) { @@ -94,7 +93,7 @@ public function get_content() { $excludedthemes = []; } $themes = core_component::get_plugin_list('theme'); - $options = array(); + $options = []; foreach ($themes as $theme => $themedir) { if (in_array($theme, $excludedthemes)) { continue; @@ -112,41 +111,41 @@ public function get_content() { unset($options['bootstrapbase']); $current = $this->page->theme->name; } - $this->content->text .= html_writer::start_tag('form', array('class' => 'themeselectorselect')); + $this->content->text .= html_writer::start_tag('form', ['class' => 'themeselectorselect']); $this->content->text .= html_writer::tag('label', get_string('changetheme', 'block_theme_selector'), - array('id' => 'themeselectorselectlabel', 'for' => 'themeselectorselect')); + ['id' => 'themeselectorselectlabel', 'for' => 'themeselectorselect']); $this->content->text .= html_writer::select($options, 'choose', $current, false, $selectdataarray); $this->content->text .= html_writer::end_tag('form'); if (has_capability('moodle/site:config', $coursecontext)) { // Add a button to reset theme caches. - $this->content->text .= html_writer::start_tag('form', array('action' => new moodle_url('/theme/index.php'), - 'method' => 'post', 'class' => 'themeselectorreset')); - $this->content->text .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'sesskey', - 'value' => sesskey())); - $this->content->text .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'reset', - 'value' => '1')); - $this->content->text .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'device', - 'value' => 'default')); + $this->content->text .= html_writer::start_tag('form', ['action' => new moodle_url('/theme/index.php'), + 'method' => 'post', 'class' => 'themeselectorreset', ]); + $this->content->text .= html_writer::empty_tag('input', ['type' => 'hidden', 'name' => 'sesskey', + 'value' => sesskey(), ]); + $this->content->text .= html_writer::empty_tag('input', ['type' => 'hidden', 'name' => 'reset', + 'value' => '1', ]); + $this->content->text .= html_writer::empty_tag('input', ['type' => 'hidden', 'name' => 'device', + 'value' => 'default', ]); $this->content->text .= html_writer::tag('button', get_string('resetthemecache', 'block_theme_selector'), - array('type' => 'submit')); + ['type' => 'submit']); $this->content->text .= html_writer::end_tag('form'); } if ($CFG->block_theme_selector_window == 2) { - $this->content->text .= html_writer::start_tag('form', array('class' => 'themeselectorwindow')); + $this->content->text .= html_writer::start_tag('form', ['class' => 'themeselectorwindow']); $this->content->text .= html_writer::tag('label', get_string('windowsize', 'block_theme_selector'), - array('id' => 'themeselectorwindowlabel', 'for' => 'themeselectorwindowwidth')); - $this->content->text .= html_writer::empty_tag('input', array('type' => 'number', + ['id' => 'themeselectorwindowlabel', 'for' => 'themeselectorwindowwidth']); + $this->content->text .= html_writer::empty_tag('input', ['type' => 'number', 'id' => 'themeselectorwindowwidth', 'name' => 'themeselectorwindowwidth', 'aria-labelledby' => 'themeselectorwindowlabel', - 'min' => '1', 'max' => '9999')); + 'min' => '1', 'max' => '9999', ]); $this->content->text .= html_writer::tag('span', get_string('by', 'block_theme_selector')); - $this->content->text .= html_writer::empty_tag('input', array('type' => 'number', + $this->content->text .= html_writer::empty_tag('input', ['type' => 'number', 'id' => 'themeselectorwindowheight', 'name' => 'themeselectorwindowheight', 'aria-labelledby' => 'themeselectorwindowlabel', - 'min' => '1', 'max' => '9999')); + 'min' => '1', 'max' => '9999', ]); $this->content->text .= html_writer::tag('button', get_string('createwindow', 'block_theme_selector'), - array('id' => 'themeselectorcreatewindow')); + ['id' => 'themeselectorcreatewindow']); $this->content->text .= html_writer::end_tag('form'); } } else if ($CFG->block_theme_selector_urlswitch == 1) { diff --git a/db/access.php b/db/access.php index bf833e9..3eb7671 100644 --- a/db/access.php +++ b/db/access.php @@ -27,28 +27,28 @@ defined('MOODLE_INTERNAL') || die(); -$capabilities = array( +$capabilities = [ - 'block/theme_selector:myaddinstance' => array( + 'block/theme_selector:myaddinstance' => [ 'captype' => 'write', 'contextlevel' => CONTEXT_SYSTEM, - 'archetypes' => array( - 'user' => CAP_ALLOW - ), + 'archetypes' => [ + 'user' => CAP_ALLOW, + ], - 'clonepermissionsfrom' => 'moodle/my:manageblocks' - ), + 'clonepermissionsfrom' => 'moodle/my:manageblocks', + ], - 'block/theme_selector:addinstance' => array( + 'block/theme_selector:addinstance' => [ 'riskbitmask' => RISK_SPAM | RISK_XSS, 'captype' => 'write', 'contextlevel' => CONTEXT_BLOCK, - 'archetypes' => array( + 'archetypes' => [ 'editingteacher' => CAP_ALLOW, - 'manager' => CAP_ALLOW - ), + 'manager' => CAP_ALLOW, + ], - 'clonepermissionsfrom' => 'moodle/site:manageblocks' - ), -); + 'clonepermissionsfrom' => 'moodle/site:manageblocks', + ], +]; diff --git a/db/upgrade.php b/db/upgrade.php index cd91464..2b2be65 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -25,8 +25,6 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -defined('MOODLE_INTERNAL') || die; - /** * Upgrade code for the theme selector block. * diff --git a/settings.php b/settings.php index 9114b85..5289d2e 100644 --- a/settings.php +++ b/settings.php @@ -33,10 +33,10 @@ $title = get_string('urlswitch', 'block_theme_selector'); $description = get_string('urlswitch_desc', 'block_theme_selector'); $default = 2; - $choices = array( + $choices = [ 1 => new lang_string('no'), // No. - 2 => new lang_string('yes') // Yes. - ); + 2 => new lang_string('yes'), // Yes. + ]; $settings->add(new admin_setting_configselect($name, $title, $description, $default, $choices)); /* Inner window information - 1 = no, 2 = yes. */ @@ -44,14 +44,14 @@ $title = get_string('windowinformation', 'block_theme_selector'); $description = get_string('windowinformation_desc', 'block_theme_selector'); $default = 1; - $choices = array( + $choices = [ 1 => new lang_string('no'), // No. - 2 => new lang_string('yes') // Yes. - ); + 2 => new lang_string('yes'), // Yes. + ]; $settings->add(new admin_setting_configselect($name, $title, $description, $default, $choices)); $themes = core_component::get_plugin_list('theme'); - $options = array(); + $options = []; foreach ($themes as $theme => $themedir) { $options[$theme] = ucfirst(get_string('pluginname', 'theme_' . $theme)); } diff --git a/version.php b/version.php index d685c56..cc3c4e3 100644 --- a/version.php +++ b/version.php @@ -29,6 +29,6 @@ $plugin->release = '2.9.1.5'; $plugin->version = 2015082107; -$plugin->requires = 2015051100.00; // 2.9 (Build: 20150511). +$plugin->requires = 2015051100.00; // M2.9 (Build: 20150511). $plugin->maturity = MATURITY_STABLE; $plugin->component = 'block_theme_selector';