class FeedsDrupalUserLdapEntryFetcherResult in Lightweight Directory Access Protocol (LDAP) 7
Same name and namespace in other branches
- 8.2 ldap_feeds/FeedsDrupalUserLdapEntryFetcher.inc \FeedsDrupalUserLdapEntryFetcherResult
- 7.2 ldap_feeds/FeedsDrupalUserLdapEntryFetcher.inc \FeedsDrupalUserLdapEntryFetcherResult
Hierarchy
- class \FeedsResult
- class \FeedsFetcherResult
Expanded class hierarchy of FeedsDrupalUserLdapEntryFetcherResult
File
- ldap_feeds/
FeedsDrupalUserLdapEntryFetcher.inc, line 11 - 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']));
$selectedRoles = array_filter($this->filterRoles);
$filterOnRoles = (bool) count($selectedRoles);
foreach ($users as $uid => $user) {
if ($uid == 0 || $uid == 1 || $this->filterLdapAuthenticated && !isset($user->data['ldap_authentication']) || $filterOnRoles && !array_intersect(array_values($selectedRoles), array_keys($user->roles))) {
continue;
}
if ($ldap_entry = ldap_servers_get_user_ldap_data($user)) {
unset($ldap_entry['mail']);
$ldap_entry['attr']['count'] = $ldap_entry['attr']['count'] + count($this->availableDrupalUserAttributes);
foreach ($this->availableDrupalUserAttributes as $attr_name => $attr_conf) {
$ldap_entry['attr'][] = $attr_conf['token'];
$ldap_entry['attr'][$attr_conf['token']]['count'] = 1;
$ldap_entry['attr'][$attr_conf['token']][0] = (string) $user->{$attr_name};
}
$results[] = $ldap_entry;
}
}
$results['count'] = count($results);
// drupal_set_message("<pre>" . print_r($results, TRUE));
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. |