Skip to content
Open
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
5 changes: 5 additions & 0 deletions form.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,11 @@ public function definition() {
continue;
}

// Only include activity types enabled in settings.
if (!report_editdates_mod_enabled($cm->modname)) {
continue;
}

// If activity filter is on, then filter module by activity type.
if ($activitytype && ($cm->modname != $activitytype && $activitytype != "all")) {
continue;
Expand Down
5 changes: 5 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@
continue;
}

// Only include activity types enabled in settings.
if (!report_editdates_mod_enabled($cm->modname)) {
continue;
}

$activitiesdisplayed += 1;
$activitytypes[$cm->modname] = get_string('modulename', $cm->modname);
}
Expand Down
2 changes: 2 additions & 0 deletions lang/en/report_editdates.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,5 @@
$string['editrestrictedaccess'] = 'Edit restricted access (opens a new window)';
$string['event:reportviewed'] = 'Edit dates report viewed';
$string['privacy:metadata'] = 'The Dates plugin does not store any personal data.';
$string['enabledmods'] = 'Enabled activity types';
$string['enabledmodsdesc'] = 'Press and hold Ctrl key and select or deselect activity types that should be enabled in the report.';
9 changes: 9 additions & 0 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -462,3 +462,12 @@ function report_editdates_cm_has_dates($cm, $course) {

return (bool) report_editdates_mod_date_extractor::make($cm->modname, $course);
}

/**
* Checks if the given activity type is enabled in the plugin's admin settings.
* @param string $modname Activity type to check.
* @return bool Returns true if activity type is enabled or false otherwise.
*/
function report_editdates_mod_enabled(string $modname) {
return in_array($modname, explode(',', get_config('report_editdates', 'enabledmods')));
}
8 changes: 8 additions & 0 deletions settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,12 @@
get_string('timelinemaxdesc', 'report_editdates'),
3,
$options));

// Add an admin setting to specify which activity types are enabled in the report.
$allmods = get_module_types_names();
$settings->add(new admin_setting_configmultiselect('report_editdates/enabledmods',
get_string('enabledmods', 'report_editdates'),
get_string('enabledmodsdesc', 'report_editdates'),
array_keys($allmods), // All activity types are enabled by default.
$allmods));
}