Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ jobs:
strategy:
fail-fast: false
matrix:
php: ['8.2', '8.3']
moodle-branch: ['main', 'MOODLE_500_STABLE']
php: ['8.3', '8.4']
moodle-branch: ['main', 'MOODLE_501_STABLE', 'MOODLE_500_STABLE']
database: [pgsql, mariadb]

steps:
Expand Down Expand Up @@ -66,10 +66,6 @@ jobs:
if: ${{ always() }}
run: moodle-plugin-ci phplint

- name: PHP Copy/Paste Detector
if: ${{ always() }}
run: moodle-plugin-ci phpcpd

- name: PHP Mess Detector
continue-on-error: true # This step will show errors but will not fail
if: ${{ always() }}
Expand Down
42 changes: 30 additions & 12 deletions action.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,12 @@
$duplicatetask->set_userid($USER->id);
$duplicatetask->set_custom_data(['modules' => $modulerecords]);
manager::queue_adhoc_task($duplicatetask);
redirect($returnurl, get_string('backgroundtaskinformation', 'block_massaction'), null,
notification::NOTIFY_SUCCESS);
redirect(
$returnurl,
get_string('backgroundtaskinformation', 'block_massaction'),
null,
notification::NOTIFY_SUCCESS
);
} else {
block_massaction\actions::duplicate($modulerecords);
}
Expand Down Expand Up @@ -139,8 +143,12 @@
$duplicatetask->set_userid($USER->id);
$duplicatetask->set_custom_data(['modules' => $modulerecords, 'sectionid' => $data->duplicateToTarget]);
manager::queue_adhoc_task($duplicatetask);
redirect($returnurl, get_string('backgroundtaskinformation', 'block_massaction'), null,
notification::NOTIFY_SUCCESS);
redirect(
$returnurl,
get_string('backgroundtaskinformation', 'block_massaction'),
null,
notification::NOTIFY_SUCCESS
);
} else {
block_massaction\actions::duplicate($modulerecords, $data->duplicateToTarget);
}
Expand Down Expand Up @@ -178,7 +186,6 @@
actions::print_course_select_form($courseselectform);
break;
} else if ($data = $sectionselectform->get_data()) {

// We validate the section number and default to 'same section than source course' if it is not a proper section
// number.
$targetsectionnum = property_exists($data, 'targetsectionnum') && is_numeric($data->targetsectionnum)
Expand All @@ -190,15 +197,22 @@
$duplicatetask->set_custom_data(['modules' => $modulerecords, 'sectionnum' => $targetsectionnum,
'courseid' => $targetcourseid]);
manager::queue_adhoc_task($duplicatetask);
redirect($returnurl, get_string('backgroundtaskinformation', 'block_massaction'), null,
notification::NOTIFY_SUCCESS);
redirect(
$returnurl,
get_string('backgroundtaskinformation', 'block_massaction'),
null,
notification::NOTIFY_SUCCESS
);
} else {
block_massaction\actions::duplicate_to_course($modulerecords, $targetcourseid, $targetsectionnum);
}

redirect($returnurl, get_string('actionexecuted', 'block_massaction'), null,
notification::NOTIFY_SUCCESS);

redirect(
$returnurl,
get_string('actionexecuted', 'block_massaction'),
null,
notification::NOTIFY_SUCCESS
);
} else {
$redirect = false;
actions::print_section_select_form($sectionselectform);
Expand All @@ -213,6 +227,10 @@
// Redirect back to the previous page.
// If an error has occurred, the action handler functions already should have thrown an exception to the user, so if we get to
// this point in the code, the demanded action should have been successful.
redirect($returnurl, get_string('actionexecuted', 'block_massaction'), null,
notification::NOTIFY_SUCCESS);
redirect(
$returnurl,
get_string('actionexecuted', 'block_massaction'),
null,
notification::NOTIFY_SUCCESS
);
}
67 changes: 37 additions & 30 deletions block_massaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,17 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Primary block class.
*
* @package block_massaction
* @copyright 2013 University of Minnesota
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

use block_massaction\hook\filter_sections_different_course;
use block_massaction\hook\filter_sections_same_course;

/**
* Configures and displays the block.
*
* @package block_massaction
* @copyright 2013 University of Minnesota
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class block_massaction extends block_base {

/**
* Initialize the plugin. This method is being called by the parent constructor by default.
*/
Expand Down Expand Up @@ -140,30 +132,38 @@ public function get_content(): stdClass {
$context = context_course::instance($COURSE->id);
// Actions to be rendered later on.
$actionicons = [];
if (has_capability('moodle/course:activityvisibility', $context)
&& has_capability('block/massaction:activityshowhide', $blockcontext)) {
if (
has_capability('moodle/course:activityvisibility', $context)
&& has_capability('block/massaction:activityshowhide', $blockcontext)
) {
// As we want to use this symbol for the *operation*, not the state, we switch the icons hide/show.
$actionicons['show'] = 't/hide';
$actionicons['hide'] = 't/show';
if (!empty($CFG->allowstealth)) {
$actionicons['makeavailable'] = 't/block';
}
}
if (has_capability('moodle/backup:backuptargetimport', $context)
&& has_capability('moodle/restore:restoretargetimport', $context)
&& has_capability('block/massaction:duplicate', $blockcontext)) {
if (
has_capability('moodle/backup:backuptargetimport', $context)
&& has_capability('moodle/restore:restoretargetimport', $context)
&& has_capability('block/massaction:duplicate', $blockcontext)
) {
$actionicons['duplicate'] = 't/copy';
}
if (has_capability('moodle/backup:backuptargetimport', $context)
&& has_capability('block/massaction:duplicatetocourse', $blockcontext)) {
if (
has_capability('moodle/backup:backuptargetimport', $context)
&& has_capability('block/massaction:duplicatetocourse', $blockcontext)
) {
$actionicons['duplicatetocourse'] = 't/copy';
}
if (has_capability('moodle/course:manageactivities', $context)) {
if (has_capability('block/massaction:delete', $blockcontext)) {
$actionicons['delete'] = 't/delete';
}
if (course_get_format($COURSE->id)->uses_indentation()
&& has_capability('block/massaction:indent', $blockcontext)) {
if (
course_get_format($COURSE->id)->uses_indentation()
&& has_capability('block/massaction:indent', $blockcontext)
) {
// From Moodle 4.0 on the course format has to declare if it supports indentation or not.
$actionicons['moveright'] = 't/right';
$actionicons['moveleft'] = 't/left';
Expand All @@ -183,19 +183,26 @@ public function get_content(): stdClass {
'actiontext' => get_string('action_' . $action, 'block_massaction')];
}

$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'),
$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'),
'availabletargetsections' => implode(',', $sectionsavailable),
]);
]
);
}
return $this->content;
}
Expand Down
Loading