sizeFormat() public static méthode

Get size display information.
public static sizeFormat ( integer $size ) : string
$size integer The byte size of data.
Résultat string A formatted size string.
Exemple #1
0
 /**
  * Return the rendered information about the Horde_Mime_Part object.
  *
  * URL parameters used by this function:
  *   - zip_contents: (integer) If set, show contents of ZIP file.
  *
  * @return array  See Horde_Mime_Viewer_Driver::render().
  */
 protected function _renderInfo()
 {
     global $injector;
     $vars = $injector->getInstance('Horde_Variables');
     if (!$this->getConfigParam('show_contents') && !$vars->zip_contents) {
         $status = new IMP_Mime_Status($this->_mimepart, _("This is a compressed file."));
         $status->addMimeAction('zipViewContents', _("Click to display the file contents."));
         $status->icon('mime/compressed.png');
         return array($this->_mimepart->getMimeId() => array('data' => '', 'status' => $status, 'type' => 'text/html; charset=UTF-8'));
     }
     $view = new Horde_View(array('templatePath' => IMP_TEMPLATES . '/mime'));
     $view->addHelper('Text');
     $view->downloadclass = 'zipdownload';
     $view->files = array();
     $view->tableclass = 'zipcontents';
     $zlib = Horde_Util::extensionExists('zlib');
     foreach ($this->_getZipInfo() as $key => $val) {
         $file = new stdClass();
         $file->name = $val['name'];
         $file->size = IMP::sizeFormat($val['size']);
         /* TODO: Add ability to render in-browser for filetypes we can
          *       handle. */
         if (!empty($val['size']) && strstr($val['attr'], 'D') === false && ($zlib && $val['method'] == 0x8 || $val['method'] == 0x0)) {
             $file->download = $this->getConfigParam('imp_contents')->linkView($this->_mimepart, 'download_render', '', array('class' => 'iconImg downloadAtc', 'jstext' => _("Download"), 'params' => array('zip_attachment' => $key)));
         } else {
             $file->download = '';
         }
         $view->files[] = $file;
     }
     return array($this->_mimepart->getMimeId() => array('data' => $view->render('compressed'), 'type' => 'text/html; charset=UTF-8'));
 }
Exemple #2
0
 /**
  * Return the rendered information about the Horde_Mime_Part object.
  *
  * URL parameters used by this function:
  *   - tgz_contents: (integer) If set, show contents of ZIP file.
  *
  * @return array  See Horde_Mime_Viewer_Driver::render().
  */
 protected function _renderInfo()
 {
     global $injector;
     $vars = $injector->getInstance('Horde_Variables');
     if (!$this->getConfigParam('show_contents') && !isset($vars->tgz_contents)) {
         $status = new IMP_Mime_Status($this->_mimepart, _("This is a compressed file."));
         $status->addMimeAction('tgzViewContents', _("Click to display the file contents."));
         $status->icon('mime/compressed.png');
         return array($this->_mimepart->getMimeId() => array('data' => '', 'status' => $status, 'type' => 'text/html; charset=UTF-8'));
     }
     $view = new Horde_View(array('templatePath' => IMP_TEMPLATES . '/mime'));
     $view->addHelper('Text');
     $view->downloadclass = 'tgzdownload';
     $view->files = array();
     $view->tableclass = 'tgzcontents';
     $tgzInfo = $this->_getTgzInfo();
     foreach ($tgzInfo as $key => $val) {
         if (!strlen($val['data'])) {
             continue;
         }
         $file = new stdClass();
         $file->download = '';
         $file->name = $val['name'];
         $file->size = IMP::sizeFormat($val['size']);
         if (!empty($val['size'])) {
             $file->download = $this->getConfigParam('imp_contents')->linkView($this->_mimepart, 'download_render', '', array('class' => 'iconImg downloadAtc', 'jstext' => _("Download"), 'params' => array('tgz_attachment' => $key)));
         }
         $view->files[] = $file;
     }
     return array($this->_mimepart->getMimeId() => array('data' => $view->render('compressed'), 'type' => 'text/html; charset=UTF-8'));
 }
