|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* ListNotifier |
|
4
|
|
|
* |
|
5
|
|
|
* Generates notifications for changes to the |
|
6
|
|
|
* folder contents. |
|
7
|
|
|
*/ |
|
8
|
|
|
class ListNotifier extends Notifier |
|
9
|
|
|
{ |
|
10
|
|
|
/** |
|
11
|
|
|
* @return Number Return the bitmask of events which are handled |
|
12
|
|
|
* by this notifier. The bitmask can consist of the |
|
13
|
|
|
* OBJECT_SAVE, OBJECT_DELETE, TABLE_SAVE, TABLE_DELETE, REQUEST_START and REQUEST_END flags |
|
14
|
|
|
*/ |
|
15
|
|
|
public function getEvents() |
|
16
|
|
|
{ |
|
17
|
|
|
return OBJECT_SAVE | TABLE_SAVE | TABLE_DELETE; |
|
18
|
|
|
} |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Obtain the list of Message Properties which should be returned |
|
22
|
|
|
* to the client when a Message was changed. |
|
23
|
|
|
* @return Array The properties mapping |
|
24
|
|
|
*/ |
|
25
|
|
|
protected function getPropertiesList() |
|
26
|
|
|
{ |
|
27
|
|
|
return Array(); |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* If an event elsewhere has occurred, it enters in this method. This method |
|
32
|
|
|
* executes one ore more actions, depends on the event. |
|
33
|
|
|
* @param int $event Event. |
|
34
|
|
|
* @param string $entryid Entryid. |
|
35
|
|
|
* @param array $data array of data. |
|
36
|
|
|
*/ |
|
37
|
|
|
public function update($event, $entryid, $props) |
|
38
|
|
|
{ |
|
39
|
|
|
switch ($event) { |
|
40
|
|
|
case TABLE_SAVE: |
|
41
|
|
|
$data = array(); |
|
42
|
|
|
|
|
43
|
|
|
if (isset($props[PR_STORE_ENTRYID])) { |
|
44
|
|
|
$store = $GLOBALS["mapisession"]->openMessageStore($props[PR_STORE_ENTRYID]); |
|
45
|
|
|
|
|
46
|
|
|
if (isset($props[PR_ENTRYID])) { |
|
47
|
|
|
$properties = $this->getPropertiesList(); |
|
48
|
|
|
$data = $GLOBALS["operations"]->getMessageProps($store, $GLOBALS["operations"]->openMessage($store, $props[PR_ENTRYID]), $properties); |
|
49
|
|
|
$this->addNotificationActionData("update", array( "item" => array($data) )); |
|
50
|
|
|
} else if (isset($props[PR_PARENT_ENTRYID])) { |
|
51
|
|
|
// An object was created inside this folder for which we don't know the entryid |
|
52
|
|
|
// this can happen when we copy or move a message. Just tell the javascript that |
|
53
|
|
|
// this folder has a new object. |
|
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
|
|
|
} |
|
74
|
|
|
} |
|
75
|
|
|
break; |
|
76
|
|
|
case TABLE_DELETE: |
|
77
|
|
|
$folderEntryID = isset($props[PR_PARENT_ENTRYID]) ? $props[PR_PARENT_ENTRYID] : false; |
|
78
|
|
|
|
|
79
|
|
|
if (isset($props[PR_ENTRYID]) && $folderEntryID) { |
|
80
|
|
|
$data = array(); |
|
81
|
|
|
$data["parent_entryid"] = bin2hex($folderEntryID); |
|
82
|
|
|
|
|
83
|
|
|
if (is_array($props[PR_ENTRYID])) { |
|
84
|
|
|
$data["entryid"] = array(); |
|
85
|
|
|
|
|
86
|
|
|
foreach ($props[PR_ENTRYID] as $entryid) { |
|
|
|
|
|
|
87
|
|
|
array_push($data["entryid"], bin2hex($entryid)); |
|
88
|
|
|
} |
|
89
|
|
|
} else { |
|
90
|
|
|
$data["entryid"] = bin2hex($props[PR_ENTRYID]); |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
$this->addNotificationActionData("delete", array( "item" => array($data) )); |
|
94
|
|
|
} |
|
95
|
|
|
break; |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
$GLOBALS["bus"]->addData($this->createNotificationResponseData()); |
|
99
|
|
|
} |
|
100
|
|
|
} |
|
101
|
|
|
?> |
|
|
|
|
|
|
102
|
|
|
|