Moodle PHP Documentation 4.4
Moodle 4.4.1 (Build: 20240610) (db07c09afc5)
core_favourites\privacy\provider Class Reference

Privacy class for requesting user data. More...

Inheritance diagram for core_favourites\privacy\provider:
core_privacy\local\metadata\provider core_privacy\local\request\subsystem\plugin_provider core_privacy\local\request\shared_userlist_provider core_privacy\local\request\shared_data_provider core_privacy\local\request\userlist_provider core_privacy\local\request\data_provider

Static Public Member Functions

static add_contexts_for_userid (\core_privacy\local\request\contextlist $contextlist, int $userid, string $component, string $itemtype=null)
 Provide a list of contexts which have favourites for the user, in the respective area (component/itemtype combination).
 
static add_userids_for_context (\core_privacy\local\request\userlist $userlist, string $itemtype=null)
 Add users to a userlist who have favourites within the specified context.
 
static delete_favourites_for_all_users (\context $context, string $component, string $itemtype, int $itemid=0)
 Delete all favourites for all users in the specified contexts, and component area.
 
static delete_favourites_for_user (approved_contextlist $contextlist, string $component, string $itemtype, int $itemid=0)
 Delete all favourites for the specified user, in the specified contexts.
 
static delete_favourites_for_userlist (\core_privacy\local\request\approved_userlist $userlist, string $itemtype, int $itemid=0)
 Delete all favourites for the specified users in the specified context, component area and item type.
 
static get_favourites_info_for_user (int $userid, context $context, string $component, string $itemtype, int $itemid)
 Get favourites data for the specified user in the specified component, item type and item ID.
 
static get_metadata (collection $collection)
 Returns metadata about this system.
 

Detailed Description

Privacy class for requesting user data.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Member Function Documentation

◆ add_contexts_for_userid()

static core_favourites\privacy\provider::add_contexts_for_userid ( \core_privacy\local\request\contextlist $contextlist,
int $userid,
string $component,
string $itemtype = null )
static

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.

Parameters
core_privacy\local\request\contextlist$contextlist
int$useridThe id of the user in scope.
string$componentthe frankenstyle component name.
string$itemtypethe type of the favourited items.

◆ add_userids_for_context()

static core_favourites\privacy\provider::add_userids_for_context ( \core_privacy\local\request\userlist $userlist,
string $itemtype = null )
static

Add users to a userlist who have favourites within the specified context.

Parameters
core_privacy\local\request\userlist$userlistThe userlist to add the users to.
string$itemtypethe type of the favourited items.
Return values
void

◆ delete_favourites_for_all_users()

static core_favourites\privacy\provider::delete_favourites_for_all_users ( \context $context,
string $component,
string $itemtype,
int $itemid = 0 )
static

Delete all favourites for all users in the specified contexts, and component area.

Parameters
context$contextThe context to which deletion is scoped.
string$componentThe favourite's component name.
string$itemtypeThe favourite's itemtype.
int$itemidOptional itemid associated with component.
Exceptions
dml_exceptionif any errors are encountered during deletion.

◆ delete_favourites_for_user()

static core_favourites\privacy\provider::delete_favourites_for_user ( approved_contextlist $contextlist,
string $component,
string $itemtype,
int $itemid = 0 )
static

Delete all favourites for the specified user, in the specified contexts.

Parameters
approved_contextlist$contextlistThe approved contexts and user information to delete information for.
string$componentThe favourite's component name.
string$itemtypeThe favourite's itemtype.
int$itemidOptional itemid associated with component.
Exceptions
coding_exception
dml_exception

◆ delete_favourites_for_userlist()

static core_favourites\privacy\provider::delete_favourites_for_userlist ( \core_privacy\local\request\approved_userlist $userlist,
string $itemtype,
int $itemid = 0 )
static

Delete all favourites for the specified users in the specified context, component area and item type.

Parameters
core_privacy\local\request\approved_userlist$userlistThe approved contexts and user information to delete information for.
string$itemtypeThe favourite's itemtype.
int$itemidOptional itemid associated with component.
Exceptions
dml_exceptionif any errors are encountered during deletion.

◆ get_favourites_info_for_user()

static core_favourites\privacy\provider::get_favourites_info_for_user ( int $userid,
context $context,
string $component,
string $itemtype,
int $itemid )
static

Get favourites data for the specified user in the specified component, item type and item ID.

Parameters
int$useridThe id of the user in scope.
context$contextThe context to which data is scoped.
string$componentThe favourite's component name.
string$itemtypeThe favourite's item type.
int$itemidThe favourite's item ID.
Return values
array|null

◆ get_metadata()

static core_favourites\privacy\provider::get_metadata ( collection $collection)
static

Returns metadata about this system.

Parameters
collection$collectionThe initialised collection to add items to.
Return values
collectionA listing of user data stored through this system.

Implements core_privacy\local\metadata\provider.


The documentation for this class was generated from the following file: