| Línea 819... |
Línea 819... |
| 819 |
* Check if user has permission to create data download request for themselves
|
819 |
* Check if user has permission to create data download request for themselves
|
| 820 |
*
|
820 |
*
|
| 821 |
* @param int|null $userid
|
821 |
* @param int|null $userid
|
| 822 |
* @return bool
|
822 |
* @return bool
|
| 823 |
*/
|
823 |
*/
|
| 824 |
public static function can_create_data_download_request_for_self(int $userid = null): bool {
|
824 |
public static function can_create_data_download_request_for_self(?int $userid = null): bool {
|
| 825 |
global $USER;
|
825 |
global $USER;
|
| 826 |
$userid = $userid ?: $USER->id;
|
826 |
$userid = $userid ?: $USER->id;
|
| 827 |
return has_capability('tool/dataprivacy:downloadownrequest', \context_user::instance($userid), $userid);
|
827 |
return has_capability('tool/dataprivacy:downloadownrequest', \context_user::instance($userid), $userid);
|
| 828 |
}
|
828 |
}
|
| Línea 832... |
Línea 832... |
| 832 |
*
|
832 |
*
|
| 833 |
* @param int|null $userid ID of the user.
|
833 |
* @param int|null $userid ID of the user.
|
| 834 |
* @return bool
|
834 |
* @return bool
|
| 835 |
* @throws coding_exception
|
835 |
* @throws coding_exception
|
| 836 |
*/
|
836 |
*/
|
| 837 |
public static function can_create_data_deletion_request_for_self(int $userid = null): bool {
|
837 |
public static function can_create_data_deletion_request_for_self(?int $userid = null): bool {
|
| 838 |
global $USER;
|
838 |
global $USER;
|
| 839 |
$userid = $userid ?: $USER->id;
|
839 |
$userid = $userid ?: $USER->id;
|
| 840 |
return has_capability('tool/dataprivacy:requestdelete', \context_user::instance($userid), $userid)
|
840 |
return has_capability('tool/dataprivacy:requestdelete', \context_user::instance($userid), $userid)
|
| 841 |
&& !is_primary_admin($userid);
|
841 |
&& !is_primary_admin($userid);
|
| 842 |
}
|
842 |
}
|
| Línea 847... |
Línea 847... |
| 847 |
* @param int|null $userid ID of the user.
|
847 |
* @param int|null $userid ID of the user.
|
| 848 |
* @return bool
|
848 |
* @return bool
|
| 849 |
* @throws coding_exception
|
849 |
* @throws coding_exception
|
| 850 |
* @throws dml_exception
|
850 |
* @throws dml_exception
|
| 851 |
*/
|
851 |
*/
|
| 852 |
public static function can_create_data_deletion_request_for_other(int $userid = null): bool {
|
852 |
public static function can_create_data_deletion_request_for_other(?int $userid = null): bool {
|
| 853 |
global $USER;
|
853 |
global $USER;
|
| 854 |
$userid = $userid ?: $USER->id;
|
854 |
$userid = $userid ?: $USER->id;
|
| 855 |
return has_capability('tool/dataprivacy:requestdeleteforotheruser', context_system::instance(), $userid);
|
855 |
return has_capability('tool/dataprivacy:requestdeleteforotheruser', context_system::instance(), $userid);
|
| 856 |
}
|
856 |
}
|
| Línea 861... |
Línea 861... |
| 861 |
* @param int $userid ID of a user being requested.
|
861 |
* @param int $userid ID of a user being requested.
|
| 862 |
* @param int|null $requesterid ID of a user making request.
|
862 |
* @param int|null $requesterid ID of a user making request.
|
| 863 |
* @return bool
|
863 |
* @return bool
|
| 864 |
* @throws coding_exception
|
864 |
* @throws coding_exception
|
| 865 |
*/
|
865 |
*/
|
| 866 |
public static function can_create_data_deletion_request_for_children(int $userid, int $requesterid = null): bool {
|
866 |
public static function can_create_data_deletion_request_for_children(int $userid, ?int $requesterid = null): bool {
|
| 867 |
global $USER;
|
867 |
global $USER;
|
| 868 |
$requesterid = $requesterid ?: $USER->id;
|
868 |
$requesterid = $requesterid ?: $USER->id;
|
| 869 |
return has_capability('tool/dataprivacy:makedatadeletionrequestsforchildren', \context_user::instance($userid),
|
869 |
return has_capability('tool/dataprivacy:makedatadeletionrequestsforchildren', \context_user::instance($userid),
|
| 870 |
$requesterid) && !is_primary_admin($userid);
|
870 |
$requesterid) && !is_primary_admin($userid);
|
| 871 |
}
|
871 |
}
|
| Línea 1361... |
Línea 1361... |
| 1361 |
* Creates an ad-hoc task for the data request.
|
1361 |
* Creates an ad-hoc task for the data request.
|
| 1362 |
*
|
1362 |
*
|
| 1363 |
* @param int $requestid The data request ID.
|
1363 |
* @param int $requestid The data request ID.
|
| 1364 |
* @param int $userid Optional. The user ID to run the task as, if necessary.
|
1364 |
* @param int $userid Optional. The user ID to run the task as, if necessary.
|
| 1365 |
*/
|
1365 |
*/
|
| 1366 |
public static function queue_data_request_task(int $requestid, int $userid = null): void {
|
1366 |
public static function queue_data_request_task(int $requestid, ?int $userid = null): void {
|
| 1367 |
$task = new process_data_request_task();
|
1367 |
$task = new process_data_request_task();
|
| 1368 |
$task->set_custom_data(['requestid' => $requestid]);
|
1368 |
$task->set_custom_data(['requestid' => $requestid]);
|
| 1369 |
if ($userid) {
|
1369 |
if ($userid) {
|
| 1370 |
$task->set_userid($userid);
|
1370 |
$task->set_userid($userid);
|
| 1371 |
}
|
1371 |
}
|