MDL-62600 tool_dataprivacy: Corrected availability of PO pages to admins

This commit is contained in:
Michael Hawkins
2018-08-14 11:28:31 +08:00
parent 6e445671c1
commit 161a5c8ab9
7 changed files with 107 additions and 60 deletions
+19
View File
@@ -127,6 +127,25 @@ class api {
require_capability('tool/dataprivacy:managedataregistry', $context);
}
/**
* Fetches the role shortnames of Data Protection Officer roles.
*
* @return array An array of the DPO role shortnames
*/
public static function get_dpo_role_names() : array {
global $DB;
$dporoleids = explode(',', str_replace(' ', '', get_config('tool_dataprivacy', 'dporoles')));
$dponames = array();
if (!empty($dporoleids)) {
list($insql, $inparams) = $DB->get_in_or_equal($dporoleids);
$dponames = $DB->get_fieldset_select('role', 'shortname', "id {$insql}", $inparams);
}
return $dponames;
}
/**
* Fetches the list of users with the Data Protection Officer role.
*