Start stubbing out some ideas for Kronolith_Resource implementation
authorMichael J. Rubinsky <mrubinsk@horde.org>
Mon, 17 Aug 2009 17:06:15 +0000 (13:06 -0400)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Tue, 29 Sep 2009 20:53:47 +0000 (16:53 -0400)
kronolith/lib/Resource.php [new file with mode: 0644]
kronolith/lib/Resource/Base.php [new file with mode: 0644]
kronolith/lib/Resource/Resource.php [deleted file]

diff --git a/kronolith/lib/Resource.php b/kronolith/lib/Resource.php
new file mode 100644 (file)
index 0000000..d822783
--- /dev/null
@@ -0,0 +1,40 @@
+<?php
+/**
+ *
+ */
+class Kronolith_Resource
+{
+    /**
+     *
+     * @return unknown_type
+     */
+    static public function listResources($params)
+    {
+        // Query kronolith_resource table for all(?) available resources?
+        // maybe by 'type' or 'name'? type would be arbitrary?
+    }
+
+    /**
+     * Adds a new resource to storage
+     *
+     * @param Kronolith_Resource $resource
+     * @return unknown_type
+     */
+    static public function addResource($resource)
+    {
+
+    }
+
+    /**
+     * Removes a resource from storage
+     *
+     * @param Kronolith_Resource $resource
+     * @return boolean
+     * @throws Horde_Exception
+     */
+    static public function removeResource($resource)
+    {
+
+    }
+
+}
\ No newline at end of file
diff --git a/kronolith/lib/Resource/Base.php b/kronolith/lib/Resource/Base.php
new file mode 100644 (file)
index 0000000..7a9f6e0
--- /dev/null
@@ -0,0 +1,76 @@
+<?php
+/**
+ * Kronolith resources
+ *
+ */
+class Kronolith_Resource_Base
+{
+    protected $_params = array();
+    protected $_uid = '';
+
+    public function __construct($params = array())
+    {
+        if (!empty($params['id'])) {
+            // Existing resource
+            $this->_uid = $params['id'];
+        }
+
+        $this->_params = $params;
+    }
+
+    /**
+     *
+     *  Properties:
+     * name        - Display name of resource.
+     * calendar_id - The calendar associated with this resource.
+     * category    - The category of this resource...an arbitrary label used
+     *               to group multiple resources for the resource_group implementation
+     * properties  - any other properties this resource may have?
+     *               (max capacity of room, size of TV, whatever...)
+     *               probably just for display, not sure how this would work
+     *               if we wanted to be able to search since we are implementing these generically.
+     *               Don't think we want a datatree-style attirbutes table for this.
+     */
+    public function __get($property)
+    {
+        return $this->_params[$property];
+    }
+
+    /**
+     * Should this take an event, or a time range?
+     *
+     * @param $startTime
+     * @param $endTime
+     * @return unknown_type
+     */
+    abstract public function isFree($startTime, $endTime);
+
+    /**
+     * Adds $event to this resource's calendar - thus blocking the time
+     * for any other event. Also responsible for setting the attendence status
+     * for the resource in the event object. i.e. calling addResource() (just
+     * like updating an attendee is done by calling addAttendee on the same
+     * attendee again).
+     *
+     * @param $event
+     * @return unknown_type
+     */
+    abstract public function attachToEvent($event);
+
+    /**
+     * Remove this event from resource's calendar
+     *
+     * @param $event
+     * @return unknown_type
+     */
+    abstract public function detachFromEvent($event);
+
+    /**
+     * Obtain the freebusy information for this resource.  Takes into account
+     * if this is a group of resources or not. (Returns the cumulative FB info
+     * for all the resources in the group.
+     * @return unknown_type
+     */
+    abstract public function getFreeBusy();
+
+}
\ No newline at end of file
diff --git a/kronolith/lib/Resource/Resource.php b/kronolith/lib/Resource/Resource.php
deleted file mode 100644 (file)
index 9370a97..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-<?php
-/**
- * Kronolith resources
- *
- */
-class Kronolith_Resource
-{
-    protected $_params = array();
-
-    public function __construct($params = array())
-    {
-        $this->_params = $params;
-    }
-
-    /**
-     *
-     *  Properties:
-     * name        - Display name of resource.
-     * calendar_id - The calendar associated with this resource.
-     * category    - The category of this resource...an arbitrary label used
-     *               to group multiple resources for the resource_group implementation
-     * properties  - any other properties this resource may have?
-     *               (max capacity of room, size of TV, whatever...)
-     *               probably just for display, not sure how this would work
-     *               if we wanted to be able to search since we are implementing these generically.
-     *               Don't think we want a datatree-style attirbutes table for this.
-     */
-    public function __get($property)
-    {
-        return $this->_params[$property];
-    }
-
-
-    /**
-     *
-     * @param $startTime
-     * @param $endTime
-     * @return unknown_type
-     */
-    public function isFree($startTime, $endTime)
-    {
-        //Should this take an event also, instead?
-    }
-
-    /**
-     * Adds $event to this resource's calendar - thus blocking the time
-     * for any other event.
-     *
-     * @param $event
-     * @return unknown_type
-     */
-    public function attachToEvent($event)
-    {
-
-    }
-
-    /**
-     * Remove this event from resource's calendar
-     *
-     * @param $event
-     * @return unknown_type
-     */
-    public function detachFromEvent($event)
-    {
-
-    }
-
-    /**
-     *
-     * @return unknown_type
-     */
-    static public function listResources($params)
-    {
-        // Query kronolith_resource table for all(?) available resources?
-        // maybe by 'type' or 'name'? type would be arbitrary?
-    }
-
-    /**
-     * Adds a new resource to storage
-     *
-     * @param $params
-     * @return unknown_type
-     */
-    static public function addResource($params)
-    {
-
-    }
-
-}
\ No newline at end of file