Révision 32700c57
Ajouté par Assos Assos il y a environ 5 ans
drupal7/sites/all/modules/ldap/ldap_feeds/FeedsLdapEntryParser.inc | ||
---|---|---|
2 | 2 |
|
3 | 3 |
/** |
4 | 4 |
* @file |
5 |
* |
|
6 | 5 |
* Provides the Parser for an ldap entry array. |
7 | 6 |
*/ |
8 | 7 |
|
8 |
/** |
|
9 |
* |
|
10 |
*/ |
|
9 | 11 |
class FeedsLdapEntryParser extends FeedsParser { |
10 | 12 |
public $ldap_result; |
11 | 13 |
|
12 |
/**
|
|
14 |
/** |
|
13 | 15 |
* Implements FeedsParser::parse(). |
14 | 16 |
*/ |
15 | 17 |
public function parse(FeedsSource $source, FeedsFetcherResult $fetcher_result) { |
16 | 18 |
|
17 | 19 |
$mappings = feeds_importer($this->id)->processor->config['mappings']; |
18 | 20 |
$ldap_entries = $fetcher_result->ldap_result; |
19 |
$parsed_items = array();
|
|
21 |
$parsed_items = [];
|
|
20 | 22 |
for ($i = 0; $i < $ldap_entries['count']; $i++) { |
21 | 23 |
$ldap_entry = $ldap_entries[$i]; |
22 |
$parsed_item = array('dn' => (string)$ldap_entry['dn']);
|
|
24 |
$parsed_item = ['dn' => (string) $ldap_entry['dn']];
|
|
23 | 25 |
foreach ($mappings as $j => $map) { |
24 | 26 |
$source_lcase = drupal_strtolower($map['source']); |
25 |
// dn is already parsed
|
|
27 |
// Dn is already parsed.
|
|
26 | 28 |
if ($source_lcase == 'dn') { |
27 | 29 |
continue; |
28 | 30 |
} |
29 | 31 |
$source = $map['source']; |
30 | 32 |
if (isset($ldap_entry['attr'])) { |
31 |
// exception need because of unconvential format of ldap data returned from $ldap_server->userUserNameToExistingLdapEntry
|
|
33 |
// Exception need because of unconvential format of ldap data returned from $ldap_server->userUserNameToExistingLdapEntry.
|
|
32 | 34 |
$ldap_attributes = $ldap_entry['attr']; |
33 | 35 |
} |
34 | 36 |
else { |
... | ... | |
36 | 38 |
} |
37 | 39 |
if (isset($ldap_attributes[$source_lcase][0])) { |
38 | 40 |
if ($ldap_attributes[$source_lcase]['count'] == 1 && is_scalar($ldap_attributes[$source_lcase][0])) { |
39 |
$parsed_item[$source] = (string)$ldap_attributes[$source_lcase][0]; |
|
41 |
$parsed_item[$source] = (string) $ldap_attributes[$source_lcase][0];
|
|
40 | 42 |
} |
41 | 43 |
else { |
42 | 44 |
unset($ldap_attributes[$source_lcase]['count']); |
... | ... | |
54 | 56 |
return $result; |
55 | 57 |
} |
56 | 58 |
|
57 |
|
|
58 | 59 |
/** |
59 | 60 |
* Source form. |
60 | 61 |
*/ |
61 | 62 |
public function sourceForm($source_config) { |
62 |
$form = array();
|
|
63 |
$form = [];
|
|
63 | 64 |
$mappings = feeds_importer($this->id)->processor->config['mappings']; |
64 | 65 |
if (empty($source_config)) { |
65 | 66 |
$source_config = $this->config; |
... | ... | |
71 | 72 |
* Override parent::configFormValidate(). |
72 | 73 |
*/ |
73 | 74 |
public function configFormValidate(&$values) { |
74 |
$this->setConfig(array('sources' => $values));
|
|
75 |
$this->setConfig(['sources' => $values]);
|
|
75 | 76 |
$this->save(); |
76 | 77 |
} |
77 | 78 |
|
78 |
|
|
79 | 79 |
/** |
80 |
* Override parent::getMappingSources(). |
|
81 |
*/ |
|
80 |
* Override parent::getMappingSources().
|
|
81 |
*/
|
|
82 | 82 |
public function getMappingSources() { |
83 | 83 |
return FALSE; |
84 | 84 |
} |
... | ... | |
87 | 87 |
* Override parent::configDefaults(). |
88 | 88 |
*/ |
89 | 89 |
public function configDefaults() { |
90 |
/** removed until design decisions on multivalued attributes are made |
|
91 |
return array( |
|
92 |
'multivalued' => LDAP_FEEDS_QUERY_FETCHER_MULTI_DEFAULT, |
|
93 |
); |
|
94 |
|
|
95 |
*/ |
|
96 |
return array(); |
|
90 |
return []; |
|
97 | 91 |
} |
98 | 92 |
|
99 |
/**
|
|
93 |
/** |
|
100 | 94 |
* Override parent::configForm(). |
101 | 95 |
*/ |
102 | 96 |
public function configForm(&$form_state) { |
103 |
$form = array();
|
|
97 |
$form = [];
|
|
104 | 98 |
return $form; |
105 | 99 |
} |
106 | 100 |
|
101 |
/** |
|
102 |
* |
|
103 |
*/ |
|
107 | 104 |
public function sourceDefaults() { |
108 |
return array();
|
|
105 |
return [];
|
|
109 | 106 |
} |
110 | 107 |
|
111 | 108 |
} |
Formats disponibles : Unified diff
Weekly update of contrib modules