From: Michael J. Rubinsky Date: Sat, 12 Sep 2009 16:04:25 +0000 (-0400) Subject: Remove already added resources from the select list. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=b12e031246f6bc1c46868c62f93799df5bd7df76;p=horde.git Remove already added resources from the select list. Also have listResources() return the results keyed by the resource_id --- diff --git a/kronolith/attendees.php b/kronolith/attendees.php index 9665197d2..d12ff3e2e 100644 --- a/kronolith/attendees.php +++ b/kronolith/attendees.php @@ -21,7 +21,6 @@ $resources = (isset($_SESSION['kronolith']['resources']) && is_array($_SESSION['kronolith']['resources'])) ? $_SESSION['kronolith']['resources'] : array(); -$allResources = Kronolith_Resource::listResources(); // Get the action ID and value. This specifies what action the user initiated. $actionID = Horde_Util::getFormData('actionID'); @@ -228,6 +227,12 @@ case 'clear': break; } +/* Get list of resources for select list, and remove those we already added */ +$allResources = Kronolith_Resource::listResources(); +foreach (array_keys($resources) as $id) { + unset($allResources[$id]); +} + // Get the current Free/Busy view; default to the 'day' view if none specified. $view = Horde_Util::getFormData('view', 'Day'); diff --git a/kronolith/lib/Driver/Resource.php b/kronolith/lib/Driver/Resource.php index 5aa02a32d..d44542d49 100644 --- a/kronolith/lib/Driver/Resource.php +++ b/kronolith/lib/Driver/Resource.php @@ -497,14 +497,14 @@ class Kronolith_Driver_Resource extends Kronolith_Driver_Sql public function listResources($params = array()) { $query = 'SELECT resource_id, resource_name, resource_calendar, resource_category, resource_description, resource_response_type, resource_max_reservations FROM kronolith_resources'; - $results = $this->_db->getAll($query, null, DB_FETCHMODE_ASSOC); + $results = $this->_db->getAssoc($query, true, array(), DB_FETCHMODE_ASSOC, false); if ($results instanceof PEAR_Error) { throw new Horde_Exception($results->getMessage()); } $return = array(); - foreach ($results as $result) { - $return[] = new Kronolith_Resource_Single($this->_fromDriver($result)); + foreach ($results as $key => $result) { + $return[$key] = new Kronolith_Resource_Single($this->_fromDriver(array_merge(array('resource_id' => $key), $result))); } return $return; diff --git a/kronolith/templates/attendees/attendees.inc b/kronolith/templates/attendees/attendees.inc index f6b9a823a..e8754f34d 100644 --- a/kronolith/templates/attendees/attendees.inc +++ b/kronolith/templates/attendees/attendees.inc @@ -135,7 +135,7 @@ function switchDateView(view, date)