diff --git a/mod/forum/report/summary/classes/summary_table.php b/mod/forum/report/summary/classes/summary_table.php
index 551cb8e1d93..d47f6478a0e 100644
--- a/mod/forum/report/summary/classes/summary_table.php
+++ b/mod/forum/report/summary/classes/summary_table.php
@@ -89,9 +89,10 @@ class summary_table extends table_sql {
*
* @param int $courseid The ID of the course the forum(s) exist within.
* @param array $filters Report filters in the format 'type' => [values].
+ * @param bool $bulkoperations Is the user allowed to perform bulk operations?
*/
- public function __construct(int $courseid, array $filters) {
- global $USER;
+ public function __construct(int $courseid, array $filters, bool $bulkoperations) {
+ global $USER, $OUTPUT;
$forumid = $filters['forums'][0];
@@ -107,7 +108,21 @@ class summary_table extends table_sql {
$this->courseid = intval($courseid);
- $columnheaders = [
+ $columnheaders = [];
+
+ if ($bulkoperations) {
+ $mastercheckbox = new \core\output\checkbox_toggleall('summaryreport-table', true, [
+ 'id' => 'select-all-users',
+ 'name' => 'select-all-users',
+ 'label' => get_string('selectall'),
+ 'labelclasses' => 'sr-only',
+ 'classes' => 'm-1',
+ 'checked' => false
+ ]);
+ $columnheaders['select'] = $OUTPUT->render($mastercheckbox);
+ }
+
+ $columnheaders += [
'fullname' => get_string('fullnameuser'),
'postcount' => get_string('postcount', 'forumreport_summary'),
'replycount' => get_string('replycount', 'forumreport_summary'),
@@ -153,6 +168,27 @@ class summary_table extends table_sql {
return $filternames[$filtertype];
}
+ /**
+ * Generate the select column.
+ *
+ * @param \stdClass $data
+ * @return string
+ */
+ public function col_select($data) {
+ global $OUTPUT;
+
+ $checkbox = new \core\output\checkbox_toggleall('summaryreport-table', false, [
+ 'classes' => 'usercheckbox m-1',
+ 'id' => 'user' . $data->userid,
+ 'name' => 'user' . $data->userid,
+ 'checked' => false,
+ 'label' => get_string('selectitem', 'moodle', fullname($data)),
+ 'labelclasses' => 'accesshide',
+ ]);
+
+ return $OUTPUT->render($checkbox);
+ }
+
/**
* Generate the fullname column.
*
diff --git a/mod/forum/report/summary/index.php b/mod/forum/report/summary/index.php
index dc8daa29690..b62102cf85d 100644
--- a/mod/forum/report/summary/index.php
+++ b/mod/forum/report/summary/index.php
@@ -84,8 +84,15 @@ $renderer = $PAGE->get_renderer('forumreport_summary');
echo $renderer->render_filters_form($cm, $url, $filters);
// Prepare and display the report.
-$table = new \forumreport_summary\summary_table($courseid, $filters);
+$bulkoperations = !empty($CFG->messaging) && has_capability('moodle/course:bulkmessaging', $context);
+
+$table = new \forumreport_summary\summary_table($courseid, $filters, $bulkoperations);
$table->baseurl = $url;
+
echo $renderer->render_summary_table($table, $perpage);
+if ($bulkoperations) {
+ echo $renderer->render_bulk_action_menu();
+}
+
echo $OUTPUT->footer();
diff --git a/mod/forum/report/summary/renderer.php b/mod/forum/report/summary/renderer.php
index e07b759044f..0ee81e83625 100644
--- a/mod/forum/report/summary/renderer.php
+++ b/mod/forum/report/summary/renderer.php
@@ -69,4 +69,39 @@ class forumreport_summary_renderer extends plugin_renderer_base {
return $this->render_from_template('forumreport_summary/report', ['tablehtml' => $tablehtml, 'placeholdertext' => false]);
}
+
+ /**
+ * Render the bulk action menu for the forum summary report.
+ * @return string
+ */
+ public function render_bulk_action_menu(): string {
+ $data = new stdClass();
+ $data->id = 'formactionid';
+ $data->attributes = [
+ [
+ 'name' => 'data-action',
+ 'value' => 'toggle'
+ ],
+ [
+ 'name' => 'data-togglegroup',
+ 'value' => 'summaryreport-table'
+ ],
+ [
+ 'name' => 'data-toggle',
+ 'value' => 'action'
+ ],
+ [
+ 'name' => 'disabled',
+ 'value' => true
+ ]
+ ];
+ $data->actions = [
+ [
+ 'value' => '#messageselect',
+ 'name' => get_string('messageselectadd')
+ ]
+ ];
+
+ return $this->render_from_template('forumreport_summary/bulk_action_menu', $data);
+ }
}
diff --git a/mod/forum/report/summary/templates/bulk_action_menu.mustache b/mod/forum/report/summary/templates/bulk_action_menu.mustache
new file mode 100644
index 00000000000..aa36045075d
--- /dev/null
+++ b/mod/forum/report/summary/templates/bulk_action_menu.mustache
@@ -0,0 +1,31 @@
+