Exemplo n.º 1
0
/**
 *
 * Gets all non-default role objects
 * This is used by the role selector view. Default roles (VISITOR_ROLE, ADMIN_ROLE, DEFAULT_ROLE) need to be omitted from
 * the list of selectable roles - as default roles are automatically assigned to users based on their Elgg membership type
 *
 * @return mixed An array of non-default ElggRole objects defined in the system, or false if none found
 */
function roles_get_all_selectable_roles()
{
    $dbprefix = elgg_get_config('dbprefix');
    $reserved_role_names = "('" . implode("','", ElggRole::getReservedRoleNames()) . "')";
    $options = array('type' => 'object', 'subtype' => 'role', 'limit' => 0, 'joins' => array("INNER JOIN {$dbprefix}metadata m ON (m.entity_guid = e.guid)", "INNER JOIN {$dbprefix}metastrings s1 ON (s1.id = m.name_id AND s1.string = 'name')", "INNER JOIN {$dbprefix}metastrings s2 ON (s2.id = m.value_id)"), 'wheres' => array("s2.string NOT IN {$reserved_role_names}"));
    return elgg_get_entities($options);
}
Exemplo n.º 2
0
 /**
  * 
  * Checks if a role name is reserved in the system
  * 
  * @param string $role_name The name of the role to check
  * 
  * @return boolean True if the passed $role_name is a reserved role name
  */
 public static function isReservedRoleName($role_name)
 {
     return in_array($role_name, ElggRole::getReservedRoleNames());
 }