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_Dynamic_Mailbox extends IMP_Dynamic_Base
24: {
25: 26:
27: protected function _init()
28: {
29: global $injector, $page_output, $registry, $session;
30:
31: $page_output->addScriptFile('dimpbase.js');
32: $page_output->addScriptFile('passphrase.js');
33: $page_output->addScriptFile('viewport.js');
34: $page_output->addScriptFile('external/tinycon.js');
35: $page_output->addScriptFile('dragdrop2.js', 'horde');
36: $page_output->addScriptFile('form_ghost.js', 'horde');
37: $page_output->addScriptFile('jstorage.js', 'horde');
38: $page_output->addScriptFile('slider2.js', 'horde');
39: $page_output->addScriptFile('toggle_quotes.js', 'horde');
40: $page_output->addScriptPackage('Horde_Core_Script_Package_Dialog');
41: $page_output->addScriptPackage('IMP_Script_Package_Imp');
42:
43: $imp_imap = $injector->getInstance('IMP_Factory_Imap')->create();
44:
45: if ($imp_imap->access(IMP_Imap::ACCESS_FLAGS)) {
46: $page_output->addScriptFile('colorpicker.js', 'horde');
47: $this->view->picker_img = Horde_Themes_Image::tag('colorpicker.png', array('alt' => _("Color Picker")));
48: }
49:
50: if ($imp_imap->access(IMP_Imap::ACCESS_REMOTE)) {
51: $page_output->addScriptFile('external/base64.js');
52: }
53:
54: $this->_addMailboxVars();
55:
56: $this->view->show_innocent = !empty($imp_imap->config->innocent_params);
57: $this->view->show_search = $imp_imap->access(IMP_Imap::ACCESS_SEARCH);
58: $this->view->show_spam = !empty($imp_imap->config->spam_params);
59:
60: $impSubinfo = new Horde_View(array(
61: 'templatePath' => IMP_TEMPLATES . '/dynamic'
62: ));
63: $impSubinfo->addHelper('Text');
64: $impSubinfo->quota = (bool)$imp_imap->config->quota;
65:
66: $topbar = $injector->getInstance('Horde_View_Topbar');
67: $topbar->search = $this->view->show_search;
68: $topbar->searchMenu = true;
69: $topbar->subinfo = $impSubinfo->render('mailbox_subinfo');
70: $page_output->topbar = true;
71:
72: $blank = new Horde_Url();
73: $impSidebar = new Horde_View(array(
74: 'templatePath' => array(
75: $registry->get('templates', 'horde') . '/sidebar',
76: IMP_TEMPLATES . '/dynamic'
77: )
78: ));
79: $impSidebar->addHelper('Text');
80: $impSidebar->containers = array(
81: array(
82: 'id' => 'imp-specialmboxes'
83: )
84: );
85: if ($imp_imap->isImap()) {
86: $impSidebar->containers[] = array(
87: 'rows' => array(
88: array(
89: 'id' => 'folderopts_link',
90: 'cssClass' => 'folderoptsImg',
91: 'link' => $blank->link() . _("Folder Actions") . '</a>'
92: ),
93: array(
94: 'id' => 'dropbase',
95: 'style' => 'display:none',
96: 'cssClass' => 'folderImg',
97: 'link' => $blank->link() . _("Move to Base Level") . '</a>'
98: )
99: )
100: );
101: $impSidebar->containers[] = array(
102: 'id' => 'imp-normalmboxes'
103: );
104: }
105:
106: $sidebar = $injector->getInstance('Horde_View_Sidebar');
107: $sidebar->newLink = $blank->link(array('id' => 'composelink',
108: 'class' => 'icon'));
109: $sidebar->newText = _("New Message");
110: $sidebar->content = $impSidebar->render('sidebar');
111:
112: $this->view->sidebar = $sidebar->render();
113:
114: $this->view->max_fsize = intval($session->get('imp', 'file_upload'));
115:
116: $page_output->noDnsPrefetch();
117:
118: $this->_pages[] = 'mailbox';
119: }
120:
121: 122:
123: public static function url(array $opts = array())
124: {
125: return Horde::url('dynamic.php')->add('page', 'mailbox');
126: }
127:
128: 129:
130: protected function _addMailboxVars()
131: {
132: global $conf, $injector, $prefs, $registry;
133:
134:
135: $imp_imap = $injector->getInstance('IMP_Factory_Imap')->create();
136: $acl = $imp_imap->access(IMP_Imap::ACCESS_ACL);
137:
138: $subscribe = $prefs->getValue('subscribe');
139:
140: $this->js_conf += array_filter(array(
141:
142: 'URI_LISTINFO' => strval(IMP_Basic_Listinfo::url()->setRaw(true)),
143: 'URI_MESSAGE' => strval(IMP_Dynamic_Message::url()->setRaw(true)),
144: 'URI_PORTAL' => strval($registry->getServiceLink('portal')->setRaw(true)),
145: 'URI_PREFS_IMP' => strval($registry->getServiceLink('prefs', 'imp')->setRaw(true)),
146: 'URI_SEARCH' => strval(IMP_Basic_Search::url()->setRaw(true)),
147: 'URI_THREAD' => strval(IMP_Basic_Thread::url()->setRaw(true)),
148:
149:
150: 'FLAG_DELETED' => Horde_Imap_Client::FLAG_DELETED,
151: 'FLAG_DRAFT' => Horde_Imap_Client::FLAG_DRAFT,
152: 'FLAG_INNOCENT' => Horde_Imap_Client::FLAG_NOTJUNK,
153: 'FLAG_SEEN' => Horde_Imap_Client::FLAG_SEEN,
154: 'FLAG_SPAM' => Horde_Imap_Client::FLAG_JUNK,
155:
156:
157: 'msglist_template_horiz' => file_get_contents(IMP_TEMPLATES . '/dynamic/msglist_horiz.html'),
158: 'msglist_template_vert' => file_get_contents(IMP_TEMPLATES . '/dynamic/msglist_vert.html'),
159:
160:
161: 'acl' => $acl,
162: 'filter_any' => intval($prefs->getValue('filter_any_mailbox')),
163: 'from_link' => intval($prefs->getValue('from_link') == 0),
164: 'fsearchid' => IMP_Mailbox::formTo(IMP_Search::MBOX_PREFIX . IMP_Search::DIMP_FILTERSEARCH),
165: 'initial_page' => is_null($initial_page = IMP::getInitialPage()->mbox) ? null : $initial_page->form_to,
166: 'mbox_expand' => intval($prefs->getValue('nav_expanded') == 2),
167: 'name' => $registry->get('name', 'imp'),
168: 'poll_alter' => intval(!$prefs->isLocked('nav_poll') && !$prefs->getValue('nav_poll_all')),
169: 'qsearchid' => IMP_Mailbox::formTo(IMP_Search::MBOX_PREFIX . IMP_Search::DIMP_QUICKSEARCH),
170: 'refresh_time' => intval($prefs->getValue('refresh_time')),
171: 'sidebar_width' => max(intval($prefs->getValue('sidebar_width')), 150),
172: 'sort' => array(
173: 'from' => array(
174: 'c' => 'msgFrom',
175: 't' => _("From"),
176: 'v' => Horde_Imap_Client::SORT_FROM
177: ),
178: 'to' => array(
179: 'c' => 'msgFrom',
180: 'ec' => 'msgFromTo',
181: 't' => _("To"),
182: 'v' => Horde_Imap_Client::SORT_TO
183: ),
184: 'subject' => array(
185: 'c' => 'msgSubject',
186: 't' => _("Subject"),
187: 'v' => Horde_Imap_Client::SORT_SUBJECT
188: ),
189: 'thread' => array(
190: 'c' => 'msgSubject',
191: 'v' => Horde_Imap_Client::SORT_THREAD
192: ),
193: 'date' => array(
194: 'c' => 'msgDate',
195: 't' => _("Date"),
196: 'v' => IMP::IMAP_SORT_DATE
197: ),
198: 'msgarrival' => array(
199: 'c' => 'msgDate',
200: 'v' => Horde_Imap_Client::SORT_ARRIVAL
201: ),
202: 'msgdate' => array(
203: 'c' => 'msgDate',
204: 'v' => Horde_Imap_Client::SORT_DATE
205: ),
206: 'sequence' => array(
207: 'v' => Horde_Imap_Client::SORT_SEQUENCE
208: ),
209: 'size' => array(
210: 'c' => 'msgSize',
211: 't' => _("Size"),
212: 'v' => Horde_Imap_Client::SORT_SIZE
213: )
214: ),
215: 'subscribe' => intval($subscribe)
216: ));
217:
218: $context = array(
219: 'ctx_container' => array(
220: '_mbox' => '',
221: '_sep1' => null,
222: 'create' => _("Create subfolder"),
223: 'rename' => _("Rename"),
224: 'delete' => _("Delete subfolders"),
225: '_sep2' => null,
226: 'search' => _("Search"),
227: '_sep3' => null,
228: 'expand' => _("Expand All"),
229: 'collapse' => _("Collapse All")
230: ),
231: 'ctx_datesort' => array(
232: '*msgarrival' => _("Arrival Time"),
233: '*msgdate' => _("Message Date")
234: ),
235: 'ctx_flag' => array(),
236: 'ctx_flagunset' => array(),
237: 'ctx_flag_search' => array(),
238: 'ctx_mbox_flag' => array(
239: 'seen' => _("Seen"),
240: 'unseen' => _("Unseen")
241: ),
242: 'ctx_noactions' => array(
243: '_mbox' => '',
244: '_sep1' => null,
245: 'noaction' => _("No actions available")
246: ),
247: 'ctx_remoteauth' => array(
248: '_mbox' => '',
249: '_sep1' => null,
250: 'create' => _("Create Mailbox"),
251: 'logout' => _("Log Out")
252: ),
253: 'ctx_sortopts' => array(
254: 'from' => _("From"),
255: 'to' => _("To"),
256: 'subject' => _("Subject"),
257: 'thread' => _("Thread"),
258: 'msgarrival' => _("Date (Arrival)"),
259: 'msgdate' => _("Date (Message)"),
260: 'size' => _("Size"),
261: '_sep1' => null,
262: 'sequence' => _("No Sort")
263: ),
264: 'ctx_subjectsort' => array(
265: 'thread' => _("Thread Sort"),
266: ),
267: 'ctx_template' => array(
268: 'edit' => _("Edit Template"),
269: 'new' => _("Create New Template")
270: ),
271: 'ctx_vcontainer' => array(
272: '_mbox' => _("Virtual Folders"),
273: '_sep1' => null,
274: 'edit' => _("Edit Virtual Folders")
275: ),
276: 'ctx_vfolder' => array(
277: '_mbox' => '',
278: '_sep1' => null,
279: 'edit' => _("Edit Virtual Folder"),
280: 'delete' => _("Delete Virtual Folder")
281: )
282: );
283:
284:
285: if ($imp_imap->access(IMP_Imap::ACCESS_FOLDERS)) {
286: $context['ctx_folderopts'] = array(
287: 'new' => _("Create Mailbox"),
288: 'sub' => _("Hide Unsubscribed"),
289: 'unsub' => _("Show All Mailboxes"),
290: 'expand' => _("Expand All"),
291: 'collapse' => _("Collapse All"),
292: '_sep1' => null,
293: 'reload' => _("Rebuild Folder List")
294: );
295: }
296:
297: if (!$subscribe) {
298: unset(
299: $context['ctx_folderopts']['sub'],
300: $context['ctx_folderopts']['unsub']
301: );
302: }
303:
304:
305: $context['ctx_message'] = array(
306: '_sub1' => array(
307: 'resume' => _("Resume Draft"),
308: 'template' => _("Use Template"),
309: 'template_edit' => _("Edit Template"),
310: 'view' => _("View Message")
311: ),
312: 'reply' => _("Reply"),
313: 'forward' => _("Forward"),
314: '_sub2' => array(
315: '_sep1' => null,
316: 'setflag' => _("Mark as") . '...',
317: 'unsetflag' => _("Unmark as") . '...',
318: ),
319: '_sep2' => null,
320: 'spam' => _("Report as Spam"),
321: 'innocent' => _("Report as Innocent"),
322: 'blacklist' => _("Blacklist"),
323: 'whitelist' => _("Whitelist"),
324: 'addfilter' => _("Create Filter"),
325: 'delete' => _("Delete"),
326: 'undelete' => _("Undelete"),
327: '_sub3' => array(
328: '_sep3' => null,
329: 'source' => _("View Source")
330: )
331: );
332:
333: if (empty($imp_imap->config->spam_params)) {
334: unset($context['ctx_message']['spam']);
335: }
336: if (empty($imp_imap->config->innocent_params)) {
337: unset($context['ctx_message']['innocent']);
338: }
339: if (!$registry->hasLink('mail/newEmailFilter')) {
340: unset($context['ctx_message']['addfilter']);
341: }
342: if ($prefs->getValue('use_trash')) {
343: unset($context['ctx_message']['undelete']);
344: }
345: if (empty($conf['user']['allow_view_source'])) {
346: unset($context['ctx_message']['_sub3']);
347: }
348:
349:
350: $context['ctx_mbox'] = array(
351: '_mbox' => '',
352: '_sep1' => null,
353: 'create' => _("Create subfolder"),
354: 'rename' => _("Rename"),
355: 'empty' => _("Empty"),
356: 'delete' => _("Delete"),
357: '_sep2' => null,
358: 'setflag' => _("Mark all as"),
359: '_sep3' => null,
360: 'poll' => _("Check for New Mail"),
361: 'nopoll' => _("Do Not Check for New Mail"),
362: 'sub' => _("Subscribe"),
363: 'unsub' => _("Unsubscribe"),
364: '_sep4' => null,
365: 'search' => _("Search"),
366: '_sub1' => array(
367: '_sep5' => null,
368: 'expand' => _("Expand All"),
369: 'collapse' => _("Collapse All")
370: ),
371: '_sep6' => null,
372: 'export' => _("Export"),
373: 'import' => _("Import"),
374: '_sep7' => null,
375: 'size' => _("Mailbox Size"),
376: '_sub2' => array(
377: '_sep8' => null,
378: 'acl' => _("Edit ACL")
379: ),
380: );
381:
382: if (!$subscribe) {
383: unset(
384: $context['ctx_mbox']['sub'],
385: $context['ctx_mbox']['unsub']
386: );
387: }
388: if (!$imp_imap->access(IMP_Imap::ACCESS_IMPORT)) {
389: unset($context['ctx_mbox']['import']);
390: }
391: if (!$imp_imap->access(IMP_Imap::ACCESS_FLAGS)) {
392: unset(
393: $context['ctx_mbox']['_sep2'],
394: $context['ctx_mbox']['setflag'],
395: $context['ctx_mbox']['_sep3'],
396: $context['ctx_mbox']['poll'],
397: $context['ctx_mbox']['nopoll']
398: );
399: }
400: if (!$imp_imap->access(IMP_Imap::ACCESS_FOLDERS)) {
401: unset(
402: $context['ctx_mbox']['_sep7'],
403: $context['ctx_mbox']['size']
404: );
405: }
406: if (!$imp_imap->access(IMP_Imap::ACCESS_SEARCH)) {
407: unset(
408: $context['ctx_mbox']['_sep4'],
409: $context['ctx_mbox']['search']
410: );
411: }
412:
413:
414: $context['ctx_oa'] = array(
415: 'preview_hide' => _("Hide Preview"),
416: 'preview_show' => _("Show Preview"),
417: 'layout_horiz' => _("Horizontal Layout"),
418: 'layout_vert' => _("Vertical Layout"),
419: '_sub1' => array(
420: '_sep1' => null,
421: 'setflag' => _("Mark as") . '...',
422: 'unsetflag' => _("Unmark as") . '...',
423: ),
424: 'blacklist' => _("Blacklist"),
425: 'whitelist' => _("Whitelist"),
426: '_sub2' => array(
427: '_sep2' => null,
428: 'purge_deleted' => _("Purge Deleted"),
429: 'undelete' => _("Undelete")
430: ),
431: 'show_deleted' => _("Show Deleted"),
432: 'hide_deleted' => _("Hide Deleted"),
433: '_sub3' => array(
434: '_sep3' => null,
435: 'clear_sort' => _("Clear Sort")
436: )
437: );
438: if ($prefs->getValue('use_trash')) {
439: unset($context['ctx_oa']['_sub2']);
440: }
441: if ($prefs->isLocked('delhide')) {
442: unset($context['ctx_oa']['hide_deleted']);
443: }
444:
445:
446: if (!$registry->hasMethod('mail/blacklistFrom')) {
447: unset(
448: $context['ctx_message']['blacklist'],
449: $context['ctx_oa']['blacklist']
450: );
451: }
452: if (!$registry->hasMethod('mail/whitelistFrom')) {
453: unset(
454: $context['ctx_message']['whitelist'],
455: $context['ctx_oa']['whitelist']
456: );
457: }
458:
459:
460: $context['ctx_preview'] = array(
461: 'save' => _("Save"),
462: 'viewsource' => _("View Source"),
463: 'allparts' => _("All Parts"),
464: 'thread' => _("View Thread"),
465: 'listinfo' => _("List Info")
466: );
467:
468: if (empty($conf['user']['allow_view_source'])) {
469: unset($context['ctx_preview']['viewsource']);
470: }
471:
472:
473: if ($imp_imap->access(IMP_Imap::ACCESS_SEARCH)) {
474: $context['ctx_filteropts'] = array(
475: '*filter' => _("Filter By"),
476: '*flag' => _("Show Only"),
477: '*flagnot' => _("Don't Show")
478: );
479: if (IMP_Filter::canApplyFilters()) {
480: $context['ctx_filteropts']['_sub1'] = array(
481: '_sep1' => null,
482: 'applyfilters' => _("Apply Filters")
483: );
484: }
485:
486: $context['ctx_qsearchopts'] = array(
487: '*all' => _("Entire Message"),
488: '*body' => _("Body"),
489: '*from' => _("From"),
490: '*recip' => _("Recipients (To/Cc/Bcc)"),
491: '*subject' => _("Subject"),
492: '_sep1' => null,
493: '*advanced' => _("Advanced Search...")
494: );
495:
496: $iterator = IMP_Search_IteratorFilter::create(
497: IMP_Search_IteratorFilter::FILTER
498: );
499:
500: $context['ctx_filter'] = array();
501: foreach ($iterator as $val) {
502: if ($val->enabled) {
503: $context['ctx_filter']['*' . $val->id] = $val->label;
504: }
505: }
506: }
507:
508:
509: if ($imp_imap->access(IMP_Imap::ACCESS_REMOTE)) {
510: $context['ctx_rcontainer'] = array(
511: '*prefs' => _("Manage Remote Accounts")
512: );
513: }
514:
515: $this->js_context = array_merge($context, $this->js_context);
516:
517: $this->js_text += array(
518: 'badaddr' => _("Invalid Address"),
519: 'badsubject' => _("Invalid Subject"),
520: 'baselevel' => _("base level of the folder tree"),
521: 'check' => _("Checking..."),
522: 'copyto' => _("Copy %s to %s"),
523: 'create_prompt' => _("Create mailbox:"),
524: 'createsub_prompt' => _("Create subfolder of %s:"),
525: 'delete_mbox' => _("Permanently delete %s?"),
526: 'download_mbox' => _("All messages in this mailbox will be downloaded into the format that you choose. Depending on the size of the mailbox, this action may take awhile."),
527: 'empty_mbox' => _("Permanently delete all %d messages in %s?"),
528: 'import_mbox' => _("Mbox or .eml file:"),
529: 'import_mbox_loading' => _("Importing (this may take some time)..."),
530: 'listmsg_wait' => _("The server is still generating the message list."),
531: 'listmsg_timeout' => _("The server was unable to generate the message list."),
532: 'loading' => _("Loading..."),
533: 'message_0' => _("No messages"),
534: 'message_1' => _("1 message"),
535: 'message_2' => _("%d messages"),
536: 'mboxsize' => _("%s is: %s."),
537: 'moveto' => _("Move %s to %s"),
538: 'newflag_name' => _("Flag Name:"),
539: 'newflag_wait' => _("Creating New Flag..."),
540: 'onlogout' => _("Logging Out..."),
541: 'portal' => _("Portal"),
542: 'prefs' => _("User Options"),
543: 'remote_password' => _("Password for %s:"),
544: 'rename_prompt' => _("Rename %s to:"),
545: 'search' => _("Search"),
546: 'search_input' => _("Search (%s)"),
547: 'search_time' => _("Results are %d Minutes Old"),
548: 'selected' => _("%s selected."),
549: 'slidertext' => _("Messages %d - %d"),
550: 'vfolder' => _("Virtual Folder: %s"),
551: 'vp_empty' => _("There are no messages in this mailbox."),
552: 'vp_empty_search' => _("No messages matched the search query.")
553: );
554:
555: if ($subscribe) {
556: $this->js_text += array(
557: 'subscribe_mbox' => _("Subscribe to %s?"),
558: 'subscribe_mbox_subfolders' => _("Subscribe to all subfolders of %s?"),
559: 'unsubscribe_mbox' => _("Unsubscribe to %s?"),
560: 'unsubscribe_mbox_subfolders' => _("Unsubscribe to all subfolders of %s?"),
561: );
562: }
563: }
564:
565: }
566: