summaryrefslogtreecommitdiff
path: root/lib/Kolab/FreeBusy/Directory.php
diff options
context:
space:
mode:
authorThomas Bruederli <bruederli@kolabsys.com>2013-01-16 14:37:00 (GMT)
committerThomas Bruederli <bruederli@kolabsys.com>2013-01-16 14:37:00 (GMT)
commita261ddd670c5617c996f4155dfea483228628ca6 (patch)
tree7b2234366da9cabadb2ff6f592b6465d8b40b0a2 /lib/Kolab/FreeBusy/Directory.php
downloadkolab-freebusy-a261ddd670c5617c996f4155dfea483228628ca6.tar.gz
Initial import
Diffstat (limited to 'lib/Kolab/FreeBusy/Directory.php')
-rw-r--r--lib/Kolab/FreeBusy/Directory.php63
1 files changed, 63 insertions, 0 deletions
diff --git a/lib/Kolab/FreeBusy/Directory.php b/lib/Kolab/FreeBusy/Directory.php
new file mode 100644
index 0000000..25b9038
--- /dev/null
+++ b/lib/Kolab/FreeBusy/Directory.php
@@ -0,0 +1,63 @@
+<?php
+
+namespace Kolab;
+
+/**
+ * Abstract class representing an address directory for free/busy data lookups
+ */
+abstract class FBDirectory
+{
+ protected $config;
+
+ /**
+ * Factory method creating an instace of FBDirectory according to config
+ *
+ * @param array Hash array with config
+ */
+ public static function factory($config)
+ {
+ switch (strtolower($config['type'])) {
+ case 'ldap':
+ return new FBDirectoryLDAP($config);
+
+ case 'default':
+ case 'external':
+ return new FBDirectoryDefault($config);
+
+ default:
+ trigger_error("Invalid directory type '" . $config['type'] . "'!", E_USER_ERROR);
+ }
+
+ return null;
+ }
+
+ /**
+ * Resolve the given username to a FBEntity object
+ *
+ * @param string Username/Email to resolve
+ * @return object FBEntity if found, otherwise False
+ */
+ abstract public function resolve($user);
+
+ /**
+ * Retrieve free/busy data for the given user.
+ *
+ * @param string Username or email to resolve
+ * @param boolean Get extemded free-busy if possible
+ * @return string VCalendar container if found, False otherwise
+ */
+ public function getFreeBusyData($user, $extended = false)
+ {
+ // resolve user record first
+ if ($user = $this->resolve($user)) {
+ $fbsource = $this->config['fbsource'];
+ if ($source = FBSource::Factory($fbsource)) {
+ // foward request to FBSource instance
+ return $source->getFreeBusyData($user, $extended);
+ }
+ }
+
+ return false;
+ }
+
+} \ No newline at end of file