grommunio /
grommunio-web
| 1 | <?php |
||
| 2 | require_once(__DIR__ . '/class.listnotifier.php'); |
||
| 3 | |||
| 4 | /** |
||
| 5 | * AppointmentListNotifier |
||
| 6 | * |
||
| 7 | * Generates notifications for changes to the |
||
| 8 | * Appointment Folder contents. |
||
| 9 | */ |
||
| 10 | class AppointmentListNotifier extends ListNotifier |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * Obtain the list of Message Properties which should be returned |
||
| 14 | * to the client when a Message was changed. |
||
| 15 | * @return Array The properties mapping |
||
| 16 | */ |
||
| 17 | protected function getPropertiesList() |
||
| 18 | { |
||
| 19 | return $GLOBALS["properties"]->getAppointmentListProperties(); |
||
| 20 | } |
||
| 21 | |||
| 22 | /** |
||
| 23 | * If an event elsewhere has occurred, it enters in this method. This method |
||
| 24 | * executes one ore more actions, depends on the event. |
||
| 25 | * @param int $event Event. |
||
| 26 | * @param string $entryid Entryid. |
||
| 27 | * @param array $data array of data. |
||
| 28 | */ |
||
| 29 | public function update($event, $entryid, $props) |
||
| 30 | { |
||
| 31 | switch ($event) { |
||
| 32 | case TABLE_SAVE: |
||
| 33 | $data = array(); |
||
| 34 | |||
| 35 | if (isset($props[PR_STORE_ENTRYID])) { |
||
| 36 | $store = $GLOBALS["mapisession"]->openMessageStore($props[PR_STORE_ENTRYID]); |
||
| 37 | $properties = $this->getPropertiesList(); |
||
| 38 | |||
| 39 | $message = null; |
||
| 40 | if (isset($props[PR_ENTRYID])) { |
||
| 41 | $message = $GLOBALS["operations"]->openMessage($store, $props[PR_ENTRYID]); |
||
| 42 | $messageProps = mapi_getprops($message, $properties); |
||
| 43 | } else { |
||
| 44 | $messageProps = array(); |
||
| 45 | } |
||
| 46 | |||
| 47 | if (!isset($props[PR_ENTRYID]) || (isset($messageProps[$properties['recurring']]) && $messageProps[$properties['recurring']])) { |
||
| 48 | |||
| 49 | // An object was created inside this folder for which we don't know the entryid |
||
| 50 | // this can happen when we copy or move a message. Just tell the javascript that |
||
| 51 | // this folder has a new object. |
||
| 52 | // Alternatively the recurrence could have been changed, this means that we should send a notification to the client |
||
| 53 | // to inform the possibility that a different number of occurrences might be inside his view now. |
||
| 54 | $folder = mapi_msgstore_openentry($store, $props[PR_PARENT_ENTRYID]); |
||
| 55 | $folderProps = mapi_getprops($folder, array(PR_ENTRYID, PR_PARENT_ENTRYID, PR_STORE_ENTRYID, PR_CONTENT_COUNT, PR_CONTENT_UNREAD, PR_DISPLAY_NAME)); |
||
| 56 | |||
| 57 | $data = array( |
||
| 58 | "item" => array( |
||
| 59 | array( |
||
| 60 | "content_count" => $folderProps[PR_CONTENT_COUNT], |
||
| 61 | "content_unread" => $folderProps[PR_CONTENT_UNREAD], |
||
| 62 | // Add store_entryid,entryid of folder and display_name of folder |
||
| 63 | // to JSON data in order to refresh the list. |
||
| 64 | "store_entryid" => bin2hex($folderProps[PR_STORE_ENTRYID]), |
||
| 65 | "parent_entryid" => bin2hex($folderProps[PR_PARENT_ENTRYID]), |
||
| 66 | "entryid" => bin2hex($folderProps[PR_ENTRYID]), |
||
| 67 | "display_name" => $folderProps[PR_DISPLAY_NAME] |
||
| 68 | ) |
||
| 69 | ) |
||
| 70 | ); |
||
| 71 | |||
| 72 | $this->addNotificationActionData("newobject", $data); |
||
| 73 | } else { |
||
| 74 | $data = $GLOBALS["operations"]->getMessageProps($store, $message, $properties); |
||
| 75 | /** |
||
| 76 | * We dose't need these properties in AppointmentListNotifier, |
||
| 77 | * because if we send this properties in AppointmentListNotifier |
||
| 78 | * webapp use this properties and try to re-draw appointment in calendar |
||
| 79 | * which look annoying when user drag and drop same appointment frequently |
||
| 80 | * in calendar (related to WA-8897). |
||
| 81 | */ |
||
| 82 | unset($data['props']['startdate']); |
||
| 83 | unset($data['props']['duedate']); |
||
| 84 | unset($data['props']['commonstart']); |
||
| 85 | unset($data['props']['commonend']); |
||
| 86 | $this->addNotificationActionData("update", array( "item" => array($data))); |
||
| 87 | } |
||
| 88 | |||
| 89 | $GLOBALS["bus"]->addData($this->createNotificationResponseData()); |
||
| 90 | } |
||
| 91 | break; |
||
| 92 | case TABLE_DELETE: |
||
| 93 | parent::update($event, $entryid, $props); |
||
| 94 | break; |
||
| 95 | } |
||
| 96 | |||
| 97 | } |
||
| 98 | } |
||
| 99 | ?> |
||
|
0 ignored issues
–
show
|
|||
| 100 |
Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.
A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.