You are here

public function LdapAuthorizationConsumerOG::sortConsumerIds in Lightweight Directory Access Protocol (LDAP) 7

Same name and namespace in other branches
  1. 8.2 ldap_authorization/ldap_authorization_og/LdapAuthorizationConsumerOG.class.php \LdapAuthorizationConsumerOG::sortConsumerIds()
  2. 7.2 ldap_authorization/ldap_authorization_og/LdapAuthorizationConsumerOG.class.php \LdapAuthorizationConsumerOG::sortConsumerIds()

some authorization schemes such as organic groups, require a certain order. implement this method to sort consumer ids/authorization ids before they are granted to the user

Parameters

string $op 'grant' or 'revoke' signifying what to do with the $consumer_ids:

alters $consumer_ids by reference

in organic groups, consumer ids are in form gid-rid such as 3-2, 3-3. We want highest authorization available granted. But, granting member role (2), revokes other roles such as admin in OG. So for granting we want the order: 3-1, 3-2, 3-3 such that 3-3 is retained. For revoking, the order should not matter, but reverse sorting makes intuitive sense.

Overrides LdapAuthorizationConsumerAbstract::sortConsumerIds

File

ldap_authorization/ldap_authorization_og/LdapAuthorizationConsumerOG.class.php, line 201

Class

LdapAuthorizationConsumerOG

Code

public function sortConsumerIds($op, &$consumer_ids) {
  if ($op == 'revoke') {
    arsort($consumer_ids, SORT_STRING);
  }
  else {
    asort($consumer_ids, SORT_STRING);
  }
}