Exemple #3
0
 /**
  * URL Parameters:
  *   - a: (string) The action ID.
  *   - action: (string) The action ID (used on redirect page).
  *   - bcc: (string) BCC address(es).
  *   - bcc_expand_[1-5]: (string) Expand matches for BCC addresses.
  *   - cc: (string) CC address(es).
  *   - cc_expand_[1-5]: (string) Expand matches for BCC addresses.
  *   - composeCache: (string) Compose object cache ID.
  *   - from: (string) From address to use.
  *   - identity: (integer) The identity to use for composing.
  *   - message: (string) Message text.
  *   - subject: (string) Message subject.
  *   - to: (string) To address(es).
  *   - to_expand_[1-5]: (string) Expand matches for To addresses.
  *   - u: (string) Unique ID (cache buster).
  */
 protected function _init()
 {
     global $injector, $notification, $prefs, $registry;
     /* The message text and headers. */
     $expand = array();
     $header = array('to' => '', 'cc' => '', 'bcc' => '');
     $msg = '';
     $this->title = _("Compose Message");
     /* Get the list of headers to display. */
     $display_hdrs = array('to' => _("To: "), 'cc' => _("Cc: "), 'bcc' => "Bcc: ");
     /* Set the current identity. */
     $identity = $injector->getInstance('IMP_Identity');
     if (!$prefs->isLocked('default_identity') && isset($this->vars->identity)) {
         $identity->setDefault($this->vars->identity);
     }
     /* Determine if mailboxes are readonly. */
     $drafts = IMP_Mailbox::getPref(IMP_Mailbox::MBOX_DRAFTS);
     $readonly_drafts = $drafts && $drafts->readonly;
     $sent_mail = $identity->getValue(IMP_Mailbox::MBOX_SENT);
     $save_sent_mail = !$sent_mail || $sent_mail->readonly ? false : $prefs->getValue('save_sent_mail');
     /* Determine if compose mode is disabled. */
     $compose_disable = !IMP_Compose::canCompose();
     /* Initialize objects. */
     $imp_compose = $injector->getInstance('IMP_Factory_Compose')->create($this->vars->composeCache);
     /* Are attachments allowed? */
     $attach_upload = $imp_compose->canUploadAttachment();
     foreach (array_keys($display_hdrs) as $val) {
         $header[$val] = $this->vars->{$val};
         /* If we are reloading the screen, check for expand matches. */
         if ($this->vars->composeCache) {
             $expanded = array();
             for ($i = 0; $i < 5; ++$i) {
                 if ($tmp = $this->vars->get($val . '_expand_' . $i)) {
                     $expanded[] = $tmp;
                 }
             }
             if (!empty($expanded)) {
                 $header['to'] = strlen($header['to']) ? implode(', ', $expanded) . ', ' . $header['to'] : implode(', ', $expanded);
             }
         }
     }
     /* Add attachment. */
     if ($attach_upload && isset($_FILES['upload_1']) && strlen($_FILES['upload_1']['name'])) {
         try {
             $atc_ob = $imp_compose->addAttachmentFromUpload('upload_1');
             if ($atc_ob[0] instanceof IMP_Compose_Exception) {
                 throw $atc_ob[0];
             }
             if ($this->vars->a == _("Expand Names")) {
                 $notification->push(sprintf(_("Added \"%s\" as an attachment."), $atc_ob[0]->getPart()->getName()), 'horde.success');
             }
         } catch (IMP_Compose_Exception $e) {
             $this->vars->a = null;
             $notification->push($e, 'horde.error');
         }
     }
     /* Run through the action handlers. */
     switch ($this->vars->a) {
         // 'd' = draft
         // 'en' = edit as new
         // 't' = template
         case 'd':
         case 'en':
         case 't':
             try {
                 switch ($this->vars->a) {
                     case 'd':
                         $result = $imp_compose->resumeDraft($this->indices, array('format' => 'text'));
                         $this->view->resume = true;
                         break;
                     case 'en':
                         $result = $imp_compose->editAsNew($this->indices, array('format' => 'text'));
                         break;
                     case 't':
                         $result = $imp_compose->useTemplate($this->indices, array('format' => 'text'));
                         break;
                 }
                 $msg = $result['body'];
                 $header = array_merge($header, $this->_convertToHeader($result));
                 if (!is_null($result['identity']) && $result['identity'] != $identity->getDefault() && !$prefs->isLocked('default_identity')) {
                     $identity->setDefault($result['identity']);
                     $sent_mail = $identity->getValue(IMP_Mailbox::MBOX_SENT);
                 }
             } catch (IMP_Compose_Exception $e) {
                 $notification->push($e);
             }
             break;
         case _("Expand Names"):
             foreach (array_keys($display_hdrs) as $val) {
                 if ($val == 'to' || $this->vars->action != 'rc') {
                     $res = $this->_expandAddresses($header[$val]);
                     if (is_string($res)) {
                         $header[$val] = $res;
                     } else {
                         $header[$val] = $res[0];
                         $expand[$val] = array_slice($res, 1);
                     }
                 }
             }
             if (isset($this->vars->action)) {
                 $this->vars->a = $this->vars->action;
             }
             break;
             // 'r' = reply
             // 'rl' = reply to list
             // 'ra' = reply to all
         // 'r' = reply
         // 'rl' = reply to list
         // 'ra' = reply to all
         case 'r':
         case 'ra':
         case 'rl':
             $actions = array('r' => IMP_Compose::REPLY_SENDER, 'ra' => IMP_Compose::REPLY_ALL, 'rl' => IMP_Compose::REPLY_LIST);
             try {
                 $reply_msg = $imp_compose->replyMessage($actions[$this->vars->a], $this->_getContents(), array('format' => 'text', 'to' => $header['to']));
             } catch (IMP_Exception $e) {
                 $notification->push($e, 'horde.error');
                 break;
             }
             $header = $this->_convertToHeader($reply_msg);
             $notification->push(_("Reply text will be automatically appended to your outgoing message."), 'horde.message');
             $this->title = _("Reply");
             break;
             // 'f' = forward
         // 'f' = forward
         case 'f':
             try {
                 $fwd_msg = $imp_compose->forwardMessage(IMP_Compose::FORWARD_ATTACH, $this->_getContents(), false);
             } catch (IMP_Exception $e) {
                 $notification->push($e, 'horde.error');
                 break;
             }
             $header = $this->_convertToHeader($fwd_msg);
             $notification->push(_("Forwarded message will be automatically added to your outgoing message."), 'horde.message');
             $this->title = _("Forward");
             break;
             // 'rc' = redirect compose
         // 'rc' = redirect compose
         case 'rc':
             $imp_compose->redirectMessage($this->indices);
             $this->title = _("Redirect");
             break;
         case _("Redirect"):
             try {
                 $num_msgs = $imp_compose->sendRedirectMessage($header['to']);
                 $imp_compose->destroy('send');
                 $notification->push(ngettext("Message redirected successfully.", "Messages redirected successfully.", count($num_msgs)), 'horde.success');
                 IMP_Minimal_Mailbox::url(array('mailbox' => $this->indices->mailbox))->redirect();
             } catch (Horde_Exception $e) {
                 $this->vars->a = 'rc';
                 $notification->push($e);
             }
             break;
         case _("Save Draft"):
         case _("Send"):
             switch ($this->vars->a) {
                 case _("Save Draft"):
                     if ($readonly_drafts) {
                         break 2;
                     }
                     break;
                 case _("Send"):
                     if ($compose_disable) {
                         break 2;
                     }
                     break;
             }
             $message = strval($this->vars->message);
             $f_to = $header['to'];
             $old_header = $header;
             $header = array();
             switch ($imp_compose->replyType(true)) {
                 case IMP_Compose::REPLY:
                     try {
                         $reply_msg = $imp_compose->replyMessage(IMP_Compose::REPLY_SENDER, $imp_compose->getContentsOb(), array('to' => $f_to));
                         $msg = $reply_msg['body'];
                     } catch (IMP_Exception $e) {
                         $notification->push($e, 'horde.error');
                         $msg = '';
                     }
                     $message .= "\n" . $msg;
                     break;
                 case IMP_Compose::FORWARD:
                     try {
                         $fwd_msg = $imp_compose->forwardMessage(IMP_Compose::FORWARD_ATTACH, $imp_compose->getContentsOb());
                         $msg = $fwd_msg['body'];
                     } catch (IMP_Exception $e) {
                         $notification->push($e, 'horde.error');
                     }
                     $message .= "\n" . $msg;
                     break;
             }
             try {
                 $header['from'] = strval($identity->getFromLine(null, $this->vars->from));
             } catch (Horde_Exception $e) {
                 $header['from'] = '';
             }
             $header['replyto'] = $identity->getValue('replyto_addr');
             $header['subject'] = strval($this->vars->subject);
             foreach (array_keys($display_hdrs) as $val) {
                 $header[$val] = $old_header[$val];
             }
             switch ($this->vars->a) {
                 case _("Save Draft"):
                     try {
                         $notification->push($imp_compose->saveDraft($header, $message), 'horde.success');
                         if ($prefs->getValue('close_draft')) {
                             $imp_compose->destroy('save_draft');
                             IMP_Minimal_Mailbox::url(array('mailbox' => $this->indices->mailbox))->redirect();
                         }
                     } catch (IMP_Compose_Exception $e) {
                         $notification->push($e);
                     }
                     break;
                 case _("Send"):
                     try {
                         $imp_compose->buildAndSendMessage($message, $header, $identity, array('readreceipt' => $prefs->getValue('request_mdn') == 'always', 'save_sent' => $save_sent_mail, 'sent_mail' => $sent_mail));
                         $imp_compose->destroy('send');
                         $notification->push(_("Message sent successfully."), 'horde.success');
                         IMP_Minimal_Mailbox::url(array('mailbox' => $this->indices->mailbox))->redirect();
                     } catch (IMP_Compose_Exception $e) {
                         $notification->push($e);
                         /* Switch to tied identity. */
                         if (!is_null($e->tied_identity)) {
                             $identity->setDefault($e->tied_identity);
                             $notification->push(_("Your identity has been switched to the identity associated with the current recipient address. The identity will not be checked again during this compose action."));
                         }
                     }
                     break;
             }
             break;
         case _("Cancel"):
             $imp_compose->destroy('cancel');
             IMP_Minimal_Mailbox::url(array('mailbox' => $this->indices->mailbox))->redirect();
             exit;
         case _("Discard Draft"):
             $imp_compose->destroy('discard');
             IMP_Minimal_Mailbox::url(array('mailbox' => $this->indices->mailbox))->redirect();
             exit;
     }
     /* Grab any data that we were supplied with. */
     if (empty($msg)) {
         $msg = strval($this->vars->message);
     }
     if (empty($header['subject'])) {
         $header['subject'] = strval($this->vars->subject);
     }
     $this->view->cacheid = $imp_compose->getCacheId();
     $this->view->hmac = $imp_compose->getHmac();
     $this->view->menu = $this->getMenu('compose');
     $this->view->url = self::url();
     $this->view->user = $registry->getAuth();
     switch ($this->vars->a) {
         case 'rc':
             $this->_pages[] = 'redirect';
             $this->_pages[] = 'menu';
             unset($display_hdrs['cc'], $display_hdrs['bcc']);
             break;
         default:
             $this->_pages[] = 'compose';
             $this->_pages[] = 'menu';
             $this->view->compose_enable = !$compose_disable;
             $this->view->msg = $msg;
             $this->view->save_draft = $injector->getInstance('IMP_Factory_Imap')->create()->access(IMP_Imap::ACCESS_DRAFTS) && !$readonly_drafts;
             $this->view->subject = $header['subject'];
             $select_list = $identity->getSelectList();
             $default_identity = $identity->getDefault();
             if ($prefs->isLocked('default_identity')) {
                 $select_list = array($default_identity => $select_list[$default_identity]);
             }
             $tmp = array();
             foreach ($select_list as $key => $val) {
                 $tmp[] = array('key' => $key, 'sel' => $key == $default_identity, 'val' => $val);
             }
             $this->view->identities = $tmp;
             if ($attach_upload) {
                 $this->view->attach = true;
                 if (count($imp_compose)) {
                     $atc_part = $imp_compose[0]->getPart();
                     $this->view->attach_name = $atc_part->getName();
                     $this->view->attach_size = IMP::sizeFormat($atc_part->getBytes());
                     $this->view->attach_type = $atc_part->getType();
                 }
             }
             $this->title = _("Message Composition");
     }
     $hdrs = array();
     foreach ($display_hdrs as $key => $val) {
         $tmp = array('key' => $key, 'label' => $val, 'val' => $header[$key]);
         if (isset($expand[$key])) {
             $tmp['matchlabel'] = count($expand[$key][1]) > 5 ? sprintf(_("Ambiguous matches for \"%s\" (first 5 matches displayed):"), $expand[$key][0]) : sprintf(_("Ambiguous matches for \"%s\":"), $expand[$key][0]);
             $tmp['match'] = array();
             foreach ($expand[$key][1] as $key2 => $val2) {
                 if ($key2 == 5) {
                     break;
                 }
                 $tmp['match'][] = array('id' => $key . '_expand_' . $key2, 'val' => $val2);
             }
         }
         $hdrs[] = $tmp;
     }
     $this->view->hdrs = $hdrs;
     $this->view->title = $this->title;
 }
