Moodle APIs
3.8
Moodle 3.8.6 (Build: 20201109)
|
Privacy class for requesting user data. More...
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). More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
static | get_metadata (collection $collection) |
Returns metadata about this system. More... | |
Privacy class for requesting user data.
|
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.
core_privacy\local\request\contextlist | $contextlist | |
int | $userid | The id of the user in scope. |
string | $component | the frankenstyle component name. |
string | $itemtype | the type of the favourited items. |
|
static |
Add users to a userlist who have favourites within the specified context.
core_privacy\local\request\userlist | $userlist | The userlist to add the users to. |
string | $itemtype | the type of the favourited items. |
void |
|
static |
Delete all favourites for all users in the specified contexts, and component area.
context | $context | The context to which deletion is scoped. |
string | $component | The favourite's component name. |
string | $itemtype | The favourite's itemtype. |
int | $itemid | Optional itemid associated with component. |
dml_exception | if any errors are encountered during deletion. |
|
static |
Delete all favourites for the specified user, in the specified contexts.
approved_contextlist | $contextlist | The approved contexts and user information to delete information for. |
string | $component | The favourite's component name. |
string | $itemtype | The favourite's itemtype. |
int | $itemid | Optional itemid associated with component. |
coding_exception | |
dml_exception |
|
static |
Delete all favourites for the specified users in the specified context, component area and item type.
core_privacy\local\request\approved_userlist | $userlist | The approved contexts and user information to delete information for. |
string | $itemtype | The favourite's itemtype. |
int | $itemid | Optional itemid associated with component. |
dml_exception | if any errors are encountered during deletion. |
|
static |
Get favourites data for the specified user in the specified component, item type and item ID.
int | $userid | The id of the user in scope. |
context | $context | The context to which data is scoped. |
string | $component | The favourite's component name. |
string | $itemtype | The favourite's item type. |
int | $itemid | The favourite's item ID. |
array|null |
|
static |
Returns metadata about this system.
collection | $collection | The initialised collection to add items to. |
collection | A listing of user data stored through this system. |
Implements core_privacy\local\metadata\provider.