mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 05:58:34 +01:00
MDL-63387 access: add parameter to define how role names are returned.
This commit is contained in:
parent
38abfb6a01
commit
a9165e69b4
@ -3163,9 +3163,11 @@ function get_assignable_roles(context $context, $rolenamedisplay = ROLENAME_ALIA
|
|||||||
* test the moodle/role:switchroles to see if the user is allowed to switch in the first place.
|
* test the moodle/role:switchroles to see if the user is allowed to switch in the first place.
|
||||||
*
|
*
|
||||||
* @param context $context a context.
|
* @param context $context a context.
|
||||||
|
* @param int $rolenamedisplay the type of role name to display. One of the
|
||||||
|
* ROLENAME_X constants. Default ROLENAME_ALIAS.
|
||||||
* @return array an array $roleid => $rolename.
|
* @return array an array $roleid => $rolename.
|
||||||
*/
|
*/
|
||||||
function get_switchable_roles(context $context) {
|
function get_switchable_roles(context $context, $rolenamedisplay = ROLENAME_ALIAS) {
|
||||||
global $USER, $DB;
|
global $USER, $DB;
|
||||||
|
|
||||||
// You can't switch roles without this capability.
|
// You can't switch roles without this capability.
|
||||||
@ -3208,7 +3210,7 @@ function get_switchable_roles(context $context) {
|
|||||||
ORDER BY r.sortorder";
|
ORDER BY r.sortorder";
|
||||||
$roles = $DB->get_records_sql($query, $params);
|
$roles = $DB->get_records_sql($query, $params);
|
||||||
|
|
||||||
return role_fix_names($roles, $context, ROLENAME_ALIAS, true);
|
return role_fix_names($roles, $context, $rolenamedisplay, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -3216,9 +3218,11 @@ function get_switchable_roles(context $context) {
|
|||||||
*
|
*
|
||||||
* @param context $context a context.
|
* @param context $context a context.
|
||||||
* @param int $userid id of user.
|
* @param int $userid id of user.
|
||||||
|
* @param int $rolenamedisplay the type of role name to display. One of the
|
||||||
|
* ROLENAME_X constants. Default ROLENAME_ALIAS.
|
||||||
* @return array an array $roleid => $rolename.
|
* @return array an array $roleid => $rolename.
|
||||||
*/
|
*/
|
||||||
function get_viewable_roles(context $context, $userid = null) {
|
function get_viewable_roles(context $context, $userid = null, $rolenamedisplay = ROLENAME_ALIAS) {
|
||||||
global $USER, $DB;
|
global $USER, $DB;
|
||||||
|
|
||||||
if ($userid == null) {
|
if ($userid == null) {
|
||||||
@ -3260,7 +3264,7 @@ function get_viewable_roles(context $context, $userid = null) {
|
|||||||
ORDER BY r.sortorder";
|
ORDER BY r.sortorder";
|
||||||
$roles = $DB->get_records_sql($query, $params);
|
$roles = $DB->get_records_sql($query, $params);
|
||||||
|
|
||||||
return role_fix_names($roles, $context, ROLENAME_ALIAS, true);
|
return role_fix_names($roles, $context, $rolenamedisplay, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -31,6 +31,8 @@ information provided here is intended especially for developers.
|
|||||||
* The form element 'htmleditor', which was deprecated in 3.6, has been removed.
|
* The form element 'htmleditor', which was deprecated in 3.6, has been removed.
|
||||||
* The `core_output_load_fontawesome_icon_map` web service has been deprecated and replaced by
|
* The `core_output_load_fontawesome_icon_map` web service has been deprecated and replaced by
|
||||||
`core_output_load_fontawesome_icon_system_map` which takes the name of the theme to generate the icon system map for.
|
`core_output_load_fontawesome_icon_system_map` which takes the name of the theme to generate the icon system map for.
|
||||||
|
* A new parameter `$rolenamedisplay` has been added to `get_viewable_roles()` and `get_switchable_roles` to define how role names
|
||||||
|
should be returned.
|
||||||
* The class coursecat_sortable_records has been removed.
|
* The class coursecat_sortable_records has been removed.
|
||||||
* Admin setting admin_setting_configselect now supports lazy-loading the options list by supplying
|
* Admin setting admin_setting_configselect now supports lazy-loading the options list by supplying
|
||||||
a callback function instead of an array of options.
|
a callback function instead of an array of options.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user