diff --git a/action.php b/action.php index e9f13ab..75befde 100644 --- a/action.php +++ b/action.php @@ -154,7 +154,7 @@ 'request' => $massactionrequest, 'instance_id' => $instanceid, 'return_url' => $returnurl, - 'sourcecourseid' => $context->instanceid + 'sourcecourseid' => $context->instanceid, ]; $courseselectform = new course_select_form(null, $options); diff --git a/block_massaction.php b/block_massaction.php index 163e9dd..1c478ba 100644 --- a/block_massaction.php +++ b/block_massaction.php @@ -177,15 +177,16 @@ public function get_content(): stdClass { } $this->content->text = $OUTPUT->render_from_template('block_massaction/block_massaction', - ['actions' => $actions, 'formaction' => $CFG->wwwroot . '/blocks/massaction/action.php', - 'instanceid' => $this->instance->id, 'requesturi' => $_SERVER['REQUEST_URI'], - 'helpicon' => $OUTPUT->help_icon('usage', 'block_massaction'), - 'show_moveto_select' => (has_capability('moodle/course:manageactivities', $context) - && has_capability('block/massaction:movetosection', $context)), - 'show_duplicateto_select' => (has_capability('moodle/backup:backuptargetimport', $context) && - has_capability('moodle/restore:restoretargetimport', $context) - && has_capability('block/massaction:movetosection', $context)), - 'sectionselecthelpicon' => $OUTPUT->help_icon('sectionselect', 'block_massaction') + ['actions' => $actions, + 'formaction' => $CFG->wwwroot . '/blocks/massaction/action.php', + 'instanceid' => $this->instance->id, 'requesturi' => $_SERVER['REQUEST_URI'], + 'helpicon' => $OUTPUT->help_icon('usage', 'block_massaction'), + 'show_moveto_select' => (has_capability('moodle/course:manageactivities', $context) && + has_capability('block/massaction:movetosection', $context)), + 'show_duplicateto_select' => (has_capability('moodle/backup:backuptargetimport', $context) && + has_capability('moodle/restore:restoretargetimport', $context) && + has_capability('block/massaction:movetosection', $context)), + 'sectionselecthelpicon' => $OUTPUT->help_icon('sectionselect', 'block_massaction'), ]); } return $this->content; diff --git a/classes/actions.php b/classes/actions.php index 31e7e55..821b71f 100644 --- a/classes/actions.php +++ b/classes/actions.php @@ -185,7 +185,7 @@ public static function duplicate(array $modules, $sectionnumber = false): void { $section = $modinfo->get_section_info($duplicatedmod->sectionnum); } else { // Duplicate to a specific section. // Verify target. - if (!$section = $DB->get_record('course_sections', array('course' => $courseid, 'section' => $sectionnumber))) { + if (!$section = $DB->get_record('course_sections', ['course' => $courseid, 'section' => $sectionnumber])) { throw new moodle_exception('sectionnotexist', 'block_massaction'); } } @@ -261,7 +261,7 @@ public static function duplicate_to_course(array $modules, int $targetcourseid, // Update course format setting to prevent new orphaned sections. if (isset($targetformatopt['numsections'])) { - update_course((object)array('id' => $targetcourseid, 'numsections' => $targetformatopt['numsections'] + 1)); + update_course((object)['id' => $targetcourseid, 'numsections' => $targetformatopt['numsections'] + 1]); } // Make sure new sectionnum is set accurately. @@ -286,7 +286,7 @@ public static function duplicate_to_course(array $modules, int $targetcourseid, // Update course format setting to prevent orphaned sections. $targetformatopt = $targetformat->get_format_options(); if (isset($targetformatopt['numsections']) && $targetformatopt['numsections'] < $srcmaxsectionnum) { - update_course((object)array('id' => $targetcourseid, 'numsections' => $srcmaxsectionnum)); + update_course((object)['id' => $targetcourseid, 'numsections' => $srcmaxsectionnum]); } } @@ -415,7 +415,7 @@ public static function print_deletion_confirmation(array $modules, string $massa 'instance_id' => $instanceid, 'return_url' => $returnurl, 'request' => $massactionrequest, - 'del_confirm' => 1 + 'del_confirm' => 1, ]; $optionsoncancel = ['id' => $cm->course]; @@ -461,7 +461,7 @@ public static function perform_deletion(array $modules): void { new moodle_exception('invalidcoursemodule'); } - if (!$DB->get_record('course', array('id' => $cm->course))) { + if (!$DB->get_record('course', ['id' => $cm->course])) { throw new moodle_exception('invalidcourseid'); } @@ -575,7 +575,7 @@ public static function perform_moveto(array $modules, int $target): void { } // Verify target. - if (!$section = $DB->get_record('course_sections', array('course' => $cm->course, 'section' => $target))) { + if (!$section = $DB->get_record('course_sections', ['course' => $cm->course, 'section' => $target])) { throw new moodle_exception('sectionnotexist', 'block_massaction'); } diff --git a/db/access.php b/db/access.php index d72c6b7..8c03b44 100644 --- a/db/access.php +++ b/db/access.php @@ -41,9 +41,9 @@ 'contextlevel' => CONTEXT_BLOCK, 'archetypes' => [ 'editingteacher' => CAP_ALLOW, - 'manager' => CAP_ALLOW + 'manager' => CAP_ALLOW, ], - 'clonepermissionsfrom' => 'moodle/site:manageblocks' + 'clonepermissionsfrom' => 'moodle/site:manageblocks', ], 'block/massaction:activityshowhide' => [ @@ -54,7 +54,7 @@ 'editingteacher' => CAP_ALLOW, 'manager' => CAP_ALLOW, ], - 'clonepermissionsfrom' => 'moodle/course:manageactivities' + 'clonepermissionsfrom' => 'moodle/course:manageactivities', ], 'block/massaction:duplicate' => [ @@ -65,7 +65,7 @@ 'editingteacher' => CAP_ALLOW, 'manager' => CAP_ALLOW, ], - 'clonepermissionsfrom' => 'moodle/course:manageactivities' + 'clonepermissionsfrom' => 'moodle/course:manageactivities', ], 'block/massaction:duplicatetocourse' => [ @@ -76,7 +76,7 @@ 'editingteacher' => CAP_ALLOW, 'manager' => CAP_ALLOW, ], - 'clonepermissionsfrom' => 'moodle/course:manageactivities' + 'clonepermissionsfrom' => 'moodle/course:manageactivities', ], 'block/massaction:delete' => [ @@ -87,7 +87,7 @@ 'editingteacher' => CAP_ALLOW, 'manager' => CAP_ALLOW, ], - 'clonepermissionsfrom' => 'moodle/course:manageactivities' + 'clonepermissionsfrom' => 'moodle/course:manageactivities', ], 'block/massaction:indent' => [ @@ -98,7 +98,7 @@ 'editingteacher' => CAP_ALLOW, 'manager' => CAP_ALLOW, ], - 'clonepermissionsfrom' => 'moodle/course:manageactivities' + 'clonepermissionsfrom' => 'moodle/course:manageactivities', ], 'block/massaction:descriptionshowhide' => [ @@ -109,7 +109,7 @@ 'editingteacher' => CAP_ALLOW, 'manager' => CAP_ALLOW, ], - 'clonepermissionsfrom' => 'moodle/course:manageactivities' + 'clonepermissionsfrom' => 'moodle/course:manageactivities', ], 'block/massaction:sendcontentchangednotifications' => [ @@ -120,7 +120,7 @@ 'editingteacher' => CAP_ALLOW, 'manager' => CAP_ALLOW, ], - 'clonepermissionsfrom' => 'moodle/course:manageactivities' + 'clonepermissionsfrom' => 'moodle/course:manageactivities', ], 'block/massaction:movetosection' => [ @@ -131,6 +131,6 @@ 'editingteacher' => CAP_ALLOW, 'manager' => CAP_ALLOW, ], - 'clonepermissionsfrom' => 'moodle/course:manageactivities' + 'clonepermissionsfrom' => 'moodle/course:manageactivities', ], ]; diff --git a/templates/block_massaction.mustache b/templates/block_massaction.mustache index 8d55148..1ee0d35 100644 --- a/templates/block_massaction.mustache +++ b/templates/block_massaction.mustache @@ -47,7 +47,7 @@ -
+
{{> block_massaction/section_select}} @@ -58,7 +58,7 @@


+

{{#str}} withselected, block_massaction {{/str}}: {{/actions.0.action}} diff --git a/tests/massaction_test.php b/tests/massaction_test.php index dfc6726..f03b9d3 100644 --- a/tests/massaction_test.php +++ b/tests/massaction_test.php @@ -64,7 +64,7 @@ public function setUp(): void { // Generate two modules of each type for each of the 5 sections, so we have 6 modules per section. $modulerecord = [ 'course' => $this->course->id, - 'showdescription' => 0 + 'showdescription' => 0, ]; for ($i = 0; $i < 10; $i++) { $generator->create_module('assign', $modulerecord, ['section' => floor($i / 2)]);