Skip to content

Commit

Permalink
Release 7.3.1 (Moodle 4.4+)
Browse files Browse the repository at this point in the history
  • Loading branch information
Syxton authored May 7, 2024
1 parent 70b0b7e commit 387c144
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 23 deletions.
6 changes: 3 additions & 3 deletions block_massaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '';
Expand Down
8 changes: 4 additions & 4 deletions classes/actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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) {
Expand Down Expand Up @@ -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);
}

Expand Down
4 changes: 2 additions & 2 deletions classes/form/section_select_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand All @@ -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']);
Expand Down
20 changes: 10 additions & 10 deletions classes/hook/filter_sections_different_course.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand All @@ -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;
}

/**
Expand All @@ -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;
}
}
2 changes: 0 additions & 2 deletions db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down
4 changes: 2 additions & 2 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';

0 comments on commit 387c144

Please sign in to comment.