Exemple #4
0
 /**
  * Return information about the current attachment(s) for a message.
  *
  * @param mixed $ob      If an IMP_Compose object, return info on all
  *                       attachments. If an IMP_Compose_Attachment object,
  *                       only return information on that object.
  * @param integer $type  The compose type.
  */
 public function attachment($ob, $type = IMP_Compose::COMPOSE)
 {
     global $injector;
     $parts = $ob instanceof IMP_Compose ? iterator_to_array($ob) : array($ob);
     $viewer = $injector->getInstance('IMP_Factory_MimeViewer');
     foreach ($parts as $val) {
         $mime = $val->getPart();
         $mtype = $mime->getType();
         $tmp = array('icon' => strval(Horde_Url_Data::create('image/png', file_get_contents($viewer->getIcon($mtype)->fs))), 'name' => $mime->getName(true), 'num' => $val->id, 'type' => $mtype, 'size' => IMP::sizeFormat($mime->getBytes()));
         if ($viewer->create($mime)->canRender('full')) {
             $tmp['url'] = strval($val->viewUrl()->setRaw(true));
             $tmp['view'] = intval(!in_array($type, array(IMP_Compose::FORWARD_ATTACH, IMP_Compose::FORWARD_BOTH)) && $mtype != 'application/octet-stream');
         }
         $this->_atc[] = $tmp;
     }
 }
