canHtmlCompose() public static method

Is the HTML editor available for compostion?
public static canHtmlCompose ( ) : boolean
return boolean True if HTML editor is available.
Ejemplo n.º 1
0
 /**
  * Constructor.
  */
 public function __construct()
 {
     global $page_output, $prefs, $registry;
     $this->_files[] = new Horde_Script_File_JsDir('compose.js', 'imp');
     $this->_files[] = new Horde_Script_File_JsDir('draghandler.js', 'imp');
     $this->_files[] = new Horde_Script_File_JsDir('editor.js', 'imp');
     $this->_files[] = new Horde_Script_File_JsDir('imp.js', 'imp');
     if (!$prefs->isLocked('default_encrypt') && (IMP_Pgp::enabled() || IMP_Smime::enabled())) {
         $page_output->addScriptPackage('Horde_Core_Script_Package_Dialog');
         $this->_files[] = new Horde_Script_File_JsDir('passphrase.js', 'imp');
     }
     if (!IMP_Compose::canHtmlCompose()) {
         return;
     }
     switch ($registry->getView()) {
         case $registry::VIEW_BASIC:
         case $registry::VIEW_DYNAMIC:
             $this->_files[] = new Horde_Script_File_JsDir('ckeditor/imageupload.js', 'imp');
             $this->_files[] = new Horde_Script_File_JsDir('ckeditor/images.js', 'imp');
             $page_output->addInlineJsVars(array('ImpCkeditorImgs.related_attr' => IMP_Compose::RELATED_ATTR));
             $js = new Horde_Script_File_JsDir('ckeditor/pasteattachment.js', 'imp');
             $upload_url = $registry->getServiceLink('ajax', 'imp')->url . 'addAttachmentCkeditor';
             $page_output->addInlineScript(array('if (window.CKEDITOR) { CKEDITOR.on("loaded", function(e) {' . 'CKEDITOR.plugins.addExternal("pasteattachment", "' . $js->url->url . '", "");' . 'CKEDITOR.config.filebrowserImageUploadUrl = "' . $upload_url . '";' . '}); };'), true);
             break;
     }
 }
Ejemplo n.º 2
0
 /**
  */
 protected function _compose($base, $view, $args)
 {
     global $injector, $registry, $page_output, $prefs;
     $view->title = $args['title'];
     /* Load Identity. */
     $identity = $injector->getInstance('IMP_Identity');
     $selected_identity = intval($identity->getDefault());
     /* Generate identities list. */
     $this->_addIdentityJs();
     if (IMP_Compose::canHtmlCompose()) {
         $view->compose_html = !empty($args['show_editor']);
         $view->rte = true;
         $page_output->addScriptPackage('IMP_Script_Package_Editor');
         $page_output->addScriptFile('external/base64.js');
     }
     /* Create list for sent-mail selection. */
     $imp_imap = $injector->getInstance('IMP_Factory_Imap')->create();
     if ($imp_imap->access(IMP_Imap::ACCESS_FOLDERS) && !$prefs->isLocked('save_sent_mail')) {
         $view->save_sent_mail = true;
         $view->save_sent_mail_select = !$prefs->isLocked(IMP_Mailbox::MBOX_SENT);
     }
     $view->drafts = $imp_imap->access(IMP_Imap::ACCESS_DRAFTS) && ($draft = IMP_Mailbox::getPref(IMP_Mailbox::MBOX_DRAFTS)) && !$draft->readonly;
     $view->compose_link = $registry->getServiceLink('ajax', 'imp')->url . 'addAttachment';
     $view->resume = !empty($args['resume']);
     $view->is_template = !empty($args['template']);
     $view->read_receipt_set = strcasecmp($prefs->getValue('request_mdn'), 'always') === 0;
     $view->user = $registry->getAuth();
     if (IMP_Compose::canUploadAttachment()) {
         $view->attach = true;
         $view->max_size = IMP_Compose::maxAttachmentSize();
         $view->save_attach_set = strcasecmp($prefs->getValue('save_attachments'), 'always') === 0;
     } else {
         $view->attach = false;
     }
     if ($prefs->getValue('use_pgp') && $prefs->getValue('pgp_public_key')) {
         $view->pgp_pubkey = $prefs->getValue('pgp_attach_pubkey');
     }
     if ($registry->hasMethod('contacts/ownVCard')) {
         $view->vcard_attach = true;
     }
     $view->priority = $prefs->getValue('set_priority');
     if (!$prefs->isLocked('default_encrypt') && (IMP_Pgp::enabled() || IMP_Smime::enabled())) {
         $view->encrypt = $prefs->getValue('default_encrypt');
     }
     $from_list = array();
     foreach ($identity->getSelectList() as $id => $from) {
         $from_list[] = array('label' => $from, 'sel' => $id == $selected_identity, 'val' => $id);
     }
     $view->from_list = $from_list;
     $view->signature = $identity->hasSignature(true);
     $view->sigExpanded = $prefs->getValue('signature_expanded');
 }
Ejemplo n.º 3
0
 /**
  * URL parameters:
  *   - bcc: BCC addresses.
  *   - bcc_json: JSON encoded addresses to send to. Overwrites 'bcc'.
  *   - body: Message body text.
  *   - cc: CC addresses.
  *   - cc_json: JSON encoded addresses to send to. Overwrites 'cc'.
  *   - identity: Force message to use this identity by default.
  *   - popup_link: Compose window generated via a popup link.
  *   - subject: Subject to use.
  *   - type: redirect, reply, reply_auto, reply_all, reply_list,
  *           forward_attach, forward_auto, forward_body, forward_both,
  *           forward_redirect, resume, new, new_to, editasnew, template,
  *           template_edit, template_new
  *   - to: Addresses to send to.
  *   - to_json: JSON encoded addresses to send to. Overwrites 'to'.
  */
 protected function _init()
 {
     global $injector, $notification, $page_output, $prefs;
     $alist = $injector->getInstance('IMP_Dynamic_AddressList');
     $clink = new IMP_Compose_Link($this->vars);
     $addr = array();
     foreach (array('to', 'cc', 'bcc') as $val) {
         $var_name = $val . '_json';
         if (isset($this->vars->{$var_name})) {
             /* Check for JSON encoded information. */
             $addr[$val] = $alist->parseAddressList($this->vars->{$var_name});
         } elseif (isset($clink->args[$val])) {
             /* Non-JSON encoded address information. */
             $addr[$val] = IMP::parseAddressList($clink->args[$val]);
         }
     }
     $subject = isset($clink->args['subject']) ? $clink->args['subject'] : null;
     $identity = $injector->getInstance('IMP_Identity');
     if (!$prefs->isLocked('default_identity') && isset($this->vars->identity)) {
         $identity->setDefault($this->vars->identity);
     }
     /* Init objects. */
     $imp_compose = $injector->getInstance('IMP_Factory_Compose')->create();
     $compose_ajax = new IMP_Ajax_Application_Compose($imp_compose, $this->vars->type);
     $ajax_queue = $injector->getInstance('IMP_Ajax_Queue');
     $ajax_queue->compose($imp_compose);
     $compose_opts = array('title' => _("New Message"));
     switch ($this->vars->type) {
         case 'reply':
         case 'reply_all':
         case 'reply_auto':
         case 'reply_list':
             try {
                 $result = $imp_compose->replyMessage($compose_ajax->reply_map[$this->vars->type], $this->_getContents(), array('to' => isset($addr['to']) ? $addr['to'] : null));
             } catch (IMP_Exception $e) {
                 $notification->push($e, 'horde.error');
                 break;
             }
             $onload = $compose_ajax->getResponse($result);
             switch ($result['type']) {
                 case IMP_Compose::REPLY_SENDER:
                     $compose_opts['title'] = _("Reply");
                     break;
                 case IMP_Compose::REPLY_ALL:
                     $compose_opts['title'] = _("Reply to All");
                     break;
                 case IMP_Compose::REPLY_LIST:
                     $compose_opts['title'] = _("Reply to List");
                     break;
             }
             $compose_opts['title'] .= ': ' . $result['subject'];
             break;
         case 'forward_attach':
         case 'forward_auto':
         case 'forward_body':
         case 'forward_both':
             try {
                 if (count($this->indices) > 1) {
                     if (!in_array($this->vars->type, array('forward_attach', 'forward_auto'))) {
                         $notification->push(_("Multiple messages can only be forwarded as attachments."), 'horde.warning');
                     }
                     $result = $imp_compose->forwardMultipleMessages($this->indices);
                 } else {
                     $result = $imp_compose->forwardMessage($compose_ajax->forward_map[$this->vars->type], $this->_getContents());
                 }
             } catch (IMP_Exception $e) {
                 $notification->push($e, 'horde.error');
                 break;
             }
             $onload = $compose_ajax->getResponse($result);
             $compose_opts['title'] = $result['title'];
             $ajax_queue->attachment($imp_compose, IMP_Compose::FORWARD_ATTACH);
             break;
         case 'forward_redirect':
             try {
                 $imp_compose->redirectMessage($this->indices);
                 $compose_opts['title'] = _("Redirect");
             } catch (IMP_Compose_Exception $e) {
                 $notification->push($e, 'horde.error');
             }
             // Not used in JS
             $onload = new stdClass();
             break;
         case 'editasnew':
         case 'resume':
         case 'template':
         case 'template_edit':
             try {
                 switch ($this->vars->type) {
                     case 'editasnew':
                         $result = $imp_compose->editAsNew($this->indices);
                         break;
                     case 'resume':
                         $result = $imp_compose->resumeDraft($this->indices);
                         $compose_opts['resume'] = true;
                         break;
                     case 'template':
                         $result = $imp_compose->useTemplate($this->indices);
                         break;
                     case 'template_edit':
                         $result = $imp_compose->editTemplate($this->indices);
                         $compose_opts['template'] = true;
                         break;
                 }
                 $onload = $compose_ajax->getResponse($result);
                 $ajax_queue->attachment($imp_compose, $result['type']);
                 $show_editor = $result['format'] == 'html';
             } catch (IMP_Compose_Exception $e) {
                 $notification->push($e);
             }
             break;
         case 'new_to':
             $h = $this->_getContents()->getHeader();
             $f = $h['reply-to'] ?: $h['from'];
             $addr['to'] = $f->getAddressList(true);
             // Fall-through
         // Fall-through
         case 'new':
         case 'template_new':
         default:
             $show_editor = $prefs->getValue('compose_html') && IMP_Compose::canHtmlCompose();
             $onload = $compose_ajax->getBaseResponse();
             $onload->body = isset($clink->args['body']) ? strval($clink->args['body']) : '';
             if ($show_editor) {
                 $onload->format = 'html';
             }
             if ($this->vars->type == 'template_new') {
                 $compose_opts['template'] = true;
             }
             break;
     }
     $compose_opts['redirect'] = $this->vars->type == 'forward_redirect';
     if (isset($onload->addr) || !empty($addr)) {
         foreach (array('to', 'cc', 'bcc') as $val) {
             if (!isset($onload->addr[$val])) {
                 $onload->addr[$val] = array();
             }
             if (isset($addr[$val])) {
                 $tmp = new IMP_Ajax_Addresses($addr[$val]);
                 $onload->addr[$val] = array_merge($onload->addr[$val], $tmp->toAutocompleteArray());
             }
         }
     }
     if (!is_null($subject)) {
         $onload->subject = $subject;
     }
     $this->title = $compose_opts['title'];
     $this->view->compose = $injector->getInstance('IMP_Dynamic_Compose_Common')->compose($this, $compose_opts);
     $page_output->addInlineJsVars(array('ImpCompose.popup_link' => intval($this->vars->popup_link), 'ImpCompose.onload_show' => $onload, 'ImpCompose.tasks' => $injector->getInstance('Horde_Core_Factory_Ajax')->create('imp', $this->vars)->getTasks()));
     Horde::startBuffer();
     $notification->notify(array('listeners' => array('status', 'audio')));
     $this->view->status = Horde::endBuffer();
     $this->_pages[] = 'compose-base';
 }
