Skip to content

Instantly share code, notes, and snippets.

@Dagefoerde
Created May 17, 2018 13:44
Show Gist options
  • Select an option

  • Save Dagefoerde/7d486139376ed6f9eb704c5e09ed0bde to your computer and use it in GitHub Desktop.

Select an option

Save Dagefoerde/7d486139376ed6f9eb704c5e09ed0bde to your computer and use it in GitHub Desktop.
Reduces the plugin registry report to those plugins that do not implement the Privacy API yet (Screenshot: https://pasteboard.co/HlBmyul.png)
diff --git a/classes/metadata_registry.php b/classes/metadata_registry.php
index 6282cc4..90164e2 100644
--- a/classes/metadata_registry.php
+++ b/classes/metadata_registry.php
@@ -38,7 +38,7 @@ class metadata_registry {
*
* @return array An array with all of the plugin types / plugins and the user data they store.
*/
- public function get_registry_metadata() {
+ public function get_registry_metadata($onlynoncompliant = false) {
$manager = new \core_privacy\manager();
$manager->set_observer(new \tool_dataprivacy\manager_observer());
@@ -77,6 +77,13 @@ class metadata_registry {
}
return $internaldata;
}, $leaves['plugins']);
+
+ if ($onlynoncompliant) {
+ $plugins = array_values(array_filter($plugins, function ($plugin) {
+ return !$plugin['compliant'];
+ }));
+ }
+
$fullyrichtree[$branch]['plugin_type_raw'] = $plugintype;
// We're done using the plugin type. Convert it to a readable string.
$fullyrichtree[$branch]['plugin_type'] = $pluginman->plugintype_name($plugintype);
diff --git a/pluginregistry.php b/pluginregistry.php
index 060bd81..934d368 100644
--- a/pluginregistry.php
+++ b/pluginregistry.php
@@ -27,6 +27,7 @@ require_once($CFG->dirroot . '/' . $CFG->admin . '/tool/dataprivacy/lib.php');
$contextlevel = optional_param('contextlevel', CONTEXT_SYSTEM, PARAM_INT);
$contextid = optional_param('contextid', 0, PARAM_INT);
+$onlynoncompliant = optional_param('onlynoncompliant', 0, PARAM_BOOL);
$url = new moodle_url('/' . $CFG->admin . '/tool/dataprivacy/pluginregistry.php');
$title = get_string('pluginregistry', 'tool_dataprivacy');
@@ -38,7 +39,7 @@ echo $output->header();
// Get data!
$metadatatool = new \tool_dataprivacy\metadata_registry();
-$metadata = $metadatatool->get_registry_metadata();
+$metadata = $metadatatool->get_registry_metadata($onlynoncompliant === 1);
$dataregistry = new tool_dataprivacy\output\data_registry_compliance_page($metadata);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment