ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilLDAPResult Class Reference

Class ilLDAPPagedResult. More...

+ Collaboration diagram for ilLDAPResult:

Public Member Functions

 __construct ($a_ldap_handle, $a_result=null)
 
 numRows ()
 Total count of resulted rows. More...
 
 setResult ($result)
 Resource from ldap_search() More...
 
 get ()
 Returns last result. More...
 
 getRows ()
 Returns complete results. More...
 
 run ()
 Starts ldap_get_entries() and transforms results. More...
 
 __destruct ()
 

Private Member Functions

 addEntriesToRows (array $entries)
 Adds Results from ldap_get_entries() to rows. More...
 
 toSimpleArray (array $entry)
 Transforms results from ldap_get_entries() to a simple format. More...
 

Private Attributes

 $handle
 
 $result = null
 
array $rows = []
 
array $last_row
 

Detailed Description

Class ilLDAPPagedResult.

Author
Fabian Wolf

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

Constructor & Destructor Documentation

◆ __construct()

ilLDAPResult::__construct (   $a_ldap_handle,
  $a_result = null 
)
Parameters
resource | \Ldap\Connection$a_ldap_handlefrom ldap_connect()
null|false|resource|list<

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

References null.

46  {
47  $this->handle = $a_ldap_handle;
48 
49  if ($a_result !== null && $a_result !== false) {
50  $this->result = $a_result;
51  }
52  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null

◆ __destruct()

ilLDAPResult::__destruct ( )

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

152  {
153  if ($this->result) {
154  ldap_free_result($this->result);
155  }
156  }

Member Function Documentation

◆ addEntriesToRows()

ilLDAPResult::addEntriesToRows ( array  $entries)
private

Adds Results from ldap_get_entries() to rows.

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

References $data, and toSimpleArray().

Referenced by run().

105  : void
106  {
107  $num = $entries['count'];
108  if ($num === 0) {
109  return;
110  }
111 
112  for ($row_counter = 0; $row_counter < $num; $row_counter++) {
113  $data = $this->toSimpleArray($entries[$row_counter]);
114  $this->rows[] = $data;
115  $this->last_row = $data;
116  }
117  }
toSimpleArray(array $entry)
Transforms results from ldap_get_entries() to a simple format.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get()

ilLDAPResult::get ( )

Returns last result.

Returns
array

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

75  : array
76  {
77  return is_array($this->last_row) ? $this->last_row : [];
78  }

◆ getRows()

ilLDAPResult::getRows ( )

Returns complete results.

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

References $rows.

83  : array
84  {
85  return $this->rows;
86  }

◆ numRows()

ilLDAPResult::numRows ( )

Total count of resulted rows.

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

57  : int
58  {
59  return count($this->rows);
60  }

◆ run()

ilLDAPResult::run ( )

Starts ldap_get_entries() and transforms results.

Returns
self $this

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

References addEntriesToRows().

92  : self
93  {
94  if ($this->result) {
95  $entries = ldap_get_entries($this->handle, $this->result);
96  $this->addEntriesToRows($entries);
97  }
98 
99  return $this;
100  }
addEntriesToRows(array $entries)
Adds Results from ldap_get_entries() to rows.
+ Here is the call graph for this function:

◆ setResult()

ilLDAPResult::setResult (   $result)

Resource from ldap_search()

Parameters
false|resource|list<

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

References $result.

66  : void
67  {
68  $this->result = $result;
69  }

◆ toSimpleArray()

ilLDAPResult::toSimpleArray ( array  $entry)
private

Transforms results from ldap_get_entries() to a simple format.

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

References $data.

Referenced by addEntriesToRows().

122  : array
123  {
124  $data = [];
125  foreach ($entry as $key => $value) {
126  if (is_int($key)) {
127  continue;
128  }
129 
130  $key = strtolower($key);
131  if ($key === 'dn') {
132  $data['dn'] = $value;
133  continue;
134  }
135  if (is_array($value)) {
136  if ($value['count'] > 1) {
137  for ($i = 0; $i < $value['count']; $i++) {
138  $data[$key][] = $value[$i];
139  }
140  } elseif ($value['count'] === 1) {
141  $data[$key] = $value[0];
142  }
143  } else {
144  $data[$key] = $value;
145  }
146  }
147 
148  return $data;
149  }
+ Here is the caller graph for this function:

Field Documentation

◆ $handle

ilLDAPResult::$handle
private

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

◆ $last_row

array ilLDAPResult::$last_row
private

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

◆ $result

ilLDAPResult::$result = null
private

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

Referenced by setResult().

◆ $rows

array ilLDAPResult::$rows = []
private

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

Referenced by getRows().


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