本文整理汇总了PHP中Horde_Icalendar::getAttribute方法的典型用法代码示例。如果您正苦于以下问题:PHP Horde_Icalendar::getAttribute方法的具体用法?PHP Horde_Icalendar::getAttribute怎么用?PHP Horde_Icalendar::getAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Horde_Icalendar
的用法示例。
在下文中一共展示了Horde_Icalendar::getAttribute方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testvTodo
/**
* @requires extension bcmath
*/
public function testvTodo()
{
$tnef = Horde_Compress::factory('Tnef');
$mime = Horde_Mime_Part::parseMessage(file_get_contents(__DIR__ . '/fixtures/tnef_task.eml'));
try {
$tnef_data = $tnef->decompress($mime->getPart(2)->getContents());
} catch (Horde_Mapi_Exception $e) {
$this->markTestSkipped('Horde_Mapi is not available');
} catch (Horde_Compress_Exception $e) {
var_dump($e);
}
// Test the generated iCalendar.
$iCal = new Horde_Icalendar();
if (!$iCal->parsevCalendar($tnef_data[0]['stream'])) {
throw new Horde_Compress_Exception(_("There was an error importing the iCalendar data."));
}
$this->assertEquals($iCal->getAttribute('METHOD'), 'REQUEST');
$components = $iCal->getComponents();
if (count($components) == 0) {
throw new Horde_Compress_Exception(_("No iCalendar data was found."));
}
$vTodo = current($components);
$this->assertEquals($vTodo->getAttribute('SUMMARY'), 'Test Task');
$this->assertEquals($vTodo->getAttribute('UID'), 'EDF71E6FA6FB69A79D79FE1D6DCDBBD300000000DFD9B6FB');
$this->assertEquals($vTodo->getAttribute('ATTENDEE'), 'Michael Rubinsky <mrubinsk@horde.org>');
$params = $vTodo->getAttribute('ATTENDEE', true);
if (!$params) {
throw new Horde_Compress_Exception('Could not find expected parameters.');
}
$this->assertEquals($params[0]['ROLE'], 'REQ-PARTICIPANT');
$this->assertEquals($vTodo->getAttribute('ORGANIZER'), 'mailto: mike@theupstairsroom.com');
}
示例2: _buildMailMessage
//.........这里部分代码省略.........
$ids = array_keys($imap_message->contentTypeMap());
reset($ids);
$part1_id = next($ids);
$part2_id = Horde_Mime::mimeIdArithmetic($part1_id, 'next');
$lines = explode(chr(13), $imap_message->getBodyPart($part2_id, array('decode' => true)));
switch ($part->getContentTypeParameter('report-type')) {
case 'delivery-status':
foreach ($lines as $line) {
if (strpos(trim($line), 'Action:') === 0) {
switch (trim(substr(trim($line), 7))) {
case 'failed':
$eas_message->messageclass = 'REPORT.IPM.NOTE.NDR';
break 2;
case 'delayed':
$eas_message->messageclass = 'REPORT.IPM.NOTE.DELAYED';
break 2;
case 'delivered':
$eas_message->messageclass = 'REPORT.IPM.NOTE.DR';
break 2;
}
}
}
break;
case 'disposition-notification':
foreach ($lines as $line) {
if (strpos(trim($line), 'Disposition:') === 0) {
if (strpos($line, 'displayed') !== false) {
$eas_message->messageclass = 'REPORT.IPM.NOTE.IPNRN';
} elseif (strpos($line, 'deleted') !== false) {
$eas_message->messageclass = 'REPORT.IPM.NOTE.IPNNRN';
}
break;
}
}
}
}
$part = null;
// Check for meeting requests and POOMMAIL_FLAG data
if ($version >= Horde_ActiveSync::VERSION_TWELVE) {
$eas_message->contentclass = 'urn:content-classes:message';
if ($mime_part = $imap_message->hasiCalendar()) {
$data = Horde_ActiveSync_Utils::ensureUtf8($mime_part->getContents(), $mime_part->getCharset());
$vCal = new Horde_Icalendar();
if ($vCal->parsevCalendar($data, 'VCALENDAR', $mime_part->getCharset())) {
$classes = $vCal->getComponentClasses();
} else {
$classes = array();
}
if (!empty($classes['horde_icalendar_vevent'])) {
try {
$method = $vCal->getAttribute('METHOD');
$eas_message->contentclass = 'urn:content-classes:calendarmessage';
} catch (Horde_Icalendar_Exception $e) {
}
switch ($method) {
case 'REQUEST':
case 'PUBLISH':
$eas_message->messageclass = 'IPM.Schedule.Meeting.Request';
$mtg = Horde_ActiveSync::messageFactory('MeetingRequest');
$mtg->fromvEvent($vCal);
$eas_message->meetingrequest = $mtg;
break;
case 'REPLY':
try {
$reply_status = $this->_getiTipStatus($vCal);
switch ($reply_status) {
case 'ACCEPTED':
$eas_message->messageclass = 'IPM.Schedule.Meeting.Resp.Pos';
break;
case 'DECLINED':
$eas_message->messageclass = 'IPM.Schedule.Meeting.Resp.Neg';
break;
case 'TENTATIVE':
$eas_message->messageclass = 'IPM.Schedule.Meeting.Resp.Tent';
}
$mtg = Horde_ActiveSync::messageFactory('MeetingRequest');
$mtg->fromvEvent($vCal);
$eas_message->meetingrequest = $mtg;
} catch (Horde_ActiveSync_Exception $e) {
$this->_logger->err($e->getMessage());
}
}
}
}
if ($imap_message->getFlag(Horde_Imap_Client::FLAG_FLAGGED)) {
$poommail_flag = Horde_ActiveSync::messageFactory('Flag');
$poommail_flag->subject = $imap_message->getSubject();
$poommail_flag->flagstatus = Horde_ActiveSync_Message_Flag::FLAG_STATUS_ACTIVE;
$poommail_flag->flagtype = Horde_Imap_Client::FLAG_FLAGGED;
$eas_message->flag = $poommail_flag;
}
}
if ($version >= Horde_ActiveSync::VERSION_FOURTEEN) {
$eas_message->messageid = $imap_message->getHeaders()->getValue('Message-ID');
$eas_message->forwarded = $imap_message->getFlag(Horde_Imap_Client::FLAG_FORWARDED);
$eas_message->answered = $imap_message->getFlag(Horde_Imap_Client::FLAG_ANSWERED);
}
$imap_message = null;
return $eas_message;
}
示例3: _handlevEventRecurrence
/**
* Handle parsing recurrence related fields.
*
* @param Horde_Icalendar $vEvent
* @throws Kronolith_Exception
*/
protected function _handlevEventRecurrence($vEvent)
{
// Recurrence.
try {
$rrule = $vEvent->getAttribute('RRULE');
if (!is_array($rrule)) {
$this->recurrence = new Horde_Date_Recurrence($this->start);
if (strpos($rrule, '=') !== false) {
$this->recurrence->fromRRule20($rrule);
} else {
$this->recurrence->fromRRule10($rrule);
}
/* Delete all existing exceptions to this event if it
* already exists */
if (!empty($this->uid)) {
$kronolith_driver = Kronolith::getDriver(null, $this->calendar);
$search = new StdClass();
$search->start = $this->recurrence->getRecurStart();
$search->end = $this->recurrence->getRecurEnd();
$search->baseid = $this->uid;
$results = $kronolith_driver->search($search);
foreach ($results as $days) {
foreach ($days as $exception) {
$kronolith_driver->deleteEvent($exception->id);
}
}
}
// Exceptions. EXDATE represents deleted events, just add the
// exception, no new event is needed.
$exdates = $vEvent->getAttributeValues('EXDATE');
if (is_array($exdates)) {
foreach ($exdates as $exdate) {
if (is_array($exdate)) {
$this->recurrence->addException((int) $exdate['year'], (int) $exdate['month'], (int) $exdate['mday']);
}
}
}
}
} catch (Horde_Icalendar_Exception $e) {
}
// RECURRENCE-ID indicates that this event represents an exception
try {
$recurrenceid = $vEvent->getAttribute('RECURRENCE-ID');
$kronolith_driver = Kronolith::getDriver(null, $this->calendar);
$originaldt = new Horde_Date($recurrenceid);
$this->exceptionoriginaldate = $originaldt;
$this->baseid = $this->uid;
$this->uid = null;
try {
$originalEvent = $kronolith_driver->getByUID($this->baseid);
$originalEvent->recurrence->addException($originaldt->format('Y'), $originaldt->format('m'), $originaldt->format('d'));
$originalEvent->save();
} catch (Horde_Exception_NotFound $e) {
throw new Kronolith_Exception(_("Unable to locate original event series."));
}
} catch (Horde_Icalendar_Exception $e) {
}
}
示例4: newComponent
/**
* Return a reference to a new component.
*
* @param string $type The type of component to return
* @param Horde_Icalendar $container A container that this component
* will be associated with.
*
* @return object Reference to a Horde_Icalendar_* object as specified.
*/
public static function newComponent($type, $container)
{
$type = Horde_String::lower($type);
$class = __CLASS__ . '_' . Horde_String::ucfirst($type);
if (class_exists($class)) {
$component = new $class();
if ($container !== false) {
$component->_container = $container;
// Use version of container, not default set by component
// constructor.
$component->setVersion($container->getAttribute('VERSION'));
}
} else {
// Should return an dummy x-unknown type class here.
$component = false;
}
return $component;
}
示例5: _renderInline
/**
* Return the rendered inline version of the Horde_Mime_Part object.
*
* @return array See parent::render().
*/
protected function _renderInline()
{
$GLOBALS['page_output']->growler = true;
$data = $this->_mimepart->getContents();
$mime_id = $this->_mimepart->getMimeId();
// Parse the iCal file.
$vCal = new Horde_Icalendar();
if (!$vCal->parsevCalendar($data, 'VCALENDAR', $this->_mimepart->getCharset())) {
$status = new IMP_Mime_Status($this->_mimepart, _("The calendar data is invalid"));
$status->action(IMP_Mime_Status::ERROR);
return array($mime_id => array('data' => '', 'status' => $status, 'type' => 'text/html; charset=UTF-8'));
}
// Check if we got vcard data with the wrong vcalendar mime type.
$imp_contents = $this->getConfigParam('imp_contents');
$c = $vCal->getComponentClasses();
if (count($c) == 1 && !empty($c['horde_icalendar_vcard'])) {
return $imp_contents->renderMIMEPart($mime_id, IMP_Contents::RENDER_INLINE, array('type' => 'text/x-vcard'));
}
$imple = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Imple')->create('IMP_Ajax_Imple_ItipRequest', array('mime_id' => $mime_id, 'muid' => strval($imp_contents->getIndicesOb())));
// Get the method type.
try {
$method = $vCal->getAttribute('METHOD');
} catch (Horde_Icalendar_Exception $e) {
$method = '';
}
$out = array();
$exceptions = array();
$components = $vCal->getComponents();
foreach ($components as $key => $component) {
switch ($component->getType()) {
case 'vEvent':
try {
if ($component->getAttribute('RECURRENCE-ID')) {
$exceptions[] = $this->_vEvent($component, $key, $method, $components);
}
} catch (Horde_ICalendar_Exception $e) {
$out[] = $this->_vEvent($component, $key, $method, $components);
}
break;
case 'vTodo':
$out[] = $this->_vTodo($component, $key, $method);
break;
case 'vTimeZone':
// Ignore them.
break;
case 'vFreebusy':
$out[] = $this->_vFreebusy($component, $key, $method);
break;
// @todo: handle stray vcards here as well.
// @todo: handle stray vcards here as well.
default:
$out[] = sprintf(_("Unhandled component of type: %s"), $component->getType());
break;
}
}
// If we don't have any other parts, any exceptions should be shown
// since this is likely an update to a series instance such as a
// cancellation etc...
if (empty($out)) {
$out = $exceptions;
}
$view = $this->_getViewOb();
$view->formid = $imple->getDomId();
$view->out = implode('', $out);
return array($mime_id => array('data' => $view->render('base'), 'type' => 'text/html; charset=UTF-8'));
}
示例6: _handle
/**
* Variables required in form input:
* - identity (TODO: ? Code uses it, but it is never set anywhere)
* - imple_submit: itip_action(s)
* - mime_id
* - muid
*
* @return boolean True on success.
*/
protected function _handle(Horde_Variables $vars)
{
global $injector, $notification, $registry;
$actions = (array) $vars->imple_submit;
$result = false;
$vCal = new Horde_Icalendar();
/* Retrieve the calendar data from the message. */
try {
$contents = $injector->getInstance('IMP_Factory_Contents')->create(new IMP_Indices_Mailbox($vars));
if (!($mime_part = $contents->getMimePart($vars->mime_id))) {
throw new IMP_Exception(_("Cannot retrieve calendar data from message."));
}
if ($vars->ctype) {
$mime_part = clone $mime_part;
$mime_part->setType($vars->ctype);
}
if (!$vCal->parsevCalendar($mime_part->getContents(), 'VCALENDAR', $mime_part->getCharset())) {
throw new IMP_Exception(_("The calendar data is invalid"));
}
$components = $vCal->getComponents();
$v1 = $vCal->getAttribute('VERSION') == '1.0';
} catch (Exception $e) {
$notification->push($e, 'horde.error');
$actions = array();
}
foreach ($actions as $key => $action) {
$pos = strpos($key, '[');
$key = substr($key, $pos + 1, strlen($key) - $pos - 2);
switch ($action) {
case 'delete':
// vEvent cancellation.
if ($registry->hasMethod('calendar/delete')) {
$guid = $components[$key]->getAttributeSingle('UID');
$recurrenceId = null;
$range = null;
try {
// This is a cancellation of a recurring event instance.
$recurrenceId = $components[$key]->getAttributeSingle('RECURRENCE-ID');
$atts = $components[$key]->getAttribute('RECURRENCE-ID', true);
foreach ($atts as $att) {
if (array_key_exists('RANGE', $att)) {
$range = $att['RANGE'];
}
}
} catch (Horde_Icalendar_Exception $e) {
}
try {
$registry->call('calendar/delete', array($guid, $recurrenceId, $range));
$notification->push(_("Event successfully deleted."), 'horde.success');
$result = true;
} catch (Horde_Exception $e) {
$notification->push(sprintf(_("There was an error deleting the event: %s"), $e->getMessage()), 'horde.error');
}
} else {
$notification->push(_("This action is not supported."), 'horde.warning');
}
break;
case 'update':
// vEvent reply.
// vTodo reply.
switch ($components[$key]->getType()) {
case 'vEvent':
if ($registry->hasMethod('calendar/updateAttendee')) {
try {
if ($tmp = $contents->getHeader()->getHeader('from')) {
$registry->call('calendar/updateAttendee', array($components[$key], $tmp->getAddressList(true)->first()->bare_address));
$notification->push(_("Respondent Status Updated."), 'horde.success');
$result = true;
}
} catch (Horde_Exception $e) {
$notification->push(sprintf(_("There was an error updating the event: %s"), $e->getMessage()), 'horde.error');
}
} else {
$notification->push(_("This action is not supported."), 'horde.warning');
}
break;
case 'vTodo':
if ($registry->hasMethod('tasks/updateAttendee')) {
try {
if ($tmp = $contents->getHeader()->getHeader('from')) {
$registry->call('tasks/updateAttendee', array($components[$key], $tmp->getAddressList(true)->first()->bare_address));
$notification->push(_("Respondent Status Updated."), 'horde.success');
$result = true;
}
} catch (Horde_Exception $e) {
$notification->push(sprintf(_("There was an error updating the task: %s"), $e->getMessage()), 'horde.error');
}
} else {
$notification->push(_("This action is not supported."), 'horde.warning');
}
break;
//.........这里部分代码省略.........
示例7: _handlevEventRecurrence
/**
* Parses the various exception related fields. Only deal with the EXDATE
* field here.
*
* @param Horde_Icalendar $vEvent The vEvent part.
*/
protected function _handlevEventRecurrence($vEvent)
{
// Recurrence.
try {
$rrule = $vEvent->getAttribute('RRULE');
if (!is_array($rrule)) {
$this->recurrence = new Horde_Date_Recurrence($this->start);
if (strpos($rrule, '=') !== false) {
$this->recurrence->fromRRule20($rrule);
} else {
$this->recurrence->fromRRule10($rrule);
}
// Exceptions. EXDATE represents deleted events, just add the
// exception, no new event is needed.
$exdates = $vEvent->getAttributeValues('EXDATE');
if (is_array($exdates)) {
foreach ($exdates as $exdate) {
if (is_array($exdate)) {
$this->recurrence->addException((int) $exdate['year'], (int) $exdate['month'], (int) $exdate['mday']);
}
}
}
}
} catch (Horde_Icalendar_Exception $e) {
}
}
示例8: _handlevEventRecurrence
/**
* Handle parsing recurrence related fields.
*
* @param Horde_Icalendar $vEvent
* @throws Kronolith_Exception
*/
protected function _handlevEventRecurrence($vEvent)
{
// Recurrence.
try {
$rrule = $vEvent->getAttribute('RRULE');
if (!is_array($rrule)) {
$this->recurrence = new Horde_Date_Recurrence($this->start);
if (strpos($rrule, '=') !== false) {
$this->recurrence->fromRRule20($rrule);
} else {
$this->recurrence->fromRRule10($rrule);
}
// Exceptions. EXDATE represents deleted events, just add the
// exception, no new event is needed.
$exdates = $vEvent->getAttributeValues('EXDATE');
if (is_array($exdates)) {
foreach ($exdates as $exdate) {
if (is_array($exdate)) {
$this->recurrence->addException((int) $exdate['year'], (int) $exdate['month'], (int) $exdate['mday']);
}
}
}
}
} catch (Horde_Icalendar_Exception $e) {
}
// RECURRENCE-ID indicates that this event represents an exception
try {
$this->recurrenceid = $vEvent->getAttribute('RECURRENCE-ID');
$originaldt = new Horde_Date($this->recurrenceid);
$this->exceptionoriginaldate = $originaldt;
$this->baseid = $this->uid;
$this->uid = null;
try {
$originalEvent = $this->getDriver()->getByUID($this->baseid);
$originalEvent->recurrence->addException($originaldt->format('Y'), $originaldt->format('m'), $originaldt->format('d'));
$originalEvent->save();
} catch (Horde_Exception_NotFound $e) {
throw new Kronolith_Exception(_("Unable to locate original event series."));
}
} catch (Horde_Icalendar_Exception $e) {
}
}