Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Privacy class for requesting user data for the favourites subsystem.

Copyright: 2018 Jake Dallimore <jrhdallimore@gmail.com>
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 270 lines (11 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: provider  - X-Ref

Privacy class for requesting user data.

get_metadata(collection $collection)   X-Ref
Returns metadata about this system.

param: collection $collection The initialised collection to add items to.
return: collection     A listing of user data stored through this system.

add_contexts_for_userid(\core_privacy\local\request\contextlist $contextlist, int $userid,string $component, string $itemtype = null)   X-Ref
Provide a list of contexts which have favourites for the user, in the respective area (component/itemtype combination).

This method is to be called by consumers of the favourites subsystem (plugins), in their get_contexts_for_userid() method,
to add the contexts for items which may have been favourited, but would normally not be reported as having user data by the
plugin responsible for them.

Consider an example: Favourite courses.
Favourite courses will be handled by the core_course subsystem and courses can be favourited at site context.

Now normally, the course provider method get_contexts_for_userid() would report the context of any courses the user is in.
Then, we'd export data for those contexts. This won't include courses the user has favourited, but is not a member of.

To report the full list, the course provider needs to be made aware of the contexts of any courses the user may have marked
as favourites. Course will need to ask th favourites subsystem for this - a call to add_contexts_for_userid($userid).

Once called, if a course has been marked as a favourite, at site context, then we'd return the site context. During export,
the consumer (course), just looks at all contexts and decides whether to export favourite courses for each one.

param: \core_privacy\local\request\contextlist $contextlist
param: int $userid The id of the user in scope.
param: string $component the frankenstyle component name.
param: string $itemtype the type of the favourited items.

add_userids_for_context(\core_privacy\local\request\userlist $userlist,string $itemtype = null)   X-Ref
Add users to a userlist who have favourites within the specified context.

param: \core_privacy\local\request\userlist $userlist The userlist to add the users to.
param: string $itemtype the type of the favourited items.
return: void

get_favourites_info_for_user(int $userid, \context $context,string $component, string $itemtype, int $itemid)   X-Ref
Get favourites data for the specified user in the specified component, item type and item ID.

param: int $userid The id of the user in scope.
param: \context $context The context to which data is scoped.
param: string $component The favourite's component name.
param: string $itemtype The favourite's item type.
param: int $itemid The favourite's item ID.
return: array|null

delete_favourites_for_all_users(\context $context, string $component, string $itemtype,int $itemid = 0)   X-Ref
Delete all favourites for all users in the specified contexts, and component area.

param: \context $context The context to which deletion is scoped.
param: string $component The favourite's component name.
param: string $itemtype The favourite's itemtype.
param: int $itemid Optional itemid associated with component.

delete_favourites_for_userlist(\core_privacy\local\request\approved_userlist $userlist,string $itemtype, int $itemid = 0)   X-Ref
Delete all favourites for the specified users in the specified context, component area and item type.

param: \core_privacy\local\request\approved_userlist $userlist The approved contexts and user information
param: string $itemtype The favourite's itemtype.
param: int $itemid Optional itemid associated with component.

delete_favourites_for_user(approved_contextlist $contextlist, string $component, string $itemtype,int $itemid = 0)   X-Ref
Delete all favourites for the specified user, in the specified contexts.

param: approved_contextlist $contextlist The approved contexts and user information to delete information for.
param: string $component The favourite's component name.
param: string $itemtype The favourite's itemtype.
param: int $itemid Optional itemid associated with component.