|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* ExpandDistlist Module |
|
4
|
|
|
*/ |
|
5
|
|
|
class ExpandDistlistModule extends Module |
|
6
|
|
|
{ |
|
7
|
|
|
/** |
|
8
|
|
|
* Constructor |
|
9
|
|
|
*/ |
|
10
|
|
|
function __construct($id, $data) |
|
11
|
|
|
{ |
|
12
|
|
|
parent::__construct($id, $data); |
|
13
|
|
|
|
|
14
|
|
|
$this->properties = $GLOBALS["properties"]->getRecipientProperties(); |
|
|
|
|
|
|
15
|
|
|
} |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Executes all the actions in the $data variable. |
|
19
|
|
|
*/ |
|
20
|
|
|
function execute() |
|
21
|
|
|
{ |
|
22
|
|
|
foreach($this->data as $actionType => $action) |
|
23
|
|
|
{ |
|
24
|
|
|
if(isset($actionType)) { |
|
25
|
|
|
try { |
|
26
|
|
|
switch($actionType) |
|
27
|
|
|
{ |
|
28
|
|
|
case 'expand': |
|
29
|
|
|
$this->expand($action); |
|
30
|
|
|
break; |
|
31
|
|
|
default: |
|
32
|
|
|
$this->handleUnknownActionType($actionType); |
|
33
|
|
|
} |
|
34
|
|
|
} catch (MAPIException $e) { |
|
35
|
|
|
$this->processException($e, $actionType); |
|
36
|
|
|
} |
|
37
|
|
|
} |
|
38
|
|
|
} |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* Function which expands a distribution list, optionally expands a distribution list in a distribution list. |
|
43
|
|
|
* Duplicate members will not be be filtered. |
|
44
|
|
|
* |
|
45
|
|
|
* @param string $entryid entryid of distribution list. |
|
46
|
|
|
* @param array $data an array of members in the distribution list. |
|
47
|
|
|
* @param boolean $isRecurse true if we want to expand a distribution list in distribution lists. |
|
48
|
|
|
* @return array $data an array of members in the distribution list. |
|
49
|
|
|
*/ |
|
50
|
|
|
function expandDist($entryid, $data = Array(), $isRecurse = false) |
|
51
|
|
|
{ |
|
52
|
|
|
$heid = bin2hex($entryid); |
|
53
|
|
|
if($GLOBALS['entryid']->hasAddressBookGUID($heid) || $GLOBALS['entryid']->hasAddressBookRecipientGUID($heid)) { |
|
54
|
|
|
$abentry = mapi_ab_openentry($this->addrbook, $entryid); |
|
55
|
|
|
$table = mapi_folder_getcontentstable($abentry, MAPI_DEFERRED_ERRORS); |
|
56
|
|
|
$rows = mapi_table_queryrows($table, $this->properties, 0, (ABITEMDETAILS_MAX_NUM_DISTLIST_MEMBERS > 0) ? ABITEMDETAILS_MAX_NUM_DISTLIST_MEMBERS : 0x7fffffff); |
|
57
|
|
|
/* |
|
58
|
|
|
* To prevent loading a huge list that the browser cannot handle, it is possible to |
|
59
|
|
|
* limit the maximum number of shown items. Note that when the table doesn't |
|
60
|
|
|
* contain the requested number of rows, it will not give any errors and simply |
|
61
|
|
|
* return what is available. |
|
62
|
|
|
* When the limit is 0 or below, then no limit is applied and we use 0x7fffffff |
|
63
|
|
|
* to indicate we want to have all rows from the table. |
|
64
|
|
|
*/ |
|
65
|
|
|
for ($i = 0, $len = count($rows); $i < $len; $i++) { |
|
66
|
|
|
$memberProps = Conversion::mapMAPI2XML($this->properties, $rows[$i]); |
|
67
|
|
|
$isDistlist = $memberProps['props']['object_type'] == MAPI_DISTLIST; |
|
68
|
|
|
if ($isDistlist && $isRecurse == True) { |
|
|
|
|
|
|
69
|
|
|
$data = array_merge($data, $this->expandDist(hex2bin($memberProps['entryid']), array(), $isRecurse)); |
|
70
|
|
|
} else { |
|
71
|
|
|
$data[] = $memberProps; |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
} else { |
|
75
|
|
|
/** |
|
76
|
|
|
* If distribution list was belongs to local/shared folder then |
|
77
|
|
|
* it will expand all members of distribution list. |
|
78
|
|
|
*/ |
|
79
|
|
|
$distlistMembers = $GLOBALS['operations']->expandDistList($heid, $isRecurse); |
|
80
|
|
|
$recipients = array(); |
|
81
|
|
|
foreach($distlistMembers as $distlistMember) { |
|
82
|
|
|
$recipients['props'] = $distlistMember; |
|
83
|
|
|
array_push($data, $recipients); |
|
84
|
|
|
} |
|
85
|
|
|
} |
|
86
|
|
|
return $data; |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* Function which expand the distribution list, sent by the client. This function is used |
|
91
|
|
|
* when a user wants to replace the distribution list with its members |
|
92
|
|
|
* in the to, cc and bcc field. This function retrieve members of that particular distribution list |
|
93
|
|
|
* and send that list back to the client. |
|
94
|
|
|
* @param array $action the action data, sent by the client |
|
95
|
|
|
*/ |
|
96
|
|
|
function expand($action) |
|
97
|
|
|
{ |
|
98
|
|
|
// Get the distribution list entryid from request |
|
99
|
|
|
$entryid = hex2bin($action["entryid"]); |
|
100
|
|
|
$this->addrbook = $GLOBALS["mapisession"]->getAddressbook(); |
|
|
|
|
|
|
101
|
|
|
|
|
102
|
|
|
if($entryid) { |
|
103
|
|
|
$data["results"] = $this->expandDist($entryid, array(), $action['recurse']); |
|
|
|
|
|
|
104
|
|
|
$this->addActionData("expand", $data); |
|
105
|
|
|
$GLOBALS["bus"]->addData($this->getResponseData()); |
|
106
|
|
|
} |
|
107
|
|
|
} |
|
108
|
|
|
} |
|
109
|
|
|
?> |
|
|
|
|
|
|
110
|
|
|
|