* @param $resource
*
* @return Kronolith_Resource object
+ * @throws Horde_Exception
*/
public function saveResource($resource)
{
return $resource;
}
+ /**
+ * Obtain a Kronolith_Resource by the resource's id
+ *
+ * @param int $id The key for the Kronolith_Resource
+ *
+ * @return array A hash of resource object properties
+ * @throws Horde_Exception
+ */
public function getResource($id)
{
$query = 'SELECT resource_id, resource_name, resource_calendar, resource_category FROM kronolith_resources WHERE resource_id = ?';
return $return;
}
+ /**
+ * Obtain the resource id associated with the given calendar uid.
+ *
+ * @param string $calendar The calendar's uid
+ *
+ * @return int The Kronolith_Resource id
+ * @throws Horde_Exception
+ */
public function getResourceIdByCalendar($calendar)
{
$query = 'SELECT resource_id FROM kronolith_resources WHERE resource_calendar = ?';
}
/**
+ * Return a list of Kronolith_Resources
+ *
+ * This method will likely be a moving target as group resources are
+ * fleshed out.
+ *
+ */
+ function listResources($params = array())
+ {
+ $query = 'SELECT resource_id, resource_name, resource_calendar, resource_category FROM kronolith_resources';
+ $results = $this->_db->getAll($query, null, DB_FETCHMODE_ASSOC);
+ if ($results instanceof PEAR_Error) {
+ throw new Horde_Exception($results->getMessage());
+ }
+
+ return $results;
+ }
+
+ /**
* Attempts to open a connection to the SQL server.
*
* @return boolean True.
/**
*
- * @return unknown_type
+ * @return array of Kronolith_Resource objects
*/
static public function listResources($params = array())
{
self::$_driver = Kronolith::getDriver('Sql');
}
- self::$_driver->listResources($params);
+ $resources = self::$_driver->listResources($params);
+ $return = array();
+ foreach ($resources as $resource) {
+ $return[] = new Kronolith_Resource_Single($resource);
+ }
+
+ return $return;
}
/**
}
/**
- * 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.
+ * Obtain the freebusy information for this resource.
+ *
* @return unknown_type
*/
public function getFreeBusy($startstamp = null, $endstamp = null, $asObject = false)
//var_dump($results);
/* Test adding resource to event */
-$resource = Kronolith_Resource::getResource(6);
-$driver = Kronolith::getDriver('Sql');
-$event = $driver->getByUID('20090817131028.10427ipjxgq69hk4@localhost');
-$event->addResource($resource, Kronolith::RESPONSE_NONE);
-$event->save();
+//$resource = Kronolith_Resource::getResource(6);
+//$driver = Kronolith::getDriver('Sql');
+//$event = $driver->getByUID('20090730102515.90466g7f034lxucc@localhost');
+//$event->addResource($resource, Kronolith::RESPONSE_NONE);
+//$event->save();
+//
+//var_dump($resource->getFreeBusy(null, null, true));
-var_dump($resource->getFreeBusy(null, null, true));
\ No newline at end of file
+/* Test listing resources */
+var_dump(Kronolith_Resource::listResources());
\ No newline at end of file