Overview

Packages

  • IMP
  • None

Classes

  • IMP
  • IMP_Ajax_Application
  • IMP_Ajax_Imple_ContactAutoCompleter
  • IMP_Ajax_Imple_PassphraseDialog
  • IMP_Ajax_Queue
  • IMP_Api
  • IMP_Auth
  • IMP_Block_Newmail
  • IMP_Block_Summary
  • IMP_Compose
  • IMP_Compose_Exception
  • IMP_Compose_Stationery
  • IMP_Contents
  • IMP_Crypt_Pgp
  • IMP_Crypt_Smime
  • IMP_Dimp
  • IMP_Exception
  • IMP_Factory_AuthImap
  • IMP_Factory_Compose
  • IMP_Factory_Contents
  • IMP_Factory_Flags
  • IMP_Factory_Identity
  • IMP_Factory_Imap
  • IMP_Factory_Imaptree
  • IMP_Factory_Mail
  • IMP_Factory_Mailbox
  • IMP_Factory_MailboxList
  • IMP_Factory_MimeViewer
  • IMP_Factory_Pgp
  • IMP_Factory_Quota
  • IMP_Factory_Search
  • IMP_Factory_Sentmail
  • IMP_Factory_Smime
  • IMP_Filter
  • IMP_Flag_Base
  • IMP_Flag_Imap
  • IMP_Flag_Imap_Answered
  • IMP_Flag_Imap_Deleted
  • IMP_Flag_Imap_Draft
  • IMP_Flag_Imap_Flagged
  • IMP_Flag_Imap_Forwarded
  • IMP_Flag_Imap_Junk
  • IMP_Flag_Imap_NotJunk
  • IMP_Flag_Imap_Seen
  • IMP_Flag_System_Attachment
  • IMP_Flag_System_Encrypted
  • IMP_Flag_System_HighPriority
  • IMP_Flag_System_List
  • IMP_Flag_System_LowPriority
  • IMP_Flag_System_Match_Address
  • IMP_Flag_System_Match_Flag
  • IMP_Flag_System_Match_Header
  • IMP_Flag_System_Personal
  • IMP_Flag_System_Signed
  • IMP_Flag_System_Unseen
  • IMP_Flag_User
  • IMP_Flags
  • IMP_Imap
  • IMP_Imap_Acl
  • IMP_Imap_Exception
  • IMP_Imap_PermanentFlags
  • IMP_Imap_Thread
  • IMP_Imap_Tree
  • IMP_Indices
  • IMP_Indices_Form
  • IMP_LoginTasks_SystemTask_GarbageCollection
  • IMP_LoginTasks_SystemTask_Upgrade
  • IMP_LoginTasks_SystemTask_UpgradeAuth
  • IMP_LoginTasks_Task_Autocreate
  • IMP_LoginTasks_Task_DeleteAttachmentsMonthly
  • IMP_LoginTasks_Task_DeleteSentmailMonthly
  • IMP_LoginTasks_Task_FilterOnLogin
  • IMP_LoginTasks_Task_PurgeSentmail
  • IMP_LoginTasks_Task_PurgeSpam
  • IMP_LoginTasks_Task_PurgeTrash
  • IMP_LoginTasks_Task_RecoverDraft
  • IMP_LoginTasks_Task_RenameSentmailMonthly
  • IMP_Mailbox
  • IMP_Mailbox_List
  • IMP_Mailbox_List_Track
  • IMP_Maillog
  • IMP_Menu_Dimp
  • IMP_Message
  • IMP_Mime_Status
  • IMP_Mime_Viewer_Alternative
  • IMP_Mime_Viewer_Appledouble
  • IMP_Mime_Viewer_Audio
  • IMP_Mime_Viewer_Enriched
  • IMP_Mime_Viewer_Externalbody
  • IMP_Mime_Viewer_Html
  • IMP_Mime_Viewer_Images
  • IMP_Mime_Viewer_Itip
  • IMP_Mime_Viewer_Mdn
  • IMP_Mime_Viewer_Partial
  • IMP_Mime_Viewer_Pdf
  • IMP_Mime_Viewer_Pgp
  • IMP_Mime_Viewer_Plain
  • IMP_Mime_Viewer_Related
  • IMP_Mime_Viewer_Rfc822
  • IMP_Mime_Viewer_Smil
  • IMP_Mime_Viewer_Smime
  • IMP_Mime_Viewer_Status
  • IMP_Mime_Viewer_Vcard
  • IMP_Mime_Viewer_Video
  • IMP_Mime_Viewer_Zip
  • IMP_Notification_Event_Status
  • IMP_Notification_Handler_Decorator_ImapAlerts
  • IMP_Notification_Handler_Decorator_NewmailNotify
  • IMP_Notification_Listener_AjaxStatus
  • Imp_Prefs_Identity
  • IMP_Prefs_Ui
  • IMP_Quota
  • IMP_Quota_Base
  • IMP_Quota_Command
  • IMP_Quota_Hook
  • IMP_Quota_Imap
  • IMP_Quota_Maildir
  • IMP_Quota_Mdaemon
  • IMP_Quota_Mercury32
  • IMP_Quota_Null
  • IMP_Quota_Sql
  • IMP_Search
  • IMP_Search_Element
  • IMP_Search_Element_Attachment
  • IMP_Search_Element_Autogenerated
  • IMP_Search_Element_Bulk
  • IMP_Search_Element_Contacts
  • IMP_Search_Element_Date
  • IMP_Search_Element_Flag
  • IMP_Search_Element_Header
  • IMP_Search_Element_Mailinglist
  • IMP_Search_Element_Or
  • IMP_Search_Element_Personal
  • IMP_Search_Element_Recipient
  • IMP_Search_Element_Size
  • IMP_Search_Element_Text
  • IMP_Search_Element_Within
  • IMP_Search_Filter
  • IMP_Search_Filter_Attachment
  • IMP_Search_Filter_Autogenerated
  • IMP_Search_Filter_Builtin
  • IMP_Search_Filter_Bulk
  • IMP_Search_Filter_Contacts
  • IMP_Search_Filter_Mailinglist
  • IMP_Search_Filter_Personal
  • IMP_Search_Query
  • IMP_Search_Vfolder
  • IMP_Search_Vfolder_Builtin
  • IMP_Search_Vfolder_Vinbox
  • IMP_Search_Vfolder_Vtrash
  • IMP_Sentmail
  • IMP_Sentmail_Base
  • IMP_Sentmail_Null
  • IMP_Sentmail_Sql
  • IMP_Spam
  • IMP_Test
  • IMP_Tree_Flist
  • IMP_Tree_Jquerymobile
  • IMP_Tree_Simplehtml
  • IMP_Ui_Compose
  • IMP_Ui_Editor
  • IMP_Ui_Folder
  • IMP_Ui_Headers
  • IMP_Ui_Imageview
  • IMP_Ui_Mailbox
  • IMP_Ui_Message
  • IMP_Ui_Mimp
  • IMP_Ui_Search
  • IMP_Views_Compose
  • IMP_Views_ListMessages
  • IMP_Views_ShowMessage
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * DIMP compose view logic.
  4:  *
  5:  * Copyright 2005-2012 Horde LLC (http://www.horde.org/)
  6:  *
  7:  * See the enclosed file COPYING for license information (GPL). If you
  8:  * did not receive this file, see http://www.horde.org/licenses/gpl.
  9:  *
 10:  * @author   Michael Slusarz <slusarz@horde.org>
 11:  * @category Horde
 12:  * @license  http://www.horde.org/licenses/gpl GPL
 13:  * @package  IMP
 14:  */
 15: class IMP_Views_Compose
 16: {
 17:     /**
 18:      * Create content needed to output the compose screen.
 19:      *
 20:      * @param array $args  Configuration parameters:
 21:      *   - composeCache: (string) The cache ID of the IMP_Compose object.
 22:      *   - fwdattach: (boolean) Are we forwarding and attaching the original
 23:      *     message?
 24:      *   - qreply: (boolean) Is this a quickreply view?
 25:      *   - redirect: (string) Display the redirect interface?
 26:      *   - show_editor: (boolean) Show the HTML editor?
 27:      *
 28:      * @return array  Array with the following keys:
 29:      *   - html: (string) The rendered HTML content.
 30:      *   - js: (array) Javascript code to run immediately.
 31:      *   - jsonload: (array) Javascript code to run on load.
 32:      */
 33:     static public function showCompose($args)
 34:     {
 35:         global $conf, $injector, $prefs, $registry, $session;
 36: 
 37:         $result = array(
 38:             'html' => '',
 39:             'js' => array(),
 40:             'jsonload' => array()
 41:         );
 42: 
 43:         $t = $injector->createInstance('Horde_Template');
 44:         $t->setOption('gettext', true);
 45: 
 46:         if (!empty($args['composeCache'])) {
 47:             $imp_compose = $injector->getInstance('IMP_Factory_Compose')->create($args['composeCache']);
 48:             $t->set('composeCache', $args['composeCache']);
 49:         }
 50: 
 51:         if (empty($args['redirect'])) {
 52:             /* Load Identity. */
 53:             $identity = $injector->getInstance('IMP_Identity');
 54:             $t->set('selected_identity', intval($identity->getDefault()));
 55: 
 56:             /* Generate identities list. */
 57:             $result['js'] = array_merge($result['js'], $injector->getInstance('IMP_Ui_Compose')->identityJs());
 58: 
 59:             if ($t->get('composeCache') && count($imp_compose)) {
 60:                 foreach ($imp_compose as $num => $atc) {
 61:                     $mime = $atc['part'];
 62:                     $opts = array(
 63:                         'name' => $mime->getName(true),
 64:                         'num' => intval($num),
 65:                         'size' => $mime->getSize(),
 66:                         'type' => $mime->getType()
 67:                     );
 68:                     if (!empty($args['fwdattach'])) {
 69:                         $opts['fwdattach'] = 1;
 70:                     }
 71:                     $result['jsonload'][] = 'DimpCompose.addAttach(' . Horde_Serialize::serialize($opts, Horde_Serialize::JSON, 'UTF-8') . ')';
 72:                 }
 73:             }
 74: 
 75:             if (!empty($args['qreply'])) {
 76:                 $result['js'][] = 'DIMP.conf_compose.qreply = 1';
 77:             }
 78: 
 79:             if ($session->get('imp', 'rteavail')) {
 80:                 $t->set('compose_html', !empty($args['show_editor']));
 81:                 $t->set('rte', true);
 82: 
 83:                 IMP_Ui_Editor::init(!$t->get('compose_html'));
 84:             }
 85: 
 86:             /* Create list for sent-mail selection. */
 87:             if ($injector->getInstance('IMP_Factory_Imap')->create()->access(IMP_Imap::ACCESS_FOLDERS)) {
 88:                 $t->set('save_sent_mail', !$prefs->isLocked('save_sent_mail'));
 89: 
 90:                 if (!empty($conf['user']['select_sentmail_folder']) &&
 91:                     !$prefs->isLocked('sent_mail_folder')) {
 92:                     /* Check to make sure the sent-mail folders are created -
 93:                      * they need to exist to show up in drop-down list. */
 94:                     foreach (array_keys($identity->getAll('id')) as $ident) {
 95:                         $folder = $identity->getValue('sent_mail_folder', $ident);
 96:                         if ($folder instanceof IMP_Mailbox) {
 97:                             $folder->create();
 98:                         }
 99:                     }
100: 
101:                     $flist = array();
102:                     $imaptree = $injector->getInstance('IMP_Imap_Tree');
103: 
104:                     foreach ($imaptree as $val) {
105:                         $tmp = array(
106:                             'f' => $val->display,
107:                             'l' => Horde_String::abbreviate(str_repeat(' ', 2 * $val->level) . $val->basename, 30),
108:                             'v' => $val->container ? '' : $val->form_to
109:                         );
110:                         if ($tmp['f'] == $tmp['v']) {
111:                             unset($tmp['f']);
112:                         }
113:                         $flist[] = $tmp;
114:                     }
115:                     $result['js'] = array_merge($result['js'], Horde::addInlineJsVars(array(
116:                         'DIMP.conf_compose.flist' => $flist
117:                     ), array('ret_vars' => true)));
118:                 }
119:             }
120: 
121:             $compose_link = Horde::getServiceLink('ajax', 'imp');
122:             $compose_link->pathInfo = 'addAttachment';
123:             $t->set('compose_link', $compose_link);
124: 
125:             $t->set('send_button', IMP_Dimp::actionButton(array(
126:                 'icon' => 'Forward',
127:                 'id' => 'send_button',
128:                 'title' => _("Send")
129:             )));
130:             $t->set('spell_button', IMP_Dimp::actionButton(array(
131:                 'id' => 'spellcheck',
132:                 'title' => _("Check Spelling")
133:             )));
134:             $t->set('draft_button', IMP_Dimp::actionButton(array(
135:                 'icon' => 'Drafts',
136:                 'id' => 'draft_button',
137:                 'title' => _("Save as Draft")
138:             )));
139: 
140:             $d_read = $prefs->getValue('request_mdn');
141:             if ($d_read != 'never') {
142:                 $t->set('read_receipt', true);
143:                 $t->set('read_receipt_set', ($d_read != 'ask'));
144:             }
145: 
146:             $t->set('priority', $prefs->getValue('set_priority'));
147:             if (!$prefs->isLocked('default_encrypt') &&
148:                 ($prefs->getValue('use_pgp') || $prefs->getValue('use_smime'))) {
149:                 $t->set('encrypt', $prefs->getValue('default_encrypt'));
150:             }
151: 
152:             $select_list = array();
153:             foreach ($identity->getSelectList() as $id => $from) {
154:                 $select_list[] = array(
155:                     'label' => htmlspecialchars($from),
156:                     'sel' => ($id == $t->get('selected_identity')),
157:                     'val' => htmlspecialchars($id)
158:                 );
159:             }
160:             $t->set('select_list', $select_list);
161: 
162:             $save_attach = $prefs->getValue('save_attachments');
163:             if (strpos($save_attach, 'prompt') !== false) {
164:                 $t->set('save_attach', true);
165:                 $t->set('save_attach_set', strpos($save_attach, 'yes') !== false);
166:             }
167:         } else {
168:             $result['js'] = array_merge($result['js'], Horde::addInlineJsVars(array(
169:                 '-DIMP.conf_compose.redirect' => 1
170:             ), array('ret_vars' => true)));
171:         }
172: 
173:         $t->set('bcc', $prefs->getValue('compose_bcc'));
174:         $t->set('cc', $prefs->getValue('compose_cc'));
175:         $t->set('bcc_or_cc', $t->get('bcc') || $t->get('cc'));
176:         $t->set('compose_enable', IMP::canCompose());
177:         $t->set('forminput', Horde_Util::formInput());
178:         $t->set('redirect_button', IMP_Dimp::actionButton(array(
179:             'icon' => 'Forward',
180:             'id' => 'send_button_redirect',
181:             'title' => _("Redirect")
182:         )));
183: 
184:         $result['html'] = $t->fetch(IMP_TEMPLATES . '/dimp/compose/compose.html');
185: 
186:         return $result;
187:     }
188: 
189: }
190: 
API documentation generated by ApiGen