<?php
+/**
+ * Part of bdrem
+ *
+ * PHP version 5
+ *
+ * @category Tools
+ * @package Bdrem
+ * @author Christian Weiske <cweiske@cweiske.de>
+ * @copyright 2014 Christian Weiske
+ * @license http://www.gnu.org/licenses/agpl.html GNU AGPL v3
+ * @link http://cweiske.de/bdrem.htm
+ */
namespace bdrem;
/**
* Fetch data from an LDAP server.
* Works fine with evolutionPerson schema.
+ *
+ * @category Tools
+ * @package Bdrem
+ * @author Christian Weiske <cweiske@cweiske.de>
+ * @copyright 2014 Christian Weiske
+ * @license http://www.gnu.org/licenses/agpl.html GNU AGPL v3
+ * @link http://cweiske.de/bdrem.htm
*/
class Source_Ldap
{
+ /**
+ * LDAP server configuration
+ *
+ * Keys:
+ * - host - LDAP server host name
+ * - basedn - root DN that gets searched
+ * - binddn - Username to authenticate with
+ * - bindpw - Password for username
+ *
+ * @var array
+ */
protected $config;
/**
}
/**
- * @param string $strDate Date the events shall be found for, YYYY-MM-DD
+ * Return all events for the given date range
+ *
+ * @param string $strDate Date the events shall be found for,
+ * YYYY-MM-DD
+ * @param integer $nDaysPrevious Include number of days before $strDate
+ * @param integer $nDaysNext Include number of days after $strDate
+ *
+ * @return Event[] Array of matching event objects
*/
public function getEvents($strDate, $nDaysPrevious, $nDaysNext)
{
$filters[] = \Net_LDAP2_Filter::create($dateAttribute, 'ends', $day);
}
- $filter = \Net_LDAP2_Filter::combine('or', $filters);
+ if (count($filters) < 2) {
+ $filter = $filters[0];
+ } else {
+ $filter = \Net_LDAP2_Filter::combine('or', $filters);
+ }
$options = array(
'scope' => 'sub',
'attributes' => array(
return $arEvents;
}
+ /**
+ * Extract the name from the given LDAP entry object.
+ * Uses displayName or givenName + sn
+ *
+ * @param object $entry LDAP entry
+ *
+ * @return string Name or NULL
+ */
protected function getNameFromEntry(\Net_LDAP2_Entry $entry)
{
$arEntry = $entry->getValues();
}
/**
+ * Create an array of dates that are included in the given range.
+ *
+ * @param string $strDate Date the events shall be found for,
+ * YYYY-MM-DD
+ * @param integer $nDaysPrevious Include number of days before $strDate
+ * @param integer $nDaysNext Include number of days after $strDate
+ *
* @return array Values like "-01-24" ("-$month-$day")
*/
protected function getDates($strDate, $nDaysPrevious, $nDaysNext)
} while (--$numDays >= 0);
return $arDays;
}
-
}
?>