コード例 #1
0
ファイル: Messagepart.php プロジェクト: jubinpatel/horde
 /**
  * URL Parameters:
  *   - atc
  *   - buid
  *   - id
  */
 protected function _init()
 {
     global $injector;
     /* Parse the message. */
     try {
         $imp_contents = $injector->getInstance('IMP_Factory_Contents')->create($this->indices);
     } catch (IMP_Exception $e) {
         IMP_Minimal_Mailbox::url(array('mailbox' => $this->indices->mailbox))->add('a', 'm')->redirect();
     }
     if (isset($this->vars->atc)) {
         $summary = $imp_contents->getSummary($this->vars->atc, IMP_Contents::SUMMARY_SIZE | IMP_Contents::SUMMARY_DESCRIP | IMP_Contents::SUMMARY_DOWNLOAD);
         $this->title = _("Download Attachment");
         $this->view->descrip = $summary['description_raw'];
         $this->view->download = $summary['download_url'];
         $this->view->size = $summary['size'];
         $this->view->type = $summary['type'];
     } else {
         $this->title = _("View Attachment");
         $data = $imp_contents->renderMIMEPart($this->vars->id, $imp_contents->canDisplay($this->vars->id, IMP_Contents::RENDER_INLINE));
         $this->view->data = isset($data[$this->vars->id]) ? $data[$this->vars->id]['data'] : _("This part is empty.");
     }
     $this->view->self_link = IMP_Minimal_Message::url(array('buid' => $this->vars->buid, 'mailbox' => $this->indices->mailbox));
     $this->view->title = $this->title;
     $this->_pages[] = 'messagepart';
 }
コード例 #2
0
ファイル: Search.php プロジェクト: DSNS-LAB/Dmail
 /**
  * URL Parameters:
  *   - a: (string) Action ID.
  *   - checkbox: TODO
  *   - mt: TODO
  *   - p: (integer) Page.
  *   - search: (sring) The search string
  *   - start: (integer) Start.
  */
 protected function _init()
 {
     $this->title = sprintf(_("Search %s"), $this->indicees->mailbox->display);
     $this->view->mailbox = $this->indices->mailbox->form_to;
     $this->view->menu = $this->getMenu('search');
     $this->view->title = $this->title;
     $this->view->url = IMP_Minimal_Mailbox::url();
     $this->_pages[] = 'search';
     $this->_pages[] = 'menu';
 }
コード例 #3
0
ファイル: Base.php プロジェクト: jubinpatel/horde
 /**
  * Output the menu.
  *
  * @param string $page  The current page ('compose', 'folders', 'mailbox',
  *                                        'message', 'search').
  * @param array $items  Additional menu items to add to the menu. First
  *                      element is label, second is URL to link to.
  *
  * @return string  The menu.
  */
 public function getMenu($page, $items = array())
 {
     if (!in_array($page, array('mailbox', 'message')) || !$this->indices->mailbox->inbox) {
         $items[] = array(_("Inbox"), IMP_Minimal_Mailbox::url(array('mailbox' => 'INBOX')));
     }
     if (!in_array($page, array('compose', 'search')) && IMP_Compose::canCompose()) {
         $items[] = array(_("New Message"), IMP_Minimal_Compose::url());
     }
     if (!in_array($page, array('folders', 'search')) && $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->access(IMP_Imap::ACCESS_FOLDERS)) {
         $items[] = array(_("Folders"), IMP_Minimal_Folders::url());
     }
     $items[] = array(_("Log out"), $GLOBALS['registry']->getServiceLink('logout', 'imp')->setRaw(false));
     $menu = new Horde_Menu();
     foreach ($menu->getSiteLinks() as $menuitem) {
         if ($menuitem != 'separator') {
             $items[] = array($menuitem['text'], $menuitem['url']);
         }
     }
     return $items;
 }
コード例 #4
0
ファイル: Folders.php プロジェクト: jubinpatel/horde
 /**
  * URL Parameters:
  *   - ts: (integer) Toggle subscribe view.
  */
 protected function _init()
 {
     global $injector, $notification, $prefs, $session;
     $imp_imap = $injector->getInstance('IMP_Factory_Imap')->create();
     /* Redirect back to the mailbox if folder use is not allowed. */
     if (!$imp_imap->access(IMP_Imap::ACCESS_FOLDERS)) {
         $notification->push(_("The folder view is not enabled."), 'horde.error');
         IMP_Minimal_Mailbox::url()->redirect();
     }
     /* Decide whether or not to show all the unsubscribed mailboxes. */
     $subscribe = $prefs->getValue('subscribe');
     $showAll = !$subscribe || $session->get('imp', 'showunsub');
     /* Toggle subscribed view, if necessary. */
     if ($subscribe && $this->vars->ts) {
         $showAll = !$showAll;
         $session->set('imp', 'showunsub', $showAll);
     }
     /* Initialize the IMP_Ftree object. */
     $ftree = $injector->getInstance('IMP_Ftree');
     $iterator = new IMP_Ftree_IteratorFilter($ftree);
     $iterator->add($iterator::REMOTE);
     if ($showAll) {
         $ftree->loadUnsubscribed();
         $iterator->remove($iterator::UNSUB);
     }
     $tree = $ftree->createTree('mimp_folders', array('iterator' => $iterator, 'poll_info' => true, 'render_type' => 'IMP_Tree_Simplehtml'));
     $selfurl = self::url();
     $menu = array(array(_("Refresh"), $selfurl));
     if ($subscribe) {
         $menu[] = array($showAll ? _("Show Subscribed Mailboxes") : _("Show All Mailboxes"), $selfurl->copy()->add('ts', 1));
     }
     $this->title = _("Folders");
     $this->view->menu = $this->getMenu('folders', $menu);
     $this->view->title = $this->title;
     $this->view->tree = $tree->getTree(true);
     $this->_pages[] = 'folders';
     $this->_pages[] = 'menu';
 }
コード例 #5
0
ファイル: Compose.php プロジェクト: jubinpatel/horde
 /**
  * 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;
 }
コード例 #6
0
ファイル: IMP.php プロジェクト: DSNS-LAB/Dmail
 /**
  * Returns the initial page for IMP.
  *
  * @return object  Object with the following properties:
  * <pre>
  *   - mbox (IMP_Mailbox)
  *   - url (Horde_Url)
  * </pre>
  */
 public static function getInitialPage()
 {
     global $injector, $prefs, $registry;
     $init_url = $prefs->getValue('initial_page');
     if (!$init_url || !$injector->getInstance('IMP_Factory_Imap')->create()->access(IMP_Imap::ACCESS_FOLDERS)) {
         $init_url = 'INBOX';
     }
     if ($init_url == IMP::INITIAL_FOLDERS) {
         $mbox = null;
     } else {
         $mbox = IMP_Mailbox::get($init_url);
         if (!$mbox->exists) {
             $mbox = IMP_Mailbox::get('INBOX');
         }
     }
     $result = new stdClass();
     $result->mbox = $mbox;
     switch ($registry->getView()) {
         case Horde_Registry::VIEW_BASIC:
             $result->url = is_null($mbox) ? IMP_Basic_Folders::url() : $mbox->url('mailbox');
             break;
         case Horde_Registry::VIEW_DYNAMIC:
             $result->url = IMP_Dynamic_Mailbox::url(array('mailbox' => is_null($mbox) ? 'INBOX' : $mbox));
             break;
         case Horde_Registry::VIEW_MINIMAL:
             $result->url = is_null($mbox) ? IMP_Minimal_Folders::url() : IMP_Minimal_Mailbox::url(array('mailbox' => $mbox));
             break;
         case Horde_Registry::VIEW_SMARTMOBILE:
             $result->url = is_null($mbox) ? Horde::url('smartmobile.php', true) : $mbox->url('mailbox');
             break;
     }
     return $result;
 }
コード例 #7
0
ファイル: Message.php プロジェクト: DSNS-LAB/Dmail
 /**
  * URL Parameters:
  *   a: (string) Action ID.
  *   allto: (boolean) View all To addresses?
  *   buid: (string) Browser UID.
  *   t: (string) Token.
  */
 protected function _init()
 {
     global $injector, $notification, $page_output, $prefs, $session;
     $imp_mailbox = $this->indices->mailbox->list_ob;
     $imp_mailbox->setIndex($this->indices);
     $mailbox_url = IMP_Minimal_Mailbox::url(array('mailbox' => $this->indices->mailbox));
     /* Make sure we have a valid index. */
     if (!$imp_mailbox->isValidIndex()) {
         $mailbox_url->add('a', 'm')->redirect();
     }
     $imp_ui = $injector->getInstance('IMP_Message_Ui');
     /* Run through action handlers */
     $msg_delete = false;
     switch ($this->vars->a) {
         // 'd' = delete message
         case 'd':
             $old_index = $imp_mailbox->getIndex();
             try {
                 $session->checkToken($this->vars->t);
                 $msg_delete = (bool) $injector->getInstance('IMP_Message')->delete($this->indices, array('mailboxob' => $imp_mailbox));
             } catch (Horde_Exception $e) {
                 $notification->push($e);
             }
             break;
             // 'u' = undelete message
         // 'u' = undelete message
         case 'u':
             $old_index = $imp_mailbox->getIndex();
             $injector->getInstance('IMP_Message')->undelete($this->indices);
             break;
             // 'rs' = report spam
             // 'ri' = report innocent
         // 'rs' = report spam
         // 'ri' = report innocent
         case 'rs':
         case 'ri':
             $old_index = $imp_mailbox->getIndex();
             $msg_delete = $injector->getInstance('IMP_Factory_Spam')->create($this->vars->a == 'rs' ? IMP_Spam::SPAM : IMP_Spam::INNOCENT)->report($this->indices, array('mailboxob' => $imp_mailbox)) === 1;
             break;
     }
     if ($msg_delete && $imp_ui->moveAfterAction($this->indices->mailbox)) {
         $imp_mailbox->setIndex(1);
     }
     /* We may have done processing that has taken us past the end of the
      * message array, so we will return to the mailbox. */
     if (!$imp_mailbox->isValidIndex() || $msg_delete && $prefs->getValue('mailbox_return')) {
         $mailbox_url->add('s', $old_index)->redirect();
     }
     /* Now that we are done processing, get the index and array index of
      * the current message. */
     $msg_index = $imp_mailbox[$imp_mailbox->getIndex()];
     $mailbox = $msg_index['m'];
     $uid = $msg_index['u'];
     $buid = $imp_mailbox->getBuid($mailbox, $uid);
     /* Get envelope/flag/header information. */
     try {
         $imp_imap = $mailbox->imp_imap;
         /* Need to fetch flags before HEADERTEXT, because SEEN flag might
          * be set before we can grab it. */
         $query = new Horde_Imap_Client_Fetch_Query();
         $query->flags();
         $flags_ret = $imp_imap->fetch($mailbox, $query, array('ids' => $imp_imap->getIdsOb($uid)));
         $query = new Horde_Imap_Client_Fetch_Query();
         $query->envelope();
         $fetch_ret = $imp_imap->fetch($mailbox, $query, array('ids' => $imp_imap->getIdsOb($uid)));
     } catch (IMP_Imap_Exception $e) {
         $mailbox_url->add('a', 'm')->redirect();
     }
     $envelope = $fetch_ret->first()->getEnvelope();
     $flags = $flags_ret->first()->getFlags();
     /* Parse the message. */
     try {
         $imp_contents = $injector->getInstance('IMP_Factory_Contents')->create(new IMP_Indices($imp_mailbox));
         $mime_headers = $imp_contents->getHeaderAndMarkAsSeen();
     } catch (IMP_Exception $e) {
         $mailbox_url->add('a', 'm')->redirect();
     }
     /* Get the starting index for the current message and the message
      * count. */
     $msgindex = $imp_mailbox->getIndex();
     $msgcount = count($imp_mailbox);
     /* Generate the mailbox link. */
     $mailbox_link = $mailbox_url->add('s', $msgindex);
     $self_link = self::url(array('buid' => $buid, 'mailbox' => $this->indices->mailbox));
     /* Create the Identity object. */
     $user_identity = $injector->getInstance('IMP_Identity');
     /* Develop the list of headers to display. */
     $basic_headers = $imp_ui->basicHeaders();
     $display_headers = $msgAddresses = array();
     if ($subject = $mime_headers->getValue('subject')) {
         /* Filter the subject text, if requested. */
         $subject = Horde_String::truncate(IMP::filterText($subject), 50);
     } else {
         $subject = _("[No Subject]");
     }
     $display_headers['subject'] = $subject;
     $format_date = $imp_ui->getLocalTime($envelope->date);
     if (!empty($format_date)) {
         $display_headers['date'] = $format_date;
     }
     /* Build From address links. */
     $display_headers['from'] = $imp_ui->buildAddressLinks($envelope->from, null, false);
     /* Build To/Cc/Bcc links. */
     foreach (array('to', 'cc', 'bcc') as $val) {
         $msgAddresses[] = $mime_headers->getValue($val);
         $addr_val = $imp_ui->buildAddressLinks($envelope->{$val}, null, false);
         if (!empty($addr_val)) {
             $display_headers[$val] = $addr_val;
         }
     }
     /* Check for the presence of mailing list information. */
     $list_info = $imp_ui->getListInformation($mime_headers);
     /* See if the priority has been set. */
     switch ($priority = $injector->getInstance('IMP_Mime_Headers')->getPriority($mime_headers)) {
         case 'high':
         case 'low':
             $basic_headers['priority'] = _("Priority");
             $display_headers['priority'] = Horde_String::ucfirst($priority);
             break;
     }
     /* Set the status information of the message. */
     $status = '';
     $match_identity = $identity = null;
     if (!empty($msgAddresses)) {
         $match_identity = $identity = $user_identity->getMatchingIdentity($msgAddresses);
         if (is_null($identity)) {
             $identity = $user_identity->getDefault();
         }
     }
     $flag_parse = $injector->getInstance('IMP_Flags')->parse(array('flags' => $flags, 'personal' => $match_identity));
     foreach ($flag_parse as $val) {
         if ($abbrev = $val->abbreviation) {
             $status .= $abbrev;
         } elseif ($val instanceof IMP_Flag_User) {
             $status .= ' *' . Horde_String::truncate($val->label, 8) . '*';
         }
     }
     /* Create the body of the message. */
     $inlineout = $imp_contents->getInlineOutput(array('display_mask' => IMP_Contents::RENDER_INLINE, 'no_inline_all' => true));
     $msg_text = $inlineout['msgtext'];
     $this->view->msg = nl2br($injector->getInstance('Horde_Core_Factory_TextFilter')->filter($msg_text, 'space2html'));
     $menu = array();
     if ($this->indices->mailbox->access_deletemsgs) {
         $menu[] = in_array(Horde_Imap_Client::FLAG_DELETED, $flags) ? array(_("Undelete"), $self_link->copy()->add('a', 'u')) : array(_("Delete"), $self_link->copy()->add(array('a' => 'd', 't' => $session->getToken())));
     }
     /* Add compose actions (Reply, Reply List, Reply All, Forward,
      * Redirect, Edit as New). */
     if (IMP_Compose::canCompose()) {
         $clink_ob = new IMP_Compose_Link();
         $clink_ob->args['buid'] = $buid;
         $clink_ob->args['mailbox'] = $this->indices->mailbox;
         $clink = $clink_ob->link()->add(array('identity' => $identity));
         $menu[] = array(_("Reply"), $clink->copy()->add(array('a' => 'r')));
         if ($list_info['reply_list']) {
             $menu[] = array(_("Reply to List"), $clink->copy()->add(array('a' => 'rl')));
         }
         $addr_ob = clone $envelope->to;
         $addr_ob->add($envelope->cc);
         $addr_ob->setIteratorFilter(0, $user_identity->getAllFromAddresses());
         if (count($addr_ob)) {
             $menu[] = array(_("Reply All"), $clink->copy()->add(array('a' => 'ra')));
         }
         $menu[] = array(_("Forward"), $clink->copy()->add(array('a' => 'f')));
         $menu[] = array(_("Redirect"), $clink->copy()->add(array('a' => 'rc')));
         $menu[] = array(_("Edit as New"), $clink->copy()->add(array('a' => 'en')));
     }
     /* Generate previous/next links. */
     if ($prev_msg = $imp_mailbox[$imp_mailbox->getIndex() - 1]) {
         $menu[] = array(_("Previous Message"), self::url(array('buid' => $imp_mailbox->getBuid($prev_msg['m'], $prev_msg['u']), 'mailbox' => $this->indices->mailbox)));
     }
     if ($next_msg = $imp_mailbox[$imp_mailbox->getIndex() + 1]) {
         $menu[] = array(_("Next Message"), self::url(array('buid' => $imp_mailbox->getBuid($next_msg['m'], $next_msg['u']), 'mailbox' => $this->indices->mailbox)));
     }
     $menu[] = array(sprintf(_("To %s"), $this->indices->mailbox->label), $mailbox_link);
     if ($mailbox->spam_show) {
         $menu[] = array(_("Report as Spam"), $self_link->copy()->add(array('a' => 'rs', 't' => $session->getToken())));
     }
     if ($mailbox->innocent_show) {
         $menu[] = array(_("Report as Innocent"), $self_link->copy()->add(array('a' => 'ri', 't' => $session->getToken())));
     }
     $this->view->menu = $this->getMenu('message', $menu);
     $hdrs = array();
     foreach ($display_headers as $head => $val) {
         $tmp = array('label' => $basic_headers[$head]);
         if (Horde_String::lower($head) == 'to' && !isset($this->vars->allto) && ($pos = strpos($val, ',')) !== false) {
             $val = Horde_String::substr($val, 0, $pos);
             $tmp['all_to'] = $self_link->copy()->add('allto', 1);
         }
         $tmp['val'] = $val;
         $hdrs[] = $tmp;
     }
     $this->view->hdrs = $hdrs;
     $atc = array();
     foreach ($inlineout['atc_parts'] as $key) {
         $summary = $imp_contents->getSummary($key, IMP_Contents::SUMMARY_BYTES | IMP_Contents::SUMMARY_SIZE | IMP_Contents::SUMMARY_DESCRIP | IMP_Contents::SUMMARY_DOWNLOAD);
         $tmp = array('descrip' => $summary['description_raw'], 'size' => $summary['size'], 'type' => $summary['type']);
         if (!empty($summary['download'])) {
             /* Preference: if set, only show download confirmation screen
              * if attachment over a certain size. */
             $tmp['download'] = IMP_Minimal_Messagepart::url(array('buid' => $buid, 'mailbox' => $this->indices->mailbox))->add('atc', $key);
         }
         if ($imp_contents->canDisplay($key, IMP_Contents::RENDER_INLINE)) {
             $tmp['view'] = IMP_Minimal_Messagepart::url(array('buid' => $buid, 'mailbox' => $this->indices->mailbox))->add('id', $key);
         }
         $atc[] = $tmp;
     }
     $this->view->atc = $atc;
     $this->title = $display_headers['subject'];
     $this->view->title = ($status ? $status . ' ' : '') . sprintf(_("(Message %d of %d)"), $msgindex, $msgcount);
     $page_output->noDnsPrefetch();
     $this->_pages[] = 'message';
     $this->_pages[] = 'menu';
 }
コード例 #8
0
ファイル: Ftree.php プロジェクト: jubinpatel/horde
 /**
  * Creates a Horde_Tree representation of the current tree.
  *
  * @param string|Horde_Tree $name  Either the tree name, or a Horde_Tree
  *                                 object to add nodes to.
  * @param array $opts              Additional options:
  *   - basename: (boolean) Use raw basename instead of abbreviated label?
  *               DEFAULT: false
  *   - checkbox: (boolean) Display checkboxes?
  *               DEFAULT: false
  *   - editvfolder: (boolean) Display vfolder edit links?
  *                  DEFAULT: false
  *   - iterator: (Iterator) Tree iterator to use.
  *               DEFAULT: Base iterator.
  *   - open: (boolean) Force child mailboxes to this status.
  *           DEFAULT: null
  *   - parent: (string) The parent object of the current level.
  *             DEFAULT: null (add to base level)
  *   - poll_info: (boolean) Include poll information in output?
  *                DEFAULT: false
  *   - render_params: (array) List of params to pass to renderer if
  *                    auto-creating.
  *                    DEFAULT: 'alternate', 'lines', and 'lines_base'
  *                             are passed in with true values.
  *   - render_type: (string) The renderer name.
  *                  DEFAULT: Javascript
  *
  * @return Horde_Tree  The tree object.
  */
 public function createTree($name, array $opts = array())
 {
     global $injector, $registry;
     $opts = array_merge(array('parent' => null, 'render_params' => array(), 'render_type' => 'Javascript'), $opts);
     $view = $registry->getView();
     if ($name instanceof Horde_Tree_Renderer_Base) {
         $tree = $name;
         $parent = $opts['parent'];
     } else {
         $tree = $injector->getInstance('Horde_Core_Factory_Tree')->create($name, $opts['render_type'], array_merge(array('alternate' => true, 'lines' => true, 'lines_base' => true, 'nosession' => true), $opts['render_params']));
         $parent = null;
     }
     $iterator = empty($opts['iterator']) ? new IMP_Ftree_IteratorFilter($this) : $opts['iterator'];
     foreach ($iterator as $val) {
         $after = '';
         $elt_parent = null;
         $mbox_ob = $val->mbox_ob;
         $params = array();
         switch ($opts['render_type']) {
             case 'IMP_Tree_Flist':
                 if ($mbox_ob->vfolder_container) {
                     continue 2;
                 }
                 $is_open = true;
                 $label = $params['orig_label'] = empty($opts['basename']) ? $mbox_ob->abbrev_label : $mbox_ob->basename;
                 break;
             case 'IMP_Tree_Jquerymobile':
                 $is_open = true;
                 $label = $mbox_ob->display_html;
                 $icon = $mbox_ob->icon;
                 $params['icon'] = $icon->icon;
                 $params['special'] = $mbox_ob->inbox || $mbox_ob->special;
                 $params['class'] = 'imp-folder';
                 $params['urlattributes'] = array('id' => 'imp-mailbox-' . $mbox_ob->form_to);
                 /* Force to flat tree so that non-polled parents don't cause
                  * polled children to be skipped by renderer (see Bug
                  * #11238). */
                 $elt_parent = $this[self::BASE_ELT];
                 break;
             case 'IMP_Tree_Simplehtml':
                 $is_open = $val->open;
                 if ($tree->shouldToggle($mbox_ob->form_to)) {
                     if ($is_open) {
                         $this->collapse($val);
                     } else {
                         $this->expand($val);
                     }
                     $is_open = !$is_open;
                 }
                 $label = htmlspecialchars(Horde_String::abbreviate($mbox_ob->abbrev_label, 30 - $val->level * 2));
                 break;
             case 'Javascript':
                 $is_open = $val->open;
                 $label = empty($opts['basename']) ? htmlspecialchars($mbox_ob->abbrev_label) : htmlspecialchars($mbox_ob->basename);
                 $icon = $mbox_ob->icon;
                 $params['icon'] = $icon->icon;
                 $params['iconopen'] = $icon->iconopen;
                 break;
         }
         if (!empty($opts['poll_info']) && $val->polled) {
             $poll_info = $mbox_ob->poll_info;
             if ($poll_info->unseen) {
                 switch ($opts['render_type']) {
                     case 'IMP_Tree_Jquerymobile':
                         $after = $poll_info->unseen;
                         break;
                     default:
                         $label = '<strong>' . $label . '</strong>&nbsp;(' . $poll_info->unseen . ')';
                 }
             }
         }
         if ($val->container) {
             $params['container'] = true;
         } else {
             switch ($view) {
                 case $registry::VIEW_MINIMAL:
                     $params['url'] = IMP_Minimal_Mailbox::url(array('mailbox' => $mbox_ob));
                     break;
                 case $registry::VIEW_SMARTMOBILE:
                     $url = new Horde_Core_Smartmobile_Url();
                     $url->add('mbox', $mbox_ob->form_to);
                     $url->setAnchor('mailbox');
                     $params['url'] = strval($url);
                     break;
                 default:
                     $params['url'] = $mbox_ob->url('mailbox')->setRaw(true);
                     break;
             }
             if (!$val->subscribed) {
                 $params['class'] = 'mboxunsub';
             }
         }
         $checkbox = empty($opts['checkbox']) ? '' : '<input type="checkbox" class="checkbox" name="mbox_list[]" value="' . $mbox_ob->form_to . '"';
         if ($val->nonimap) {
             $checkbox .= ' disabled="disabled"';
         }
         if ($val->vfolder && !empty($opts['editvfolder']) && $val->container) {
             $after = '&nbsp[' . $registry->getServiceLink('prefs', 'imp')->add('group', 'searches')->link(array('title' => _("Edit Virtual Folder"))) . _("Edit") . '</a>' . ']';
         }
         if (is_null($elt_parent)) {
             $elt_parent = $val->parent;
         }
         $tree->addNode(array('id' => $mbox_ob->form_to, 'parent' => $elt_parent->base_elt ? $parent : $elt_parent->mbox_ob->form_to, 'label' => $label, 'expanded' => isset($opts['open']) ? $opts['open'] : $is_open, 'params' => $params, 'right' => $after, 'left' => empty($opts['checkbox']) ? null : $checkbox . ' />'));
     }
     return $tree;
 }
