Some ideas on feeling out a UI for administration...some of this will likely change
authorMichael J. Rubinsky <mrubinsk@horde.org>
Thu, 20 Aug 2009 23:13:36 +0000 (19:13 -0400)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Tue, 29 Sep 2009 20:53:49 +0000 (16:53 -0400)
kronolith/attendees.php
kronolith/lib/Driver/Sql.php
kronolith/lib/Kronolith.php
kronolith/lib/Resource.php
kronolith/resources.php
kronolith/templates/attendees/attendees.inc

index 9c28a9e..d48314b 100644 (file)
@@ -263,6 +263,10 @@ $vfb_html = $attendee_view->render($date);
 $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'));
index 6a86da8..2675433 100644 (file)
@@ -765,9 +765,9 @@ class Kronolith_Driver_Sql extends Kronolith_Driver
      */
     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());
@@ -776,7 +776,7 @@ class Kronolith_Driver_Sql extends Kronolith_Driver
             $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;
index a273501..ea204b8 100644 (file)
@@ -740,6 +740,8 @@ class Kronolith
                     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;
@@ -788,6 +790,10 @@ class Kronolith
             }
         }
 
+//        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();
index d67d095..5257f77 100644 (file)
@@ -50,8 +50,8 @@ class Kronolith_Resource
     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');
@@ -80,12 +80,9 @@ class Kronolith_Resource
 
     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
index a8cc38a..e8b45bd 100644 (file)
@@ -9,20 +9,20 @@ $title = _("Edit resources");
 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 */
index 203ab20..3a615bd 100644 (file)
@@ -81,7 +81,7 @@ function switchDateView(view, date)
 <tr class="item nowrap leftAlign">
  <th width="2%">&nbsp;</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 -->
@@ -91,7 +91,7 @@ function switchDateView(view, date)
  <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");
@@ -102,6 +102,7 @@ function switchDateView(view, date)
     } ?>
   </td>
  </tr>
+
  <?php $i++; ?>
 <?php endforeach; ?>
 <?php endif; ?>
@@ -110,6 +111,7 @@ function switchDateView(view, date)
 <br />
 
 <table width="100%" cellspacing="2" class="nowrap control">
+ <!-- Add Attendees -->
  <tr>
   <td class="rightAlign">&nbsp;<strong><?php $label = empty($editAttendee) ? _("Add attendees") : _("Edit attendee"); echo Horde::highlightAccessKey($label, $ak = Horde::getAccessKey($label)) ?></strong></td>
   <td>
@@ -122,6 +124,21 @@ function switchDateView(view, date)
   <td width="100%">&nbsp;</td>
 <?php endif; ?>
  </tr>
+
+ <!-- Add Resources -->
+  <tr>
+  <td class="rightAlign">&nbsp;<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%">&nbsp;</td>
+<?php endif; ?>
+ </tr>
+
 </table>
 
 <br />