ILIAS  release_4-4 Revision
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$

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

Constructor & Destructor Documentation

◆ __construct()

ilLDAPResult::__construct (   $a_ldap_connection,
  $a_result 
)

Constructor.

public

Parameters
resourceldap connection
resourceldap result

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

References toSimpleArray().

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.
+ Here is the call graph for this function:

◆ __destruct()

ilLDAPResult::__destruct ( )

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

162  {
163  @ldap_free_result($this->result);
164  }

Member Function Documentation

◆ get()

ilLDAPResult::get ( )

Get search result as array.

public

Parameters

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

67  {
68  return $this->data ? $this->data : array();
69  }

◆ getEntries()

ilLDAPResult::getEntries ( )
private

Wrapper for ldap_get_entries.

private

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

References $entries.

Referenced by toSimpleArray().

173  {
174  return $this->entries = @ldap_get_entries($this->ldap_handle,$this->result);
175 
176  // this way ldap_get_entries is binary safe
177 
178  $i=0;
179  $tmp_entries = array();
180  $entry = ldap_first_entry($this->ldap_handle,$this->result);
181  do {
182  $attributes = @ldap_get_attributes($this->ldap_handle, $entry);
183  for($j=0; $j<$attributes['count']; $j++)
184  {
185  $values = ldap_get_values_len($this->ldap_handle, $entry,$attributes[$j]);
186  $tmp_entries[$i][strtolower($attributes[$j])] = $values;
187  }
188  $i++;
189  } while ($entry = @ldap_next_entry($this->ldap_handle,$entry));
190 
191  if($i)
192  {
193  $tmp_entries['count'] = $i;
194  }
195  $this->entries = $tmp_entries;
196  return $this->entries;
197  }
+ Here is the caller graph for this function:

◆ getRows()

ilLDAPResult::getRows ( )

Get all result rows.

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

public

Parameters

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

References $num_results.

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

◆ toSimpleArray()

ilLDAPResult::toSimpleArray ( )
private

Transform ldap result in simple array.

private

Parameters

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

References $data, and getEntries().

Referenced by __construct().

102  {
103  $this->data = array();
104  $this->num_results = 0;
105 
106  if(!$this->entries = $this->getEntries())
107  {
108  return false;
109  }
110 
111  $this->num_results = $this->entries['count'];
112  if($this->entries['count'] == 0)
113  {
114  return true;
115  }
116 
117  for($row_counter = 0; $row_counter < $this->entries['count'];$row_counter++)
118  {
119  $data = array();
120  foreach($this->entries[$row_counter] as $key => $value)
121  {
122  $key = strtolower($key);
123 
124  if(is_int($key))
125  {
126  continue;
127  }
128  if($key == 'dn')
129  {
130  $data['dn'] = $value;
131  continue;
132  }
133  if(is_array($value))
134  {
135  if($value['count'] > 1)
136  {
137  for($i = 0; $i < $value['count']; $i++)
138  {
139  $data[$key][] = $value[$i];
140  }
141  }
142  elseif($value['count'] == 1)
143  {
144  $data[$key] = $value[0];
145  }
146  }
147  else
148  {
149  $data[$key] = $value;
150  }
151  }
152  $this->all_rows[] = $data;
153  if($row_counter == 0)
154  {
155  $this->data = $data;
156  }
157  }
158  return true;
159  }
getEntries()
Wrapper for ldap_get_entries.
+ 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: