diff --git a/form.php b/form.php index aa6a258..481b347 100644 --- a/form.php +++ b/form.php @@ -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; diff --git a/index.php b/index.php index edef980..5d332aa 100644 --- a/index.php +++ b/index.php @@ -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); } diff --git a/lang/en/report_editdates.php b/lang/en/report_editdates.php index 8970b88..6f56c2b 100644 --- a/lang/en/report_editdates.php +++ b/lang/en/report_editdates.php @@ -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.'; diff --git a/lib.php b/lib.php index f569753..1620475 100644 --- a/lib.php +++ b/lib.php @@ -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'))); +} diff --git a/settings.php b/settings.php index 2a1b517..9588d03 100644 --- a/settings.php +++ b/settings.php @@ -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)); }