You are here

public function FeedsDrupalUserLdapEntryFetcherResult::getRaw in Lightweight Directory Access Protocol (LDAP) 8.2

Same name and namespace in other branches
  1. 7.2 ldap_feeds/FeedsDrupalUserLdapEntryFetcher.inc \FeedsDrupalUserLdapEntryFetcherResult::getRaw()
  2. 7 ldap_feeds/FeedsDrupalUserLdapEntryFetcher.inc \FeedsDrupalUserLdapEntryFetcherResult::getRaw()

Overrides parent::getRaw();

1 call to FeedsDrupalUserLdapEntryFetcherResult::getRaw()
FeedsDrupalUserLdapEntryFetcherResult::__construct in ldap_feeds/FeedsDrupalUserLdapEntryFetcher.inc
Constructor.

File

ldap_feeds/FeedsDrupalUserLdapEntryFetcher.inc, line 33
FeedsDrupalUserLdapEntryFetcher

Class

FeedsDrupalUserLdapEntryFetcherResult

Code

public function getRaw() {

  // needs to loop through all users, and query ldap for each, one at a time
  $query = new EntityFieldQuery();
  $entities = $query
    ->entityCondition('entity_type', 'user')
    ->execute();
  $users = entity_load('user', array_keys($entities['user']));
  if ($this->filterRoles) {
    $selectedRoles = array_filter($this->filterRoles);
    $filterOnRoles = (bool) count($selectedRoles);
  }
  else {
    $filterOnRoles = FALSE;
  }
  foreach ($users as $uid => $user) {
    if ($uid == 0 || $uid == 1 || $this->filterLdapAuthenticated && !isset($user->data['ldap_user']) || $filterOnRoles && !array_intersect(array_values($selectedRoles), array_keys($user->roles))) {
      continue;
    }
    if ($ldap_user = ldap_servers_get_user_ldap_data($user)) {
      unset($ldap_user['mail']);
      $ldap_user['attr']['count'] = $ldap_user['attr']['count'] + count($this->availableDrupalUserAttributes);
      foreach ($this->availableDrupalUserAttributes as $attr_name => $attr_conf) {
        $ldap_user['attr'][] = $attr_conf['token'];
        $ldap_user['attr'][$attr_conf['token']]['count'] = 1;
        $ldap_user['attr'][$attr_conf['token']][0] = (string) $user->{$attr_name};
      }
      $results[] = $ldap_user;
    }
  }
  $results['count'] = count($results);

  // drupal_set_message("<pre>" . print_r($results, TRUE));
  return $results;
}