Changeset View
Changeset View
Standalone View
Standalone View
plugins/calendar/drivers/ldap/resources_driver_ldap.php
Show All 35 Lines | class resources_driver_ldap extends resources_driver | ||||
{ | { | ||||
$this->cal = $cal; | $this->cal = $cal; | ||||
$this->rc = $cal->rc; | $this->rc = $cal->rc; | ||||
} | } | ||||
/** | /** | ||||
* Fetch resource objects to be displayed for booking | * Fetch resource objects to be displayed for booking | ||||
* | * | ||||
* @param string $query Search query (optional) | * @param string $query Search query (optional) | ||||
* @param int $num Max size of the result | * @param int $num Max size of the result | ||||
* @param string $searchField Field to search with query | |||||
* | * | ||||
* @return array List of resource records available for booking | * @return array List of resource records available for booking | ||||
*/ | */ | ||||
public function load_resources($query = null, $num = 5000) | public function load_resources($query = null, $num = 5000, $searchField = '*') | ||||
{ | { | ||||
if (!($ldap = $this->connect())) { | if (!($ldap = $this->connect())) { | ||||
return []; | return []; | ||||
} | } | ||||
// TODO: apply paging | // TODO: apply paging | ||||
$ldap->set_pagesize($num); | $ldap->set_pagesize($num); | ||||
if (isset($query)) { | if (isset($query)) { | ||||
$results = $ldap->search('*', $query, 0, true, true); | $results = $ldap->search($searchField, $query, 0, true, true); | ||||
} | } | ||||
else { | else { | ||||
$results = $ldap->list_records(); | $results = $ldap->list_records(); | ||||
} | } | ||||
if ($results instanceof ArrayAccess) { | if ($results instanceof ArrayAccess) { | ||||
foreach ($results as $i => $rec) { | foreach ($results as $i => $rec) { | ||||
$results[$i] = $this->decode_resource($rec); | $results[$i] = $this->decode_resource($rec); | ||||
▲ Show 20 Lines • Show All 90 Lines • Show Last 20 Lines |