當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Kronolith::responseFromICal方法代碼示例

本文整理匯總了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);
     }
 }
開發者ID:horde,項目名稱:horde,代碼行數:83,代碼來源:Api.php


注:本文中的Kronolith::responseFromICal方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。