Exemple #5
0
 /**
  */
 protected function _init()
 {
     global $injector, $notification, $page_output, $prefs, $registry, $session;
     $mailbox = $this->indices->mailbox;
     /* Call the mailbox redirection hook, if requested. */
     try {
         $redirect = $injector->getInstance('Horde_Core_Hooks')->callHook('mbox_redirect', 'imp', array($mailbox));
         if (!empty($redirect)) {
             Horde::url($redirect, true)->redirect();
         }
     } catch (Horde_Exception_HookNotSet $e) {
     }
     $mailbox_url = Horde::url('basic.php')->add('page', 'mailbox');
     $mailbox_imp_url = $mailbox->url('mailbox')->add('newmail', 1);
     $imp_flags = $injector->getInstance('IMP_Flags');
     $imp_imap = $mailbox->imp_imap;
     $imp_search = $injector->getInstance('IMP_Search');
     /* Run through the action handlers */
     if (($actionID = $this->vars->actionID) && $actionID != 'message_missing') {
         try {
             $session->checkToken($this->vars->token);
         } catch (Horde_Exception $e) {
             $notification->push($e);
             $actionID = null;
         }
     }
     /* We know we are going to be exclusively dealing with this mailbox,
      * so select it on the IMAP server (saves some STATUS calls). Open
      * R/W to clear the RECENT flag. This call will catch invalid
      * mailboxes. */
     $imp_imap->openMailbox($mailbox, Horde_Imap_Client::OPEN_READWRITE);
     $imp_mailbox = $mailbox->list_ob;
     /* Determine if mailbox is readonly. */
     $readonly = $mailbox->readonly;
     switch ($actionID) {
         case 'change_sort':
             $mailbox->setSort($this->vars->sortby, $this->vars->sortdir);
             break;
         case 'blacklist':
             $injector->getInstance('IMP_Filter')->blacklistMessage($this->indices);
             break;
         case 'whitelist':
             $injector->getInstance('IMP_Filter')->whitelistMessage($this->indices);
             break;
         case 'spam_report':
             $injector->getInstance('IMP_Factory_Spam')->create(IMP_Spam::SPAM)->report($this->indices);
             break;
         case 'innocent_report':
             $injector->getInstance('IMP_Factory_Spam')->create(IMP_Spam::INNOCENT)->report($this->indices);
             break;
         case 'message_missing':
             $notification->push(_("Requested message not found."), 'horde.error');
             break;
         case 'fwd_digest':
         case 'redirect_messages':
         case 'template_edit':
             if (count($this->indices)) {
                 $compose_actions = array('fwd_digest' => 'fwd_digest', 'redirect_messages' => 'redirect_compose', 'template_edit' => 'template_edit');
                 $clink = new IMP_Compose_Link($this->vars);
                 $options = array_merge(array('actionID' => $compose_actions[$actionID], 'muid' => strval($this->indices)), $clink->args);
                 if ($prefs->getValue('compose_popup')) {
                     $page_output->addInlineScript(array(Horde::popupJs(IMP_Basic_Compose::url(), array('novoid' => true, 'params' => array_merge(array('popup' => 1), $options)))), true);
                 } else {
                     IMP_Basic_Compose::url()->add($options)->redirect();
                 }
             }
             break;
         case 'delete_messages':
             $injector->getInstance('IMP_Message')->delete($this->indices, array('mailboxob' => $imp_mailbox));
             break;
         case 'undelete_messages':
             $injector->getInstance('IMP_Message')->undelete($this->indices);
             break;
         case 'move_messages':
         case 'copy_messages':
             if (isset($this->vars->targetMbox) && count($this->indices) && (!$readonly || $actionID == 'copy_messages')) {
                 $targetMbox = IMP_Mailbox::formFrom($this->vars->targetMbox);
                 if (!empty($this->vars->newMbox) && $this->vars->newMbox == 1) {
                     $targetMbox = IMP_Mailbox::get($this->vars->targetMbox)->namespace_append;
                     $newMbox = true;
                 } else {
                     $targetMbox = IMP_Mailbox::formFrom($this->vars->targetMbox);
                     $newMbox = false;
                 }
                 $injector->getInstance('IMP_Message')->copy($targetMbox, $actionID == 'move_messages' ? 'move' : 'copy', $this->indices, array('create' => $newMbox, 'mailboxob' => $imp_mailbox));
             }
             break;
         case 'flag_messages':
             if (!$readonly && $this->vars->flag && count($this->indices)) {
                 $flag = $imp_flags->parseFormId($this->vars->flag);
                 $injector->getInstance('IMP_Message')->flag(array($flag['set'] ? 'add' : 'remove' => array($flag['flag'])), $this->indices);
             }
             break;
         case 'filter_messages':
             if (!$readonly) {
                 $filter = IMP_Mailbox::formFrom($this->vars->filter);
                 $q_ob = null;
                 if (strpos($filter, self::FLAG_FILTER_PREFIX) === 0) {
                     /* Flag filtering. */
                     $flag_filter = $imp_flags->parseFormId(substr($filter, strpos($filter, "") + 1));
                     try {
                         $q_ob = $imp_search->createQuery(array(new IMP_Search_Element_Flag($flag_filter['flag'], $flag_filter['set'])), array('mboxes' => array($mailbox), 'type' => IMP_Search::CREATE_QUERY));
                     } catch (InvalidArgumentException $e) {
                     }
                 } else {
                     /* Pre-defined filters. */
                     try {
                         $q_ob = $imp_search->applyFilter($filter, array($mailbox));
                     } catch (InvalidArgumentException $e) {
                     }
                 }
                 if ($q_ob) {
                     IMP_Mailbox::get($q_ob)->url('mailbox')->redirect();
                     exit;
                 }
             }
             break;
         case 'hide_deleted':
             $mailbox->setHideDeletedMsgs(!$prefs->getValue('delhide'));
             break;
         case 'expunge_mailbox':
             $injector->getInstance('IMP_Message')->expungeMailbox(array(strval($mailbox) => 1), array('mailboxob' => $imp_mailbox));
             break;
         case 'filter':
             $mailbox->filter();
             break;
         case 'empty_mailbox':
             $injector->getInstance('IMP_Message')->emptyMailbox(array(strval($mailbox)));
             break;
         case 'view_messages':
             $mailbox->url(IMP_Basic_Thread::url(), null, false)->add(array('mode' => 'msgview', 'muid' => strval($this->indices)))->redirect();
             break;
     }
     /* Token to use in requests. */
     $token = $session->getToken();
     $search_mbox = $mailbox->search;
     /* Deal with filter options. */
     if (!$readonly && IMP_Filter::canApplyFilters() && !$mailbox->filterOnDisplay() && ($mailbox->inbox || $prefs->getValue('filter_any_mailbox') && !$search_mbox)) {
         $filter_url = $mailbox_imp_url->copy()->add(array('actionID' => 'filter', 'token' => $token));
     }
     /* Generate folder options list. */
     if ($imp_imap->access(IMP_Imap::ACCESS_FOLDERS)) {
         $iterator = new IMP_Ftree_IteratorFilter($injector->getInstance('IMP_Ftree'));
         $iterator->add($iterator::NONIMAP);
         $folder_options = new IMP_Ftree_Select(array('heading' => _("Messages to"), 'inc_notepads' => true, 'inc_tasklists' => true, 'iterator' => $iterator, 'new_mbox' => true));
     }
     /* Build the list of messages in the mailbox. */
     $pageOb = $imp_mailbox->buildMailboxPage($this->vars->mpage, $this->vars->start);
     $show_preview = $prefs->getValue('preview_enabled');
     $mbox_info = $imp_mailbox->getMailboxArray(range($pageOb['begin'], $pageOb['end']), array('headers' => true, 'preview' => (int) $show_preview, 'type' => $prefs->getValue('atc_flag')));
     /* Determine sorting preferences. */
     $sortpref = $mailbox->getSort();
     $thread_sort = $sortpref->sortby == Horde_Imap_Client::SORT_THREAD;
     /* Determine if we are going to show the Hide/Purge Deleted Message
      * links. */
     if (!($use_trash = $prefs->getValue('use_trash')) && !$mailbox->vinbox) {
         $showdelete = array('hide' => true, 'purge' => $mailbox->access_expunge);
     } else {
         $showdelete = array('hide' => false, 'purge' => false);
     }
     if ($showdelete['hide'] && !$prefs->isLocked('delhide')) {
         if ($prefs->getValue('delhide')) {
             $deleted_prompt = _("Show Deleted");
         } else {
             $deleted_prompt = _("Hide Deleted");
         }
     }
     /* Generate paging links. */
     if ($pageOb['pagecount']) {
         if ($pageOb['page'] == 1) {
             $url_first = $url_prev = null;
             $pages_first = 'navfirstgreyImg';
             $pages_prev = 'navleftgreyImg';
         } else {
             $url_first = $mailbox_imp_url->copy()->add('mpage', 1);
             $pages_first = 'navfirstImg';
             $url_prev = $mailbox_imp_url->copy()->add('mpage', $pageOb['page'] - 1);
             $pages_prev = 'navleftImg';
         }
         if ($pageOb['page'] == $pageOb['pagecount']) {
             $url_last = $url_next = null;
             $pages_last = 'navlastgreyImg';
             $pages_next = 'navrightgreyImg';
         } else {
             $url_next = $mailbox_imp_url->copy()->add('mpage', $pageOb['page'] + 1);
             $pages_next = 'navrightImg';
             $url_last = $mailbox_imp_url->copy()->add('mpage', $pageOb['pagecount']);
             $pages_last = 'navlastImg';
         }
     }
     /* Generate RSS link. */
     if ($mailbox->inbox) {
         $rss_box = '';
     } else {
         $ns_info = $mailbox->namespace_info;
         if (is_null($ns_info)) {
             $rss_box = null;
         } else {
             $rss_box = str_replace(rawurlencode($ns_info->delimiter), '/', rawurlencode($ns_info->delimiter . ($ns_info->type == $ns_info::NS_PERSONAL ? $ns_info->stripNamespace($mailbox) : $mailbox)));
         }
     }
     if (!is_null($rss_box)) {
         $page_output->addLinkTag(array('href' => Horde::url('rss.php', true, -1) . $rss_box));
     }
     /* If user wants the mailbox to be refreshed, set time here. */
     $refresh_url = $mailbox_imp_url->copy()->add('mpage', $pageOb['page']);
     if (isset($filter_url)) {
         $filter_url->add('mpage', $pageOb['page']);
     }
     /* Determine if we are showing previews. */
     $preview_tooltip = $show_preview ? $prefs->getValue('preview_show_tooltip') : false;
     if (!$preview_tooltip) {
         $strip_preview = $prefs->getValue('preview_strip_nl');
     }
     $unread = $imp_mailbox->unseenMessages(Horde_Imap_Client::SEARCH_RESULTS_COUNT);
     $page_output->addInlineJsVars(array('ImpMailbox.pop3' => intval(!$mailbox->is_imap), 'ImpMailbox.text' => array('delete_messages' => _("Are you sure you wish to PERMANENTLY delete these messages?"), 'delete_all' => _("Are you sure you wish to delete all mail in this mailbox?"), 'delete_vfolder' => _("Are you sure you want to delete this Virtual Folder Definition?"), 'innocent_report' => _("Are you sure you wish to report this message as innocent?"), 'moveconfirm' => _("Are you sure you want to move the message(s)? (Some message information might get lost, like message headers, text formatting or attachments!)"), 'newmbox' => _("You are copying/moving to a new mailbox.") . "\n" . _("Please enter a name for the new mailbox:") . "\n", 'no' => _("No"), 'selectone' => _("You must select at least one message first."), 'selectonlyone' => _("You must select only one message for this action."), 'spam_report' => _("Are you sure you wish to report this message as spam?"), 'submit' => _("You must select at least one message first."), 'target_mbox' => _("You must select a target mailbox first.")), 'ImpMailbox.unread' => intval($unread)));
     $pagetitle = $this->title = $mailbox->label;
     if ($mailbox->editvfolder) {
         $query_text = wordwrap($imp_search[$mailbox]->querytext);
         $pagetitle .= ' [' . Horde::linkTooltip('#', $query_text, '', '', '', $query_text) . _("Virtual Folder") . '</a>]';
         $this->title .= ' [' . _("Virtual Folder") . ']';
     } elseif ($mailbox->editquery) {
         $query_text = wordwrap($imp_search[$mailbox]->querytext);
         $pagetitle = Horde::linkTooltip('#', $query_text, '', '', '', $query_text) . $pagetitle . '</a>';
     } else {
         $pagetitle = $this->title = htmlspecialchars($this->title);
     }
     /* Generate mailbox summary string. */
     $subinfo = new IMP_View_Subinfo(array('mailbox' => $mailbox));
     $subinfo->value = $pagetitle . ' (';
     if (empty($pageOb['end'])) {
         $subinfo->value .= _("No Messages");
     } else {
         $subinfo->value .= $pageOb['pagecount'] > 1 ? sprintf(_("%d Messages"), $pageOb['msgcount']) . ' / ' . sprintf(_("Page %d of %d"), $pageOb['page'], $pageOb['pagecount']) : sprintf(_("%d Messages"), $pageOb['msgcount']);
     }
     $subinfo->value .= ')';
     $injector->getInstance('Horde_View_Topbar')->subinfo = $subinfo->render();
     $page_output->addScriptFile('hordecore.js', 'horde');
     $page_output->addScriptFile('mailbox.js');
     $page_output->addScriptPackage('Horde_Core_Script_Package_Dialog');
     $page_output->metaRefresh($prefs->getValue('refresh_time'), $refresh_url);
     /* Prepare the header template. */
     $view = new Horde_View(array('templatePath' => IMP_TEMPLATES . '/basic/mailbox'));
     $view->addHelper('FormTag');
     $view->addHelper('Horde_Core_View_Helper_Accesskey');
     $view->addHelper('Tag');
     $hdr_view = clone $view;
     $hdr_view->readonly = $readonly;
     $hdr_view->refresh_url = $refresh_url;
     if (isset($filter_url)) {
         $hdr_view->filter_url = $filter_url;
     }
     if ($mailbox->access_search) {
         if (!$search_mbox) {
             $hdr_view->search_url = $mailbox->url(IMP_Basic_Searchbasic::url());
         } else {
             if ($mailbox->editvfolder) {
                 $edit_search = _("Edit Virtual Folder");
             } elseif ($mailbox->query) {
                 if ($mailbox->editquery) {
                     $edit_search = _("Edit Search Query");
                 } else {
                     /* Basic search results. */
                     $search_mailbox = IMP_Mailbox::get($imp_search[$mailbox]->mboxes[0]);
                     $hdr_view->search_url = $search_mailbox->url(IMP_Basic_Searchbasic::url());
                     $hdr_view->searchclose = $search_mailbox->url('mailbox');
                 }
             }
             if (isset($edit_search)) {
                 $hdr_view->edit_search_url = $imp_search->editUrl($mailbox);
                 $hdr_view->edit_search_title = $edit_search;
             }
         }
     }
     if ($mailbox->access_empty) {
         $hdr_view->empty = $mailbox_imp_url->copy()->add(array('actionID' => 'empty_mailbox', 'token' => $token));
     }
     $this->output = $hdr_view->render('header');
     /* If no messages, exit immediately. */
     if (empty($pageOb['end'])) {
         if ($pageOb['anymsg'] && isset($deleted_prompt)) {
             /* Show 'Show Deleted' prompt if mailbox has no viewable
              * message but has hidden, deleted messages. */
             $del_view = clone $view;
             $del_view->hide = Horde::widget(array('url' => $refresh_url->copy()->add(array('actionID' => 'hide_deleted', 'token' => $token)), 'class' => 'hideAction', 'title' => $deleted_prompt));
             if ($mailbox->access_expunge) {
                 $del_view->purge = Horde::widget(array('url' => $refresh_url->copy()->add(array('actionID' => 'expunge_mailbox', 'token' => $token)), 'class' => 'purgeAction', 'title' => _("Pur_ge Deleted")));
             }
             $this->output .= $del_view->render('actions_deleted');
         }
         $empty_view = clone $view;
         $empty_view->search_mbox = $search_mbox;
         $this->output .= $empty_view->render('empty_mailbox');
         return;
     }
     $clink_ob = new IMP_Compose_Link();
     $clink = $clink_ob->link();
     /* Display the navbar and actions if there is at least 1 message in
      * mailbox. */
     if ($pageOb['msgcount']) {
         /* Prepare the navbar template. */
         $n_view = clone $view;
         $n_view->id = 1;
         $n_view->readonly = $readonly;
         $filtermsg = false;
         if ($mailbox->access_flags) {
             $args = array('imap' => true, 'mailbox' => $search_mbox ? null : $mailbox);
             $form_set = $form_unset = array();
             foreach ($imp_flags->getList($args) as $val) {
                 if ($val->canset) {
                     $form_set[] = array('f' => $val->form_set, 'l' => $val->label, 'v' => IMP_Mailbox::formTo(self::FLAG_FILTER_PREFIX . $val->form_set));
                     $form_unset[] = array('f' => $val->form_unset, 'l' => $val->label, 'v' => IMP_Mailbox::formTo(self::FLAG_FILTER_PREFIX . $val->form_unset));
                 }
             }
             $n_view->flaglist_set = $form_set;
             $n_view->flaglist_unset = $form_unset;
             if (!$search_mbox && $mailbox->access_search) {
                 $filtermsg = $n_view->flag_filter = true;
             }
         }
         if (!$search_mbox && $mailbox->access_filters) {
             $filters = array();
             $iterator = IMP_Search_IteratorFilter::create(IMP_Search_IteratorFilter::FILTER);
             foreach ($iterator as $val) {
                 $filters[] = array('l' => $val->label, 'v' => IMP_Mailbox::formTo($val));
             }
             if (!empty($filters)) {
                 $filtermsg = true;
                 $n_view->filters = $filters;
             }
         }
         $n_view->filtermsg = $filtermsg;
         if ($imp_imap->access(IMP_Imap::ACCESS_FOLDERS)) {
             $n_view->move = Horde::widget(array('url' => '#', 'class' => 'moveAction', 'title' => _("Move"), 'nocheck' => true));
             $n_view->copy = Horde::widget(array('url' => '#', 'class' => 'copyAction', 'title' => _("Copy"), 'nocheck' => true));
             $n_view->folder_options = $folder_options;
         }
         $n_view->mailbox_url = $mailbox_url;
         $n_view->mailbox = $mailbox->form_to;
         if ($pageOb['pagecount'] > 1) {
             $n_view->multiple_page = true;
             $n_view->pages_first = $pages_first;
             $n_view->url_first = $url_first;
             $n_view->pages_prev = $pages_prev;
             $n_view->url_prev = $url_prev;
             $n_view->pages_next = $pages_next;
             $n_view->url_next = $url_next;
             $n_view->pages_last = $pages_last;
             $n_view->url_last = $url_last;
             $n_view->page_val = $pageOb['page'];
             $n_view->page_size = Horde_String::length($pageOb['pagecount']);
         }
         $this->output .= $n_view->render('navbar');
         /* Prepare the actions template. */
         $a_view = clone $view;
         if ($mailbox->access_deletemsgs) {
             $del_class = $use_trash && $mailbox->trash ? 'permdeleteAction' : 'deleteAction';
             $a_view->delete = Horde::widget(array('url' => '#', 'class' => $del_class, 'title' => _("_Delete")));
         }
         if ($showdelete['purge'] || $mailbox->vtrash) {
             $a_view->undelete = Horde::widget(array('url' => '#', 'class' => 'undeleteAction', 'title' => _("_Undelete")));
         }
         $mboxactions = array();
         if ($showdelete['purge']) {
             $mailbox_link = $mailbox_imp_url->copy()->add('mpage', $pageOb['page']);
             if (isset($deleted_prompt)) {
                 $mboxactions[] = Horde::widget(array('url' => $mailbox_link->copy()->add(array('actionID' => 'hide_deleted', 'token' => $token)), 'class' => 'hideAction', 'title' => $deleted_prompt));
             }
             $mboxactions[] = Horde::widget(array('url' => $mailbox_link->copy()->add(array('actionID' => 'expunge_mailbox', 'token' => $token)), 'class' => 'purgeAction', 'title' => _("Pur_ge Deleted")));
         }
         if (!$sortpref->sortby_locked && $sortpref->sortby != Horde_Imap_Client::SORT_SEQUENCE) {
             $mboxactions[] = Horde::widget(array('url' => $mailbox_imp_url->copy()->add(array('sortby' => Horde_Imap_Client::SORT_SEQUENCE, 'actionID' => 'change_sort', 'token' => $token)), 'title' => _("Clear Sort")));
         }
         if ($mailbox->templates) {
             $a_view->templateedit = Horde::widget(array('url' => '#', 'class' => 'templateeditAction', 'title' => _("Edit Template")));
             $mboxactions[] = Horde::widget(array('url' => $clink->copy()->add(array('actionID' => 'template_new')), 'title' => _("Create New Template")));
         }
         $a_view->mboxactions = $mboxactions;
         if ($registry->hasMethod('mail/blacklistFrom')) {
             $a_view->blacklist = Horde::widget(array('url' => '#', 'class' => 'blacklistAction', 'title' => _("_Blacklist")));
         }
         if ($registry->hasMethod('mail/whitelistFrom')) {
             $a_view->whitelist = Horde::widget(array('url' => '#', 'class' => 'whitelistAction', 'title' => _("_Whitelist")));
         }
         if (IMP_Compose::canCompose()) {
             $a_view->forward = Horde::widget(array('url' => '#', 'class' => 'forwardAction', 'title' => _("Fo_rward")));
             $a_view->redirect = Horde::widget(array('url' => '#', 'class' => 'redirectAction', 'title' => _("Redirect")));
         }
         if ($mailbox->spam_show) {
             $a_view->spam = Horde::widget(array('url' => '#', 'class' => 'spamAction', 'title' => _("Report as Spam")));
         }
         if ($mailbox->innocent_show) {
             $a_view->innocent = Horde::widget(array('url' => '#', 'class' => 'innocentAction', 'title' => _("Report as Innocent")));
         }
         $a_view->view_messages = Horde::widget(array('url' => '#', 'class' => 'viewAction', 'title' => _("View Messages")));
         $this->output .= $a_view->render('actions');
     }
     /* Define some variables now so we don't have to keep redefining in
      * the foreach loop or the templates. */
     $lastMbox = '';
     $mh_count = 0;
     $sortImg = $sortpref->sortdir ? 'sortup' : 'sortdown';
     $headers = array(Horde_Imap_Client::SORT_TO => array('id' => 'mboxto', 'stext' => _("Sort by To Address"), 'text' => _("To")), Horde_Imap_Client::SORT_FROM => array('id' => 'mboxfrom', 'stext' => _("Sort by From Address"), 'text' => _("Fro_m")), Horde_Imap_Client::SORT_THREAD => array('id' => 'mboxthread', 'stext' => _("Sort by Thread"), 'text' => _("_Thread")), Horde_Imap_Client::SORT_SUBJECT => array('id' => 'mboxsubject', 'stext' => _("Sort by Subject"), 'text' => _("Sub_ject")), IMP::IMAP_SORT_DATE => array('id' => 'mboxdate', 'stext' => _("Sort by Date"), 'text' => _("Dat_e")), Horde_Imap_Client::SORT_SIZE => array('id' => 'mboxsize', 'stext' => _("Sort by Message Size"), 'text' => _("Si_ze")));
     /* If this is the Drafts or Sent-Mail mailbox, sort by To instead of
      * From. */
     if ($mailbox->special_outgoing) {
         unset($headers[Horde_Imap_Client::SORT_FROM]);
     } else {
         unset($headers[Horde_Imap_Client::SORT_TO]);
     }
     /* Determine which of Subject/Thread to emphasize. */
     if (!$mailbox->access_sortthread || $sortpref->sortby_locked) {
         unset($headers[Horde_Imap_Client::SORT_THREAD]);
         if ($sortpref->sortby_locked && $thread_sort) {
             $sortpref->sortby = Horde_Imap_Client::SORT_SUBJECT;
         }
     } else {
         if ($thread_sort) {
             $extra = Horde_Imap_Client::SORT_SUBJECT;
             $standard = Horde_Imap_Client::SORT_THREAD;
         } else {
             $extra = Horde_Imap_Client::SORT_THREAD;
             $standard = Horde_Imap_Client::SORT_SUBJECT;
         }
         $headers[$standard]['altsort'] = Horde::widget(array('url' => $mailbox_imp_url->copy()->add(array('actionID' => 'change_sort', 'token' => $token, 'sortby' => $extra)), 'title' => $headers[$extra]['text']));
         unset($headers[$extra]);
     }
     foreach ($headers as $key => $val) {
         $ptr =& $headers[$key];
         if ($sortpref->sortby == $key) {
             $csl_icon = '<span class="iconImg ' . $sortImg . '"></span>';
             if ($sortpref->sortdir_locked) {
                 $ptr['change_sort_link'] = $csl_icon;
                 $ptr['change_sort_widget'] = Horde::stripAccessKey($val['text']);
             } else {
                 $tmp = $mailbox_imp_url->copy()->add(array('sortby' => $key, 'sortdir' => intval(!$sortpref->sortdir), 'actionID' => 'change_sort', 'token' => $token));
                 $ptr['change_sort_link'] = Horde::link($tmp, $val['stext'], null, null, null, $val['stext']) . $csl_icon . '</a>';
                 $ptr['change_sort_widget'] = Horde::widget(array('url' => $tmp, 'title' => $val['text']));
             }
         } else {
             $ptr['change_sort_link'] = null;
             $ptr['change_sort_widget'] = $sortpref->sortby_locked ? Horde::stripAccessKey($val['text']) : Horde::widget(array('url' => $mailbox_imp_url->copy()->add(array('actionID' => 'change_sort', 'token' => $token, 'sortby' => $key)), 'title' => $val['text']));
         }
         $ptr['class'] = 'horde-split-left';
     }
     /* Output the form start. */
     $f_view = clone $view;
     $f_view->mailbox = $mailbox->form_to;
     $f_view->mailbox_url = $mailbox_url;
     $f_view->page = $pageOb['page'];
     $f_view->token = $token;
     $this->output .= $f_view->render('form_start');
     /* Prepare the message headers template. */
     $mh_view = clone $view;
     $mh_view->headers = $headers;
     if (!$search_mbox) {
         $mh_view->show_checkbox = !$mh_count++;
         $this->output .= $mh_view->render('message_headers');
     }
     /* Initialize repetitively used variables. */
     $fromlinkstyle = $prefs->getValue('from_link');
     $imp_ui = new IMP_Mailbox_Ui($mailbox);
     /* Display message information. */
     $msgs = array();
     $search_view = clone $view;
     $summary_view = clone $view;
     while (list(, $ob) = each($mbox_info['overview'])) {
         if ($search_mbox) {
             if (empty($lastMbox) || $ob['mailbox'] != $lastMbox) {
                 if (!empty($lastMbox)) {
                     $this->_outputSummaries($msgs, $summary_view);
                     $msgs = array();
                 }
                 $mbox = IMP_Mailbox::get($ob['mailbox']);
                 $search_view->mbox_link = Horde::link($mbox->url($mailbox_url), sprintf(_("View messages in %s"), $mbox->display), 'smallheader') . $mbox->display_html . '</a>';
                 $this->output .= $search_view->render('searchmbox');
                 $mh_view->show_checkbox = !$mh_count++;
                 $this->output .= $mh_view->render('message_headers');
             }
         }
         $lastMbox = $ob['mailbox'];
         /* Initialize the data fields. */
         $msg = array('bg' => '', 'buid' => $imp_mailbox->getBuid($ob['mailbox'], $ob['uid']), 'class' => '', 'date' => $imp_ui->getDate($ob['envelope']->date), 'preview' => '', 'status' => '', 'size' => IMP::sizeFormat($ob['size']));
         /* Generate the target link. */
         if ($mailbox->drafts || $mailbox->templates) {
             $clink_copy = clone $clink_ob;
             $clink_copy->args['buid'] = $msg['buid'];
             $clink_copy->args['mailbox'] = $mailbox;
             $target = $clink_copy->link()->add(array('actionID' => $mailbox->drafts ? 'draft' : 'template'));
         } else {
             $target = $mailbox->url('message', $msg['buid']);
         }
         /* Get all the flag information. */
         $flag_parse = $imp_flags->parse(array('flags' => $ob['flags'], 'headers' => $ob['headers'], 'runhook' => $ob, 'personal' => $ob['envelope']->to));
         $css_class = $subject_flags = array();
         foreach ($flag_parse as $val) {
             if ($val instanceof IMP_Flag_User) {
                 $subject_flags[] = $val;
             } else {
                 if (!$val->bgdefault) {
                     $msg['bg'] = $val->bgcolor;
                 }
                 $css_class[] = $val->css;
                 $msg['status'] .= $val->span;
             }
         }
         $msg['class'] = implode(' ', $css_class);
         /* Show message preview? */
         if ($show_preview && isset($ob['preview'])) {
             if (empty($ob['preview'])) {
                 $ptext = '[[' . _("No Preview Text") . ']]';
             } else {
                 $ptext = empty($strip_preview) ? str_replace("\r", '', $ob['preview']) : preg_replace(array('/\\n/', '/(\\s)+/'), array(' ', '$1'), str_replace("\r", "\n", $ob['preview']));
                 if (!$preview_tooltip) {
                     $ptext = $injector->getInstance('Horde_Core_Factory_TextFilter')->filter($ptext, 'text2html', array('parselevel' => Horde_Text_Filter_Text2html::NOHTML));
                 }
                 $maxlen = $prefs->getValue('preview_maxlen');
                 if (Horde_String::length($ptext) > $maxlen) {
                     $ptext = Horde_String::truncate($ptext, $maxlen);
                 } elseif (empty($ob['previewcut'])) {
                     $ptext .= '[[' . _("END") . ']]';
                 }
             }
             $msg['preview'] = $ptext;
         }
         /* Format the From: Header. */
         $getfrom = $imp_ui->getFrom($ob['envelope']);
         $msg['from'] = htmlspecialchars($getfrom['from'], ENT_QUOTES, 'UTF-8');
         switch ($fromlinkstyle) {
             case 0:
                 $from_tmp = array();
                 foreach ($getfrom['from_list']->base_addresses as $from_ob) {
                     $from_tmp[] = call_user_func_array(array('Horde', $preview_tooltip ? 'linkTooltip' : 'link'), array($clink->copy()->add(array('actionID' => 'mailto_link', 'to' => strval($from_ob))), sprintf(_("New Message to %s"), $from_ob->label))) . htmlspecialchars($from_ob->label, ENT_QUOTES, 'UTF-8') . '</a>';
                 }
                 if (!empty($from_tmp)) {
                     $msg['from'] = implode(', ', $from_tmp);
                 }
                 break;
             default:
                 $from_uri = $mailbox->url('message', $msg['buid']);
                 $msg['from'] = Horde::link($from_uri) . $msg['from'] . '</a>';
                 break;
         }
         /* Format the Subject: Header. */
         $msg['subject'] = $imp_ui->getSubject($ob['envelope']->subject, true);
         $msg['subject'] = $preview_tooltip ? substr(Horde::linkTooltip($target, $msg['preview'], '', '', '', $msg['preview']), 0, -1) . ' class="mboxSubject">' . $msg['subject'] . '</a>' : substr(Horde::link($target, $imp_ui->getSubject($ob['envelope']->subject)), 0, -1) . ' class="mboxSubject">' . $msg['subject'] . '</a>' . (!empty($msg['preview']) ? '<br /><small>' . $msg['preview'] . '</small>' : '');
         /* Add subject flags. */
         foreach ($subject_flags as $val) {
             $flag_label = Horde_String::truncate($val->label, 12);
             $msg['subject'] = '<span class="' . $val->css . '" style="' . ($val->bgdefault ? '' : 'background:' . htmlspecialchars($val->bgcolor) . ';') . 'color:' . htmlspecialchars($val->fgcolor) . '" title="' . htmlspecialchars($val->label) . '">' . htmlspecialchars($flag_label) . '</span>' . $msg['subject'];
         }
         /* Set up threading tree now. */
         if ($thread_sort) {
             $t_ob = $imp_mailbox->getThreadOb($ob['idx']);
             $msg['subject'] = ($sortpref->sortdir ? $t_ob->reverse_img : $t_ob->img) . ' ' . $msg['subject'];
         }
         $msgs[$msg['buid']] = $msg;
     }
     $this->_outputSummaries($msgs, $summary_view);
     $this->output .= '</form>';
     /* If there are 20 messages or less, don't show the actions/navbar
      * again. */
     if ($pageOb['end'] - $pageOb['begin'] >= 20) {
         $this->output .= $a_view->render('actions');
         $n_view->id = 2;
         $this->output .= $n_view->render('navbar');
     }
 }
