ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilLDAPResult Class Reference
+ Collaboration diagram for ilLDAPResult:

Public Member Functions

 __construct ($a_ldap_connection, $a_result)
 Constructor. More...
 
 get ()
 Get search result as array. More...
 
 getRows ()
 Get all result rows. More...
 
 numRows ()
 get number of rows More...
 
 __destruct ()
 

Private Member Functions

 toSimpleArray ()
 Transform ldap result in simple array. More...
 
 getEntries ()
 Wrapper for ldap_get_entries. More...
 

Private Attributes

 $ldap_handle = null
 
 $result = null
 
 $entries = null
 
 $num_results = null
 
 $data = null
 

Detailed Description

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

@ilCtrl_Calls

Definition at line 34 of file class.ilLDAPResult.php.

Constructor & Destructor Documentation

◆ __construct()

ilLDAPResult::__construct (   $a_ldap_connection,
  $a_result 
)

Constructor.

@access public

Parameters
resourceldap connection
resourceldap result

Definition at line 51 of file class.ilLDAPResult.php.

52 {
53 $this->ldap_handle = $a_ldap_connection;
54 $this->result = $a_result;
55
56 $this->toSimpleArray();
57 }
toSimpleArray()
Transform ldap result in simple array.

References toSimpleArray().

+ Here is the call graph for this function:

◆ __destruct()

ilLDAPResult::__destruct ( )

Definition at line 147 of file class.ilLDAPResult.php.

148 {
149 @ldap_free_result($this->result);
150 }

Member Function Documentation

◆ get()

ilLDAPResult::get ( )

Get search result as array.

@access public

Parameters

Definition at line 66 of file class.ilLDAPResult.php.

67 {
68 return $this->data ? $this->data : array();
69 }
$this data['403_header']

References data.

◆ getEntries()

ilLDAPResult::getEntries ( )
private

Wrapper for ldap_get_entries.

@access private

Definition at line 158 of file class.ilLDAPResult.php.

159 {
160 return $this->entries = @ldap_get_entries($this->ldap_handle, $this->result);
161
162 // this way ldap_get_entries is binary safe
163
164 $i = 0;
165 $tmp_entries = array();
166 $entry = ldap_first_entry($this->ldap_handle, $this->result);
167 do {
168 $attributes = @ldap_get_attributes($this->ldap_handle, $entry);
169 for ($j = 0; $j < $attributes['count']; $j++) {
170 $values = ldap_get_values_len($this->ldap_handle, $entry, $attributes[$j]);
171 $tmp_entries[$i][strtolower($attributes[$j])] = $values;
172 }
173 $i++;
174 } while ($entry = @ldap_next_entry($this->ldap_handle, $entry));
175
176 if ($i) {
177 $tmp_entries['count'] = $i;
178 }
179 $this->entries = $tmp_entries;
180 return $this->entries;
181 }
$i
Definition: disco.tpl.php:19
if(array_key_exists('yes', $_REQUEST)) $attributes
Definition: getconsent.php:85
$values

References $attributes, $entries, $i, and $values.

Referenced by toSimpleArray().

+ Here is the caller graph for this function:

◆ getRows()

ilLDAPResult::getRows ( )

Get all result rows.

@access public

Definition at line 77 of file class.ilLDAPResult.php.

78 {
79 return $this->all_rows ? $this->all_rows : array();
80 }

◆ numRows()

ilLDAPResult::numRows ( )

get number of rows

@access public

Parameters

Definition at line 89 of file class.ilLDAPResult.php.

90 {
91 return $this->num_results;
92 }

References $num_results.

◆ toSimpleArray()

ilLDAPResult::toSimpleArray ( )
private

Transform ldap result in simple array.

@access private

Parameters

Definition at line 101 of file class.ilLDAPResult.php.

102 {
103 $this->data = array();
104 $this->num_results = 0;
105
106 if (!$this->entries = $this->getEntries()) {
107 return false;
108 }
109
110 $this->num_results = $this->entries['count'];
111 if ($this->entries['count'] == 0) {
112 return true;
113 }
114
115 for ($row_counter = 0; $row_counter < $this->entries['count'];$row_counter++) {
116 $data = array();
117 foreach ($this->entries[$row_counter] as $key => $value) {
118 $key = strtolower($key);
119
120 if (is_int($key)) {
121 continue;
122 }
123 if ($key == 'dn') {
124 $data['dn'] = $value;
125 continue;
126 }
127 if (is_array($value)) {
128 if ($value['count'] > 1) {
129 for ($i = 0; $i < $value['count']; $i++) {
130 $data[$key][] = $value[$i];
131 }
132 } elseif ($value['count'] == 1) {
133 $data[$key] = $value[0];
134 }
135 } else {
136 $data[$key] = $value;
137 }
138 }
139 $this->all_rows[] = $data;
140 if ($row_counter == 0) {
141 $this->data = $data;
142 }
143 }
144 return true;
145 }
getEntries()
Wrapper for ldap_get_entries.
$key
Definition: croninfo.php:18

References $data, $i, $key, data, and getEntries().

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $data

ilLDAPResult::$data = null
private

Definition at line 41 of file class.ilLDAPResult.php.

Referenced by toSimpleArray().

◆ $entries

ilLDAPResult::$entries = null
private

Definition at line 38 of file class.ilLDAPResult.php.

Referenced by getEntries().

◆ $ldap_handle

ilLDAPResult::$ldap_handle = null
private

Definition at line 36 of file class.ilLDAPResult.php.

◆ $num_results

ilLDAPResult::$num_results = null
private

Definition at line 40 of file class.ilLDAPResult.php.

Referenced by numRows().

◆ $result

ilLDAPResult::$result = null
private

Definition at line 37 of file class.ilLDAPResult.php.


The documentation for this class was generated from the following file: