Import an event into the user's default calendar.
public calendar_import ( Horde_ActiveSync_Message_Appointment $content, string $calendar = null ) : string | ||
$content | Horde_ActiveSync_Message_Appointment | The event content |
$calendar | string | The calendar id. @since 2.12.0 |
리턴 | string | The event's UID. |
/** * Add/Edit a message * * @param string $folderid The server id of the message's folder. * @param string $id The server's uid for the message if this is a * change to an existing message, false if new. * @param Horde_ActiveSync_Message_Base $message The activesync message. * @param Horde_ActiveSync_Device $device The device information * @since 2.5.0 * * @return array|boolean A stat array if successful, otherwise false. * Contains the following keys: * - id: (mixed) The UID of the message/item. * - mod: (mixed) A value to indicate the last modification. * - flags: (array) an empty array if no flag changes. * - categories: (array|boolean) false if no changes. */ public function changeMessage($folderid, $id, Horde_ActiveSync_Message_Base $message, $device) { $this->_logger->info(sprintf("[%s] Horde_Core_ActiveSync_Driver::changeMessage(%s, %s ...)", $this->_pid, $folderid, $id)); ob_start(); $folder_split = $this->_parseFolderId($folderid); if (is_array($folder_split)) { $folder_class = $folder_split[self::FOLDER_PART_CLASS]; $server_id = $folder_split[self::FOLDER_PART_ID]; } else { $folder_class = $folder_split; $server_id = null; } $stat = false; switch ($folder_class) { case Horde_ActiveSync::CLASS_CALENDAR: if (!$id) { try { $id = $this->_connector->calendar_import($message, $server_id); } catch (Horde_Exception $e) { $this->_logger->err($e->getMessage()); $this->_endBuffer(); return false; } $stat = array('mod' => $this->getSyncStamp($folderid), 'id' => $id, 'flags' => 1); } else { // ActiveSync messages do NOT contain the serverUID value, put // it in ourselves so we can have it during import/change. $message->setServerUID($id); if (!empty($device->supported[self::APPOINTMENTS_FOLDER_UID])) { $message->setSupported($device->supported[self::APPOINTMENTS_FOLDER_UID]); } try { $this->_connector->calendar_replace($id, $message); } catch (Horde_Exception $e) { $this->_logger->err($e->getMessage()); $this->_endBuffer(); return false; } $stat = $this->_smartStatMessage($folderid, $id, false); } break; case Horde_ActiveSync::CLASS_CONTACTS: if (!$id) { try { $id = $this->_connector->contacts_import($message, $server_id); } catch (Horde_Exception $e) { $this->_logger->err($e->getMessage()); $this->_endBuffer(); return false; } $stat = array('mod' => $this->getSyncStamp($folderid), 'id' => $id, 'flags' => 1); } else { if (!empty($device->supported[self::CONTACTS_FOLDER_UID])) { $message->setSupported($device->supported[self::CONTACTS_FOLDER_UID]); } try { $this->_connector->contacts_replace($id, $message); } catch (Horde_Exception $e) { $this->_logger->err($e->getMessage()); $this->_endBuffer(); return false; } $stat = $this->_smartStatMessage($folderid, $id, false); } break; case Horde_ActiveSync::CLASS_TASKS: if (!$id) { try { $id = $this->_connector->tasks_import($message, $server_id); } catch (Horde_Exception $e) { $this->_logger->err($e->getMessage()); $this->_endBuffer(); return false; } $stat = array('mod' => $this->getSyncStamp($folderid), 'id' => $id, 'flags' => 1); } else { if (!empty($device->supported[self::TASKS_FOLDER_UID])) { $message->setSupported($device->supported[self::TASKS_FOLDER_UID]); } try { $this->_connector->tasks_replace($id, $message); } catch (Horde_Exception $e) { $this->_logger->err($e->getMessage()); $this->_endBuffer(); return false; } $stat = $this->_smartStatMessage($folderid, $id, false); } break; case Horde_ActiveSync::CLASS_NOTES: if (!$id) { try { $id = $this->_connector->notes_import($message, $server_id); } catch (Horde_Exception $e) { $this->_logger->err($e->getMessage()); $this->_endBuffer(); return false; } $stat = array('mod' => $this->getSyncStamp($folderid), 'id' => $id, 'flags' => 1); } else { if (!empty($device->supported[self::NOTES_FOLDER_UID])) { $message->setSupported($device->supported[self::NOTES_FOLDER_UID]); } try { $this->_connector->notes_replace($id, $message); } catch (Horde_Exception $e) { $this->_logger->err($e->getMessage()); $this->_endBuffer(); return false; } $stat = $this->_smartStatMessage($folderid, $id, false); } break; default: if ($message instanceof Horde_ActiveSync_Message_Mail) { $stat = array('id' => $id, 'mod' => 0, 'flags' => array(), 'categories' => false); if ($message->read !== '') { $this->setReadFlag($folderid, $id, $message->read); $stat['flags'] = array_merge($stat['flags'], array('read' => $message->read)); } if ($message->propertyExists('flag')) { if (!$message->flag) { $message->flag = Horde_ActiveSync::messageFactory('Flag'); } $this->_imap->setMessageFlag($folderid, $id, $message->flag); $stat['flags'] = array_merge($stat['flags'], array('flagged' => $message->flag->flagstatus)); } if ($message->propertyExists('categories')) { // We *try* to make sure the category is added as a custom // IMAP flag. This might fail in some edge cases, like e.g. // with non-ascii characters. $this->_connector->mail_ensureMessageFlags($message->categories); $this->_imap->categoriesToFlags($folderid, $message->categories, $id); $stat['categories'] = $message->categories; } } else { $this->_endBuffer(); return false; } } $this->_endBuffer(); return $stat; }