You are here

function fasttoggle_get_user_role_array in Fasttoggle 7

Same name and namespace in other branches
  1. 6 fasttoggle.module \fasttoggle_get_user_role_array()

Toggle a role in the list of roles assigned to a user.

Parameters

object $account: The object account.

string $role: The role to be toggled.

Return value

mixed The new list of roles assigned to the user.

1 string reference to 'fasttoggle_get_user_role_array'
fasttoggle_user_fasttoggle_available_links in module/fasttoggle_user/fasttoggle_user.module
Implements hook_fasttoggle_available_links().

File

module/fasttoggle_user/fasttoggle_user.module, line 173

Code

function fasttoggle_get_user_role_array($account, $role) {
  $result = $account->roles;
  if (isset($account->roles[$role])) {
    unset($result[$role]);
  }
  else {
    $result[$role] = TRUE;
  }
  return $result;
}