: array();
$editAttendee = null;
+$resources = (isset($_SESSION['kronolith']['resources']) &&
+ is_array($_SESSION['kronolith']['resources']))
+ ? $_SESSION['kronolith']['resources']
+ : array();
+$editResource = null;
+
// Get the action ID and value. This specifies what action the user initiated.
$actionID = Horde_Util::getFormData('actionID');
if (Horde_Util::getFormData('clearAll')) {
}
}
+// Add Free/Busy for resources
+foreach ($resources as $r_id => $resource) {
+ $r = Kronolith_Resource::getResource($r_id);
+ $vfb = $r->getFreeBusy(null, null, true);
+ $attendee_view->addResourceMember($vfb);
+}
+
$date = Horde_Util::getFormData('date', date('Ymd')) . '000000';
$date = new Horde_Date($date);
$vfb_html = $attendee_view->render($date);
' event_recurtype, event_recurenddate, event_recurinterval,' .
' event_recurdays, event_start, event_end, event_allday,' .
' event_alarm, event_alarm_methods, event_modified,' .
- ' event_exceptions, event_creator_id' .
+ ' event_exceptions, event_creator_id, event_resources' .
' FROM ' . $this->_params['table'] .
' WHERE calendar_id = ?';
$values = array($this->_calendar);
' event_recurtype, event_recurenddate, event_recurinterval,' .
' event_recurdays, event_start, event_end, event_allday,' .
' event_alarm, event_alarm_methods, event_modified,' .
- ' event_exceptions, event_creator_id' .
+ ' event_exceptions, event_creator_id, event_resources' .
' FROM ' . $this->_params['table'] . ' WHERE event_id = ? AND calendar_id = ?';
$values = array($eventId, $this->_calendar);
' event_recurtype, event_recurenddate, event_recurinterval,' .
' event_recurdays, event_start, event_end, event_allday,' .
' event_alarm, event_alarm_methods, event_modified,' .
- ' event_exceptions, event_creator_id' .
+ ' event_exceptions, event_creator_id, event_resources' .
' FROM ' . $this->_params['table'] . ' WHERE event_uid = ?';
$values = array($uid);
return $return;
}
+ public function getResourceIdByCalendar($calendar)
+ {
+ $query = 'SELECT resource_id FROM kronolith_resources WHERE resource_calendar = ?';
+ $results = $this->_db->getOne($query, array($calendar));
+ if ($results instanceof PEAR_Error) {
+ throw new Horde_Exception($results->getMessage());
+ }
+ if (empty($results)) {
+ throw new Horde_Exception('Resource not found');
+ }
+
+ return $results;
+ }
+
/**
* Attempts to open a connection to the SQL server.
*
* @package Kronolith
*/
class Kronolith_FreeBusy {
-
/**
* Generates the free/busy text for $calendar. Cache it for at least an
* hour, as well.
/* Fetch the appropriate share and check permissions. */
$share = &$kronolith_shares->getShare($calendar[0]);
if (is_a($share, 'PEAR_Error')) {
- return $returnObj ? $share : '';
+ // Might be a Kronolith_Resource
+ try {
+ $resource = Kronolith_Resource::isResourceCalendar($calendar[0]);
+ $owner = $calendar[0];
+ } catch (Horde_Exception $e) {
+ return $returnObj ? $share : '';
+ }
+ } else {
+ $owner = $share->get('owner');
}
/* Default the start date to today. */
/* Get the Identity for the owner of the share. */
$identity = &Identity::singleton('none',
- $user ? $user : $share->get('owner'));
+ $user ? $user : $owner);
$email = $identity->getValue('from_addr');
$cn = $identity->getValue('fullname');
$vFb->setAttribute('DTSTAMP', $_SERVER['REQUEST_TIME']);
$vFb->setAttribute('DTSTART', $startstamp);
$vFb->setAttribute('DTEND', $endstamp);
- $vFb->setAttribute('URL', Horde::applicationUrl('fb.php?u=' . $share->get('owner'), true, -1));
+ $vFb->setAttribute('URL', Horde::applicationUrl('fb.php?u=' . $owner, true, -1));
/* Add all the busy periods. */
foreach ($busy as $events) {
var $_requiredMembers = array();
var $_optionalMembers = array();
+ var $_resourceMembers = array();
var $_timeBlocks = array();
var $_startHour;
$this->_optionalMembers[] = clone $vFreebusy;
}
+ function addResourceMember($vFreebusy)
+ {
+ $this->_resourceMembers[] = clone $vFreebusy;
+ }
+
function render($day = null)
{
global $prefs;
$html .= $template->fetch(KRONOLITH_TEMPLATES . '/fbview/section.html');
}
+ // Resources
+ if (count($this->_resourceMembers) > 0) {
+ $template = new Horde_Template();
+ $rows = '';
+ foreach ($this->_resourceMembers as $member) {
+ $member->simplify();
+ $blocks = $this->_getBlocks($member, $member->getBusyPeriods(), 'busyblock.html', _("Busy"));
+ $template = new Horde_Template();
+ $template->set('blocks', $blocks);
+ $template->set('name', $member->getName());
+ $rows .= $template->fetch(KRONOLITH_TEMPLATES . '/fbview/row.html');
+ }
+ $template = new Horde_Template();
+ $template->set('title', _("Resources"));
+ $template->set('rows', $rows);
+ $template->set('span', count($this->_timeBlocks));
+ $template->set('hours', $hours_html);
+ $template->set('legend', '');
+ $html .= $template->fetch(KRONOLITH_TEMPLATES . '/fbview/section.html');
+ }
+
// Possible meeting times.
$optimal->setAttribute('ORGANIZER', _("All Attendees"));
$blocks = $this->_getBlocks($optimal,
return new Kronolith_Resource_Single($driver->getResource($id));
}
+ static public function isResourceCalendar($calendar)
+ {
+ $driver = Kronolith::getDriver('Sql');
+ $resource = $driver->getResourceIdByCalendar($calendar);
+
+ return $resource > 0;
+ }
+
}
\ No newline at end of file
* for all the resources in the group.
* @return unknown_type
*/
- public function getFreeBusy()
+ public function getFreeBusy($startstamp = null, $endstamp = null, $asObject = false)
{
+ $vfb = Kronolith_Freebusy::generate($this->calendar, $startstamp, $endstamp, $asObject);
+ $vfb->removeAttribute('ORGANIZER');
+ $vfb->setAttribute('ORGANIZER', $this->name);
+ return $vfb;
}
public function setId($id)
$calendar_id .= ':' . $share->get('owner');
}
$_SESSION['kronolith']['attendees'] = $this->event->getAttendees();
-
+ $_SESSION['kronolith']['resources'] = $this->event->getResources();
if ($datetime = Horde_Util::getFormData('datetime')) {
$datetime = new Horde_Date($datetime);
$month = $datetime->month;
/* Test adding resource to event */
$resource = Kronolith_Resource::getResource(6);
$driver = Kronolith::getDriver('Sql');
-$event = $driver->getByUID('20090610181329.12687chinwtntsg8@localhost');
+$event = $driver->getByUID('20090817131028.10427ipjxgq69hk4@localhost');
$event->addResource($resource, Kronolith::RESPONSE_NONE);
$event->save();
+
+var_dump($resource->getFreeBusy(null, null, true));
\ No newline at end of file
<?php $i++; ?>
<?php endforeach; ?>
<?php endif; ?>
+
+<!-- resource list header -->
+<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>
+</tr>
+
+<!-- resources -->
+<?php $i = 0; if (empty($resources)): ?>
+ <tr><td colspan="4"><em><?php echo _("No attendees") ?></em></td></tr>
+<?php else: foreach ($resources as $id => $resource): ?>
+ <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>
+ <?php switch ($resource['response']) {
+ case Kronolith::RESPONSE_ACCEPTED:
+ echo _("Accepted");
+ break;
+ case Kronolith::RESPONSE_DECLINED:
+ echo _("Declined");
+ break;
+ } ?>
+ </td>
+ </tr>
+ <?php $i++; ?>
+<?php endforeach; ?>
+<?php endif; ?>
</table>
<br />