Exemple #6
0
 /**
  * Adds linked attachments to message.
  *
  * @param string &$body  Plaintext data.
  * @param mixed $html    HTML data (Horde_Domhtml) or null.
  *
  * @throws IMP_Compose_Exception
  */
 protected function _linkAttachments(&$body, $html)
 {
     global $conf;
     if (empty($conf['compose']['link_attachments'])) {
         return;
     }
     $link_all = false;
     $linked = array();
     if (!empty($conf['compose']['link_attach_size_hard'])) {
         $limit = intval($conf['compose']['link_attach_size_hard']);
         foreach ($this as $val) {
             if (($limit -= $val->getPart()->getBytes()) < 0) {
                 $link_all = true;
                 break;
             }
         }
     }
     foreach (iterator_to_array($this) as $key => $val) {
         if ($link_all && !$val->linked) {
             $val = new IMP_Compose_Attachment($this, $val->getPart(), $val->storage->getTempFile());
             $val->forceLinked = true;
             unset($this[$key]);
             $this[$key] = $val;
         }
         if ($val->linked && !$val->related) {
             $linked[] = $val;
         }
     }
     if (empty($linked)) {
         return;
     }
     if ($del_time = IMP_Compose_LinkedAttachment::keepDate(false)) {
         /* Subtract 1 from time to get the last day of the previous
          * month. */
         $expire = ' (' . sprintf(_("links will expire on %s"), strftime('%x', $del_time - 1)) . ')';
     }
     $body .= "\n-----\n" . _("Attachments") . $expire . ":\n";
     if ($html) {
         $body = $html->getBody();
         $dom = $html->dom;
         $body->appendChild($dom->createElement('HR'));
         $body->appendChild($div = $dom->createElement('DIV'));
         $div->appendChild($dom->createElement('H4', _("Attachments") . $expire . ':'));
         $div->appendChild($ol = $dom->createElement('OL'));
     }
     $i = 0;
     foreach ($linked as $val) {
         $apart = $val->getPart();
         $name = $apart->getName(true);
         $size = IMP::sizeFormat($apart->getBytes());
         $url = strval($val->link_url->setRaw(true));
         $body .= "\n" . ++$i . '. ' . $name . ' (' . $size . ') [' . $apart->getType() . "]\n" . sprintf(_("Download link: %s"), $url) . "\n";
         if ($html) {
             $ol->appendChild($li = $dom->createElement('LI'));
             $li->appendChild($dom->createElement('STRONG', $name));
             $li->appendChild($dom->createTextNode(' (' . $size . ') [' . htmlspecialchars($apart->getType()) . ']'));
             $li->appendChild($dom->createElement('BR'));
             $li->appendChild($dom->createTextNode(_("Download link") . ': '));
             $li->appendChild($a = $dom->createElement('A', htmlspecialchars($url)));
             $a->setAttribute('href', $url);
         }
     }
 }
