本文整理汇总了PHP中Horde_Icalendar::newComponent方法的典型用法代码示例。如果您正苦于以下问题:PHP Horde_Icalendar::newComponent方法的具体用法?PHP Horde_Icalendar::newComponent怎么用?PHP Horde_Icalendar::newComponent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Horde_Icalendar
的用法示例。
在下文中一共展示了Horde_Icalendar::newComponent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _create
/**
*/
protected function _create($mbox, $subject, $body)
{
global $notification, $registry;
$list = str_replace(self::TASKLIST_EDIT, '', $mbox);
/* Create a new iCalendar. */
$vCal = new Horde_Icalendar();
$vCal->setAttribute('PRODID', '-//The Horde Project//IMP ' . $registry->getVersion() . '//EN');
$vCal->setAttribute('METHOD', 'PUBLISH');
/* Create a new vTodo object using this message's contents. */
$vTodo = Horde_Icalendar::newComponent('vtodo', $vCal);
$vTodo->setAttribute('SUMMARY', $subject);
$vTodo->setAttribute('DESCRIPTION', $body);
$vTodo->setAttribute('PRIORITY', '3');
/* Get the list of editable tasklists. */
$lists = $this->getTasklists(true);
/* Attempt to add the new vTodo item to the requested tasklist. */
try {
$res = $registry->call('tasks/import', array($vTodo, 'text/calendar', $list));
} catch (Horde_Exception $e) {
$notification->push($e);
return;
}
if (!$res) {
$notification->push(_("An unknown error occured while creating the new task."), 'horde.error');
} elseif (!empty($lists)) {
$name = '"' . htmlspecialchars($subject) . '"';
/* Attempt to convert the object name into a hyperlink. */
if ($registry->hasLink('tasks/show')) {
$name = sprintf('<a href="%s">%s</a>', Horde::url($registry->link('tasks/show', array('uid' => $res))), $name);
}
$notification->push(sprintf(_("%s was successfully added to \"%s\"."), $name, htmlspecialchars($lists[$list]->get('name'))), 'horde.success', array('content.raw'));
}
}
示例2: getVevent
/**
* Return the response as an iCalendar vEvent object.
*
* @param Horde_Itip_Response_Type $type The response type.
* @param Horde_Icalendar|boolean $vCal The parent container or false if not
* provided.
*
* @return Horde_Icalendar_Vevent The response object.
*/
public function getVevent(Horde_Itip_Response_Type $type, $vCal = false)
{
$itip_reply = new Horde_Itip_Event_Vevent(Horde_Icalendar::newComponent('VEVENT', $vCal));
$this->_request->copyEventInto($itip_reply);
$type->setRequest($this->_request);
$itip_reply->setAttendee($this->_resource->getMailAddress(), $this->_resource->getCommonName(), $type->getStatus());
return $itip_reply->getVevent();
}
示例3: toiCalendar
/**
* Exports this event in iCalendar format.
*
* @param Horde_Icalendar $calendar A Horde_Icalendar object that acts as
* a container.
*
* @return array An array of Horde_Icalendar_Vevent objects for this event.
*/
public function toiCalendar($calendar)
{
$vEvent = Horde_Icalendar::newComponent('vevent', $calendar);
$v1 = $calendar->getAttribute('VERSION') == '1.0';
$vEvents = array();
// For certain recur types, we must output in the event's timezone
// so that the BYDAY values do not get out of sync with the UTC
// date-time. See Bug: 11339
if ($this->recurs()) {
switch ($this->recurrence->getRecurType()) {
case Horde_Date_Recurrence::RECUR_WEEKLY:
case Horde_Date_Recurrence::RECUR_YEARLY_WEEKDAY:
case Horde_Date_Recurrence::RECUR_MONTHLY_WEEKDAY:
if (!$this->timezone) {
$this->timezone = date_default_timezone_get();
}
}
}
if ($this->isAllDay()) {
$vEvent->setAttribute('DTSTART', $this->start, array('VALUE' => 'DATE'));
$vEvent->setAttribute('DTEND', $this->end, array('VALUE' => 'DATE'));
$vEvent->setAttribute('X-FUNAMBOL-ALLDAY', 1);
} else {
$this->setTimezone(true);
$params = array();
if ($this->timezone) {
try {
if (!$this->baseid) {
$tz = $GLOBALS['injector']->getInstance('Horde_Timezone');
$vEvents[] = $tz->getZone($this->timezone)->toVtimezone();
}
$params['TZID'] = $this->timezone;
} catch (Horde_Exception $e) {
Horde::log('Unable to locate the tz database.', 'WARN');
}
}
$vEvent->setAttribute('DTSTART', clone $this->start, $params);
$vEvent->setAttribute('DTEND', clone $this->end, $params);
}
$vEvent->setAttribute('DTSTAMP', $_SERVER['REQUEST_TIME']);
$vEvent->setAttribute('UID', $this->uid);
/* Get the event's create and last modify date. */
$created = $modified = null;
try {
$history = $GLOBALS['injector']->getInstance('Horde_History');
$created = $history->getActionTimestamp('kronolith:' . $this->calendar . ':' . $this->uid, 'add');
$modified = $history->getActionTimestamp('kronolith:' . $this->calendar . ':' . $this->uid, 'modify');
/* The history driver returns 0 for not found. If 0 or null does
* not matter, strip this. */
if ($created == 0) {
$created = null;
}
if ($modified == 0) {
$modified = null;
}
} catch (Exception $e) {
}
if (!empty($created)) {
$vEvent->setAttribute($v1 ? 'DCREATED' : 'CREATED', $created);
if (empty($modified)) {
$modified = $created;
}
}
if (!empty($modified)) {
$vEvent->setAttribute('LAST-MODIFIED', $modified);
}
$vEvent->setAttribute('SUMMARY', $this->getTitle());
// Organizer
if (count($this->attendees)) {
$name = Kronolith::getUserName($this->creator);
$email = Kronolith::getUserEmail($this->creator);
$params = array();
if ($v1) {
$tmp = new Horde_Mail_Rfc822_Address($email);
if (!empty($name)) {
$tmp->personal = $name;
}
$email = strval($tmp);
} else {
if (!empty($name)) {
$params['CN'] = $name;
}
if (!empty($email)) {
$email = 'mailto:' . $email;
}
}
$vEvent->setAttribute('ORGANIZER', $email, $params);
}
if (!$this->isPrivate()) {
if (!empty($this->description)) {
$vEvent->setAttribute('DESCRIPTION', $this->description);
}
//.........这里部分代码省略.........
示例4: fetch
/**
* Fetch the free/busy data.
*
* @params array $params Additional options.
*
* @return array The free/busy data.
*/
public function fetch($params = array())
{
$this->logger->debug(sprintf("Free/busy data of owner %s requested by user %s (remote: %s).", $this->callee, $this->user, $this->remote));
if (!empty($this->remote)) {
/* Try to fetch the data if it is stored on a remote server */
//@todo: How to determine which hook/processor to run?
return $this->fetchRemote($params);
// if (is_a($result, 'PEAR_Error')) {
// $error = array('type' => FREEBUSY_ERROR_UNAUTHORIZED, 'error' => $result);
}
global $conf;
/* Which files will we access? */
if (!empty($conf['fb']['use_acls'])) {
$aclcache =& Horde_Kolab_FreeBusy_Cache_DB_acl::singleton('acl', $this->_cache_dir);
$files = $aclcache->get($access->owner);
if (is_a($files, 'PEAR_Error')) {
return $files;
}
} else {
$file_uid = str_replace("", '', str_replace(".", "^", $access->owner));
$files = array();
$this->findAll_readdir($file_uid, $conf['fb']['cache_dir'] . '/' . $file_uid, $files);
}
$owner = $access->owner;
if (ereg('(.*)@(.*)', $owner, $regs)) {
$owner = $regs[2] . '/' . $regs[1];
}
$user = $access->user;
if (ereg('(.*)@(.*)', $user, $regs)) {
$user = $regs[2] . '/' . $regs[1];
}
$c_file = str_replace("", '', str_replace('.', '^', $user . '/' . $owner));
$c_vcal = new Horde_Kolab_FreeBusy_Cache_File_vcal($this->_cache_dir, $c_file, $extended);
/* If the current vCal cache did not expire, we can deliver it */
if (!$this->cache->expired($files)) {
return $this->cache->loadVcal();
}
// Create the new iCalendar.
$vCal = new Horde_Icalendar();
$vCal->setAttribute('PRODID', '-//kolab.org//NONSGML Kolab Server 2//EN');
$vCal->setAttribute('METHOD', 'PUBLISH');
// Create new vFreebusy.
$vFb = Horde_Icalendar::newComponent('vfreebusy', $vCal);
$params = array();
$cn = $access->owner_object->get(Horde_Kolab_Server_Object_Kolab_User::ATTRIBUTE_CN);
if (!empty($cn) || is_a($cn, 'PEAR_Error')) {
$params['cn'] = $access->owner_object->get(Horde_Kolab_Server_Object_Kolab_User::ATTRIBUTE_CN);
}
$vFb->setAttribute('ORGANIZER', 'MAILTO:' . $access->owner, $params);
$vFb->setAttribute('DTSTAMP', time());
if (isset($_SERVER['SERVER_NAME'])) {
$host = $_SERVER['SERVER_NAME'];
} else {
$host = 'localhost';
}
if (isset($_SERVER['REQUEST_URI'])) {
$uri = $_SERVER['REQUEST_URI'];
} else {
$uri = '/';
}
$vFb->setAttribute('URL', 'http://' . $host . $uri);
$mtimes = array();
foreach ($files as $file) {
if ($extended && !empty($conf['fb']['use_acls'])) {
$extended_pvc = $this->_allowExtended($file, $access);
} else {
$extended_pvc = $extended;
}
$c_pvcal = new Horde_Kolab_FreeBusy_Cache_File_pvcal($this->_cache_dir, $file);
$pvCal = $c_pvcal->loadPVcal($extended_pvc);
if (is_a($pvCal, 'PEAR_Error')) {
Horde::log(sprintf("Ignoring partial free/busy file %s: %s)", $file, $pvCal->getMessage()), 'INFO');
continue;
}
$pvFb =& $pvCal->findComponent('vfreebusy');
if (!$pvFb) {
Horde::log(sprintf("Could not find free/busy info in file %s.)", $file), 'INFO');
continue;
}
if ($ets = $pvFb->getAttributeDefault('DTEND', false) !== false) {
// PENDING(steffen): Make value configurable
if ($ets < time()) {
Horde::log(sprintf("Free/busy info in file %s is too old.)", $file), 'INFO');
$c_pvcal->purge();
continue;
}
}
$vFb->merge($pvFb);
/* Store last modification time */
$mtimes[$file] = array($c_pvcal->getFile(), $c_pvcal->getMtime());
}
if (!empty($conf['fb']['remote_servers'])) {
$remote_vfb = $this->_fetchRemote($conf['fb']['remote_servers'], $access);
//.........这里部分代码省略.........
示例5: toiCalendar
/**
* Export this memo in iCalendar format.
*
* @param array memo The memo (hash array) to export
* @param Horde_Icalendar A Horde_Icalendar object that acts as container.
*
* @return Horde_Icalendar_Vnote object for this event.
*/
public function toiCalendar($memo, $calendar)
{
global $prefs;
$vnote = Horde_Icalendar::newComponent('vnote', $calendar);
$vnote->setAttribute('UID', $memo['uid']);
$vnote->setAttribute('BODY', $memo['body']);
$vnote->setAttribute('SUMMARY', $memo['desc']);
if (!empty($memo['tags'])) {
$vnote->setAttribute('CATEGORIES', implode(', ', $memo['tags']));
}
/* Get the note's history. */
$history = $GLOBALS['injector']->getInstance('Horde_History');
$log = $history->getHistory('mnemo:' . $memo['memolist_id'] . ':' . $memo['uid']);
if ($log) {
foreach ($log as $entry) {
switch ($entry['action']) {
case 'add':
$created = $entry['ts'];
break;
case 'modify':
$modified = $entry['ts'];
break;
}
}
}
if (!empty($created)) {
$vnote->setAttribute('DCREATED', $created);
}
if (!empty($modified)) {
$vnote->setAttribute('LAST-MODIFIED', $modified);
}
return $vnote;
}
示例6: _getMinimalInvitation
private function _getMinimalInvitation()
{
$start = new Horde_Date('20080926T110000');
$end = new Horde_Date('20080926T120000');
$vCal = new Horde_Icalendar();
$vCal->setAttribute('METHOD', 'REQUEST');
$inv = Horde_Icalendar::newComponent('VEVENT', $vCal);
$inv->setAttribute('UID', '1001');
$inv->setAttribute('ORGANIZER', 'mailto:orga@example.org', array('cn' => 'Mr. Orga'));
$inv->setAttribute('DTSTART', $start->timestamp());
$inv->setAttribute('DTEND', $end->timestamp());
return $inv;
}
示例7: toiCalendar
/**
* Exports this task in iCalendar format.
*
* @param Horde_Icalendar $calendar A Horde_Icalendar object that acts as
* the container.
*
* @return Horde_Icalendar_Vtodo A vtodo component of this task.
*/
public function toiCalendar(Horde_Icalendar $calendar)
{
$vTodo = Horde_Icalendar::newComponent('vtodo', $calendar);
$v1 = $calendar->getAttribute('VERSION') == '1.0';
$vTodo->setAttribute('UID', $this->uid);
if (!empty($this->assignee)) {
$vTodo->setAttribute('ATTENDEE', Nag::getUserEmail($this->assignee), array('ROLE' => 'REQ-PARTICIPANT'));
}
$vTodo->setAttribute('ORGANIZER', !empty($this->organizer) ? Nag::getUserEmail($this->organizer) : Nag::getUserEmail($this->owner));
if (!empty($this->name)) {
$vTodo->setAttribute('SUMMARY', $this->name);
}
if (!empty($this->desc)) {
$vTodo->setAttribute('DESCRIPTION', $this->desc);
}
if (isset($this->priority)) {
$vTodo->setAttribute('PRIORITY', $this->priority);
}
if (!empty($this->parent_id) && !empty($this->parent)) {
$vTodo->setAttribute('RELATED-TO', $this->parent->uid);
}
if ($this->private) {
$vTodo->setAttribute('CLASS', 'PRIVATE');
}
if (!empty($this->start)) {
$vTodo->setAttribute('DTSTART', $this->start);
}
if ($this->due) {
$vTodo->setAttribute('DUE', $this->due);
if ($this->alarm) {
if ($v1) {
$vTodo->setAttribute('AALARM', $this->due - $this->alarm * 60);
} else {
$vAlarm = Horde_Icalendar::newComponent('valarm', $vTodo);
$vAlarm->setAttribute('ACTION', 'DISPLAY');
$vAlarm->setAttribute('TRIGGER;VALUE=DURATION', '-PT' . $this->alarm . 'M');
$vTodo->addComponent($vAlarm);
}
}
}
if ($this->completed) {
$vTodo->setAttribute('STATUS', 'COMPLETED');
$vTodo->setAttribute('COMPLETED', $this->completed_date ? $this->completed_date : $_SERVER['REQUEST_TIME']);
$vTodo->setAttribute('PERCENT-COMPLETE', '100');
} else {
if (!empty($this->estimate)) {
$vTodo->setAttribute('PERCENT-COMPLETE', $this->actual / $this->estimate * 100);
}
if ($v1) {
$vTodo->setAttribute('STATUS', 'NEEDS ACTION');
} else {
$vTodo->setAttribute('STATUS', 'NEEDS-ACTION');
}
}
// Recurrence.
// We may have to implicitely set DTSTART if not set explicitely, may
// some clients choke on missing DTSTART attributes while RRULE exists.
if ($this->recurs()) {
if ($v1) {
$rrule = $this->recurrence->toRRule10($calendar);
} else {
$rrule = $this->recurrence->toRRule20($calendar);
}
if (!empty($rrule)) {
$vTodo->setAttribute('RRULE', $rrule);
}
/* The completions represent deleted recurrences */
foreach ($this->recurrence->getCompletions() as $exception) {
if (!empty($exception)) {
// Use multiple EXDATE attributes instead of EXDATE
// attributes with multiple values to make Apple iCal
// happy.
list($year, $month, $mday) = sscanf($exception, '%04d%02d%02d');
$vTodo->setAttribute('EXDATE', array(new Horde_Date($year, $month, $mday)), array('VALUE' => 'DATE'));
}
}
}
if ($this->tags) {
$vTodo->setAttribute('CATEGORIES', implode(', ', $this->tags));
}
/* Get the task's history. */
$created = $modified = null;
try {
$log = $GLOBALS['injector']->getInstance('Horde_History')->getHistory('nag:' . $this->tasklist . ':' . $this->uid);
foreach ($log as $entry) {
switch ($entry['action']) {
case 'add':
$created = $entry['ts'];
break;
case 'modify':
$modified = $entry['ts'];
break;
//.........这里部分代码省略.........
示例8: testGetMethodReturnsDefaultMethod
public function testGetMethodReturnsDefaultMethod()
{
$inv = Horde_Icalendar::newComponent('VEVENT', false);
$vevent = new Horde_Itip_Event_Vevent($inv);
$this->assertEquals('REQUEST', $vevent->getMethod());
}
示例9: toiCalendar
/**
* Exports this task in iCalendar format.
*
* @param Horde_Icalendar $calendar A Horde_Icalendar object that acts as
* the container.
*
* @return Horde_Icalendar_Vtodo A vtodo component of this task.
*/
public function toiCalendar(Horde_Icalendar $calendar)
{
$vTodo = Horde_Icalendar::newComponent('vtodo', $calendar);
$v1 = $calendar->getAttribute('VERSION') == '1.0';
$vTodo->setAttribute('UID', $this->uid);
if (!empty($this->assignee)) {
$vTodo->setAttribute('ORGANIZER', $this->assignee);
}
if (!empty($this->name)) {
$vTodo->setAttribute('SUMMARY', $this->name);
}
if (!empty($this->desc)) {
$vTodo->setAttribute('DESCRIPTION', $this->desc);
}
if (isset($this->priority)) {
$vTodo->setAttribute('PRIORITY', $this->priority);
}
if (!empty($this->parent_id) && !empty($this->parent)) {
$vTodo->setAttribute('RELATED-TO', $this->parent->uid);
}
if ($this->private) {
$vTodo->setAttribute('CLASS', 'PRIVATE');
}
if (!empty($this->start)) {
$vTodo->setAttribute('DTSTART', $this->start);
}
if ($this->due) {
$vTodo->setAttribute('DUE', $this->due);
if ($this->alarm) {
if ($v1) {
$vTodo->setAttribute('AALARM', $this->due - $this->alarm * 60);
} else {
$vAlarm = Horde_Icalendar::newComponent('valarm', $vTodo);
$vAlarm->setAttribute('ACTION', 'DISPLAY');
$vAlarm->setAttribute('TRIGGER;VALUE=DURATION', '-PT' . $this->alarm . 'M');
$vTodo->addComponent($vAlarm);
}
}
}
if ($this->completed) {
$vTodo->setAttribute('STATUS', 'COMPLETED');
$vTodo->setAttribute('COMPLETED', $this->completed_date ? $this->completed_date : $_SERVER['REQUEST_TIME']);
} else {
if ($v1) {
$vTodo->setAttribute('STATUS', 'NEEDS ACTION');
} else {
$vTodo->setAttribute('STATUS', 'NEEDS-ACTION');
}
}
if ($this->tags) {
$vTodo->setAttribute('CATEGORIES', implode(', ', $this->tags));
}
/* Get the task's history. */
$created = $modified = null;
try {
$log = $GLOBALS['injector']->getInstance('Horde_History')->getHistory('nag:' . $this->tasklist . ':' . $this->uid);
foreach ($log as $entry) {
switch ($entry['action']) {
case 'add':
$created = $entry['ts'];
break;
case 'modify':
$modified = $entry['ts'];
break;
}
}
} catch (Exception $e) {
}
if (!empty($created)) {
$vTodo->setAttribute($v1 ? 'DCREATED' : 'CREATED', $created);
if (empty($modified)) {
$modified = $created;
}
}
if (!empty($modified)) {
$vTodo->setAttribute('LAST-MODIFIED', $modified);
}
return $vTodo;
}
示例10: _tovTodo
protected function _tovTodo()
{
$iCal = new Horde_Icalendar();
$iCal->setAttribute('METHOD', $this->_method);
$vtodo = Horde_Icalendar::newComponent('vtodo', $iCal);
$vtodo->setAttribute('UID', $this->_guid);
// For REQUESTS, we MUST have the ORGANIZER and an ATTENDEE.
if ($this->_state == self::STATE_ASSIGNERS_COPY || $this->_ownership == self::OWNERSHIP_ASSIGNERS_COPY) {
// When sending a REQUEST the lastUser to edit it should be the
// ORGANIZER. I can't find any of the other properties that work
// consistently.
$vtodo->setAttribute('ORGANIZER', 'mailto: ' . $this->_lastUser);
$list = new Horde_Mail_Rfc822_List($this->_owner);
foreach ($list as $email) {
$vtodo->setAttribute('ATTENDEE', $email, array('ROLE' => 'REQ-PARTICIPANT'));
}
}
if ($this->_due) {
$vtodo->setAttribute('DUE', $this->_due);
}
if ($this->_start) {
$vtodo->setAttribute('DTSTART', $this->_start);
}
if ($this->_completed) {
$vtodo->setAttribute('COMPLETED', $this->_completed);
}
if (isset($this->_percentComplete)) {
$vtodo->setAttribute('PERCENT-COMPLETE', $this->_percentComplete);
}
// Summary is stored in the message data.
$msg = $this->_options['parent']->getMsgInfo();
if ($msg->subject) {
$vtodo->setAttribute('SUMMARY', $msg->subject);
}
// Figure out the body.
if ($this->_bodyPlain) {
$vtodo->setAttribute('DESCRIPTION', $this->_bodyPlain);
} elseif ($this->_bodyHtml) {
$vtodo->setAttribute('DESCRIPTION', Horde_Text_Filter::filter($this->_bodyHtml, 'html2text'));
}
$iCal->addComponent($vtodo);
return array('type' => 'text', 'subtype' => 'calendar', 'name' => $msg->subject ? $msg->subject . '.vtodo' : 'Untitled.vtodo', 'stream' => $iCal->exportvCalendar());
}
示例11: _getInvitation
private function _getInvitation()
{
$vCal = new Horde_Icalendar();
$inv = Horde_Icalendar::newComponent('VEVENT', $vCal);
$inv->setAttribute('METHOD', 'REQUEST');
$inv->setAttribute('UID', '1');
$inv->setAttribute('SUMMARY', 'Test Invitation');
$inv->setAttribute('DESCRIPTION', 'You are invited');
$inv->setAttribute('LOCATION', 'Somewhere');
$inv->setAttribute('ORGANIZER', 'orga@example.org');
$inv->setAttribute('DTSTART', 1222419600);
$inv->setAttribute('DTEND', 1222423200);
return $inv;
}
示例12: get
/**
* Retrieves the free/busy information for a given email address, if any
* information is available.
*
* @param string $email The email address to look for.
* @param boolean $json Whether to return the free/busy data as a simple
* object suitable to be transferred as json.
*
* @return Horde_Icalendar_Vfreebusy|object Free/busy component.
* @throws Kronolith_Exception
*/
public static function get($email, $json = false)
{
$default_domain = empty($GLOBALS['conf']['storage']['default_domain']) ? null : $GLOBALS['conf']['storage']['default_domain'];
$rfc822 = new Horde_Mail_Rfc822();
try {
$res = $rfc822->parseAddressList($email, array('default_domain' => $default_domain));
} catch (Horde_Mail_Exception $e) {
throw new Kronolith_Exception($e);
}
if (!($tmp = $res[0])) {
throw new Kronolith_Exception(_("No valid email address found"));
}
$email = $tmp->bare_address;
/* Check if we can retrieve a VFB from the Free/Busy URL, if one is
* set. */
$url = self::getUrl($email);
if ($url) {
$url = trim($url);
$http = $GLOBALS['injector']->getInstance('Horde_Core_Factory_HttpClient')->create(array('request.verifyPeer' => false));
try {
$response = $http->get($url);
} catch (Horde_Http_Exception $e) {
throw new Kronolith_Exception(sprintf(_("The free/busy url for %s cannot be retrieved."), $email));
}
if ($response->code == 200 && ($data = $response->getBody())) {
// Detect the charset of the iCalendar data.
$contentType = $response->getHeader('Content-Type');
if ($contentType && strpos($contentType, ';') !== false) {
list(, $charset, ) = explode(';', $contentType);
$data = Horde_String::convertCharset($data, trim(str_replace('charset=', '', $charset)), 'UTF-8');
}
$vCal = new Horde_Icalendar();
$vCal->parsevCalendar($data, 'VCALENDAR');
$components = $vCal->getComponents();
$vCal = new Horde_Icalendar();
$vFb = Horde_Icalendar::newComponent('vfreebusy', $vCal);
$vFb->setAttribute('ORGANIZER', $email);
$found = false;
foreach ($components as $component) {
if ($component instanceof Horde_Icalendar_Vfreebusy) {
$found = true;
$vFb->merge($component);
}
}
if ($found) {
// @todo: actually store the results in the storage, so
// that they can be retrieved later. We should store the
// plain iCalendar data though, to avoid versioning
// problems with serialize iCalendar objects.
return $json ? self::toJson($vFb) : $vFb;
}
}
}
/* Check storage driver. */
$storage = $GLOBALS['injector']->getInstance('Kronolith_Factory_Storage')->create();
try {
$fb = $storage->search($email);
return $json ? self::toJson($fb) : $fb;
} catch (Horde_Exception_NotFound $e) {
if ($url) {
throw new Kronolith_Exception(sprintf(_("No free/busy information found at the free/busy url of %s."), $email));
}
throw new Kronolith_Exception(sprintf(_("No free/busy url found for %s."), $email));
}
}
示例13: render
/**
* Renders the fb view
*
* @global Horde_Prefs $prefs
* @param Horde_Date $day The day to render
*
* @return string The html of the rendered fb view.
*/
public function render(Horde_Date $day = null)
{
global $prefs;
$this->_startHour = floor($prefs->getValue('day_hour_start') / 2);
$this->_endHour = floor(($prefs->getValue('day_hour_end') + 1) / 2);
$this->_render($day);
$vCal = new Horde_Icalendar();
/* Required members */
$required = Horde_Icalendar::newComponent('vfreebusy', $vCal);
foreach ($this->_requiredMembers as $member) {
$required->merge($member, false);
}
foreach ($this->_requiredResourceMembers as $member) {
$required->merge($member, false);
}
$required->simplify();
/* Optional members */
$optional = Horde_Icalendar::newComponent('vfreebusy', $vCal);
foreach ($this->_optionalMembers as $member) {
$optional->merge($member, false);
}
foreach ($this->_optionalResourceMembers as $member) {
$optional->merge($member, false);
}
$optional->simplify();
/* Optimal time calculation */
$optimal = Horde_Icalendar::newComponent('vfreebusy', $vCal);
$optimal->merge($required, false);
$optimal->merge($optional);
$template = $GLOBALS['injector']->createInstance('Horde_Template');
$template->set('title', $this->_title());
$html = $template->fetch(KRONOLITH_TEMPLATES . '/fbview/header.html');
$hours_html = $this->_hours();
// Set C locale to avoid localized decimal separators during CSS width
// calculation.
$lc = setlocale(LC_NUMERIC, 0);
setlocale(LC_NUMERIC, 'C');
// Required to attend.
if (count($this->_requiredMembers) > 0) {
$rows = '';
foreach ($this->_requiredMembers as $member) {
$member->simplify();
$blocks = $this->_getBlocks($member, $member->getBusyPeriods(), 'busyblock.html', _("Busy"));
$template = $GLOBALS['injector']->createInstance('Horde_Template');
$template->set('blocks', $blocks);
$template->set('name', htmlspecialchars($member->getName()));
$rows .= $template->fetch(KRONOLITH_TEMPLATES . '/fbview/row.html');
}
$template = $GLOBALS['injector']->createInstance('Horde_Template');
$template->set('title', _("Required Attendees"));
$template->set('rows', $rows);
$template->set('span', count($this->_timeBlocks));
$template->set('hours', $hours_html);
$html .= $template->fetch(KRONOLITH_TEMPLATES . '/fbview/section.html');
}
// Optional to attend.
if (count($this->_optionalMembers) > 0) {
$rows = '';
foreach ($this->_optionalMembers as $member) {
$member->simplify();
$blocks = $this->_getBlocks($member, $member->getBusyPeriods(), 'busyblock.html', _("Busy"));
$template = $GLOBALS['injector']->createInstance('Horde_Template');
$template->set('blocks', $blocks);
$template->set('name', htmlspecialchars($member->getName()));
$rows .= $template->fetch(KRONOLITH_TEMPLATES . '/fbview/row.html');
}
$template = $GLOBALS['injector']->createInstance('Horde_Template');
$template->set('title', _("Optional Attendees"));
$template->set('rows', $rows);
$template->set('span', count($this->_timeBlocks));
$template->set('hours', $hours_html);
$html .= $template->fetch(KRONOLITH_TEMPLATES . '/fbview/section.html');
}
// Resources
if (count($this->_requiredResourceMembers) > 0 || count($this->_optionalResourceMembers) > 0) {
$template = $GLOBALS['injector']->createInstance('Horde_Template');
$rows = '';
foreach ($this->_requiredResourceMembers as $member) {
$member->simplify();
$blocks = $this->_getBlocks($member, $member->getBusyPeriods(), 'busyblock.html', _("Busy"));
$template = $GLOBALS['injector']->createInstance('Horde_Template');
$template->set('blocks', $blocks);
$template->set('name', htmlspecialchars($member->getName()));
$rows .= $template->fetch(KRONOLITH_TEMPLATES . '/fbview/row.html');
}
foreach ($this->_optionalResourceMembers as $member) {
$member->simplify();
$blocks = $this->_getBlocks($member, $member->getBusyPeriods(), 'busyblock.html', _("Busy"));
$template = $GLOBALS['injector']->createInstance('Horde_Template');
$template->set('blocks', $blocks);
$template->set('name', htmlspecialchars($member->getName()));
$rows .= $template->fetch(KRONOLITH_TEMPLATES . '/fbview/row.html');
//.........这里部分代码省略.........
示例14: _toItip
/**
* Generate an iTip from embedded TNEF MEETING data.
*
* @return array see @self::toArray().
*/
protected function _toItip()
{
$iCal = new Horde_Icalendar();
// METHOD
if ($this->_type) {
switch ($this->_type) {
case Horde_Compress_Tnef::MAPI_MEETING_INITIAL:
case Horde_Compress_Tnef::MAPI_MEETING_FULL_UPDATE:
$this->_method = 'REQUEST';
break;
case Horde_Compress_Tnef::MAPI_MEETING_INFO:
$this->_method = 'PUBLISH';
break;
}
}
$iCal->setAttribute('METHOD', $this->_method);
// VEVENT
$vEvent = Horde_Icalendar::newComponent('vevent', $iCal);
if (empty($this->_endUtc)) {
return;
}
$end = clone $this->_endUtc;
$end->sec++;
if ($this->_allday) {
$vEvent->setAttribute('DTSTART', $this->_startUtc, array('VALUE' => 'DATE'));
$vEvent->setAttribute('DTEND', $end, array('VALUE' => 'DATE'));
} else {
$vEvent->setAttribute('DTSTART', $this->_startUtc);
$vEvent->setAttribute('DTEND', $end);
}
$vEvent->setAttribute('DTSTAMP', $_SERVER['REQUEST_TIME']);
$vEvent->setAttribute('UID', $this->_uid);
if ($this->_created) {
$vEvent->setAttribute('CREATED', $this->_created);
}
if ($this->_modified) {
$vEvent->setAttribute('LAST-MODIFIED', $this->_modified);
}
// SUMMARY and DESCRIPTION
$vEvent->setAttribute('SUMMARY', $this->_summary);
if ($this->_description) {
$vEvent->setAttribute('DESCRIPTION', trim($this->_description));
}
// ORGANIZER
if (!$this->_organizer && $this->_lastModifier) {
$email = $this->_lastModifier;
} else {
if ($this->_organizer) {
$email = $this->_organizer;
}
}
if (!empty($email)) {
$vEvent->setAttribute('ORGANIZER', 'mailto:' . $email);
}
// ATTENDEE
if (empty($this->_requiredAttendees) && $this->_method == 'REPLY') {
$this->_requiredAttendees = $this->_from;
}
if (!empty($this->_requiredAttendees)) {
$list = new Horde_Mail_Rfc822_List($this->_requiredAttendees);
foreach ($list as $email) {
$params = array('ROLE' => 'REQ-PARTICIPANT');
if (!empty($this->_partStat)) {
$params['PARTSTAT'] = $this->_partStat;
}
if ($this->_rsvp) {
$params['RSVP'] = 'TRUE';
}
$vEvent->setAttribute('ATTENDEE', $email->bare_address, $params);
}
}
// LOCATION
if ($this->_location) {
$vEvent->setAttribute('LOCATION', $this->_location);
}
// URL
if ($this->_url) {
$vEvent->setAttribute('URL', $this->_url);
}
// RECUR
if (!empty($this->_recurrence['recur'])) {
$rrule = $this->_recurrence['recur']->toRRule20($iCal);
$vEvent->setAttribute('RRULE', $rrule);
}
$iCal->addComponent($vEvent);
$this->_content = $iCal->exportvCalendar();
return array('type' => 'text', 'subtype' => 'calendar', 'name' => $this->_summary, 'stream' => $this->_content);
}
示例15: testTimezone
public function testTimezone()
{
$date = new Horde_Date(array('year' => 2010, 'month' => 1, 'mday' => 1, 'hour' => 1, 'min' => 0, 'sec' => 0), 'UTC');
$ical = new Horde_Icalendar();
$event = Horde_Icalendar::newComponent('vevent', $ical);
$event->setAttribute('UID', 'uid');
$event->setAttribute('DTSTAMP', $date);
$event->setAttribute('DTSTART', $date);
$ical->addComponent($event);
$this->assertEquals('BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//The Horde Project//Horde iCalendar Library//EN
BEGIN:VEVENT
UID:uid
DTSTAMP:20100101T010000Z
DTSTART:20100101T010000Z
END:VEVENT
END:VCALENDAR
', $ical->exportVCalendar());
$ical = new Horde_Icalendar();
$event = Horde_Icalendar::newComponent('vevent', $ical);
$event->setAttribute('UID', 'uid');
$event->setAttribute('DTSTAMP', $date);
$date->setTimezone('Europe/Berlin');
$event->setAttribute('DTSTART', $date, array('TZID' => 'Europe/Berlin'));
$ical->addComponent($event);
$this->assertEquals('BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//The Horde Project//Horde iCalendar Library//EN
BEGIN:VEVENT
UID:uid
DTSTAMP:20100101T010000Z
DTSTART;TZID=Europe/Berlin:20100101T020000
END:VEVENT
END:VCALENDAR
', $ical->exportVCalendar());
$ical = new Horde_Icalendar();
$tz = $ical->parsevCalendar('BEGIN:VCALENDAR
BEGIN:VTIMEZONE
TZID:Europe/Berlin
BEGIN:DAYLIGHT
TZOFFSETFROM:+0100
TZOFFSETTO:+0200
DTSTART:19800406T010000
RRULE:FREQ=YEARLY;BYMONTH=4;BYDAY=1SU;UNTIL=19800406T00000Z
TZNAME:CEST
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETFROM:+0200
TZOFFSETTO:+0100
DTSTART:19800928T010000
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=9;UNTIL=19950923T23000Z
TZNAME:CE-T
END:STANDARD
BEGIN:DAYLIGHT
TZOFFSETFROM:+0100
TZOFFSETTO:+0200
DTSTART:19810329T010000
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=3
TZNAME:CEST
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETFROM:+0200
TZOFFSETTO:+0100
DTSTART:19961027T010000
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10
TZNAME:CE-T
END:STANDARD
END:VTIMEZONE
END:VCALENDAR
');
$tz = $ical->getComponent(0);
$ical = new Horde_Icalendar();
$ical->addComponent($tz);
$event = Horde_Icalendar::newComponent('vevent', $ical);
$event->setAttribute('UID', 'uid');
$event->setAttribute('DTSTAMP', $date);
$date->setTimezone('Europe/Berlin');
$event->setAttribute('DTSTART', $date, array('TZID' => 'Europe/Berlin'));
$ical->addComponent($event);
$ical->addComponent($tz);
$event = Horde_Icalendar::newComponent('vevent', $ical);
$event->setAttribute('UID', 'uid2');
$event->setAttribute('DTSTAMP', $date);
$date->setTimezone('Europe/Berlin');
$start = clone $date;
$start->mday++;
$event->setAttribute('DTSTART', $start, array('TZID' => 'Europe/Berlin'));
$ical->addComponent($event);
$this->assertEquals('BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//The Horde Project//Horde iCalendar Library//EN
BEGIN:VTIMEZONE
TZID:Europe/Berlin
BEGIN:DAYLIGHT
TZOFFSETFROM:+0100
TZOFFSETTO:+0200
DTSTART:19800406T010000
RRULE:FREQ=YEARLY;BYMONTH=4;BYDAY=1SU;UNTIL=19800406T00000Z
TZNAME:CEST
//.........这里部分代码省略.........