You are here

public function LdapAuthorizationConsumerDrupalRole::revokeSingleAuthorization in Lightweight Directory Access Protocol (LDAP) 7

Same name and namespace in other branches
  1. 8.2 ldap_authorization/ldap_authorization_drupal_role/LdapAuthorizationConsumerRole.class.php \LdapAuthorizationConsumerDrupalRole::revokeSingleAuthorization()
  2. 7.2 ldap_authorization/ldap_authorization_drupal_role/LdapAuthorizationConsumerRole.class.php \LdapAuthorizationConsumerDrupalRole::revokeSingleAuthorization()

Parameters

drupal user object $user to have $consumer_id revoked:

string $consumer_id $consumer_id such as drupal role name, og group name, etc.:

array $user_auth_data array of $user data specific to this consumer type.: stored in $user->data['ldap_authorization'][<consumer_type>] array

return boolen TRUE on success, FALSE on fail. If user save is FALSE, the user object will not be saved and reloaded, so a returned TRUE may be misleading.

Overrides LdapAuthorizationConsumerAbstract::revokeSingleAuthorization

File

ldap_authorization/ldap_authorization_drupal_role/LdapAuthorizationConsumerRole.class.php, line 113

Class

LdapAuthorizationConsumerDrupalRole

Code

public function revokeSingleAuthorization(&$user, $role_name, &$user_auth_data) {
  $user_edit = array(
    'roles' => array_diff($user->roles, array(
      $this
        ->getDrupalRoleByName($role_name) => $role_name,
    )),
  );
  $account = user_load($user->uid);
  $user = user_save($account, $user_edit);
  $result = $user && !isset($user->roles[$this
    ->getDrupalRoleByName($role_name)]);
  if ($this->detailedWatchdogLog) {
    watchdog('ldap_authorization', 'LdapAuthorizationConsumerDrupalRole.revokeSingleAuthorization()
        revoked:  rid=%rid, role_name=%role_name for username=%username, result=%result', array(
      '%rid' => $this
        ->getDrupalRoleByName($role_name),
      '%role_name' => $role_name,
      '%username' => $user->name,
      '%result' => $result,
    ), WATCHDOG_DEBUG);
  }
  return $result;
}