Skip to content

Commit

Permalink
MDL-38319 make role_get_names() faster and more useful
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Mar 17, 2013
1 parent 7112729 commit ab633da
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lib/accesslib.php
Expand Up @@ -4368,23 +4368,27 @@ function role_get_description(stdClass $role) {

/**
* Get all the localised role names for a context.
* @param context $context the context
*
* @param context $context the context, null means system context
* @param array of role objects with a ->localname field containing the context-specific role name.
* @param int $rolenamedisplay
* @param bool $returnmenu true means id=>localname, false means id=>rolerecord
* @return array Array of context-specific role names, or role objects with a ->localname field added.
*/
function role_get_names(context $context) {
return role_fix_names(get_all_roles(), $context);
function role_get_names(context $context = null, $rolenamedisplay = ROLENAME_ALIAS, $returnmenu = null) {
return role_fix_names(get_all_roles($context), $context, $rolenamedisplay, $returnmenu);
}

/**
* Prepare list of roles for display, apply aliases and format text
*
* @param array $roleoptions array roleid => roleobject (with optional coursealias), strings are accepted for backwards compatibility only
* @param context|bool $context a context
* @param context $context the context, null means system context
* @param int $rolenamedisplay
* @param bool $returnmenu null means keep the same format as $roleoptions, true means id=>localname, false means id=>rolerecord
* @return array Array of context-specific role names, or role objects with a ->localname field added.
*/
function role_fix_names($roleoptions, $context = null, $rolenamedisplay = ROLENAME_ALIAS, $returnmenu = null) {
function role_fix_names($roleoptions, context $context = null, $rolenamedisplay = ROLENAME_ALIAS, $returnmenu = null) {
global $DB;

if (empty($roleoptions)) {
Expand Down

0 comments on commit ab633da

Please sign in to comment.