diff --git a/block_massaction.php b/block_massaction.php index 405f7bf..80b3bd1 100644 --- a/block_massaction.php +++ b/block_massaction.php @@ -114,13 +114,13 @@ public function get_content(): stdClass { // Check for double instances. This usually should not be an issue, but in rare cases users manage to add // two blocks to the site. - $massactionblockscount = 0; + $instancecounter = 0; foreach ($this->page->blocks->get_regions() as $region) { foreach ($this->page->blocks->get_blocks_for_region($region) as $block) { if ($block instanceof block_massaction) { - $massactionblockscount++; + $instancecounter++; } - if ($massactionblockscount > 1) { + if ($instancecounter > 1) { $this->content = new stdClass(); $this->content->text = get_string('multipleinstances', 'block_massaction'); $this->content->footer = ''; diff --git a/classes/actions.php b/classes/actions.php index 0d744ae..8b29536 100644 --- a/classes/actions.php +++ b/classes/actions.php @@ -251,7 +251,7 @@ public static function duplicate_to_course(array $modules, int $targetcourseid, \core\di::get(\core\hook\manager::class)->dispatch($filtersectionshook); $filteredsections = $filtersectionshook->get_sectionnums(); - if ($targetsectionnum == -1 && !$filtersectionshook->is_keeporiginalsectionallowed()) { + if ($targetsectionnum == -1 && !$filtersectionshook->is_originsectionkept()) { // The course modules should be in the same section number as in the original course. However, the hook listener(s) // disabled this option, so we cancel the operation. // This is only a security measure and should not happen unless someone manipulates the UI. @@ -265,7 +265,7 @@ public static function duplicate_to_course(array $modules, int $targetcourseid, } $canaddsection = has_capability('moodle/course:update', context_course::instance($targetcourseid)) - && $filtersectionshook->is_createnewsectionallowed(); + && $filtersectionshook->is_makesectionallowed(); // If a new section (that means that $sectionnum of the user is higher than $targetsectionnum), we create one. if ($sectionnum > $targetsectionnum) { @@ -321,12 +321,12 @@ public static function duplicate_to_course(array $modules, int $targetcourseid, $errors = []; $filtersectionshook = new filter_sections_same_course($sourcecourseid, array_keys($sourcemodinfo->get_section_info_all())); \core\di::get(\core\hook\manager::class)->dispatch($filtersectionshook); - $sourcefilteredsections = $filtersectionshook->get_sectionnums(); + $srcfilteredsections = $filtersectionshook->get_sectionnums(); foreach ($idsincourseorder as $cmid) { $sourcecm = $sourcemodinfo->get_cm($cmid); // Not duplicated if the section is restricted. - if (!in_array($sourcecm->sectionnum, $sourcefilteredsections)) { + if (!in_array($sourcecm->sectionnum, $srcfilteredsections)) { throw new moodle_exception('sectionrestricted', 'block_massaction', '', $sourcecm->sectionnum); } diff --git a/classes/form/section_select_form.php b/classes/form/section_select_form.php index 0e2dc09..7364120 100644 --- a/classes/form/section_select_form.php +++ b/classes/form/section_select_form.php @@ -106,7 +106,7 @@ public function definition() { // Check for permissions. $canaddsection = has_capability('moodle/course:update', \context_course::instance($targetcourseid)) - && $filtersectionshook->is_createnewsectionallowed(); + && $filtersectionshook->is_makesectionallowed(); // Find maximum section that may need to be created. $massactionrequest = $this->_customdata['request']; @@ -118,7 +118,7 @@ public function definition() { $radioarray = []; // If user can add sections in target course or don't need to be able to. - if (($canaddsection || $srcmaxsectionnum <= $targetsectionnum) && $filtersectionshook->is_keeporiginalsectionallowed()) { + if (($canaddsection || $srcmaxsectionnum <= $targetsectionnum) && $filtersectionshook->is_originsectionkept()) { // We add the default value: Restore each course module to the section number it has in the source course. $radioarray[] = $mform->createElement('radio', 'targetsectionnum', '', get_string('keepsectionnum', 'block_massaction'), -1, ['class' => 'mt-2']); diff --git a/classes/hook/filter_sections_different_course.php b/classes/hook/filter_sections_different_course.php index 984e4e5..614c7d8 100644 --- a/classes/hook/filter_sections_different_course.php +++ b/classes/hook/filter_sections_different_course.php @@ -34,16 +34,16 @@ class filter_sections_different_course { use filter_sections_handler; /** @var bool Determines if the user will be able to keep the original section of a course module when performing some operations. */ - private bool $keeporiginalsectionallowed = true; + private bool $originsectionkept = true; /** @var bool Determines if the user will be able to create a new section when performing some operations. */ - private bool $createnewsectionallowed = true; + private bool $makesectionallowed = true; /** * Disables the option to keep the original section of a course module. */ - public function disable_keeporiginalsection(): void { - $this->keeporiginalsectionallowed = false; + public function disable_originsectionkept(): void { + $this->originsectionkept = false; } /** @@ -53,15 +53,15 @@ public function disable_keeporiginalsection(): void { * * @return bool if the user will be allowed to keep the original section of the course modules */ - public function is_keeporiginalsectionallowed(): bool { - return $this->keeporiginalsectionallowed; + public function is_originsectionkept(): bool { + return $this->originsectionkept; } /** * Disables the option to create a new section. */ - public function disable_createnewsection(): void { - $this->createnewsectionallowed = false; + public function disable_makesection(): void { + $this->makesectionallowed = false; } /** @@ -71,7 +71,7 @@ public function disable_createnewsection(): void { * * @return bool if the user will be allowed to create a new section */ - public function is_createnewsectionallowed(): bool { - return $this->createnewsectionallowed; + public function is_makesectionallowed(): bool { + return $this->makesectionallowed; } } diff --git a/db/upgrade.php b/db/upgrade.php index 1421eb3..0298aa4 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -56,7 +56,6 @@ function xmldb_block_massaction_upgrade($oldversion, $block): bool { * @throws dml_exception */ function block_massaction_add_supported_format(string $addformat): void { - global $DB; // Get current settings to update. $selectedformats = get_config('block_massaction', 'applicablecourseformats'); @@ -90,7 +89,6 @@ function block_massaction_add_supported_format(string $addformat): void { * @throws dml_exception */ function block_massaction_remove_supported_format(string $removeformat): void { - global $DB; // Get current settings to update. $selectedformats = get_config('block_massaction', 'applicablecourseformats'); diff --git a/version.php b/version.php index 82e787c..3ef0dd1 100644 --- a/version.php +++ b/version.php @@ -24,8 +24,8 @@ defined('MOODLE_INTERNAL') || die; -$plugin->version = 2024011602; +$plugin->version = 2024050700; $plugin->requires = 2023100900; $plugin->component = 'block_massaction'; -$plugin->maturity = MATURITY_ALPHA; +$plugin->maturity = MATURITY_STABLE; $plugin->release = 'v7.3.1';