class FeedsDrupalUserLdapEntryFetcherResult in Lightweight Directory Access Protocol (LDAP) 7.2
Same name and namespace in other branches
- 8.2 ldap_feeds/FeedsDrupalUserLdapEntryFetcher.inc \FeedsDrupalUserLdapEntryFetcherResult
- 7 ldap_feeds/FeedsDrupalUserLdapEntryFetcher.inc \FeedsDrupalUserLdapEntryFetcherResult
Hierarchy
- class \FeedsResult
- class \FeedsFetcherResult
Expanded class hierarchy of FeedsDrupalUserLdapEntryFetcherResult
File
- ldap_feeds/
FeedsDrupalUserLdapEntryFetcher.inc, line 13 - FeedsDrupalUserLdapEntryFetcher.
View source
class FeedsDrupalUserLdapEntryFetcherResult extends FeedsFetcherResult {
public $filterLdapAuthenticated;
public $availableDrupalUserAttributes;
public $filterRoles;
/**
* Constructor.
*/
public function __construct($source_config) {
$this->availableDrupalUserAttributes = ldap_feeds_drupal_user_attributes();
$this->filterLdapAuthenticated = isset($source_config['filterLdapAuthenticated']) ? $source_config['filterLdapAuthenticated'] : LDAP_FEEDS_DRUPAL_USER_FETCHER_FILTER_AUTHENTICATED;
$this->filterRoles = isset($source_config['filterRoles']) ? $source_config['filterRoles'] : LDAP_FEEDS_DRUPAL_USER_FETCHER_FILTER_ROLES;
parent::__construct('');
$this->ldap_result = $this
->getRaw();
return $this->ldap_result;
}
/**
* Overrides parent::getRaw();.
*/
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);
return $results;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FeedsDrupalUserLdapEntryFetcherResult:: |
public | property | ||
FeedsDrupalUserLdapEntryFetcherResult:: |
public | property | ||
FeedsDrupalUserLdapEntryFetcherResult:: |
public | property | ||
FeedsDrupalUserLdapEntryFetcherResult:: |
public | function |
Overrides parent::getRaw();. Overrides FeedsFetcherResult:: |
|
FeedsDrupalUserLdapEntryFetcherResult:: |
public | function |
Constructor. Overrides FeedsFetcherResult:: |
|
FeedsFetcherResult:: |
protected | property | The path to a file where the raw data is stored. | |
FeedsFetcherResult:: |
protected | property | The raw fetched data. | |
FeedsFetcherResult:: |
protected | function | Checks that a file exists and is readable. | |
FeedsFetcherResult:: |
public | function | Constructs file name for saving the raw data. | |
FeedsFetcherResult:: |
public | function | Returns if the file to parse exists. | |
FeedsFetcherResult:: |
public | function | Returns directory for storing files that are in progress of import. | |
FeedsFetcherResult:: |
public | function | Returns the contents of a file, if it exists. | |
FeedsFetcherResult:: |
public | function | Get a path to a temporary file containing the resource provided by the fetcher. | 1 |
FeedsFetcherResult:: |
public | function | Returns if raw data exists. | |
FeedsFetcherResult:: |
public | function | Sanitize the file in place. | |
FeedsFetcherResult:: |
public | function | Sanitize the raw content string. | |
FeedsFetcherResult:: |
public | function | Sanitize the raw content string. | |
FeedsFetcherResult:: |
public | function | Saves the raw fetcher result to a file. | |
FeedsFetcherResult:: |
public | function | Prevent saving the raw result when serializing object. |