1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12:
13:
14: 15: 16: 17: 18: 19: 20: 21: 22:
23: class IMP_Message_Ui
24: {
25: 26: 27: 28: 29:
30: public function ()
31: {
32: return array(
33: 'date' => _("Date"),
34: 'from' => _("From"),
35: 'to' => _("To"),
36: 'cc' => _("Cc"),
37: 'bcc' => _("Bcc"),
38: 'reply-to' => _("Reply-To"),
39: 'subject' => _("Subject")
40: );
41: }
42:
43: 44: 45: 46: 47:
48: public function ()
49: {
50: $user_hdrs = $GLOBALS['prefs']->getValue('mail_hdr');
51:
52: 53:
54: if (is_array($user_hdrs)) {
55: $user_hdrs = implode("\n", $user_hdrs);
56: }
57: $user_hdrs = trim($user_hdrs);
58: if (empty($user_hdrs)) {
59: return array();
60: }
61:
62: $user_hdrs = array_filter(array_keys(array_flip(array_map('trim', preg_split("/[\n\r]+/", str_replace(':', '', $user_hdrs))))));
63: natcasesort($user_hdrs);
64:
65: return $user_hdrs;
66: }
67:
68: 69: 70: 71: 72: 73: 74: 75: 76:
77: public function MDNCheck(
78: IMP_Indices $indices, $headers, $confirmed = false
79: )
80: {
81: global $conf, $injector, $prefs;
82:
83: $maillog = $injector->getInstance('IMP_Maillog');
84: $pref_val = $prefs->getValue('send_mdn');
85:
86: list($mbox, ) = $indices->getSingle();
87:
88: if (!$pref_val || $mbox->readonly) {
89: return false;
90: }
91:
92:
93: $mdn = new Horde_Mime_Mdn($headers);
94: if (!($return_addr = $mdn->getMdnReturnAddr())) {
95: return false;
96: }
97:
98: $log_msg = new IMP_Maillog_Message($indices);
99: if (count($maillog->getLog($log_msg, array('forward', 'redirect', 'reply_all', 'reply_list', 'reply')))) {
100: return false;
101: }
102:
103:
104: if (!$confirmed &&
105: ((intval($pref_val) == 1) ||
106: $mdn->userConfirmationNeeded())) {
107: try {
108: if ($injector->getInstance('Horde_Core_Hooks')->callHook('mdn_check', 'imp', array($headers))) {
109: return true;
110: }
111: } catch (Horde_Exception_HookNotSet $e) {
112: return true;
113: }
114: }
115:
116:
117: $success = false;
118: try {
119: $mdn->generate(
120: false,
121: $confirmed,
122: 'displayed',
123: $conf['server']['name'],
124: $injector->getInstance('IMP_Mail'),
125: array(
126: 'charset' => 'UTF-8',
127: 'from_addr' => $injector->getInstance('Horde_Core_Factory_Identity')->create()->getDefaultFromAddress()
128: )
129: );
130:
131: $maillog->log($log_msg, new IMP_Maillog_Log_Mdn());
132:
133: $success = true;
134: } catch (Exception $e) {}
135:
136: $injector->getInstance('IMP_Sentmail')->log(
137: IMP_Sentmail::MDN,
138: '',
139: $return_addr,
140: $success
141: );
142:
143: return false;
144: }
145:
146: 147: 148: 149: 150: 151: 152:
153: public function getListInformation($headers)
154: {
155: $ret = array('exists' => false, 'reply_list' => null);
156:
157: if ($headers->listHeadersExist()) {
158: $ret['exists'] = true;
159:
160: 161:
162: if ($val = $headers->getValue('list-post')) {
163: foreach ($GLOBALS['injector']->getInstance('Horde_ListHeaders')->parse('list-post', $val) as $val2) {
164: if ($val2 instanceof Horde_ListHeaders_NoPost) {
165: break;
166: } elseif (stripos($val2->url, 'mailto:') === 0) {
167: $ret['reply_list'] = substr($val2->url, 7);
168: break;
169: }
170: }
171: }
172: }
173:
174: return $ret;
175: }
176:
177: 178: 179: 180: 181: 182: 183: 184: 185: 186:
187: public function buildAddressLinks(Horde_Mail_Rfc822_List $addrlist,
188: $addURL = null, $link = true)
189: {
190: global $prefs, $registry;
191:
192: $add_link = null;
193: $addr_array = array();
194: $minimal = ($registry->getView() == Horde_Registry::VIEW_MINIMAL);
195:
196: 197:
198: if (!is_null($addURL) && $link && $prefs->getValue('add_source')) {
199: try {
200: $add_link = $registry->hasMethod('contacts/import')
201: ? $addURL->copy()->add('actionID', 'add_address')
202: : null;
203: } catch (Horde_Exception $e) {}
204: }
205:
206: $addrlist->setIteratorFilter();
207: foreach ($addrlist->base_addresses as $ob) {
208: if ($ob instanceof Horde_Mail_Rfc822_Group) {
209: $group_array = array();
210: foreach ($ob->addresses as $ad) {
211: $ret = $minimal
212: ? strval($ad)
213: : htmlspecialchars(strval($ad));
214:
215: if ($link) {
216: $clink = new IMP_Compose_Link(array('to' => strval($ad)));
217: $ret = Horde::link($clink->link(), sprintf(_("New Message to %s"), strval($ad))) . htmlspecialchars(strval($ad)) . '</a>';
218: }
219:
220: 221:
222: if ($add_link) {
223: $curr_link = $add_link->copy()->add(array(
224: 'address' => $ad->bare_address,
225: 'name' => $ad->personal
226: ));
227: $ret .= Horde::link($curr_link, sprintf(_("Add %s to my Address Book"), $ad->bare_address)) .
228: '<span class="iconImg addrbookaddImg"></span></a>';
229: }
230:
231: $group_array[] = $ret;
232: }
233:
234: $groupname = $minimal
235: ? $ob->groupname
236: : htmlspecialchars($ob->groupname);
237:
238: $addr_array[] = $groupname . ':' . (count($group_array) ? ' ' . implode(', ', $group_array) : '');
239: } else {
240: $ret = $minimal
241: ? strval($ob)
242: : htmlspecialchars(strval($ob));
243:
244: if ($link) {
245: $clink = new IMP_Compose_Link(array('to' => strval($ob)));
246: $ret = Horde::link($clink->link(), sprintf(_("New Message to %s"), strval($ob))) . htmlspecialchars(strval($ob)) . '</a>';
247: }
248:
249: 250:
251: if ($add_link) {
252: $curr_link = $add_link->copy()->add(array(
253: 'address' => $ob->bare_address,
254: 'name' => $ob->personal
255: ));
256: $ret .= Horde::link($curr_link, sprintf(_("Add %s to my Address Book"), $ob->bare_address)) .
257: '<span class="iconImg addrbookaddImg"></span></a>';
258: }
259:
260: $addr_array[] = $ret;
261: }
262: }
263:
264: if ($minimal) {
265: return implode(', ', $addr_array);
266: }
267:
268: 269:
270: if (empty($addr_array)) {
271: $ret = _("Undisclosed Recipients");
272: } else {
273:
274: $addr_count = count($addr_array);
275: $ret = '<span class="nowrap">' . implode(',</span> <span class="nowrap">', $addr_array) . '</span>';
276: if ($link && $addr_count > 15) {
277: $ret = '<span>' .
278: '<span onclick="[ this, this.next(), this.next(1) ].invoke(\'toggle\')" class="widget largeaddrlist">' . sprintf(_("Show Addresses (%d)"), $addr_count) . '</span>' .
279: '<span onclick="[ this, this.previous(), this.next() ].invoke(\'toggle\')" class="widget largeaddrlist" style="display:none">' . _("Hide Addresses") . '</span>' .
280: '<span style="display:none">' .
281: $ret . '</span></span>';
282: }
283: }
284:
285: return $ret;
286: }
287:
288: 289: 290: 291: 292: 293: 294:
295: public function moveAfterAction(IMP_Mailbox $mailbox)
296: {
297: return (!$mailbox->hideDeletedMsgs() &&
298: !$GLOBALS['prefs']->getValue('use_trash'));
299: }
300:
301: }
302: