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');
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');
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;
<td width="100%">
<select id="resourceselect" name="resourceselect">
<option value="0"><?php echo _("Select resource")?></option>
- <?php foreach ($allResources as $resource):?>
+ <?php foreach ($allResources as $id => $resource):?>
<?php printf('<option value="%s">%s</option>', $resource->getId(), $resource->get('name')) ?>
<?php endforeach;?>
</select>