1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
|
<?php
/**
* The Kronolith_View_Event:: class provides an API for viewing events.
*
* $Horde: kronolith/lib/Views/Event.php,v 1.7.2.2 2008/02/29 04:38:09 chuck Exp $
*
* @author Chuck Hagenbuch <chuck@horde.org>
* @since Kronolith 2.2
* @package Kronolith
*/
class Kronolith_View_Event {
var $event;
/**
* @param Kronolith_Event &$event
*/
function Kronolith_View_Event(&$event)
{
$this->event = &$event;
}
function getTitle()
{
if (!$this->event || is_a($this->event, 'PEAR_Error')) {
return _("Not Found");
}
return $this->event->getTitle();
}
function link()
{
return $this->event->getViewUrl();
}
function html($active = true)
{
global $conf, $prefs;
if (!$this->event || is_a($this->event, 'PEAR_Error')) {
echo '<h3>' . _("The requested event was not found.") . '</h3>';
return;
}
require_once 'Horde/MIME.php';
require_once 'Horde/Text.php';
$createdby = '';
$modifiedby = '';
$userId = Auth::getAuth();
if ($this->event->getUID()) {
/* Get the event's history. */
$history = &Horde_History::singleton();
$log = $history->getHistory('kronolith:' . $this->event->getCalendar() . ':' .
$this->event->getUID());
if ($log && !is_a($log, 'PEAR_Error')) {
foreach ($log->getData() as $entry) {
switch ($entry['action']) {
case 'add':
$created = $entry['ts'];
if ($userId != $entry['who']) {
$createdby = sprintf(_("by %s"), Kronolith::getUserName($entry['who']));
} else {
$createdby = _("by me");
}
break;
case 'modify':
$modified = $entry['ts'];
if ($userId != $entry['who']) {
$modifiedby = sprintf(_("by %s"), Kronolith::getUserName($entry['who']));
} else {
$modifiedby = _("by me");
}
break;
}
}
}
}
$creatorId = $this->event->getCreatorId();
$category = $this->event->getCategory();
$description = $this->event->getDescription();
$location = $this->event->getLocation();
$private = $this->event->isPrivate() && $creatorId != Auth::getAuth();
$owner = Kronolith::getUserName($creatorId);
$status = Kronolith::statusToString($this->event->getStatus());
$attendees = $this->event->getAttendees();
if ($conf['metadata']['keywords']) {
include KRONOLITH_BASE . '/config/keywords.php';
$keyword_list = array();
foreach ($keywords as $cat => $list) {
$sub_list = array();
foreach ($list as $entry) {
if ($this->event->hasKeyword($entry)) {
$sub_list[] = htmlspecialchars($entry);
}
}
if (count($sub_list)) {
$keyword_list[$cat] = $sub_list;
}
}
}
if ($timestamp = (int)Util::getFormData('timestamp')) {
$month = date('n', $timestamp);
$year = date('Y', $timestamp);
} else {
$month = (int)Util::getFormData('month', date('n'));
$year = (int)Util::getFormData('year', date('Y'));
}
echo '<div id="Event"' . ($active ? '' : ' style="display:none"') . '>';
require KRONOLITH_TEMPLATES . '/view/view.inc';
echo '</div>';
if ($active && $GLOBALS['browser']->hasFeature('dom')) {
if ($this->event->hasPermission(PERMS_EDIT)) {
require_once KRONOLITH_BASE . '/lib/Views/EditEvent.php';
$edit = new Kronolith_View_EditEvent($this->event);
$edit->html(false);
}
if ($this->event->hasPermission(PERMS_DELETE)) {
require_once KRONOLITH_BASE . '/lib/Views/DeleteEvent.php';
$delete = new Kronolith_View_DeleteEvent($this->event);
$delete->html(false);
}
}
}
function getName()
{
return 'Event';
}
}
|