本文整理汇总了PHP中Kronolith::responseFromICal方法的典型用法代码示例。如果您正苦于以下问题:PHP Kronolith::responseFromICal方法的具体用法?PHP Kronolith::responseFromICal怎么用?PHP Kronolith::responseFromICal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Kronolith
的用法示例。
在下文中一共展示了Kronolith::responseFromICal方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateAttendee
/**
* Updates an attendee's response status for a specified event.
*
* @param Horde_Icalendar_Vevent $response A Horde_Icalendar_Vevent
* object, with a valid UID
* attribute that points to an
* existing event. This is
* typically the vEvent portion
* of an iTip meeting-request
* response, with the attendee's
* response in an ATTENDEE
* parameter.
* @param string $sender The email address of the
* person initiating the
* update. Attendees are only
* updated if this address
* matches.
*
* @throws Kronolith_Exception
*/
public function updateAttendee($response, $sender = null)
{
try {
$uid = $response->getAttribute('UID');
} catch (Horde_Icalendar_Exception $e) {
throw new Kronolith_Exception($e);
}
$events = Kronolith::getDriver()->getByUID($uid, null, true);
/* First try the user's own calendars. */
$ownerCalendars = Kronolith::listInternalCalendars(true, Horde_Perms::EDIT);
$event = null;
foreach ($events as $ev) {
if (isset($ownerCalendars[$ev->calendar])) {
$event = $ev;
break;
}
}
/* If not successful, try all calendars the user has access to. */
if (empty($event)) {
$editableCalendars = Kronolith::listInternalCalendars(false, Horde_Perms::EDIT);
foreach ($events as $ev) {
if (isset($editableCalendars[$ev->calendar])) {
$event = $ev;
break;
}
}
}
if (empty($event) || $event->private && $event->creator != $GLOBALS['registry']->getAuth()) {
throw new Horde_Exception_PermissionDenied();
}
$atnames = $response->getAttribute('ATTENDEE');
if (!is_array($atnames)) {
$atnames = array($atnames);
}
$atparms = $response->getAttribute('ATTENDEE', true);
$found = false;
$error = _("No attendees have been updated because none of the provided email addresses have been found in the event's attendees list.");
foreach ($atnames as $index => $attendee) {
if ($response->getAttribute('VERSION') < 2) {
$addr_ob = new Horde_Mail_Rfc822_Address($attendee);
if (!$addr_ob->valid) {
continue;
}
$attendee = $addr_ob->bare_address;
$name = $addr_ob->personal;
} else {
$attendee = str_ireplace('mailto:', '', $attendee);
$name = isset($atparms[$index]['CN']) ? $atparms[$index]['CN'] : null;
}
if ($event->hasAttendee($attendee)) {
if (is_null($sender) || $sender == $attendee) {
$event->addAttendee($attendee, Kronolith::PART_IGNORE, Kronolith::responseFromICal($atparms[$index]['PARTSTAT']), $name);
$found = true;
} else {
$error = _("The attendee hasn't been updated because the update was not sent from the attendee.");
}
}
}
$event->save();
if (!$found) {
throw new Kronolith_Exception($error);
}
}