diff --git a/privacy/classes/local/request/context_aware_provider.php b/privacy/classes/local/request/context_aware_provider.php new file mode 100644 index 00000000000..bc5a4b33708 --- /dev/null +++ b/privacy/classes/local/request/context_aware_provider.php @@ -0,0 +1,45 @@ +. + +/** + * This file contains the \core_privacy\local\request\plugin\provider interface to describe + * a class which provides data in some form for a plugin. + * + * Plugins should implement this if they need access to all approved contexts. + * + * @package core_privacy + * @copyright 2018 Adrian Greeve + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +namespace core_privacy\local\request; + +defined('MOODLE_INTERNAL') || die(); + +/** + * The provider interface for plugins which need access to all approved contexts to fill in user data. + * + * @copyright 2018 Adrian Greeve + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +interface context_aware_provider extends \core_privacy\local\request\core_data_provider { + + /** + * Export context information based on the whole approved context list collection. + * + * @param \core_privacy\local\request\contextlist_collection $contextcollection The collection of approved context lists. + */ + public static function export_complete_context_data(\core_privacy\local\request\contextlist_collection $contextcollection); +} diff --git a/privacy/classes/manager.php b/privacy/classes/manager.php index 922930adabd..14f20c7fda3 100644 --- a/privacy/classes/manager.php +++ b/privacy/classes/manager.php @@ -216,7 +216,7 @@ class manager { // told to export. $this->get_provider_classname($component)::export_user_data($approvedcontextlist); } - } else { + } else if (!$this->component_implements($component, \core_privacy\local\request\context_aware_provider::class)) { // This plugin does not know that it has data - export the shared data it doesn't know about. local\request\helper::export_data_for_null_provider($approvedcontextlist); } @@ -230,6 +230,14 @@ class manager { } } + // Check each component for context aware providers. + foreach ($this->get_component_list() as $component) { + // Core user preference providers. + if ($this->component_implements($component, \core_privacy\local\request\context_aware_provider::class)) { + $this->get_provider_classname($component)::export_complete_context_data($contextlistcollection); + } + } + return local\request\writer::with_context(\context_system::instance())->finalise_content(); }