Ejemplo n.º 4
0
 * IMPORTANT: DO NOT EDIT THIS FILE! DO NOT COPY prefs.php TO prefs.local.php!
 * Local overrides ONLY MUST be placed in prefs.local.php or prefs.d/.
 * If the 'vhosts' setting has been enabled in Horde's configuration, you can
 * use prefs-servername.php.
 */
// *** Personal Information Preferences ***
$prefGroups['identities'] = array('column' => _("General"), 'label' => _("Personal Information"), 'desc' => _("Change the name, address, and signature that people see when they read and reply to your email."), 'members' => array('replyto_addr', 'alias_addr', 'tieto_addr', 'bcc_addr', 'signature', 'sig_dashes', 'signature_html_select', 'save_sent_mail', 'sent_mail_folder', 'sentmailselect'), 'type' => 'identities');
$_prefs['replyto_addr'] = array('value' => '', 'advanced' => true, 'type' => 'text', 'desc' => _("Your Reply-to: address: <em>(optional)</em>"));
$_prefs['alias_addr'] = array('value' => '', 'advanced' => true, 'type' => 'textarea', 'desc' => _("Your alias addresses: <em>(optional, enter each address on a new line)</em>"));
$_prefs['tieto_addr'] = array('value' => '', 'advanced' => true, 'type' => 'textarea', 'desc' => _("Addresses to explicitly tie to this identity: <em>(optional, enter each address on a new line)</em>"));
$_prefs['bcc_addr'] = array('value' => '', 'advanced' => true, 'type' => 'textarea', 'desc' => _("Addresses to BCC all messages: <em>(optional, enter each address on a new line)</em>"));
$_prefs['signature'] = array('value' => '', 'type' => 'textarea', 'desc' => _("Your signature:"));
$_prefs['sig_dashes'] = array('value' => 1, 'type' => 'checkbox', 'desc' => _("Precede your text signature with dashes ('-- ')?"));
// User's HTML signature - UI widget
$_prefs['signature_html_select'] = array('type' => 'special', 'handler' => 'IMP_Prefs_Special_HtmlSignature', 'requires_nolock' => array('signature_html'), 'suppress' => function () {
    return !IMP_Compose::canHtmlCompose();
});
// User's HTML signature
$_prefs['signature_html'] = array('value' => '');
// Show signature on compose screen?
$_prefs['signature_show_compose'] = array('value' => 0, 'type' => 'checkbox', 'desc' => _("Show the signature on the compose screen?"));
$_prefs['save_sent_mail'] = array('value' => 1, 'type' => 'checkbox', 'desc' => _("Save sent mail?"));
// sent mail mailbox
$_prefs['sent_mail_folder'] = array('value' => 'Sent');
// sent mail mailbox selection widget.
$_prefs['sentmailselect'] = array('type' => 'special', 'handler' => 'IMP_Prefs_Special_Sentmail', 'requires_nolock' => array('sent_mail_folder'));
// *** ACL Preferences ***
$prefGroups['acl'] = array('column' => _("General"), 'label' => _("Share Mailboxes"), 'desc' => _("Share your mailboxes with other users."), 'members' => array('aclmanagement'), 'suppress' => function () {
    return !$GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->access(IMP_Imap::ACCESS_ACL);
});
// ACL preference management screen