/** * Constructor Method * */ function __construct($consumer_type = NULL) { $this->ogVersion = ldap_authorization_og_og_version(); $params = ldap_authorization_og_ldap_authorization_consumer(); if ($this->ogVersion == 1) { $this->ogRoles = og_roles(0); $this->ogRolesByName = array_flip($this->ogRoles); } else { $this->_setConsumerIDs(); } parent::__construct('og_group', $params['og_group']); }
/** * @see LdapAuthorizationConsumerAbstract::populateConsumersFromConsumerIds */ public function populateConsumersFromConsumerIds(&$consumers, $create_missing_consumers = FALSE) { // generate a query for all og groups of interest $gids = array(); foreach ($consumers as $consumer_id => $consumer) { if (ldap_authorization_og_og_version() == 1) { list($gid, $rid) = $this->og1ConsumerIdParts($consumer_id); $gids[] = $gid; } else { list($entity_type, $gid, $rid) = explode(':', $consumer_id); $gids[$entity_type][] = $gid; } } if (ldap_authorization_og_og_version() == 1) { $og_group_entities = og_load_multiple($gids); } else { foreach ($gids as $entity_type => $gid_x_entity) { $og_group_entities[$entity_type] = @entity_load($entity_type, $gid_x_entity); } } foreach ($consumers as $consumer_id => $consumer) { if (ldap_authorization_og_og_version() == 1) { list($gid, $rid) = $this->og1ConsumerIdParts($consumer_id); $consumer['exists'] = isset($og_group_entities[$gid]); if ($consumer['exists']) { $consumer['value'] = $og_group_entities[$gid]; if (empty($consumer['name']) && property_exists($og_group_entities[$gid], 'title')) { $consumer['name'] = $og_group_entities[$gid]->title; } $consumer['name'] = $consumer_id; } else { $consumer['value'] = NULL; $consumer['name'] = NULL; } $consumer['map_to_string'] = $consumer_id; } else { list($entity_type, $gid, $rid) = explode(':', $consumer_id); $consumer['exists'] = isset($og_group_entities[$entity_type][$gid]); $consumer['value'] = $consumer['exists'] ? $og_group_entities[$entity_type][$gid] : NULL; $consumer['map_to_string'] = $consumer_id; if (empty($consumer['name']) && !empty($og_group_entities[$entity_type][$gid]) && property_exists($og_group_entities[$entity_type][$gid], 'title')) { $consumer['name'] = $og_group_entities[$entity_type][$gid]->title; } } if (!$consumer['exists'] && $create_missing_consumers) { // @todo if creation of og groups were implemented, function would be called here // this would mean mapping would need to have enough info to configure a group, // or settings would need to include a default group type to create (entity type, // bundle, etc.) } $consumers[$consumer_id] = $consumer; } }