<div>
 <?php 
echo _("Your signature to use when composing with the HTML editor (if empty, the text signature will be used)") . ($this->img_limit ? ' (' . sprintf(_("maximum total image size is %s"), IMP::sizeFormat($this->img_limit)) . ')' : '');
?>
:
</div>

<div class="fixed">
 <textarea id="signature_html" name="signature_html" rows="4" cols="80" class="fixed"><?php 
echo $this->h($this->signature);
?>
</textarea>
</div>
Exemple #8
0
 /**
  * Obtains IMAP overview data for a given set of message UIDs.
  *
  * @param IMP_Mailbox $mbox  The current mailbox.
  * @param array $msglist     The list of message sequence numbers to
  *                           process.
  *
  * @return array  TODO
  * @throws Horde_Exception
  */
 private function _getOverviewData($mbox, $msglist)
 {
     global $injector;
     $msgs = array();
     if (empty($msglist)) {
         return $msgs;
     }
     /* Get mailbox information. */
     $flags = $mbox->access_flags;
     $imp_flags = $injector->getInstance('IMP_Flags');
     $imp_ui = new IMP_Mailbox_Ui($mbox);
     $list_ob = $mbox->list_ob;
     $overview = $list_ob->getMailboxArray($msglist);
     /* Display message information. */
     reset($overview['overview']);
     while (list(, $ob) = each($overview['overview'])) {
         /* Get all the flag information. */
         $msg = array('flag' => $flags ? array_map('strval', $imp_flags->parse(array('flags' => $ob['flags'], 'headers' => $ob['headers'], 'personal' => $ob['envelope']->to, 'runhook' => $ob, 'structure' => $ob['structure']))) : array());
         /* Format size information. */
         $msg['size'] = IMP::sizeFormat($ob['size']);
         /* Format the Date: Header. */
         $msg['date'] = strval(new IMP_Message_Date(isset($ob['envelope']->date) ? $ob['envelope']->date : null));
         /* Format the From: Header. */
         $getfrom = $imp_ui->getFrom($ob['envelope']);
         if (count($getfrom['from_list'])) {
             $from_ob = new IMP_Ajax_Addresses($getfrom['from_list']);
             $msg['from'] = $from_ob->toArray()->addr;
             if (isset($getfrom['from_label'])) {
                 $msg['fromlabel'] = $getfrom['from_label'];
             }
         } else {
             $msg['from'] = array();
             $msg['fromlabel'] = $getfrom['from'];
         }
         /* Format the Subject: Header. */
         $msg['subject'] = $imp_ui->getSubject($ob['envelope']->subject);
         /* Check to see if this is a list message. Namely, we want to
          * check for 'List-Post' information because that is the header
          * that gives the e-mail address to reply to, which is all we
          * care about. */
         if (isset($ob['headers']['List-Post'])) {
             $msg['listmsg'] = 1;
         }
         $msgs[$list_ob->getBuid($ob['mailbox'], $ob['uid'])] = $msg;
     }
     return $msgs;
 }
Exemple #9
0
 /**
  * Obtains IMAP overview data for a given set of message UIDs.
  *
  * @param IMP_Mailbox $mbox  The current mailbox.
  * @param array $msglist     The list of message sequence numbers to
  *                           process.
  *
  * @return array  TODO
  * @throws Horde_Exception
  */
 private function _getOverviewData($mbox, $msglist)
 {
     global $injector, $prefs;
     $msgs = array();
     if (empty($msglist)) {
         return $msgs;
     }
     /* Get mailbox information. */
     $flags = $mbox->access_flags;
     $imp_flags = $injector->getInstance('IMP_Flags');
     $imp_ui = new IMP_Mailbox_Ui($mbox);
     $list_ob = $mbox->list_ob;
     $overview = $list_ob->getMailboxArray($msglist, array('headers' => true, 'type' => $prefs->getValue('atc_flag')));
     /* Display message information. */
     reset($overview['overview']);
     while (list(, $ob) = each($overview['overview'])) {
         /* Get all the flag information. */
         $msg = array('flag' => $flags ? array_map('strval', $imp_flags->parse(array('flags' => $ob['flags'], 'headers' => $ob['headers'], 'runhook' => $ob, 'personal' => $ob['envelope']->to))) : array());
         /* Format size information. */
         $msg['size'] = IMP::sizeFormat($ob['size']);
         /* Format the Date: Header. */
         $msg['date'] = $imp_ui->getDate(isset($ob['envelope']->date) ? $ob['envelope']->date : null);
         /* Format the From: Header. */
         $getfrom = $imp_ui->getFrom($ob['envelope']);
         $msg['from'] = $getfrom['from'];
         if ($getfrom['from'] !== $getfrom['from_addr']) {
             $msg['fromaddr'] = $getfrom['from_addr'];
         }
         /* Format the Subject: Header. */
         $msg['subject'] = $imp_ui->getSubject($ob['envelope']->subject);
         /* Check to see if this is a list message. Namely, we want to
          * check for 'List-Post' information because that is the header
          * that gives the e-mail address to reply to, which is all we
          * care about. */
         if ($ob['headers']->getValue('list-post')) {
             $msg['listmsg'] = 1;
         }
         $msgs[$list_ob->getBuid($ob['mailbox'], $ob['uid'])] = $msg;
     }
     /* Allow user to alter template array. */
     try {
         $msgs = $injector->getInstance('Horde_Core_Hooks')->callHook('mailboxarray', 'imp', array($msgs));
     } catch (Horde_Exception_HookNotSet $e) {
     }
     return $msgs;
 }