コード例 #9
0
ファイル: Mailbox.php プロジェクト: jubinpatel/horde
 /**
  * Generate a URL using the current mailbox.
  *
  * @param string|Horde_Url $page  Page name to link to.
  * @param string $buid            The BUID to use on the linked page.
  * @param boolean $encode         Encode the argument separator?
  *
  * @return Horde_Url  URL to $page with any necessary mailbox information
  *                    added to the parameter list of the URL.
  */
 public function url($page, $buid = null, $encode = true)
 {
     if ($page instanceof Horde_Url) {
         return $page->add($this->urlParams($buid))->setRaw(!$encode);
     }
     switch ($GLOBALS['registry']->getView()) {
         case Horde_Registry::VIEW_BASIC:
             switch ($page) {
                 case 'message':
                     return IMP_Basic_Message::url(array('buid' => $buid, 'mailbox' => $this->_mbox))->setRaw(!$encode);
                 case 'mailbox':
                     return IMP_Basic_Mailbox::url(array('mailbox' => $this->_mbox))->setRaw(!$encode);
             }
             break;
         case Horde_Registry::VIEW_DYNAMIC:
             $anchor = is_null($buid) ? 'mbox:' . $this->form_to : 'msg:' . $this->form_to . ';' . $buid;
             return Horde::url('index.php')->setAnchor($anchor);
         case Horde_Registry::VIEW_MINIMAL:
             switch ($page) {
                 case 'message':
                     return IMP_Minimal_Message::url(array('buid' => $buid, 'mailbox' => $this->_mbox))->setRaw(!$encode);
                 case 'mailbox':
                     return IMP_Minimal_Mailbox::url(array('mailbox' => $this->_mbox))->setRaw(!$encode);
             }
             break;
         case Horde_Registry::VIEW_SMARTMOBILE:
             $url = Horde::url('smartmobile.php');
             $anchor = is_null($buid) ? 'mbox=' . $this->form_to : 'msg=' . $this->form_to . ';' . $buid;
             $url->setAnchor('mailbox?' . $anchor);
             return $url;
     }
     return Horde::url($page . '.php')->add($this->urlParams($buid))->setRaw(!$encode);
 }