You are here

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

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

In organic groups 7.x-1.x, 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

1 call to LdapAuthorizationConsumerOG::sortConsumerIds()
LdapAuthorizationConsumerOG::grantsAndRevokes in ldap_authorization/ldap_authorization_og/LdapAuthorizationConsumerOG.class.php

File

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

Class

LdapAuthorizationConsumerOG

Code

public function sortConsumerIds($op, &$consumers) {
  if ($op == 'revoke') {
    krsort($consumers, SORT_STRING);
  }
  else {
    ksort($consumers, SORT_STRING);
  }
}