1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12:
13:
14: 15: 16: 17: 18: 19: 20: 21: 22: 23:
24: class IMP_Basic_Message extends IMP_Basic_Base
25: {
26: 27:
28: protected function _init()
29: {
30: global $conf, $injector, $notification, $page_output, $prefs, $registry, $session;
31:
32: $mailbox = $this->indices->mailbox;
33: $imp_imap = $mailbox->imp_imap;
34:
35: 36: 37:
38: $imp_imap->openMailbox($mailbox, Horde_Imap_Client::OPEN_READWRITE);
39:
40:
41: $imp_mailbox = $mailbox->list_ob;
42: $imp_mailbox->setIndex($this->indices);
43: if (!$imp_mailbox->isValidIndex()) {
44: $this->_returnToMailbox(null, 'message_missing');
45: return;
46: }
47:
48: $imp_flags = $injector->getInstance('IMP_Flags');
49: $imp_identity = $injector->getInstance('IMP_Identity');
50: $imp_message = $injector->getInstance('IMP_Message');
51: $imp_ui = $injector->getInstance('IMP_Message_Ui');
52:
53:
54: if ($this->vars->actionID) {
55: try {
56: $session->getToken($this->vars->token);
57: } catch (Horde_Exception $e) {
58: $notification->push($e);
59: $this->vars->actionID = null;
60: }
61: }
62:
63: $readonly = $mailbox->readonly;
64: $peek = false;
65:
66: switch ($this->vars->actionID) {
67: case 'blacklist':
68: case 'whitelist':
69: if ($this->vars->actionID == 'blacklist') {
70: $injector->getInstance('IMP_Filter')->blacklistMessage($this->indices);
71: } else {
72: $injector->getInstance('IMP_Filter')->whitelistMessage($this->indices);
73: }
74: break;
75:
76: case 'delete_message':
77: $imp_message->delete(
78: $this->indices,
79: array('mailboxob' => $imp_mailbox)
80: );
81: if ($prefs->getValue('mailbox_return')) {
82: $this->_returnToMailbox($imp_mailbox->getIndex());
83: return;
84: }
85: if ($imp_ui->moveAfterAction($mailbox)) {
86: $imp_mailbox->setIndex(1);
87: }
88: break;
89:
90: case 'undelete_message':
91: $imp_message->undelete($this->indices);
92: break;
93:
94: case 'move_message':
95: case 'copy_message':
96: if (isset($this->vars->targetMbox) &&
97: (!$readonly || ($this->vars->actionID == 'copy_message'))) {
98: if ($this->vars->newMbox) {
99: $targetMbox = IMP_Mailbox::prefFrom($this->vars->targetMbox);
100: $newMbox = true;
101: } else {
102: $targetMbox = IMP_Mailbox::formFrom($this->vars->targetMbox);
103: $newMbox = false;
104: }
105: $imp_message->copy(
106: $targetMbox,
107: ($this->vars->actionID == 'move_message') ? 'move' : 'copy',
108: $this->indices,
109: array(
110: 'create' => $newMbox,
111: 'mailboxob' => $imp_mailbox
112: )
113: );
114: if ($prefs->getValue('mailbox_return')) {
115: $this->_returnToMailbox($imp_mailbox->getIndex());
116: return;
117: }
118: }
119: break;
120:
121: case 'innocent_report':
122: case 'spam_report':
123: $res = $injector->getInstance('IMP_Factory_Spam')->create(
124: ($this->vars->actionID == 'spam_report') ? IMP_Spam::SPAM : IMP_Spam::INNOCENT
125: )->report(
126: $this->indices,
127: array('mailbox' => $imp_mailbox)
128: );
129: switch ($res) {
130: case 1:
131: if ($imp_ui->moveAfterAction($mailbox)) {
132: $imp_mailbox->setIndex(1);
133: }
134: break;
135: }
136: if ($prefs->getValue('mailbox_return')) {
137: $this->_returnToMailbox($imp_mailbox->getIndex());
138: return;
139: }
140: break;
141:
142: case 'flag_message':
143: if (!$readonly &&
144: isset($this->vars->flag) &&
145: count($this->indices)) {
146: $peek = true;
147: $flag = $imp_flags->parseFormId($this->vars->flag);
148: $imp_message->flag(array(
149: ($flag['set'] ? 'add' : 'remove') => array($flag['flag'])
150: ), $this->indices);
151: if ($prefs->getValue('mailbox_return')) {
152: $this->_returnToMailbox($imp_mailbox->getIndex());
153: return;
154: }
155: }
156: break;
157:
158: case 'add_address':
159: try {
160: $contact_link = $injector->getInstance('IMP_Contacts')->addAddress($this->vars->address, $this->vars->name);
161: $notification->push(sprintf(_("Entry \"%s\" was successfully added to the address book"), $contact_link), 'horde.success', array('content.raw'));
162: } catch (Horde_Exception $e) {
163: $notification->push($e);
164: }
165: break;
166:
167: case 'strip_all':
168: case 'strip_attachment':
169: if (!$readonly) {
170: try {
171: $this->indices = new IMP_Indices_Mailbox(
172: $this->indices->mailbox,
173: $imp_message->stripPart(
174: $this->indices,
175: ($this->vars->actionID == 'strip_all') ? null : $this->vars->imapid,
176: array(
177: 'mailboxob' => $imp_mailbox
178: )
179: )
180: );
181: $notification->push(_("Attachment successfully stripped."), 'horde.success');
182: } catch (Horde_Exception $e) {
183: $notification->push($e);
184: }
185: }
186: break;
187: }
188:
189: 190:
191: if (!$imp_mailbox->isValidIndex()) {
192: $this->_returnToMailbox(count($imp_mailbox));
193: return;
194: }
195:
196: 197:
198: $msg_index = $imp_mailbox[$imp_mailbox->getIndex()];
199:
200:
201: try {
202: $imp_contents = $injector->getInstance('IMP_Factory_Contents')->create(new IMP_Indices($imp_mailbox));
203: } catch (IMP_Exception $e) {
204: $imp_mailbox->removeMsgs(true);
205: $this->_returnToMailbox(null, 'message_missing');
206: return;
207: }
208:
209:
210: try {
211: 212:
213: $query = new Horde_Imap_Client_Fetch_Query();
214: $query->flags();
215: $flags_ret = $imp_imap->fetch($msg_index['m'], $query, array(
216: 'ids' => $imp_imap->getIdsOb($msg_index['u'])
217: ));
218:
219: $query = new Horde_Imap_Client_Fetch_Query();
220: $query->envelope();
221: $fetch_ret = $imp_imap->fetch($msg_index['m'], $query, array(
222: 'ids' => $imp_imap->getIdsOb($msg_index['u'])
223: ));
224: } catch (IMP_Imap_Exception $e) {
225: $this->_returnToMailbox(null, 'message_missing');
226: return;
227: }
228:
229: $envelope = $fetch_ret->first()->getEnvelope();
230: $flags = $flags_ret->first()->getFlags();
231: $mime_headers = $peek
232: ? $imp_contents->getHeader()
233: : $imp_contents->getHeaderAndMarkAsSeen();
234:
235:
236: $page_label = $mailbox->label;
237:
238:
239: $buid = $imp_mailbox->getBuid($msg_index['m'], $msg_index['u']);
240: $msgindex = $imp_mailbox->getIndex();
241: $message_url = Horde::url('basic.php')->add('page', 'message');
242: $token = $session->getToken();
243: $self_link = self::url(array(
244: 'buid' => $buid,
245: 'mailbox' => $mailbox
246: ))->add(array(
247: 'token' => $token,
248: 'start' => $msgindex
249: ));
250:
251:
252: $basic_headers = $imp_ui->basicHeaders();
253: $display_headers = $msgAddresses = array();
254:
255: $date_ob = new IMP_Message_Date($envelope->date);
256: if ($format_date = $date_ob->format($date_ob::DATE_LOCAL)) {
257: $display_headers['date'] = $format_date;
258: }
259:
260:
261: $display_headers['from'] = $imp_ui->buildAddressLinks($envelope->from, $self_link);
262:
263:
264: if (!empty($envelope->from)) {
265: $contacts_img = new IMP_Contacts_Image($envelope->from[0]);
266: try {
267: $res = $contacts_img->getImage($contacts_img::FLAG);
268: $display_headers['from'] .= ' ' . Horde_Themes_Image::tag(
269: $res['url'],
270: array(
271: 'alt' => $res['desc'],
272: 'fullsrc' => true
273: )
274: );
275: } catch (IMP_Exception $e) {}
276: }
277:
278:
279: if ($face = $mime_headers->getValue('face')) {
280: $display_headers['from'] .= ' <img src="' .
281: Horde_Url_Data::create('image/png', base64_decode($face))
282: . '">';
283: }
284:
285:
286: foreach (array('to', 'cc', 'bcc') as $val) {
287: $msgAddresses[] = $mime_headers->getValue($val);
288: if (($val == 'to') || count($envelope->$val)) {
289: $display_headers[$val] = $imp_ui->buildAddressLinks($envelope->$val, $self_link);
290: }
291: }
292:
293:
294: if ($subject = $mime_headers->getValue('subject')) {
295: $this->title = sprintf(_("%s: %s"), $page_label, $subject);
296: $shortsub = Horde_String::truncate($subject, 100);
297: } else {
298: $shortsub = _("[No Subject]");
299: $this->title = sprintf(_("%s: %s"), $page_label, $shortsub);
300: }
301:
302:
303: switch ($injector->getInstance('IMP_Mime_Headers')->getPriority($mime_headers)) {
304: case 'high':
305: $basic_headers['priority'] = _("Priority");
306: $display_headers['priority'] = '<div class="iconImg msgflags flagHighpriority" title="' . htmlspecialchars(_("High Priority")) . '"></div> ' . _("High");
307: break;
308:
309: case 'low':
310: $basic_headers['priority'] = _("Priority");
311: $display_headers['priority'] = '<div class="iconImg msgflags flagLowpriority" title="' . htmlspecialchars(_("Low Priority")) . '"></div> ' . _("Low");
312: break;
313: }
314:
315:
316: if (!empty($envelope->reply_to) &&
317: ($envelope->from[0]->bare_address != $envelope->reply_to[0]->bare_address) &&
318: ($reply_to = $imp_ui->buildAddressLinks($envelope->reply_to, $self_link))) {
319: $display_headers['reply-to'] = $reply_to;
320: }
321:
322:
323: $all_headers = $this->vars->show_all_headers;
324: $user_hdrs = $imp_ui->getUserHeaders();
325:
326:
327: $list_info = $imp_ui->getListInformation($mime_headers);
328:
329: 330:
331: $full_headers = array();
332: if ($all_headers) {
333: $header_array = $mime_headers->toArray();
334: foreach ($header_array as $head => $val) {
335: $lc_head = strtolower($head);
336:
337:
338: if (!isset($display_headers[$lc_head]) &&
339: (!in_array($lc_head, array('importance', 'x-priority')) ||
340: !isset($display_headers['priority']))) {
341: $full_headers[$lc_head] = $val;
342: }
343: }
344: } elseif (!empty($user_hdrs)) {
345: foreach ($user_hdrs as $user_hdr) {
346: $user_val = $mime_headers->getValue($user_hdr);
347: if (!empty($user_val)) {
348: $full_headers[$user_hdr] = $user_val;
349: }
350: }
351: }
352: ksort($full_headers);
353:
354: 355: 356: 357:
358: $selfURL = $mailbox->url(Horde::selfUrlParams()->remove(array('actionID')), $buid)->add('token', $token);
359: $headersURL = $selfURL->copy()->remove(array('show_all_headers'));
360:
361:
362: $prev_msg = $imp_mailbox[$imp_mailbox->getIndex() - 1];
363: if ($prev_msg) {
364: $prev_url = self::url(array(
365: 'buid' => $imp_mailbox->getBuid($prev_msg['m'], $prev_msg['u']),
366: 'mailbox' => $mailbox
367: ))->setRaw(true);
368: $page_output->addLinkTag(array(
369: 'href' => $prev_url,
370: 'id' => 'prev',
371: 'rel' => 'Previous',
372: 'type' => null
373: ));
374: } else {
375: $prev_url = null;
376: }
377:
378: $next_msg = $imp_mailbox[$imp_mailbox->getIndex() + 1];
379: if ($next_msg) {
380: $next_url = self::url(array(
381: 'buid' => $imp_mailbox->getBuid($next_msg['m'], $next_msg['u']),
382: 'mailbox' => $mailbox
383: ))->setRaw(true);
384: $page_output->addLinkTag(array(
385: 'href' => $next_url,
386: 'id' => 'next',
387: 'rel' => 'Next',
388: 'type' => null
389: ));
390: } else {
391: $next_url = null;
392: }
393:
394:
395: $mailbox_url = $mailbox->url('mailbox')->add('start', $msgindex);
396:
397:
398:
399: $js_vars = array(
400: 'ImpMessage.text' => array(
401: 'innocent_report' => _("Are you sure you wish to report this message as innocent?"),
402: 'moveconfirm' => _("Are you sure you want to move the message(s)? (Some message information might get lost, like message headers, text formatting or attachments!)"),
403: 'newmbox' => _("You are copying/moving to a new mailbox.") . "\n" . _("Please enter a name for the new mailbox:") . "\n",
404: 'spam_report' => _("Are you sure you wish to report this message as spam?"),
405: 'target_mbox' => _("You must select a target mailbox first.")
406: )
407: );
408:
409:
410: $msgAddresses[] = $mime_headers->getValue('from');
411: $identity = $match_identity = $imp_identity->getMatchingIdentity($msgAddresses);
412: if (is_null($identity)) {
413: $identity = $imp_identity->getDefault();
414: }
415:
416: $flag_parse = $imp_flags->parse(array(
417: 'flags' => $flags,
418: 'personal' => $match_identity
419: ));
420:
421: $status = '';
422: foreach ($flag_parse as $val) {
423: if ($val instanceof IMP_Flag_User) {
424: $status .= '<span class="' . $val->css . '" style="' . ($val->bgdefault ? '' : 'background:' . htmlspecialchars($val->bgcolor) . ';') . 'color:' . htmlspecialchars($val->fgcolor) . '">' . htmlspecialchars($val->label) . '</span>';
425: } else {
426: $status .= $val->span;
427: }
428: }
429:
430: 431:
432: $h_page_label = htmlspecialchars($page_label);
433: $header_label = $h_page_label;
434: if ($mailbox->search) {
435: $header_label .= ' [' . $msg_index['m']->url('mailbox')->link() . $msg_index['m']->display_html . '</a>]';
436: }
437:
438:
439: $view = new Horde_View(array(
440: 'templatePath' => IMP_TEMPLATES . '/basic/message'
441: ));
442: $view->addHelper('FormTag');
443: $view->addHelper('Tag');
444:
445: $t_view = clone $view;
446: $t_view->buid = $buid;
447: $t_view->message_url = $message_url;
448: $t_view->mailbox = $mailbox->form_to;
449: $t_view->start = $msgindex;
450: $t_view->token = $token;
451:
452:
453: $n_view = clone $view;
454: $n_view->readonly = $readonly;
455: $n_view->id = 1;
456:
457: if ($mailbox->access_flags) {
458: $n_view->mailbox = $mailbox->form_to;
459:
460: $args = array(
461: 'imap' => true,
462: 'mailbox' => $mailbox
463: );
464:
465: $form_set = $form_unset = array();
466: foreach ($imp_flags->getList($args) as $val) {
467: if ($val->canset) {
468: $form_set[] = array(
469: 'f' => $val->form_set,
470: 'l' => $val->label
471: );
472: $form_unset[] = array(
473: 'f' => $val->form_unset,
474: 'l' => $val->label
475: );
476: }
477: }
478:
479: $n_view->flaglist_set = $form_set;
480: $n_view->flaglist_unset = $form_unset;
481: }
482:
483: if ($imp_imap->access(IMP_Imap::ACCESS_FOLDERS)) {
484: $n_view->move = Horde::widget(array(
485: 'url' => '#',
486: 'class' => 'moveAction',
487: 'title' => _("Move"),
488: 'nocheck' => true
489: ));
490: $n_view->copy = Horde::widget(array(
491: 'url' => '#',
492: 'class' => 'copyAction',
493: 'title' => _("Copy"),
494: 'nocheck' => true
495: ));
496:
497: $iterator = new IMP_Ftree_IteratorFilter(
498: $injector->getInstance('IMP_Ftree')
499: );
500: $iterator->add($iterator::NONIMAP);
501:
502: $n_view->options = new IMP_Ftree_Select(array(
503: 'heading' => _("This message to"),
504: 'inc_tasklists' => true,
505: 'inc_notepads' => true,
506: 'iterator' => $iterator,
507: 'new_mbox' => true
508: ));
509: }
510:
511: $n_view->back_to = Horde::widget(array(
512: 'url' => $mailbox_url,
513: 'title' => sprintf(_("Bac_k to %s"), $h_page_label),
514: 'nocheck' => true
515: ));
516:
517: if ($prev_url) {
518: $n_view->prev = Horde::link($prev_url, _("Previous Message"));
519: $n_view->prev_img = 'navleftImg';
520: } else {
521: $n_view->prev_img = 'navleftgreyImg';
522: }
523:
524: if ($next_url) {
525: $n_view->next = Horde::link($next_url, _("Next Message"));
526: $n_view->next_img = 'navrightImg';
527: } else {
528: $n_view->next_img = 'navrightgreyImg';
529: }
530:
531:
532: $a_view = clone $view;
533: $compose_params = array(
534: 'buid' => $buid,
535: 'identity' => $identity,
536: 'mailbox' => IMP_Mailbox::formTo($mailbox),
537: );
538: if (!$prefs->getValue('compose_popup')) {
539: $compose_params['start'] = $msgindex;
540: }
541:
542: if ($msg_index['m']->access_deletemsgs) {
543: if (in_array(Horde_Imap_Client::FLAG_DELETED, $flags)) {
544: $a_view->delete = Horde::widget(array(
545: 'url' => $self_link->copy()->add('actionID', 'undelete_message'),
546: 'title' => _("Undelete"),
547: 'nocheck' => true
548: ));
549: } else {
550: $a_view->delete = Horde::widget(array(
551: 'url' => $self_link->copy()->add('actionID', 'delete_message'),
552: 'title' => _("_Delete"),
553: 'nocheck' => true
554: ));
555: if (!$msg_index['m']->is_imap) {
556: $js_vars['ImpMessage.pop3delete'] = _("Are you sure you want to PERMANENTLY delete these messages?");
557: }
558: }
559: }
560:
561: $disable_compose = !IMP_Compose::canCompose();
562:
563: if (!$disable_compose) {
564: $clink_ob = new IMP_Compose_Link();
565: $clink = $clink_ob->link()->add($compose_params);
566:
567: $a_view->reply = Horde::widget(array(
568: 'url' => $clink->add(array('actionID' => 'reply_auto')),
569: 'class' => 'horde-hasmenu',
570: 'title' => _("_Reply"),
571: 'nocheck' => true
572: ));
573: $a_view->reply_sender = Horde::widget(array(
574: 'url' => $clink->add(array('actionID' => 'reply')),
575: 'title' => _("To Sender"),
576: 'nocheck' => true
577: ));
578:
579: if ($list_info['reply_list']) {
580: $a_view->reply_list = Horde::widget(array(
581: 'url' => $clink->add(array('actionID' => 'reply_list')),
582: 'title' => _("To _List"),
583: 'nocheck' => true
584: ));
585: }
586:
587: $addr_ob = clone $envelope->to;
588: $addr_ob->add($envelope->cc);
589: $addr_ob->setIteratorFilter(0, $imp_identity->getAllFromAddresses());
590:
591: if (count($addr_ob)) {
592: $a_view->show_reply_all = Horde::widget(array(
593: 'url' => $clink->add(array('actionID' => 'reply_all')),
594: 'title' => _("To _All"),
595: 'nocheck' => true
596: ));
597: }
598:
599: $fwd_locked = $prefs->isLocked('forward_default');
600: $a_view->forward = Horde::widget(array(
601: 'url' => $clink->add(array('actionID' => 'forward_auto')),
602: 'class' => $fwd_locked ? '' : ' horde-hasmenu',
603: 'title' => _("Fo_rward"),
604: 'nocheck' => true
605: ));
606: if (!$fwd_locked) {
607: $a_view->forward_attach = Horde::widget(array(
608: 'url' => $clink->add(array('actionID' => 'forward_attach')),
609: 'title' => _("As Attachment"),
610: 'nocheck' => true
611: ));
612: $a_view->forward_body = Horde::widget(array(
613: 'url' => $clink->add(array('actionID' => 'forward_body')),
614: 'title' => _("In Body Text"),
615: 'nocheck' => true
616: ));
617: $a_view->forward_both = Horde::widget(array(
618: 'url' => $clink->add(array('actionID' => 'forward_both')),
619: 'title' => _("Attachment and Body Text"),
620: 'nocheck' => true
621: ));
622: }
623:
624: $a_view->redirect = Horde::widget(array(
625: 'url' => $clink->add(array('actionID' => 'redirect_compose')),
626: 'title' => _("Redirec_t"),
627: 'nocheck' => true
628: ));
629:
630: $a_view->editasnew = Horde::widget(array(
631: 'url' => $clink->add(array('actionID' => 'editasnew')),
632: 'title' => _("Edit as New"),
633: 'nocheck' => true
634: ));
635: }
636:
637: if ($mailbox->access_sortthread) {
638: $a_view->show_thread = Horde::widget(array(
639: 'url' => $mailbox->url(IMP_Basic_Thread::url(), $buid)->add(array('start' => $msgindex)),
640: 'title' => _("_View Thread"),
641: 'nocheck' => true
642: ));
643: }
644:
645: if (!$readonly && $registry->hasMethod('mail/blacklistFrom')) {
646: $a_view->blacklist = Horde::widget(array(
647: 'url' => $self_link->copy()->add('actionID', 'blacklist'),
648: 'title' => _("_Blacklist"),
649: 'nocheck' => true
650: ));
651: }
652:
653: if (!$readonly && $registry->hasMethod('mail/whitelistFrom')) {
654: $a_view->whitelist = Horde::widget(array(
655: 'url' => $self_link->copy()->add('actionID', 'whitelist'),
656: 'title' => _("_Whitelist"),
657: 'nocheck' => true
658: ));
659: }
660:
661: if (!empty($conf['user']['allow_view_source'])) {
662: $a_view->view_source = $imp_contents->linkViewJS($imp_contents->getMIMEMessage(), 'view_source', _("_Message Source"), array(
663: 'css' => '',
664: 'jstext' => _("Message Source"),
665: 'widget' => true
666: ));
667: }
668:
669: if (!$disable_compose &&
670: (in_array(Horde_Imap_Client::FLAG_DRAFT, $flags) || $msg_index['m']->drafts)) {
671: $a_view->resume = Horde::widget(array(
672: 'url' => $clink->add(array('actionID' => 'draft')),
673: 'title' => _("Resume"),
674: 'nocheck' => true
675: ));
676: }
677:
678: $imp_params = $mailbox->urlParams($buid);
679: $a_view->save_as = Horde::widget(array(
680: 'url' => IMP_Contents_View::downloadUrl($subject, array_merge(array('actionID' => 'save_message'), $imp_params)),
681: 'title' => _("Sa_ve as"),
682: 'nocheck' => true
683: ));
684:
685: if ($msg_index['m']->spam_show) {
686: $a_view->spam = Horde::widget(array(
687: 'url' => '#',
688: 'class' => 'spamAction',
689: 'title' => _("Report as Spam"),
690: 'nocheck' => true
691: ));
692: }
693:
694: if ($msg_index['m']->innocent_show) {
695: $a_view->innocent = Horde::widget(array(
696: 'url' => '#',
697: 'class' => 'innocentAction',
698: 'title' => _("Report as Innocent"),
699: 'nocheck' => true
700: ));
701: }
702:
703: if (!$disable_compose) {
704: $a_view->redirect = Horde::widget(array(
705: 'url' => $clink->add(array('actionID' => 'redirect_compose')),
706: 'title' => _("Redirec_t"),
707: 'nocheck' => true
708: ));
709: }
710:
711: $a_view->headers = Horde::widget(array(
712: 'url' => '#',
713: 'class' => 'horde-hasmenu',
714: 'title' => _("Headers"),
715: 'nocheck' => true
716: ));
717: if ($all_headers) {
718: $a_view->common_headers = Horde::widget(array(
719: 'url' => $headersURL,
720: 'title' => _("Show Common Headers"),
721: 'nocheck' => true
722: ));
723: }
724: if (!$all_headers) {
725: $a_view->all_headers = Horde::widget(array(
726: 'url' => $headersURL->copy()->add('show_all_headers', 1),
727: 'title' => _("Show All Headers"),
728: 'nocheck' => true
729: ));
730: }
731: if ($list_info['exists']) {
732: $a_view->list_headers = Horde::widget(array(
733: 'onclick' => Horde::popupJs(IMP_Basic_Listinfo::url(array(
734: 'buid' => $buid,
735: 'mailbox' => $mailbox
736: )), array(
737: 'urlencode' => true
738: )),
739: 'title' => _("Show Mailing List Information"),
740: 'nocheck' => true
741: ));
742: }
743:
744: $hdrs = array();
745:
746:
747: if (!$all_headers) {
748: foreach ($display_headers as $head => $val) {
749: $hdrs[] = array(
750: 'name' => $basic_headers[$head],
751: 'val' => $val
752: );
753: }
754: }
755: foreach ($full_headers as $head => $val) {
756: if (is_array($val)) {
757: $hdrs[] = array(
758: 'name' => $head,
759: 'val' => '<ul style="margin:0;padding-left:15px"><li>' . implode("</li>\n<li>", array_map('htmlspecialchars', $val)) . '</li></ul>'
760: );
761: } else {
762: $hdrs[] = array(
763: 'name' => $head,
764: 'val' => htmlspecialchars($val)
765: );
766: }
767: }
768:
769:
770: $part_info = $part_info_display = array('icon', 'description', 'size');
771: $part_info_action = array('download', 'download_zip', 'img_save', 'strip');
772: $part_info_bodyonly = array('print');
773:
774: $show_parts = isset($this->vars->show_parts)
775: ? $this->vars->show_parts
776: : $prefs->getValue('parts_display');
777:
778: $part_info_display = array_merge($part_info_display, $part_info_action, $part_info_bodyonly);
779: $contents_mask = IMP_Contents::SUMMARY_BYTES |
780: IMP_Contents::SUMMARY_SIZE |
781: IMP_Contents::SUMMARY_ICON |
782: IMP_Contents::SUMMARY_DESCRIP_LINK |
783: IMP_Contents::SUMMARY_DOWNLOAD |
784: IMP_Contents::SUMMARY_DOWNLOAD_ZIP |
785: IMP_Contents::SUMMARY_IMAGE_SAVE |
786: IMP_Contents::SUMMARY_PRINT;
787:
788:
789: $mdntext = $imp_ui->MDNCheck(new IMP_Indices($msg_index['m'], $buid), $mime_headers, $this->vars->mdn_confirm)
790: ? strval(new IMP_Mime_Status(array(
791: _("The sender of this message is requesting a notification from you when you have read this message."),
792: sprintf(_("Click %s to send the notification message."), Horde::link($selfURL->copy()->add('mdn_confirm', 1)) . _("HERE") . '</a>')
793: )))
794: : '';
795:
796: 797:
798: $inline_ob = new IMP_Contents_InlineOutput();
799: $inlineout = $inline_ob->getInlineOutput($imp_contents, array(
800: 'mask' => $contents_mask,
801: 'part_info_display' => $part_info_display,
802: 'show_parts' => $show_parts
803: ));
804:
805:
806: $show_atc = false;
807: switch ($show_parts) {
808: case 'atc':
809: $a_view->show_parts_all = Horde::widget(array(
810: 'url' => $headersURL->copy()->add(array('show_parts' => 'all')),
811: 'title' => _("Show All Parts"),
812: 'nocheck' => true
813: ));
814: $show_atc = true;
815: break;
816:
817: case 'all':
818: if ($prefs->getValue('strip_attachments')) {
819: $js_vars['ImpMessage.text']['stripwarn'] = _("Are you sure you wish to PERMANENTLY delete this attachment?");
820: }
821: break;
822: }
823:
824: if (count($inlineout['atc_parts']) > 2) {
825: $a_view->download_all = Horde::widget(array(
826: 'url' => $imp_contents->urlView($imp_contents->getMIMEMessage(), 'download_all'),
827: 'title' => _("Download All Attachments (in .zip file)"),
828: 'nocheck' => true
829: ));
830: if ($prefs->getValue('strip_attachments')) {
831: $a_view->strip_all = Horde::widget(array(
832: 'url' => Horde::selfUrlParams()->add(array(
833: 'actionID' => 'strip_all',
834: 'token' => $token
835: )),
836: 'class' => 'stripAllAtc',
837: 'title' => _("Strip All Attachments"),
838: 'nocheck' => true
839: ));
840: $js_vars['ImpMessage.text']['stripallwarn'] = _("Are you sure you want to PERMANENTLY delete all attachments?");
841: }
842:
843: $show_atc = true;
844: }
845:
846: if ($show_atc) {
847: $a_view->atc = Horde::widget(array(
848: 'url' => '#',
849: 'class' => 'horde-hasmenu',
850: 'title' => _("Attachments"),
851: 'nocheck' => true
852: ));
853: }
854:
855: 856:
857: if (!empty($inlineout['atc_parts'])) {
858: if ($show_parts == 'all') {
859: $val = $imp_contents->getTree()->getTree(true);
860: } else {
861: $tmp = array();
862:
863: foreach ($inlineout['atc_parts'] as $id) {
864: $summary = $imp_contents->getSummary($id, $contents_mask);
865:
866: $tmp[] = '<tr>';
867: foreach ($part_info as $val) {
868: $tmp[] = '<td>' . $summary[$val] . '</td>';
869: }
870: $tmp[] = '<td>';
871: foreach ($part_info_action as $val) {
872: $tmp[] = $summary[$val];
873: }
874: $tmp[] = '</td></tr>';
875: }
876:
877: $val = '<table>' . implode('', $tmp) . '</table>';
878: }
879:
880: $hdrs[] = array(
881: 'class' => 'msgheaderParts',
882: 'name' => ($show_parts == 'all') ? _("Parts") : _("Attachments"),
883: 'val' => $val
884: );
885: }
886:
887: $m_view = clone $view;
888: $m_view->label = $shortsub;
889: $m_view->headers = $hdrs;
890: $m_view->msgtext = $mdntext . $inlineout['msgtext'];
891:
892: $subinfo = new IMP_View_Subinfo(array('mailbox' => $mailbox));
893: $subinfo->label = $header_label;
894: $subinfo->value = sprintf(_("(%d of %d)"), $msgindex, count($imp_mailbox)) . $status;
895: $injector->getInstance('Horde_View_Topbar')->subinfo = $subinfo->render();
896:
897:
898: $page_output->addInlineJsVars($js_vars, array('top' => true));
899: $page_output->addScriptFile('scriptaculous/effects.js', 'horde');
900: $page_output->addScriptFile('hordecore.js', 'horde');
901: $page_output->addScriptFile('message.js');
902: $page_output->addScriptFile('stripe.js', 'horde');
903: $page_output->addScriptPackage('IMP_Script_Package_Imp');
904:
905: if (!empty($conf['tasklist']['use_notepad']) ||
906: !empty($conf['tasklist']['use_tasklist'])) {
907: $page_output->addScriptPackage('Horde_Core_Script_Package_Dialog');
908: }
909:
910: $page_output->noDnsPrefetch();
911:
912: Horde::startBuffer();
913: foreach ($injector->getInstance('IMP_Maillog')->getLog(new IMP_Maillog_Message($this->indices, array('mdn'))) as $val) {
914: $notification->push($val->message, 'imp.' . $val->action);
915: }
916: $this->output = Horde::endBuffer();
917:
918: $this->output .= $t_view->render('navbar_top') .
919: $n_view->render('navbar_navigate') .
920: $a_view->render('navbar_actions') .
921: $m_view->render('message') .
922: $a_view->render('navbar_actions');
923:
924: $n_view->id = 2;
925: $n_view->isbottom = true;
926: $this->output .= $n_view->render('navbar_navigate');
927: }
928:
929: 930: 931: 932: 933:
934: public static function url(array $opts = array())
935: {
936: return IMP_Mailbox::get($opts['mailbox'])->url('basic')->add(array(
937: 'buid' => $opts['buid'],
938: 'page' => 'message'
939: ));
940: }
941:
942: 943:
944: protected function _returnToMailbox($start = null, $actID = null)
945: {
946: $this->vars->actionID = $actID;
947: $this->vars->start = $start;
948:
949: $ob = new IMP_Basic_Mailbox($this->vars);
950: $this->output = $ob->output;
951: }
952:
953: }
954: