$cac = Horde_Ajax_Imple::factory(array('kronolith', 'ContactAutoCompleter'), array('triggerId' => 'newAttendees'));
$cac->attach();
+// TODO - actually implement this part
+$rac = Horde_Ajax_Imple::factory(array('kronolith', 'ContactAutoCompleter'), array('triggerId' => 'newResources'));
+$rac->attach();
+
$title = _("Edit attendees");
require KRONOLITH_TEMPLATES . '/common-header.inc';
$notification->notify(array('listeners' => 'status'));
*/
public function saveResource($resource)
{
- if (!empty($resource->uid)) {
+ if (!empty($resource->id)) {
$query = 'UPDATE kronolith_resources SET resource_name = ?, resource_calendar = ?, resource_category = ? WHERE resource_id = ?';
- $values = array($resource->name, $resource->calendar_id, $resource->category, $resource->uid);
+ $values = array($resource->name, $resource->calendar, $resource->category, $resource->id);
$result = $this->_write_db->query($query, $values);
if (!($result instanceof PEAR_Error)) {
throw new Horde_Exception($result->getMessage());
$query = 'INSERT INTO kronolith_resources (resource_id, resource_name, resource_calendar, resource_category)';
$cols_values = ' VALUES (?, ?, ?, ?)';
$id = $this->_db->nextId('kronolity_resources');
- $values = array($id, $resource->name, $resource->calendar_id, $resource->category);
+ $values = array($id, $resource->name, $resource->calendar, $resource->category);
$result = $this->_write_db->query($query . $cols_values, $values);
if (!($result instanceof PEAR_Error)) {
return true;
if (!in_array($calendarId, $GLOBALS['display_external_calendars'])) {
$GLOBALS['display_external_calendars'][] = $calendarId;
}
+ } elseif (strncmp($calendarId, 'resource_', 9) === 0) {
+ $resource_cal = $calendarId;
} else {
if (!in_array($calendarId, $GLOBALS['display_calendars'])) {
$GLOBALS['display_calendars'][] = $calendarId;
}
}
+// if (!empty($resource_cal)) {
+// $GLOBALS['display_calendars'][] = $resource_cal;
+// }
+
/* Make sure all the remote calendars still exist. */
$_temp = $GLOBALS['display_remote_calendars'];
$GLOBALS['display_remote_calendars'] = array();
static public function addResource($resource)
{
// Create a new calendar id.
- $calendar = hash('md5', microtime());
- $resource->calendar_id = $calendar;
+ $calendar = 'resource_' . hash('md5', microtime());
+ $resource->calendar = $calendar;
if (empty(self::$_driver)) {
self::$_driver = Kronolith::getDriver('Sql');
static public function isResourceCalendar($calendar)
{
- if (empty(self::$_driver)) {
- self::$_driver = Kronolith::getDriver('Sql');
+ if (strncmp($calendar, 'resource_', 9) === 0) {
+ return true;
}
- $resource = self::$_driver->getResourceIdByCalendar($calendar);
-
- return $resource > 0;
}
}
\ No newline at end of file
require KRONOLITH_TEMPLATES . '/common-header.inc';
/* Test creating a new resource */
-$new = array('name' => _("N329SP"),
- 'category' => 'test');
-
+//$new = array('name' => _("Big Meeting Room"),
+// 'category' => 'conference rooms');
+//
//$resource = new Kronolith_Resource_Single($new);
//$results = Kronolith_Resource::addResource($resource);
//var_dump($results);
/* Test adding resource to event */
-//$resource = Kronolith_Resource::getResource(6);
-//$driver = Kronolith::getDriver('Sql');
-//$event = $driver->getByUID('20090730102515.90466g7f034lxucc@localhost');
-//$event->addResource($resource, Kronolith::RESPONSE_NONE);
-//$event->save();
-//
+$resource = Kronolith_Resource::getResource(9);
+$driver = Kronolith::getDriver('Sql');
+$event = $driver->getByUID('20090820100656.66097kphc3ecwf8k@localhost');
+$event->addResource($resource, Kronolith::RESPONSE_NONE);
+$event->save();
+
//var_dump($resource->getFreeBusy(null, null, true));
/* Test listing resources */
<tr class="item nowrap leftAlign">
<th width="2%"> </th>
<th width="48%"><?php echo htmlspecialchars(_("Resource")) ?></th>
- <th width="25%"><?php echo htmlspecialchars(_("Status")) ?></th>
+ <th colspan="2" width="50%"><?php echo htmlspecialchars(_("Status")) ?></th>
</tr>
<!-- resources -->
<tr>
<td class="nowrap"><?php echo Horde::img('delete.png', '', null, $registry->getImageDir('horde')) . ' ' . Horde::img('edit.png', '', null, $registry->getImageDir('horde')) . ' ' ?></td>
<td><?php echo htmlspecialchars($resource['name']) ?></td>
- <td>
+ <td colspan="2">
<?php switch ($resource['response']) {
case Kronolith::RESPONSE_ACCEPTED:
echo _("Accepted");
} ?>
</td>
</tr>
+
<?php $i++; ?>
<?php endforeach; ?>
<?php endif; ?>
<br />
<table width="100%" cellspacing="2" class="nowrap control">
+ <!-- Add Attendees -->
<tr>
<td class="rightAlign"> <strong><?php $label = empty($editAttendee) ? _("Add attendees") : _("Edit attendee"); echo Horde::highlightAccessKey($label, $ak = Horde::getAccessKey($label)) ?></strong></td>
<td>
<td width="100%"> </td>
<?php endif; ?>
</tr>
+
+ <!-- Add Resources -->
+ <tr>
+ <td class="rightAlign"> <strong><?php $label = empty($editResource) ? _("Add resources") : _("Edit resources"); echo Horde::highlightAccessKey($label, $ak = Horde::getAccessKey($label)) ?></strong></td>
+ <td>
+ <input type="text" id="newResources" name="newResources" autocomplete="off" size="40" <?php if (!empty($ak)) echo 'accesskey="' . $ak . '" '; if (!empty($editResource)) echo 'value="' . htmlspecialchars($editResource) . '" '; ?>/>
+ <span id="newResources_loading_img" style="display:none;"><?php echo Horde::img('loading.gif', _("Loading...")) ?></span>
+ <div id="newResources_results" class="autocomplete"></div>
+ </td>
+<?php if ($registry->hasMethod('contacts/search')): ?>
+ <td align="center"><?php echo 'link here to open new resource search window?' ?></td>
+ <td width="100%"> </td>
+<?php endif; ?>
+ </tr>
+
</table>
<br />