widget() public static method

Returns an anchor sequence with the relevant parameters for a widget with accesskey and text.
public static widget ( array $params ) : string
$params array A hash with widget options (other options will be passed as attributes to the link tag): - url: (string) The full URL to be linked to. - title: (string) The link title/description. - nocheck: (boolean, optional) Don't check if the accesskey already already has been used. Defaults to false (= check).
return string The full Title sequence.
Esempio n. 1
0
 $sortby = $prefs->getValue('sortby');
 $sortdir = $prefs->getValue('sortdir');
 $baseurl = Horde::url('list.php');
 if ($actionID == 'search_memos') {
     $baseurl->add(array('actionID' => 'search_memos', 'search_pattern' => $search_pattern, 'search_type' => $search_type));
 }
 $page_output->addInlineJsVars(array('Mnemo_List.ajaxUrl' => $registry->getServiceLink('ajax', 'mnemo')->url . 'setPrefValue'));
 $view->editImg = Horde::img('edit.png', _("Edit Note"), '');
 $view->showNotepad = $prefs->getValue('show_notepad');
 $view->sortdirclass = $sortdir ? 'sortup' : 'sortdown';
 $view->headers = array();
 if ($view->showNotepad) {
     $view->headers[] = array('id' => 's' . Mnemo::SORT_NOTEPAD, 'sorted' => $sortby == Mnemo::SORT_NOTEPAD, 'width' => '2%', 'label' => Horde::widget(array('url' => $baseurl->add('sortby', Mnemo::SORT_NOTEPAD), 'class' => 'sortlink', 'title' => _("Notepad"))));
 }
 $view->headers[] = array('id' => 's' . MNEMO::SORT_DESC, 'sorted' => $sortby == MNEMO::SORT_DESC, 'width' => '80%', 'label' => Horde::widget(array('url' => $baseurl->add('sortby', Mnemo::SORT_DESC), 'class' => 'sortlink', 'title' => _("No_te"))));
 $view->headers[] = array('id' => 's' . MNEMO::SORT_MOD_DATE, 'sorted' => $sortby == Mnemo::SORT_MOD_DATE, 'width' => '2%', 'label' => Horde::widget(array('url' => $baseurl->add('sortby', MNEMO::SORT_MOD_DATE), 'class' => 'sortlink', 'title' => _("Date"))));
 foreach ($memos as $memo_id => &$memo) {
     try {
         $share = $mnemo_shares->getShare($memo['memolist_id']);
     } catch (Horde_Share_Exception $e) {
         $notification->push($e);
         continue;
     }
     if ($view->showNotepad) {
         $memo['notepad'] = Mnemo::getLabel($share);
     }
     if ($share->hasPermission($registry->getAuth(), Horde_Perms::EDIT)) {
         $label = sprintf(_("Edit \"%s\""), $memo['desc']);
         $memo['edit'] = Horde::url('memo.php')->add(array('memo' => $memo['memo_id'], 'memolist' => $memo['memolist_id'], 'actionID' => 'modify_memo'))->link(array('title' => $label)) . Horde::img('edit.png', $label, '') . '</a>';
     }
     $memo['link'] = Horde::linkTooltip(Horde::url('view.php')->add(array('memo' => $memo['memo_id'], 'memolist' => $memo['memolist_id'])), '', '', '', '', $memo['body'] != $memo['desc'] ? Mnemo::getNotePreview($memo) : '') . (strlen($memo['desc']) ? htmlspecialchars($memo['desc']) : '<em>' . _("Empty Note") . '</em>') . '</a>';
Esempio n. 2
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');
     }
 }
Esempio n. 3
0
 /**
  * @throws Wicked_Exception
  */
 public function displayContents($isBlock)
 {
     $view = $GLOBALS['injector']->createInstance('Horde_View');
     $view->addHelper('Wicked_View_Helper_Navigation');
     $view->name = $this->pageName();
     $view->text = $this->getProcessor()->transform($this->getText());
     if ($isBlock) {
         return $view->render('display/standard');
     }
     $view->showTools = true;
     if ($this->allows(Wicked::MODE_EDIT) && !$this->isLocked(Wicked::lockUser())) {
         $view->edit = Horde::widget(array('url' => Wicked::url('EditPage')->add('referrer', $this->pageName()), 'title' => _("_Edit"), 'class' => 'wicked-edit'));
     }
     if ($this->isLocked()) {
         if ($this->allows(Wicked::MODE_UNLOCKING)) {
             $view->unlock = Horde::widget(array('url' => $this->pageUrl(null, 'unlock')->remove('version'), 'title' => _("Un_lock"), 'class' => 'wicked-unlock'));
         }
     } else {
         if ($this->allows(Wicked::MODE_LOCKING)) {
             $view->lock = Horde::widget(array('url' => $this->pageUrl(null, 'lock')->remove('version'), 'title' => _("_Lock"), 'class' => 'wicked-lock'));
         }
     }
     if ($this->allows(Wicked::MODE_REMOVE)) {
         $params = array('referrer' => $this->pageName());
         if ($this->isOld()) {
             $params['version'] = $this->version();
         }
         $view->remove = Horde::widget(array('url' => Wicked::url('DeletePage')->add($params), 'title' => _("_Delete"), 'class' => 'wicked-delete'));
     }
     if ($this->allows(Wicked::MODE_REMOVE) && !$this->isLocked(Wicked::lockUser())) {
         $view->rename = Horde::widget(array('url' => Wicked::url('MergeOrRename')->add('referrer', $this->pageName()), 'title' => _("_Merge/Rename")));
     }
     $view->backLinks = Horde::widget(array('url' => Wicked::url('BackLinks')->add('referrer', $this->pageName()), 'title' => _("_Backlinks")));
     $view->likePages = Horde::widget(array('url' => Wicked::url('LikePages')->add('referrer', $this->pageName()), 'title' => _("S_imilar Pages")));
     $view->attachedFiles = Horde::widget(array('url' => Wicked::url('AttachedFiles')->add('referrer', $this->pageName()), 'title' => _("Attachments")));
     if ($this->allows(Wicked::MODE_HISTORY)) {
         $view->changes = Horde::widget(array('url' => $this->pageUrl('history.php')->remove('version'), 'title' => _("Hi_story")));
     }
     if ($GLOBALS['registry']->isAdmin()) {
         $permsurl = Horde::url($GLOBALS['registry']->get('webroot', 'horde') . '/admin/perms/edit.php')->add(array('category' => 'wicked:pages:' . $this->pageId(), 'autocreate' => 1, 'autocreate_copy' => 'wicked', 'autocreate_guest' => Horde_Perms::SHOW | Horde_Perms::READ, 'autocreate_default' => Horde_Perms::SHOW | Horde_Perms::READ | Horde_Perms::EDIT | Horde_Perms::DELETE));
         $view->perms = Horde::widget(array('url' => $permsurl, 'target' => '_blank', 'title' => _("Permissio_ns")));
     }
     if ($histories = $GLOBALS['session']->get('wicked', 'history')) {
         $view->history = Horde::widget(array('url' => '#', 'onclick' => 'document.location = document.display.history[document.display.history.selectedIndex].value;', 'title' => _("Ba_ck to")));
         $view->histories = array();
         foreach ($histories as $history) {
             if (!strlen($history)) {
                 continue;
             }
             $view->histories[(string) Wicked::url($history)] = $history;
         }
     }
     $pageId = $GLOBALS['wicked']->getPageId($this->pageName());
     $attachments = $GLOBALS['wicked']->getAttachedFiles($pageId);
     if (count($attachments)) {
         $view->attachments = array();
         foreach ($attachments as $attachment) {
             $url = $GLOBALS['registry']->downloadUrl($attachment['attachment_name'], array('page' => $this->pageName(), 'file' => $attachment['attachment_name'], 'version' => $attachment['attachment_version']));
             $icon = $GLOBALS['injector']->getInstance('Horde_Core_Factory_MimeViewer')->getIcon(Horde_Mime_Magic::filenameToMime($attachment['attachment_name']));
             $view->attachments[] = Horde::link($url) . '<img src="' . $icon . '" width="16" height="16" alt="" />&nbsp;' . htmlspecialchars($attachment['attachment_name']) . '</a>';
         }
     }
     $view->downloadPlain = Wicked::url($this->pageName())->add(array('actionID' => 'export', 'format' => 'plain'))->link() . _("Plain Text") . '</a>';
     $view->downloadHtml = Wicked::url($this->pageName())->add(array('actionID' => 'export', 'format' => 'html'))->link() . _("HTML") . '</a>';
     $view->downloadLatex = Wicked::url($this->pageName())->add(array('actionID' => 'export', 'format' => 'tex'))->link() . _("Latex") . '</a>';
     $view->downloadRest = Wicked::url($this->pageName())->add(array('actionID' => 'export', 'format' => 'rst'))->link() . _("reStructuredText") . '</a>';
     return $view->render('display/standard');
 }
Esempio n. 4
0
 /**
  */
 protected function _init()
 {
     global $conf, $injector, $notification, $page_output, $prefs, $registry, $session;
     $mailbox = $this->indices->mailbox;
     $imp_imap = $mailbox->imp_imap;
     /* 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. */
     $imp_imap->openMailbox($mailbox, Horde_Imap_Client::OPEN_READWRITE);
     /* Make sure we have a valid index. */
     $imp_mailbox = $mailbox->list_ob;
     $imp_mailbox->setIndex($this->indices);
     if (!$imp_mailbox->isValidIndex()) {
         $this->_returnToMailbox(null, 'message_missing');
         return;
     }
     $imp_flags = $injector->getInstance('IMP_Flags');
     $imp_identity = $injector->getInstance('IMP_Identity');
     $imp_message = $injector->getInstance('IMP_Message');
     $imp_ui = $injector->getInstance('IMP_Message_Ui');
     /* Run through action handlers. */
     if ($this->vars->actionID) {
         try {
             $session->getToken($this->vars->token);
         } catch (Horde_Exception $e) {
             $notification->push($e);
             $this->vars->actionID = null;
         }
     }
     $readonly = $mailbox->readonly;
     $peek = false;
     switch ($this->vars->actionID) {
         case 'blacklist':
         case 'whitelist':
             if ($this->vars->actionID == 'blacklist') {
                 $injector->getInstance('IMP_Filter')->blacklistMessage($this->indices);
             } else {
                 $injector->getInstance('IMP_Filter')->whitelistMessage($this->indices);
             }
             break;
         case 'delete_message':
             $imp_message->delete($this->indices, array('mailboxob' => $imp_mailbox));
             if ($prefs->getValue('mailbox_return')) {
                 $this->_returnToMailbox($imp_mailbox->getIndex());
                 return;
             }
             if ($imp_ui->moveAfterAction($mailbox)) {
                 $imp_mailbox->setIndex(1);
             }
             break;
         case 'undelete_message':
             $imp_message->undelete($this->indices);
             break;
         case 'move_message':
         case 'copy_message':
             if (isset($this->vars->targetMbox) && (!$readonly || $this->vars->actionID == 'copy_message')) {
                 if ($this->vars->newMbox) {
                     $targetMbox = IMP_Mailbox::prefFrom($this->vars->targetMbox);
                     $newMbox = true;
                 } else {
                     $targetMbox = IMP_Mailbox::formFrom($this->vars->targetMbox);
                     $newMbox = false;
                 }
                 $imp_message->copy($targetMbox, $this->vars->actionID == 'move_message' ? 'move' : 'copy', $this->indices, array('create' => $newMbox, 'mailboxob' => $imp_mailbox));
                 if ($prefs->getValue('mailbox_return')) {
                     $this->_returnToMailbox($imp_mailbox->getIndex());
                     return;
                 }
             }
             break;
         case 'innocent_report':
         case 'spam_report':
             $res = $injector->getInstance('IMP_Factory_Spam')->create($this->vars->actionID == 'spam_report' ? IMP_Spam::SPAM : IMP_Spam::INNOCENT)->report($this->indices, array('mailbox' => $imp_mailbox));
             switch ($res) {
                 case 1:
                     if ($imp_ui->moveAfterAction($mailbox)) {
                         $imp_mailbox->setIndex(1);
                     }
                     break;
             }
             if ($prefs->getValue('mailbox_return')) {
                 $this->_returnToMailbox($imp_mailbox->getIndex());
                 return;
             }
             break;
         case 'flag_message':
             if (!$readonly && isset($this->vars->flag) && count($this->indices)) {
                 $peek = true;
                 $flag = $imp_flags->parseFormId($this->vars->flag);
                 $imp_message->flag(array($flag['set'] ? 'add' : 'remove' => array($flag['flag'])), $this->indices);
                 if ($prefs->getValue('mailbox_return')) {
                     $this->_returnToMailbox($imp_mailbox->getIndex());
                     return;
                 }
             }
             break;
         case 'add_address':
             try {
                 $contact_link = $injector->getInstance('IMP_Contacts')->addAddress($this->vars->address, $this->vars->name);
                 $notification->push(sprintf(_("Entry \"%s\" was successfully added to the address book"), $contact_link), 'horde.success', array('content.raw'));
             } catch (Horde_Exception $e) {
                 $notification->push($e);
             }
             break;
         case 'strip_all':
         case 'strip_attachment':
             if (!$readonly) {
                 try {
                     $this->indices = new IMP_Indices_Mailbox($this->indices->mailbox, $imp_message->stripPart($this->indices, $this->vars->actionID == 'strip_all' ? null : $this->vars->imapid, array('mailboxob' => $imp_mailbox)));
                     $notification->push(_("Attachment successfully stripped."), 'horde.success');
                 } catch (Horde_Exception $e) {
                     $notification->push($e);
                 }
             }
             break;
     }
     /* 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()) {
         $this->_returnToMailbox(count($imp_mailbox));
         return;
     }
     /* Now that we are done processing, get the index and array index of
      * the current message. */
     $msg_index = $imp_mailbox[$imp_mailbox->getIndex()];
     /* Parse the message. */
     try {
         $imp_contents = $injector->getInstance('IMP_Factory_Contents')->create(new IMP_Indices($imp_mailbox));
     } catch (IMP_Exception $e) {
         $imp_mailbox->removeMsgs(true);
         $this->_returnToMailbox(null, 'message_missing');
         return;
     }
     /* Get envelope/flag/header information. */
     try {
         /* 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($msg_index['m'], $query, array('ids' => $imp_imap->getIdsOb($msg_index['u'])));
         $query = new Horde_Imap_Client_Fetch_Query();
         $query->envelope();
         $fetch_ret = $imp_imap->fetch($msg_index['m'], $query, array('ids' => $imp_imap->getIdsOb($msg_index['u'])));
     } catch (IMP_Imap_Exception $e) {
         $this->_returnToMailbox(null, 'message_missing');
         return;
     }
     $envelope = $fetch_ret->first()->getEnvelope();
     $flags = $flags_ret->first()->getFlags();
     $mime_headers = $peek ? $imp_contents->getHeader() : $imp_contents->getHeaderAndMarkAsSeen();
     /* Get the title/mailbox label of the mailbox page. */
     $page_label = $mailbox->label;
     /* Generate the link to ourselves. */
     $buid = $imp_mailbox->getBuid($msg_index['m'], $msg_index['u']);
     $msgindex = $imp_mailbox->getIndex();
     $message_url = Horde::url('basic.php')->add('page', 'message');
     $token = $session->getToken();
     $self_link = self::url(array('buid' => $buid, 'mailbox' => $mailbox))->add(array('token' => $token, 'start' => $msgindex));
     /* Develop the list of headers to display. */
     $basic_headers = $imp_ui->basicHeaders();
     $display_headers = $msgAddresses = array();
     $date_ob = new IMP_Message_Date($envelope->date);
     if ($format_date = $date_ob->format($date_ob::DATE_LOCAL)) {
         $display_headers['date'] = $format_date;
     }
     /* Build From address links. */
     $display_headers['from'] = $imp_ui->buildAddressLinks($envelope->from, $self_link);
     /* Add country/flag image. */
     if (!empty($envelope->from)) {
         $contacts_img = new IMP_Contacts_Image($envelope->from[0]);
         try {
             $res = $contacts_img->getImage($contacts_img::FLAG);
             $display_headers['from'] .= '&nbsp;' . Horde_Themes_Image::tag($res['url'], array('alt' => $res['desc'], 'fullsrc' => true));
         } catch (IMP_Exception $e) {
         }
     }
     /* Look for Face information. */
     if ($face = $mime_headers->getValue('face')) {
         $display_headers['from'] .= '&nbsp;<img src="' . Horde_Url_Data::create('image/png', base64_decode($face)) . '">';
     }
     /* Build To/Cc/Bcc links. */
     foreach (array('to', 'cc', 'bcc') as $val) {
         $msgAddresses[] = $mime_headers->getValue($val);
         if ($val == 'to' || count($envelope->{$val})) {
             $display_headers[$val] = $imp_ui->buildAddressLinks($envelope->{$val}, $self_link);
         }
     }
     /* Process the subject now. */
     if ($subject = $mime_headers->getValue('subject')) {
         $this->title = sprintf(_("%s: %s"), $page_label, $subject);
         $shortsub = Horde_String::truncate($subject, 100);
     } else {
         $shortsub = _("[No Subject]");
         $this->title = sprintf(_("%s: %s"), $page_label, $shortsub);
     }
     /* See if the priority has been set. */
     switch ($injector->getInstance('IMP_Mime_Headers')->getPriority($mime_headers)) {
         case 'high':
             $basic_headers['priority'] = _("Priority");
             $display_headers['priority'] = '<div class="iconImg msgflags flagHighpriority" title="' . htmlspecialchars(_("High Priority")) . '"></div>&nbsp;' . _("High");
             break;
         case 'low':
             $basic_headers['priority'] = _("Priority");
             $display_headers['priority'] = '<div class="iconImg msgflags flagLowpriority" title="' . htmlspecialchars(_("Low Priority")) . '"></div>&nbsp;' . _("Low");
             break;
     }
     /* Build Reply-To address link. */
     if (!empty($envelope->reply_to) && $envelope->from[0]->bare_address != $envelope->reply_to[0]->bare_address && ($reply_to = $imp_ui->buildAddressLinks($envelope->reply_to, $self_link))) {
         $display_headers['reply-to'] = $reply_to;
     }
     /* Determine if all/list/user-requested headers needed. */
     $all_headers = $this->vars->show_all_headers;
     $user_hdrs = $imp_ui->getUserHeaders();
     /* Check for the presence of mailing list information. */
     $list_info = $imp_ui->getListInformation($mime_headers);
     /* Display all headers or, optionally, the user-specified headers for
      * the current identity. */
     $full_headers = array();
     if ($all_headers) {
         $header_array = $mime_headers->toArray();
         foreach ($header_array as $head => $val) {
             $lc_head = strtolower($head);
             /* Skip the header if we have already dealt with it. */
             if (!isset($display_headers[$lc_head]) && (!in_array($lc_head, array('importance', 'x-priority')) || !isset($display_headers['priority']))) {
                 $full_headers[$lc_head] = $val;
             }
         }
     } elseif (!empty($user_hdrs)) {
         foreach ($user_hdrs as $user_hdr) {
             $user_val = $mime_headers->getValue($user_hdr);
             if (!empty($user_val)) {
                 $full_headers[$user_hdr] = $user_val;
             }
         }
     }
     ksort($full_headers);
     /* For the self URL link, we can't trust the index in the query string
      * as it may have changed if we deleted/copied/moved messages. We may
      * need other stuff in the query string, so we need to do an
      * add/remove of uid info. */
     $selfURL = $mailbox->url(Horde::selfUrlParams()->remove(array('actionID')), $buid)->add('token', $token);
     $headersURL = $selfURL->copy()->remove(array('show_all_headers'));
     /* Generate previous/next links. */
     $prev_msg = $imp_mailbox[$imp_mailbox->getIndex() - 1];
     if ($prev_msg) {
         $prev_url = self::url(array('buid' => $imp_mailbox->getBuid($prev_msg['m'], $prev_msg['u']), 'mailbox' => $mailbox))->setRaw(true);
         $page_output->addLinkTag(array('href' => $prev_url, 'id' => 'prev', 'rel' => 'Previous', 'type' => null));
     } else {
         $prev_url = null;
     }
     $next_msg = $imp_mailbox[$imp_mailbox->getIndex() + 1];
     if ($next_msg) {
         $next_url = self::url(array('buid' => $imp_mailbox->getBuid($next_msg['m'], $next_msg['u']), 'mailbox' => $mailbox))->setRaw(true);
         $page_output->addLinkTag(array('href' => $next_url, 'id' => 'next', 'rel' => 'Next', 'type' => null));
     } else {
         $next_url = null;
     }
     /* Generate the mailbox link. */
     $mailbox_url = $mailbox->url('mailbox')->add('start', $msgindex);
     /* Everything below here is related to preparing the output. */
     $js_vars = array('ImpMessage.text' => array('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", 'spam_report' => _("Are you sure you wish to report this message as spam?"), 'target_mbox' => _("You must select a target mailbox first.")));
     /* Set the status information of the message. */
     $msgAddresses[] = $mime_headers->getValue('from');
     $identity = $match_identity = $imp_identity->getMatchingIdentity($msgAddresses);
     if (is_null($identity)) {
         $identity = $imp_identity->getDefault();
     }
     $flag_parse = $imp_flags->parse(array('flags' => $flags, 'personal' => $match_identity));
     $status = '';
     foreach ($flag_parse as $val) {
         if ($val instanceof IMP_Flag_User) {
             $status .= '<span class="' . $val->css . '" style="' . ($val->bgdefault ? '' : 'background:' . htmlspecialchars($val->bgcolor) . ';') . 'color:' . htmlspecialchars($val->fgcolor) . '">' . htmlspecialchars($val->label) . '</span>';
         } else {
             $status .= $val->span;
         }
     }
     /* If this is a search mailbox, display a link to the parent mailbox
      * of the message in the header. */
     $h_page_label = htmlspecialchars($page_label);
     $header_label = $h_page_label;
     if ($mailbox->search) {
         $header_label .= ' [' . $msg_index['m']->url('mailbox')->link() . $msg_index['m']->display_html . '</a>]';
     }
     /* Prepare the navbar top template. */
     $view = new Horde_View(array('templatePath' => IMP_TEMPLATES . '/basic/message'));
     $view->addHelper('FormTag');
     $view->addHelper('Tag');
     $t_view = clone $view;
     $t_view->buid = $buid;
     $t_view->message_url = $message_url;
     $t_view->mailbox = $mailbox->form_to;
     $t_view->start = $msgindex;
     $t_view->token = $token;
     /* Prepare the navbar navigate template. */
     $n_view = clone $view;
     $n_view->readonly = $readonly;
     $n_view->id = 1;
     if ($mailbox->access_flags) {
         $n_view->mailbox = $mailbox->form_to;
         $args = array('imap' => true, 'mailbox' => $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);
                 $form_unset[] = array('f' => $val->form_unset, 'l' => $val->label);
             }
         }
         $n_view->flaglist_set = $form_set;
         $n_view->flaglist_unset = $form_unset;
     }
     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));
         $iterator = new IMP_Ftree_IteratorFilter($injector->getInstance('IMP_Ftree'));
         $iterator->add($iterator::NONIMAP);
         $n_view->options = new IMP_Ftree_Select(array('heading' => _("This message to"), 'inc_tasklists' => true, 'inc_notepads' => true, 'iterator' => $iterator, 'new_mbox' => true));
     }
     $n_view->back_to = Horde::widget(array('url' => $mailbox_url, 'title' => sprintf(_("Bac_k to %s"), $h_page_label), 'nocheck' => true));
     if ($prev_url) {
         $n_view->prev = Horde::link($prev_url, _("Previous Message"));
         $n_view->prev_img = 'navleftImg';
     } else {
         $n_view->prev_img = 'navleftgreyImg';
     }
     if ($next_url) {
         $n_view->next = Horde::link($next_url, _("Next Message"));
         $n_view->next_img = 'navrightImg';
     } else {
         $n_view->next_img = 'navrightgreyImg';
     }
     /* Prepare the navbar actions template. */
     $a_view = clone $view;
     $compose_params = array('buid' => $buid, 'identity' => $identity, 'mailbox' => IMP_Mailbox::formTo($mailbox));
     if (!$prefs->getValue('compose_popup')) {
         $compose_params['start'] = $msgindex;
     }
     if ($msg_index['m']->access_deletemsgs) {
         if (in_array(Horde_Imap_Client::FLAG_DELETED, $flags)) {
             $a_view->delete = Horde::widget(array('url' => $self_link->copy()->add('actionID', 'undelete_message'), 'title' => _("Undelete"), 'nocheck' => true));
         } else {
             $a_view->delete = Horde::widget(array('url' => $self_link->copy()->add('actionID', 'delete_message'), 'title' => _("_Delete"), 'nocheck' => true));
             if (!$msg_index['m']->is_imap) {
                 $js_vars['ImpMessage.pop3delete'] = _("Are you sure you want to PERMANENTLY delete these messages?");
             }
         }
     }
     $disable_compose = !IMP_Compose::canCompose();
     if (!$disable_compose) {
         $clink_ob = new IMP_Compose_Link();
         $clink = $clink_ob->link()->add($compose_params);
         $a_view->reply = Horde::widget(array('url' => $clink->add(array('actionID' => 'reply_auto')), 'class' => 'horde-hasmenu', 'title' => _("_Reply"), 'nocheck' => true));
         $a_view->reply_sender = Horde::widget(array('url' => $clink->add(array('actionID' => 'reply')), 'title' => _("To Sender"), 'nocheck' => true));
         if ($list_info['reply_list']) {
             $a_view->reply_list = Horde::widget(array('url' => $clink->add(array('actionID' => 'reply_list')), 'title' => _("To _List"), 'nocheck' => true));
         }
         $addr_ob = clone $envelope->to;
         $addr_ob->add($envelope->cc);
         $addr_ob->setIteratorFilter(0, $imp_identity->getAllFromAddresses());
         if (count($addr_ob)) {
             $a_view->show_reply_all = Horde::widget(array('url' => $clink->add(array('actionID' => 'reply_all')), 'title' => _("To _All"), 'nocheck' => true));
         }
         $fwd_locked = $prefs->isLocked('forward_default');
         $a_view->forward = Horde::widget(array('url' => $clink->add(array('actionID' => 'forward_auto')), 'class' => $fwd_locked ? '' : ' horde-hasmenu', 'title' => _("Fo_rward"), 'nocheck' => true));
         if (!$fwd_locked) {
             $a_view->forward_attach = Horde::widget(array('url' => $clink->add(array('actionID' => 'forward_attach')), 'title' => _("As Attachment"), 'nocheck' => true));
             $a_view->forward_body = Horde::widget(array('url' => $clink->add(array('actionID' => 'forward_body')), 'title' => _("In Body Text"), 'nocheck' => true));
             $a_view->forward_both = Horde::widget(array('url' => $clink->add(array('actionID' => 'forward_both')), 'title' => _("Attachment and Body Text"), 'nocheck' => true));
         }
         $a_view->redirect = Horde::widget(array('url' => $clink->add(array('actionID' => 'redirect_compose')), 'title' => _("Redirec_t"), 'nocheck' => true));
         $a_view->editasnew = Horde::widget(array('url' => $clink->add(array('actionID' => 'editasnew')), 'title' => _("Edit as New"), 'nocheck' => true));
     }
     if ($mailbox->access_sortthread) {
         $a_view->show_thread = Horde::widget(array('url' => $mailbox->url(IMP_Basic_Thread::url(), $buid)->add(array('start' => $msgindex)), 'title' => _("_View Thread"), 'nocheck' => true));
     }
     if (!$readonly && $registry->hasMethod('mail/blacklistFrom')) {
         $a_view->blacklist = Horde::widget(array('url' => $self_link->copy()->add('actionID', 'blacklist'), 'title' => _("_Blacklist"), 'nocheck' => true));
     }
     if (!$readonly && $registry->hasMethod('mail/whitelistFrom')) {
         $a_view->whitelist = Horde::widget(array('url' => $self_link->copy()->add('actionID', 'whitelist'), 'title' => _("_Whitelist"), 'nocheck' => true));
     }
     if (!empty($conf['user']['allow_view_source'])) {
         $a_view->view_source = $imp_contents->linkViewJS($imp_contents->getMIMEMessage(), 'view_source', _("_Message Source"), array('css' => '', 'jstext' => _("Message Source"), 'widget' => true));
     }
     if (!$disable_compose && (in_array(Horde_Imap_Client::FLAG_DRAFT, $flags) || $msg_index['m']->drafts)) {
         $a_view->resume = Horde::widget(array('url' => $clink->add(array('actionID' => 'draft')), 'title' => _("Resume"), 'nocheck' => true));
     }
     $imp_params = $mailbox->urlParams($buid);
     $a_view->save_as = Horde::widget(array('url' => IMP_Contents_View::downloadUrl($subject, array_merge(array('actionID' => 'save_message'), $imp_params)), 'title' => _("Sa_ve as"), 'nocheck' => true));
     if ($msg_index['m']->spam_show) {
         $a_view->spam = Horde::widget(array('url' => '#', 'class' => 'spamAction', 'title' => _("Report as Spam"), 'nocheck' => true));
     }
     if ($msg_index['m']->innocent_show) {
         $a_view->innocent = Horde::widget(array('url' => '#', 'class' => 'innocentAction', 'title' => _("Report as Innocent"), 'nocheck' => true));
     }
     if (!$disable_compose) {
         $a_view->redirect = Horde::widget(array('url' => $clink->add(array('actionID' => 'redirect_compose')), 'title' => _("Redirec_t"), 'nocheck' => true));
     }
     $a_view->headers = Horde::widget(array('url' => '#', 'class' => 'horde-hasmenu', 'title' => _("Headers"), 'nocheck' => true));
     if ($all_headers) {
         $a_view->common_headers = Horde::widget(array('url' => $headersURL, 'title' => _("Show Common Headers"), 'nocheck' => true));
     }
     if (!$all_headers) {
         $a_view->all_headers = Horde::widget(array('url' => $headersURL->copy()->add('show_all_headers', 1), 'title' => _("Show All Headers"), 'nocheck' => true));
     }
     if ($list_info['exists']) {
         $a_view->list_headers = Horde::widget(array('onclick' => Horde::popupJs(IMP_Basic_Listinfo::url(array('buid' => $buid, 'mailbox' => $mailbox)), array('urlencode' => true)), 'title' => _("Show Mailing List Information"), 'nocheck' => true));
     }
     $hdrs = array();
     /* Prepare the main message template. */
     if (!$all_headers) {
         foreach ($display_headers as $head => $val) {
             $hdrs[] = array('name' => $basic_headers[$head], 'val' => $val);
         }
     }
     foreach ($full_headers as $head => $val) {
         if (is_array($val)) {
             $hdrs[] = array('name' => $head, 'val' => '<ul style="margin:0;padding-left:15px"><li>' . implode("</li>\n<li>", array_map('htmlspecialchars', $val)) . '</li></ul>');
         } else {
             $hdrs[] = array('name' => $head, 'val' => htmlspecialchars($val));
         }
     }
     /* Determine the fields that will appear in the MIME info entries. */
     $part_info = $part_info_display = array('icon', 'description', 'size');
     $part_info_action = array('download', 'download_zip', 'img_save', 'strip');
     $part_info_bodyonly = array('print');
     $show_parts = isset($this->vars->show_parts) ? $this->vars->show_parts : $prefs->getValue('parts_display');
     $part_info_display = array_merge($part_info_display, $part_info_action, $part_info_bodyonly);
     $contents_mask = IMP_Contents::SUMMARY_BYTES | IMP_Contents::SUMMARY_SIZE | IMP_Contents::SUMMARY_ICON | IMP_Contents::SUMMARY_DESCRIP_LINK | IMP_Contents::SUMMARY_DOWNLOAD | IMP_Contents::SUMMARY_DOWNLOAD_ZIP | IMP_Contents::SUMMARY_IMAGE_SAVE | IMP_Contents::SUMMARY_PRINT;
     /* Do MDN processing now. */
     $mdntext = $imp_ui->MDNCheck(new IMP_Indices($msg_index['m'], $buid), $mime_headers, $this->vars->mdn_confirm) ? strval(new IMP_Mime_Status(array(_("The sender of this message is requesting a notification from you when you have read this message."), sprintf(_("Click %s to send the notification message."), Horde::link($selfURL->copy()->add('mdn_confirm', 1)) . _("HERE") . '</a>')))) : '';
     /* Build body text. This needs to be done before we build the
      * attachment list that lives in the header. */
     $inlineout = $imp_contents->getInlineOutput(array('mask' => $contents_mask, 'part_info_display' => $part_info_display, 'show_parts' => $show_parts));
     /* Build the Attachments menu. */
     $show_atc = false;
     switch ($show_parts) {
         case 'atc':
             $a_view->show_parts_all = Horde::widget(array('url' => $headersURL->copy()->add(array('show_parts' => 'all')), 'title' => _("Show All Parts"), 'nocheck' => true));
             $show_atc = true;
             break;
         case 'all':
             if ($prefs->getValue('strip_attachments')) {
                 $js_vars['ImpMessage.text']['stripwarn'] = _("Are you sure you wish to PERMANENTLY delete this attachment?");
             }
             break;
     }
     if (count($inlineout['atc_parts']) > 2) {
         $a_view->download_all = Horde::widget(array('url' => $imp_contents->urlView($imp_contents->getMIMEMessage(), 'download_all'), 'title' => _("Download All Attachments (in .zip file)"), 'nocheck' => true));
         if ($prefs->getValue('strip_attachments')) {
             $a_view->strip_all = Horde::widget(array('url' => Horde::selfUrlParams()->add(array('actionID' => 'strip_all', 'token' => $token)), 'class' => 'stripAllAtc', 'title' => _("Strip All Attachments"), 'nocheck' => true));
             $js_vars['ImpMessage.text']['stripallwarn'] = _("Are you sure you want to PERMANENTLY delete all attachments?");
         }
         $show_atc = true;
     }
     if ($show_atc) {
         $a_view->atc = Horde::widget(array('url' => '#', 'class' => 'horde-hasmenu', 'title' => _("Attachments"), 'nocheck' => true));
     }
     /* Show attachment information in headers? 'atc_parts' will be empty if
      * 'parts_display' pref is 'none'. */
     if (!empty($inlineout['atc_parts'])) {
         if ($show_parts == 'all') {
             $val = $imp_contents->getTree()->getTree(true);
         } else {
             $tmp = array();
             foreach ($inlineout['atc_parts'] as $id) {
                 $summary = $imp_contents->getSummary($id, $contents_mask);
                 $tmp[] = '<tr>';
                 foreach ($part_info as $val) {
                     $tmp[] = '<td>' . $summary[$val] . '</td>';
                 }
                 $tmp[] = '<td>';
                 foreach ($part_info_action as $val) {
                     $tmp[] = $summary[$val];
                 }
                 $tmp[] = '</td></tr>';
             }
             $val = '<table>' . implode('', $tmp) . '</table>';
         }
         $hdrs[] = array('class' => 'msgheaderParts', 'name' => $show_parts == 'all' ? _("Parts") : _("Attachments"), 'val' => $val);
     }
     $m_view = clone $view;
     $m_view->label = $shortsub;
     $m_view->headers = $hdrs;
     $m_view->msgtext = $mdntext . $inlineout['msgtext'];
     $subinfo = new IMP_View_Subinfo(array('mailbox' => $mailbox));
     $subinfo->label = $header_label;
     $subinfo->value = sprintf(_("(%d of %d)"), $msgindex, count($imp_mailbox)) . $status;
     $injector->getInstance('Horde_View_Topbar')->subinfo = $subinfo->render();
     /* Output message page now. */
     $page_output->addInlineJsVars($js_vars, array('top' => true));
     $page_output->addScriptFile('scriptaculous/effects.js', 'horde');
     $page_output->addScriptFile('hordecore.js', 'horde');
     $page_output->addScriptFile('message.js');
     $page_output->addScriptFile('stripe.js', 'horde');
     $page_output->addScriptPackage('IMP_Script_Package_Imp');
     if (!empty($conf['tasklist']['use_notepad']) || !empty($conf['tasklist']['use_tasklist'])) {
         $page_output->addScriptPackage('Horde_Core_Script_Package_Dialog');
     }
     $page_output->noDnsPrefetch();
     Horde::startBuffer();
     foreach ($injector->getInstance('IMP_Maillog')->getLog(new IMP_Maillog_Message($this->indices, array('mdn'))) as $val) {
         $notification->push($val->message, 'imp.' . $val->action);
     }
     $this->output = Horde::endBuffer();
     $this->output .= $t_view->render('navbar_top') . $n_view->render('navbar_navigate') . $a_view->render('navbar_actions') . $m_view->render('message') . $a_view->render('navbar_actions');
     $n_view->id = 2;
     $n_view->isbottom = true;
     $this->output .= $n_view->render('navbar_navigate');
 }
Esempio n. 5
0
 /**
  * @param object $renderer  A Kronolith view.
  */
 public static function tabs($renderer)
 {
     global $injector, $prefs;
     $view = $injector->createInstance('Horde_View');
     $date = self::currentDate();
     $date_stamp = array('date' => $date->dateString());
     $tabname = basename($_SERVER['PHP_SELF']) == 'index.php' ? $GLOBALS['prefs']->getValue('defaultview') : str_replace('.php', '', basename($_SERVER['PHP_SELF']));
     $view->active = $tabname;
     $view->previous = $renderer->link(-1);
     $view->next = $renderer->link(1);
     switch ($tabname) {
         case 'day':
             $view->current = $renderer->getTime($prefs->getValue('date_format'));
             break;
         case 'workweek':
         case 'week':
             $view->current = $renderer->days[$renderer->startDay]->getTime($prefs->getValue('date_format')) . ' - ' . $renderer->days[$renderer->endDay]->getTime($prefs->getValue('date_format'));
             break;
         case 'month':
             $view->current = $renderer->date->strftime('%B %Y');
             break;
         case 'year':
             $view->current = $renderer->year;
             break;
     }
     $view->today = Horde::url($prefs->getValue('defaultview') . '.php')->link(Horde::getAccessKeyAndTitle(_("_Today"), false, true)) . _("Today") . '</a>';
     $view->day = Horde::widget(array('url' => Horde::url('day.php')->add($date_stamp), 'id' => 'kronolithNavDay', 'accesskey' => '1', 'title' => _("Day")));
     $view->workWeek = Horde::widget(array('url' => Horde::url('workweek.php')->add($date_stamp), 'id' => 'kronolithNavWorkweek', 'accesskey' => '2', 'title' => _("Work Week")));
     $view->week = Horde::widget(array('url' => Horde::url('week.php')->add($date_stamp), 'id' => 'kronolithNavWeek', 'accesskey' => '3', 'title' => _("Week")));
     $view->month = Horde::widget(array('url' => Horde::url('month.php')->add($date_stamp), 'id' => 'kronolithNavMonth', 'accesskey' => '4', 'title' => _("Month")));
     $view->year = Horde::widget(array('url' => Horde::url('year.php')->add($date_stamp), 'id' => 'kronolithNavYear', 'accesskey' => '5', 'title' => _("Year")));
     echo $view->render('buttonbar');
 }
Esempio n. 6
0
 /**
  * Generate a popup success window.
  */
 protected function _popupSuccess()
 {
     global $page_output;
     $page_output->topbar = $page_output->sidebar = false;
     $page_output->addInlineScript(array('$("close_success").observe("click", function() { window.close(); })'), true);
     $this->title = _("Message Successfully Sent");
     $view = new Horde_View(array('templatePath' => IMP_TEMPLATES . '/basic/compose'));
     $view->close = Horde::widget(array('id' => 'close_success', 'url' => new Horde_Url('#'), 'title' => _("Close this window")));
     $view->new = Horde::widget(array('url' => self::url(), 'title' => _("New Message")));
     $this->output = $view->render('success');
 }
Esempio n. 7
0
File: List.php Progetto: horde/horde
 /**
  * Renders the view.
  *
  * @param Horde_PageOutput $output  The output object.
  *
  * @return string  The HTML needed to render the view.
  */
 public function render(Horde_PageOutput $output)
 {
     global $prefs, $injector, $registry, $mnemo_shares;
     $output->addScriptFile('tables.js', 'horde');
     $output->addScriptFile('quickfinder.js', 'horde');
     $output->addScriptFile('list.js');
     $output->header(array('title' => $this->_title));
     $view = $injector->createInstance('Horde_View');
     $view->count = count($this->_notes);
     $view->searchImg = Horde::img('search.png', _("Search"), '');
     $view->searchUrl = Horde::url('search.php');
     $view->title = $this->_title;
     $view->browser = $this->_showTagBrowser ? $this->_getRelatedTags() . $this->_getTagTrail() : '';
     if (count($this->_notes)) {
         $sortby = $prefs->getValue('sortby');
         $sortdir = $prefs->getValue('sortdir');
         $output->addInlineJsVars(array('Mnemo_List.ajaxUrl' => $registry->getServiceLink('ajax', 'mnemo')->url . 'setPrefValue'));
         $view->editImg = Horde::img('edit.png', _("Edit Note"), '');
         $view->showNotepad = $prefs->getValue('show_notepad');
         $view->sortdirclass = $sortdir ? 'sortup' : 'sortdown';
         $view->headers = array();
         if ($view->showNotepad) {
             $view->headers[] = array('id' => 's' . Mnemo::SORT_NOTEPAD, 'sorted' => $sortby == Mnemo::SORT_NOTEPAD, 'width' => '2%', 'label' => Horde::widget(array('url' => $this->_baseurl->add('sortby', Mnemo::SORT_NOTEPAD), 'class' => 'sortlink', 'title' => _("Notepad"))));
         }
         $view->headers[] = array('id' => 's' . MNEMO::SORT_DESC, 'sorted' => $sortby == MNEMO::SORT_DESC, 'width' => '80%', 'label' => Horde::widget(array('url' => $this->_baseurl->add('sortby', Mnemo::SORT_DESC), 'class' => 'sortlink', 'title' => _("No_te"))));
         $view->headers[] = array('id' => 's' . MNEMO::SORT_MOD_DATE, 'sorted' => $sortby == Mnemo::SORT_MOD_DATE, 'width' => '2%', 'label' => Horde::widget(array('url' => $this->_baseurl->add('sortby', MNEMO::SORT_MOD_DATE), 'class' => 'sortlink', 'title' => _("Date"))));
         foreach ($this->_notes as $memo_id => &$memo) {
             try {
                 $share = $mnemo_shares->getShare($memo['memolist_id']);
             } catch (Horde_Share_Exception $e) {
                 $notification->push($e);
                 continue;
             }
             if ($view->showNotepad) {
                 $memo['notepad'] = Mnemo::getLabel($share);
             }
             if ($share->hasPermission($registry->getAuth(), Horde_Perms::EDIT)) {
                 $label = sprintf(_("Edit \"%s\""), $memo['desc']);
                 $memo['edit'] = Horde::url('memo.php')->add(array('memo' => $memo['memo_id'], 'memolist' => $memo['memolist_id'], 'actionID' => 'modify_memo'))->link(array('title' => $label)) . Horde::img('edit.png', $label, '') . '</a>';
             }
             $memo['link'] = Horde::linkTooltip(Horde::url('view.php')->add(array('memo' => $memo['memo_id'], 'memolist' => $memo['memolist_id'])), '', '', '', '', $memo['body'] != $memo['desc'] ? Mnemo::getNotePreview($memo) : '') . (strlen($memo['desc']) ? htmlspecialchars($memo['desc']) : '<em>' . _("Empty Note") . '</em>') . '</a>';
             // Get memo's most recent modification date or, if nonexistent,
             // the creation (add) date
             if (isset($memo['modified'])) {
                 $modified = $memo['modified'];
             } elseif (isset($memo['created'])) {
                 $modified = $memo['created'];
             } else {
                 $modified = null;
             }
             if ($modified) {
                 $memo['modifiedStamp'] = $modified->timestamp();
                 $memo['modifiedString'] = $modified->strftime($prefs->getValue('date_format'));
             } else {
                 $memo['modifiedStamp'] = $memo['modifiedString'] = '';
             }
         }
     }
     Horde::startBuffer();
     echo $view->render('list/header');
     if (count($this->_notes)) {
         echo $view->render('list/memo_headers');
         echo $view->renderPartial('list/summary', array('collection' => array_values($this->_notes)));
         echo $view->render('list/memo_footers');
     } else {
         echo $view->render('list/empty');
     }
     $output->footer();
     return Horde::endBuffer();
 }
Esempio n. 8
0
<div class="horde-buttonbar">
 <ul>
<?php 
if (class_exists('Horde_Pdf_Writer')) {
    ?>
  <li class="horde-icon"><?php 
    echo Horde::widget(array('url' => $this->pdfurl, 'title' => _("Save as PDF"), 'class' => 'mnemo-pdf'));
    ?>
</li>
<?php 
}
if ($this->edit) {
    ?>
  <li class="horde-icon"><?php 
    echo $this->edit;
    ?>
</li>
<?php 
}
if ($this->delete) {
    ?>
  <li class="horde-icon"><?php 
    echo $this->delete;
    ?>
</li>
<?php 
}
?>
 </ul>
</div>
Esempio n. 9
0
 /**
  */
 protected function _init()
 {
     global $injector, $notification, $page_output, $prefs, $registry, $session;
     /* Redirect back to the mailbox if folder use is not allowed. */
     $imp_imap = $injector->getInstance('IMP_Factory_Imap')->create();
     if (!$imp_imap->access(IMP_Imap::ACCESS_FOLDERS)) {
         $notification->push(_("The folder view is not enabled."), 'horde.error');
         Horde::url('mailbox', true)->redirect();
     }
     /* Decide whether or not to show all the unsubscribed mailboxes. */
     $subscribe = $prefs->getValue('subscribe');
     $showAll = !$subscribe || $session->get('imp', 'showunsub');
     $page_output->addScriptFile('hordecore.js', 'horde');
     $page_output->addScriptFile('folders.js');
     /* Get the base URL for this page. */
     $folders_url = self::url()->setRaw(true);
     /* These JS defines are required by all sub-pages. */
     $page_output->addInlineJsVars(array('ImpFolders.folders_url' => strval($folders_url), 'ImpFolders.text' => array('download1' => _("All messages in the following mailbox(es) will be downloaded into one MBOX file:"), 'download2' => _("This may take some time. Are you sure you want to continue?"), 'oneselect' => _("Only one mailbox should be selected for this action."), 'rename1' => _("You are renaming the mailbox:"), 'rename2' => _("Please enter the new name:"), 'select' => _("Please select a mailbox before you perform this action."), 'subfolder1' => _("You are creating a subfolder to"), 'subfolder2' => _("Please enter the name of the new mailbox:"), 'toplevel' => _("You are creating a top-level mailbox.") . "\n" . _("Please enter the name of the new mailbox:"))));
     /* Initialize the IMP_Ftree object. */
     $ftree = $injector->getInstance('IMP_Ftree');
     /* $mbox_list entries are urlencoded. */
     $mbox_list = isset($this->vars->mbox_list) ? IMP_Mailbox::formFrom($this->vars->mbox_list) : array();
     /* META refresh time (might be altered by actionID). */
     $refresh_time = $prefs->getValue('refresh_time');
     /* Set up the master View object. */
     $view = new Horde_View(array('templatePath' => IMP_TEMPLATES . '/basic/folders'));
     $view->addHelper('FormTag');
     $view->addHelper('Tag');
     $token = $session->getToken();
     $view->token = $token;
     /* Run through the action handlers. */
     if ($this->vars->actionID) {
         try {
             $session->checkToken($this->vars->token);
         } catch (Horde_Exception $e) {
             $notification->push($e);
             $this->vars->actionID = null;
         }
     }
     switch ($this->vars->actionID) {
         case 'expand_all_folders':
             $ftree->expandAll();
             break;
         case 'collapse_all_folders':
             $ftree->collapseAll();
             break;
         case 'rebuild_tree':
             $ftree->init();
             break;
         case 'expunge_mbox':
             if (!empty($mbox_list)) {
                 $injector->getInstance('IMP_Message')->expungeMailbox(array_fill_keys($mbox_list, null));
             }
             break;
         case 'delete_mbox':
             foreach ($mbox_list as $val) {
                 $val->delete();
             }
             break;
         case 'download_mbox':
         case 'download_mbox_zip':
             IMP_Contents_View::downloadUrl('mbox', array('actionID' => 'download_mbox', 'mbox_list' => $this->vars->mbox_list, 'type' => $this->vars->actionID == 'download_mbox' ? 'mbox' : 'mboxzip'))->redirect();
             exit;
         case 'import_mbox':
             if ($this->vars->import_mbox) {
                 try {
                     $notification->push($injector->getInstance('IMP_Mbox_Import')->import($this->vars->import_mbox, 'mbox_upload'), 'horde.success');
                 } catch (Horde_Exception $e) {
                     $notification->push($e);
                 }
                 $this->vars->actionID = null;
             } else {
                 $refresh_time = null;
             }
             break;
         case 'create_mbox':
             if (isset($this->vars->new_mailbox)) {
                 try {
                     $parent = empty($mbox_list) ? IMP_Mailbox::get(IMP_Ftree::BASE_ELT) : $mbox_list[0];
                     $new_mbox = $parent->createMailboxName($this->vars->new_mailbox);
                     if ($new_mbox->exists) {
                         $notification->push(sprintf(_("Mailbox \"%s\" already exists."), $new_mbox->display), 'horde.warning');
                     } else {
                         $new_mbox->create();
                     }
                 } catch (Horde_Exception $e) {
                     $notification->push($e);
                 }
             }
             break;
         case 'rename_mbox':
             // $old_names may be URL encoded.
             $old_names = array_map('trim', explode("\n", $this->vars->old_names));
             $new_names = array_map('trim', explode("\n", $this->vars->new_names));
             $iMax = count($new_names);
             if (!empty($new_names) && !empty($old_names) && $iMax == count($old_names)) {
                 for ($i = 0; $i < $iMax; ++$i) {
                     $old_name = IMP_Mailbox::formFrom($old_names[$i]);
                     $old_ns = $old_name->namespace_info;
                     $new = trim($new_names[$i], $old_ns->delimiter);
                     /* If this is a personal namespace, then anything goes as
                      * far as the input. Just append the personal namespace to
                      * it. */
                     if ($old_ns->type === $old_ns::NS_PERSONAL || strlen($old_ns->name) && stripos($new_names[$i], $old_ns->name) !== 0) {
                         $new = $old_ns->name . $new;
                     }
                     $old_name->rename($new);
                 }
             }
             break;
         case 'subscribe_mbox':
         case 'unsubscribe_mbox':
             if (empty($mbox_list)) {
                 $notification->push(_("No mailboxes were specified"), 'horde.message');
             } else {
                 foreach ($mbox_list as $val) {
                     $val->subscribe($this->vars->actionID == 'subscribe_mbox');
                 }
             }
             break;
         case 'toggle_subscribed_view':
             if ($subscribe) {
                 $showAll = !$showAll;
                 $session->set('imp', 'showunsub', $showAll);
             }
             break;
         case 'poll_mbox':
             if (!empty($mbox_list)) {
                 $ftree->poll->addPollList($mbox_list);
             }
             break;
         case 'nopoll_mbox':
             if (!empty($mbox_list)) {
                 $ftree->poll->removePollList($mbox_list);
             }
             break;
         case 'empty_mbox':
             if (!empty($mbox_list)) {
                 $injector->getInstance('IMP_Message')->emptyMailbox($mbox_list);
             }
             break;
         case 'mark_mbox_seen':
         case 'mark_mbox_unseen':
             if (!empty($mbox_list)) {
                 $injector->getInstance('IMP_Message')->flagAllInMailbox(array('\\seen'), $mbox_list, $this->vars->actionID == 'mark_mbox_seen');
             }
             break;
         case 'delete_mbox_confirm':
         case 'empty_mbox_confirm':
             if (!empty($mbox_list)) {
                 $loop = array();
                 foreach ($mbox_list as $val) {
                     switch ($this->vars->actionID) {
                         case 'delete_mbox_confirm':
                             if (!$val->access_deletembox) {
                                 $notification->push(sprintf(_("The mailbox \"%s\" may not be deleted."), $val->display), 'horde.error');
                                 continue 2;
                             }
                             break;
                         case 'empty_mbox_confirm':
                             if (!$val->access_empty) {
                                 $notification->push(sprintf(_("The mailbox \"%s\" may not be emptied."), $val->display), 'horde.error');
                                 continue 2;
                             }
                             break;
                     }
                     try {
                         $elt_info = $imp_imap->status($val, Horde_Imap_Client::STATUS_MESSAGES);
                     } catch (IMP_Imap_Exception $e) {
                         $elt_info = null;
                     }
                     $data = array('name' => $val->display, 'msgs' => $elt_info ? $elt_info['messages'] : 0, 'val' => $val->form_to);
                     $loop[] = $data;
                 }
                 if (!count($loop)) {
                     break;
                 }
                 $page_output->addScriptFile('stripe.js', 'horde');
                 $this->title = _("Folder Actions - Confirmation");
                 $v = clone $view;
                 if ($this->vars->actionID == 'delete_mbox_confirm') {
                     $v->actionID = 'delete_mbox';
                     $v->delete = true;
                 } elseif ($this->vars->actionID == 'empty_mbox_confirm') {
                     $v->actionID = 'empty_mbox';
                     $v->empty = true;
                 }
                 $v->mboxes = $loop;
                 $v->folders_url = $folders_url;
                 $this->output = $v->render('folders_confirm');
                 return;
             }
             break;
         case 'mbox_size':
             if (!empty($mbox_list)) {
                 $loop = array();
                 $sum = 0;
                 foreach ($mbox_list as $val) {
                     $size = $val->size;
                     $data = array('name' => $val->display, 'size' => sprintf(_("%.2fMB"), $size / (1024 * 1024)), 'sort' => $size);
                     $sum += $size;
                     $loop[] = $data;
                 }
                 /* Prepare the topbar. */
                 $injector->getInstance('Horde_View_Topbar')->subinfo = $injector->getInstance('IMP_View_Subinfo')->render();
                 $v = clone $view;
                 $v->folders_url = $folders_url;
                 $v->mboxes = $loop;
                 $v->mboxes_sum = sprintf(_("%.2fMB"), $sum / (1024 * 1024));
                 $page_output->addScriptFile('stripe.js', 'horde');
                 $page_output->addScriptFile('tables.js', 'horde');
                 $this->title = _("Mailbox Sizes");
                 $this->output = $v->render('folders_size');
                 return;
             }
             break;
         case 'search':
             if (!empty($mbox_list)) {
                 IMP_Basic_Search::url()->add(array('mailbox_list' => IMP_Mailbox::formTo($mbox_list), 'subfolder' => 1))->redirect();
             }
             break;
     }
     $this->title = _("Folder Navigator");
     $folders_url->add('token', $token);
     /* Prepare the topbar. */
     $injector->getInstance('Horde_View_Topbar')->subinfo = $injector->getInstance('IMP_View_Subinfo')->render();
     if ($session->get('imp', 'file_upload') && $this->vars->actionID == 'import_mbox') {
         /* Prepare import template. */
         $v = clone $view;
         $v->folders_url = $folders_url;
         $v->import_mbox = $mbox_list[0];
         $this->output = $v->render('import');
         return;
     }
     /* Prepare the header template. */
     $head_view = clone $view;
     $head_view->folders_url = $folders_url;
     /* Prepare the actions template. */
     $actions = clone $view;
     $actions->addHelper('Horde_Core_View_Helper_Accesskey');
     $actions->addHelper('Horde_Core_View_Helper_Help');
     $actions->id = 0;
     $actions->refresh = Horde::widget(array('title' => _("_Refresh"), 'url' => $folders_url->copy()));
     $actions->create_mbox = $imp_imap->access(IMP_Imap::ACCESS_CREATEMBOX) && $imp_imap->access(IMP_Imap::ACCESS_CREATEMBOX_MAX);
     if ($prefs->getValue('subscribe')) {
         $actions->subscribe = true;
         $subToggleText = $showAll ? _("Hide Unsubscribed") : _("Show All");
         $actions->toggle_subscribe = Horde::widget(array('url' => $folders_url->copy()->add(array('actionID' => 'toggle_subscribed_view', 'token' => $token)), 'title' => $subToggleText, 'nocheck' => true));
     }
     $actions->nav_poll = !$prefs->isLocked('nav_poll') && !$prefs->getValue('nav_poll_all');
     $actions->notrash = !$prefs->getValue('use_trash');
     $actions->file_upload = $session->get('imp', 'file_upload');
     $actions->expand_all = Horde::widget(array('url' => $folders_url->copy()->add(array('actionID' => 'expand_all_folders', 'token' => $token)), 'title' => _("Expand All"), 'nocheck' => true));
     $actions->collapse_all = Horde::widget(array('url' => $folders_url->copy()->add(array('actionID' => 'collapse_all_folders', 'token' => $token)), 'title' => _("Collapse All"), 'nocheck' => true));
     /* Build the folder tree. */
     $iterator = new IMP_Ftree_IteratorFilter($ftree);
     $iterator->add(array($iterator::REMOTE, $iterator::VFOLDER));
     if ($showAll) {
         $ftree->loadUnsubscribed();
         $iterator->remove($iterator::UNSUB);
     }
     $tree = $ftree->createTree('imp_folders', array('checkbox' => true, 'editvfolder' => true, 'iterator' => $iterator, 'poll_info' => true));
     $displayNames = $fullNames = array();
     foreach ($ftree as $val) {
         $mbox_ob = $val->mbox_ob;
         $tmp = $displayNames[] = $mbox_ob->display;
         $tmp2 = $mbox_ob->display_notranslate;
         if ($tmp != $tmp2) {
             $fullNames[strval($val)] = $tmp2;
         }
     }
     $page_output->addInlineJsVars(array('ImpFolders.ajax' => $registry->getServiceLink('ajax', 'imp')->url, 'ImpFolders.displayNames' => $displayNames, 'ImpFolders.fullNames' => $fullNames, '-ImpFolders.mbox_expand' => intval($prefs->getValue('nav_expanded') == 2)));
     $page_output->metaRefresh($refresh_time, $this->url());
     Horde::startBuffer();
     $tree->renderTree();
     $this->output = $head_view->render('head') . $actions->render('actions') . Horde::endBuffer();
     if (count($tree) > 10) {
         $actions->id = 1;
         $this->output .= $actions->render('actions');
     }
     /* No need for extra template - close out the tags here. */
     $this->output .= '</form>';
 }
Esempio n. 10
0
File: Ui.php Progetto: horde/horde
 /**
  * Generate the UI for the preferences interface, either for a
  * specific group, or the group selection interface.
  *
  * @throws Horde_Exception
  */
 public function generateUI()
 {
     global $notification, $page_output, $prefs, $registry;
     $columns = $pref_list = array();
     $identities = false;
     $prefgroups = $this->_getPrefGroups();
     if ($this->group) {
         $pref_list = $this->getChangeablePrefs($this->group);
         if (empty($pref_list)) {
             $this->group = '';
             $this->generateUI();
             return;
         }
         /* Add necessary init stuff for identities pages. */
         if (isset($prefgroups[$this->group]['type']) && $prefgroups[$this->group]['type'] == 'identities') {
             $page_output->addScriptFile('identityselect.js', 'horde');
             $identities = true;
             /* If this is an identities group, need to grab the base
              * identity fields from Horde, if current app is NOT Horde. */
             $pref_list = $this->_addHordeIdentitiesPrefs($pref_list);
         }
     } else {
         foreach ($prefgroups as $key => $val) {
             $columns[$val['column']][$key] = $val;
         }
     }
     if (empty($columns) && empty($pref_list)) {
         $notification->push(Horde_Core_Translation::t("There are no preferences available for this application."), 'horde.message');
         $this->nobuttons = true;
     }
     $options_link = $registry->getServiceLink('prefs');
     $h_templates = $registry->get('templates', 'horde');
     $base = $GLOBALS['injector']->createInstance('Horde_Template');
     $base->setOption('gettext', true);
     /* Need to buffer output - it is possible that 'special' types can
      * do things like add javascript to the page output. This should all
      * be combined and served in the page HEAD. */
     Horde::startBuffer();
     $page_output->addScriptFile('prefs.js', 'horde');
     if ($this->group) {
         if ($identities) {
             echo $this->_identityHeader($pref_list);
         }
         foreach ($pref_list as $pref) {
             if (isset($this->prefs[$pref]['on_init']) && is_callable($this->prefs[$pref]['on_init'])) {
                 $this->prefs[$pref]['on_init']($this);
             }
             if ($this->prefs[$pref]['type'] == 'special' && isset($this->prefs[$pref]['handler']) && ($ob = $GLOBALS['injector']->getInstance($this->prefs[$pref]['handler']))) {
                 $ob->init($this);
                 echo $ob->display($this);
                 continue;
             }
             $t = clone $base;
             if (isset($this->_errors[$pref])) {
                 echo $t->fetch(HORDE_TEMPLATES . '/prefs/error_start.html');
             }
             if (isset($this->prefs[$pref]['desc'])) {
                 $t->set('desc', Horde::label($pref, $this->prefs[$pref]['desc']));
             }
             $t->set('helplink', empty($this->prefs[$pref]['help']) ? null : Horde_Help::link(empty($this->prefs[$pref]['shared']) ? $this->app : 'horde', $this->prefs[$pref]['help']));
             $t->set('pref', htmlspecialchars($pref));
             $type = $this->prefs[$pref]['type'];
             switch ($type) {
                 case 'checkbox':
                     $t->set('checked', $prefs->getValue($pref));
                     break;
                 case 'enum':
                     $enum = $this->prefs[$pref]['enum'];
                     $esc = !empty($this->prefs[$pref]['escaped']);
                     $curval = $prefs->getValue($pref);
                     $tmp = array();
                     foreach ($enum as $key => $val) {
                         $tmp[] = array('l' => $esc ? $val : htmlspecialchars($val), 's' => $curval == $key, 'v' => $esc ? $key : htmlspecialchars($key));
                     }
                     $t->set('enum', $tmp);
                     break;
                 case 'prefslink':
                     $url = $this->selfUrl()->add('group', $this->prefs[$pref]['group']);
                     if (!empty($this->prefs[$pref]['app'])) {
                         $url->add('app', $this->prefs[$pref]['app']);
                     }
                     $this->prefs[$pref]['url'] = $url;
                     $type = 'link';
                     // Fall through to 'link'
                 // Fall through to 'link'
                 case 'link':
                     if (isset($this->prefs[$pref]['img'])) {
                         $t->set('img', Horde_Themes_Image::tag($this->prefs[$pref]['img'], array('alt' => $this->prefs[$pref]['desc'], 'attr' => array('class' => 'prefsLinkImg'))));
                     }
                     $t->set('url', isset($this->prefs[$pref]['url']) ? Horde::url($this->prefs[$pref]['url']) : $this->prefs[$pref]['xurl']);
                     if (isset($this->prefs[$pref]['target'])) {
                         $t->set('target', htmlspecialchars($this->prefs[$pref]['target']));
                     }
                     break;
                 case 'multienum':
                     $enum = $this->prefs[$pref]['enum'];
                     $esc = !empty($this->prefs[$pref]['escaped']);
                     if (!($selected = @unserialize($prefs->getValue($pref)))) {
                         $selected = array();
                     }
                     $tmp = array();
                     foreach ($enum as $key => $val) {
                         $tmp[] = array('l' => $esc ? $val : htmlspecialchars($val), 's' => in_array($key, $selected), 'v' => $esc ? $key : htmlspecialchars($key));
                     }
                     $t->set('enum', $tmp);
                     $t->set('size', min(4, count($enum)));
                     break;
                 case 'number':
                     $t->set('val', htmlspecialchars(intval($prefs->getValue($pref))));
                     break;
                 case 'password':
                 case 'text':
                 case 'textarea':
                     $t->set('val', htmlspecialchars($prefs->getValue($pref)));
                     break;
                 case 'rawhtml':
                     $t->set('html', $this->prefs[$pref]['value']);
                     break;
                 default:
                     throw new LogicException(sprintf('Missing or invalid type option for the %s preference.', $pref));
             }
             echo $t->fetch(HORDE_TEMPLATES . '/prefs/' . $type . '.html');
             if (isset($this->_errors[$pref])) {
                 $t->set('error', htmlspecialchars($this->_errors[$pref]));
                 echo $t->fetch(HORDE_TEMPLATES . '/prefs/error_end.html');
             }
         }
         $t = clone $base;
         $t->set('buttons', !$this->nobuttons);
         $t->set('prefgroups', count($prefgroups) > 1);
         echo $t->fetch($h_templates . '/prefs/end.html');
     } elseif (!empty($columns)) {
         $t = clone $base;
         $span = round(100 / count($columns));
         $cols = array();
         foreach ($columns as $key => $column) {
             $tmp = array('groups' => array(), 'hdr' => htmlspecialchars($key), 'width' => $span - 1);
             foreach ($column as $group => $gvals) {
                 if ($this->groupIsEditable($group)) {
                     $tmp['groups'][] = array('desc' => htmlspecialchars($gvals['desc']), 'link' => Horde::widget(array('url' => $options_link->copy()->add(array('app' => $this->app, 'group' => $group)), 'title' => $gvals['label'])));
                 }
             }
             $cols[] = $tmp;
         }
         $t->set('columns', $cols);
         echo $t->fetch($h_templates . '/prefs/overview.html');
     }
     $content = Horde::endBuffer();
     /* Get the menu output before we start to output the page.
      * Again, this will catch any javascript inserted into the page. */
     $GLOBALS['page_output']->sidebar = false;
     /* Get list of accessible applications. */
     $apps = array();
     foreach ($registry->listApps() as $app) {
         // Make sure the app is installed and has a prefs file.
         if (file_exists($registry->get('fileroot', $app) . '/config/prefs.php')) {
             $apps[$app] = $registry->get('name', $app);
         }
     }
     asort($apps);
     /* Ouptut screen. */
     $page_output->header(array('body_id' => 'services_prefs', 'title' => Horde_Core_Translation::t("User Preferences"), 'view' => $registry::VIEW_BASIC));
     $notification->notify(array('listeners' => 'status'));
     $base_ui = clone $base;
     $base_ui->set('action', $options_link);
     $base_ui->set('forminput', Horde_Util::formInput());
     /* Show the current application and a form for switching
      * applications. */
     $t = clone $base_ui;
     $t->set('horde', !empty($apps['horde']) && $this->app != 'horde');
     unset($apps['horde'], $apps[$this->app]);
     $tmp = array();
     foreach ($apps as $key => $val) {
         $tmp[] = array('l' => htmlspecialchars($val), 'v' => htmlspecialchars($key));
     }
     $t->set('apps', $tmp);
     if ($this->app == 'horde') {
         $header = Horde_Core_Translation::t("Global Preferences");
     } else {
         $header = sprintf(Horde_Core_Translation::t("Preferences for %s"), Horde::url($registry->getInitialPage($this->app))->link() . htmlspecialchars($registry->get('name', $this->app)) . '</a>');
     }
     $t->set('header', $header);
     $t->set('has_advanced', $this->hasAdvancedPrefs());
     if ($GLOBALS['session']->get('horde', 'prefs_advanced')) {
         $t->set('basic', $this->selfUrl()->add('show_basic', 1));
     } else {
         $t->set('advanced', $this->selfUrl()->add('show_advanced', 1));
     }
     echo $t->fetch($h_templates . '/prefs/app.html');
     /* Generate navigation header. */
     if ($this->group) {
         $t = clone $base_ui;
         $t->set('app', htmlspecialchars($this->app));
         $t->set('group', htmlspecialchars($this->group));
         $t->set('label', htmlspecialchars($this->prefGroups[$this->group]['label']));
         $t->set('token', $GLOBALS['injector']->getInstance('Horde_Token')->get('horde.prefs'));
         // Search for previous and next groups.
         if (count($prefgroups) > 1) {
             $prefgroups = array_keys($prefgroups);
             $key = array_search($this->group, $prefgroups);
             $previous = isset($prefgroups[$key - 1]) ? $prefgroups[$key - 1] : end($prefgroups);
             $next = isset($prefgroups[$key + 1]) ? $prefgroups[$key + 1] : reset($prefgroups);
             $prefs_url = $this->selfUrl();
             if ($next != $previous) {
                 $t->set('prev', $prefs_url->copy()->add('group', $previous));
                 $t->set('prevlabel', htmlspecialchars($this->prefGroups[$previous]['label']));
                 $t->set('previcon', Horde_Themes_Image::tag('nav/left.png'));
             }
             $t->set('next', $prefs_url->copy()->add('group', $next));
             $t->set('nextlabel', htmlspecialchars($this->prefGroups[$next]['label']));
             $t->set('nexticon', Horde_Themes_Image::tag('nav/right.png'));
         }
         echo $t->fetch($h_templates . '/prefs/begin.html');
     }
     echo $content;
     $GLOBALS['page_output']->footer();
 }
Esempio n. 11
0
<h1 class="header"><?php 
echo $this->header;
?>
</h1>

<div class="horde-buttonbar">
  <ul>
    <li class="horde-icon"><?php 
echo Horde::widget(array('url' => Horde::url('delete.php'), 'title' => _("_Delete"), 'class' => 'skeleton-delete'));
?>
</li>
    <li><?php 
echo Horde::url('foo.php')->link() . _("Foo") . '</a>';
?>
</li>
  </ul>
</div>

<table class="horde-table sortable">
  <thead>
    <tr>
      <th width="10%"><?php 
echo _("Column 1");
?>
</th>
      <th class="horde-split-left"><?php 
echo _("Column 2");
?>
</t4>
    </tr>
  </thead>
Esempio n. 12
0
</li>
<?php 
        }
    }
    if ($this->perms_delete) {
        ?>
  <li><?php 
        echo Horde::widget(array('url' => '#', 'title' => _("Delete"), 'id' => 'gollem-delete'));
        ?>
</li>
<?php 
    }
    if ($this->perms_edit) {
        ?>
  <li><?php 
        echo Horde::widget(array('url' => '#', 'title' => _("Rename"), 'id' => 'gollem-rename'));
        ?>
</li>
<?php 
    }
}
?>
 </ul>
</div>

<?php 
if ($this->empty_dir) {
    ?>
<p class="text">
 <em><?php 
    echo _("There are no files in this folder.");
Esempio n. 13
0
$view = $injector->createInstance('Horde_View');
$view->assign($memo);
try {
    $view->body = Horde::callHook('format_description', array($body), 'mnemo', $body);
} catch (Horde_Exception_HookNotSet $e) {
    $view->body = $body;
}
$view->id = $memo_id;
$view->listid = $memolist_id;
$view->passphrase = $show_passphrase;
$view->pdfurl = Horde::url('note/pdf.php')->add(array('note' => $memo_id, 'notepad' => $memolist_id));
$view->tags = implode(', ', $memo['tags']);
if ($share->hasPermission($registry->getAuth(), Horde_Perms::DELETE)) {
    $view->delete = Horde::widget(array('url' => $url->add('actionID', 'delete_memos'), 'class' => 'mnemo-delete', 'id' => 'mnemo-delete', 'title' => _("_Delete")));
}
if ($share->hasPermission($registry->getAuth(), Horde_Perms::EDIT)) {
    $view->edit = Horde::widget(array('url' => $url->add('actionID', 'modify_memo'), 'class' => 'mnemo-edit', 'title' => _("_Edit")));
}
if (isset($memo['created'])) {
    $view->created = $memo['created']->strftime($prefs->getValue('date_format')) . ' ' . $memo['created']->format($prefs->getValue('twentyFour') ? 'G:i' : 'g:i a');
}
if (isset($memo['modified'])) {
    $view->modified = $memo['modified']->strftime($prefs->getValue('date_format')) . ' ' . $memo['modified']->format($prefs->getValue('twentyFour') ? 'G:i' : 'g:i a');
}
$page_output->addScriptFile('stripe.js', 'horde');
$page_output->addScriptFile('view.js');
$page_output->addInlineJsVars(array('Mnemo_View.confirm' => _("Really delete this note?")));
$page_output->header(array('title' => $memo ? $memo['desc'] : _("Note Details")));
$notification->notify();
echo $view->render('view/view');
$page_output->footer();
Esempio n. 14
0
 public function headerWidget($baseurl, $sortdir, $sortby, $by, $content)
 {
     return Horde::widget(array('url' => $baseurl->add(array('sortby' => $by, 'sortdir' => $sortby == $by ? 1 - $sortdir : $sortdir)), 'class' => 'sortlink', 'title' => $content)) . '&nbsp;';
 }
Esempio n. 15
0
 /**
  * Generate a javascript link to the download/view page.
  *
  * @param Horde_Mime_Part $mime_part  The MIME part to view.
  * @param string $actionID            The actionID to perform.
  * @param string $text                The ESCAPED (!) link text.
  * @param array $options              Additional options:
  *   - css: (string) The CSS class to use.
  *   - jstext: (string) The javascript link text.
  *   - onload: (string) A JS function to run when popup window is
  *             fully loaded.
  *   - params: (array) A list of any additional parameters that need to be
  *             passed to download/view page. (key = name)
  *   - widget: (boolean) If true use Horde::widget() to generate,
  *             Horde::link() otherwise.
  *
  * @return string  A HTML href link to the download/view page.
  */
 public function linkViewJS($mime_part, $actionID, $text, $options = array())
 {
     if (empty($options['params'])) {
         $options['params'] = array();
     }
     if (empty($options['jstext'])) {
         $options['jstext'] = ($description = $mime_part->getDescription(true)) ? sprintf(_("View %s"), $description) : null;
     }
     $url = Horde::popupJs(Horde::url('view.php'), array('menu' => true, 'onload' => empty($options['onload']) ? 'IMP_JS.resizePopup' : $options['onload'], 'params' => $this->_urlViewParams($mime_part, $actionID, isset($options['params']) ? $options['params'] : array()), 'urlencode' => true));
     return empty($options['widget']) ? Horde::link('#', $options['jstext'], empty($options['css']) ? null : $options['css'], null, $url) . $text . '</a>' : Horde::widget(array('url' => '#', 'class' => empty($options['css']) ? null : $options['css'], 'onclick' => $url, 'title' => $text));
 }
Esempio n. 16
0
    $share_name = $backkey . '|' . Gollem::$backend['dir'];
    $template->share_folder = Horde::widget(array('url' => $perms_url_base->add('share', $share_name), 'title' => _("Share Folder"), 'target' => '_blank', 'class' => 'gollem-sharefolder', 'onclick' => Horde::popupJs($perms_url_base, array('params' => array('share' => $share_name), 'urlencode' => true)) . 'return false;'));
}
if ($edit_perms) {
    $template->perms_edit = true;
    $template->upload_file = _("Upload File(s)");
    $template->upload_identifier = session_id();
    $template->upload_help = Horde_Help::link('gollem', 'file-upload');
    $template->perms_chmod = in_array('permission', $columns);
    $injector->getInstance('Horde_View_Sidebar')->addNewButton(_("Create Folder"), Horde::url('#'), array('id' => 'gollem-createfolder'));
} else {
    $template->perms_edit = false;
    $template->perms_chmod = false;
}
if ($read_perms) {
    $template->change_folder = Horde::widget(array('url' => Horde::url('#'), 'title' => _("Change Folder"), 'id' => 'gollem-changefolder'));
}
if ($numitem) {
    $template->list_count = true;
    $template->perms_delete = $delete_perms;
    $topbar = $injector->getInstance('Horde_View_Topbar');
    $topbar->search = true;
    $topbar->searchAction = $refresh_url;
    $topbar->searchLabel = $session->get('gollem', 'filter') ?: _("Filter");
    $topbar->searchIcon = Horde_Themes::img('filter-topbar.png');
} else {
    $template->list_count = false;
}
$icon_cache = array();
$total = 0;
if (is_array($list) && $numitem && $read_perms) {
Esempio n. 17
0
 /**
  */
 protected function _init()
 {
     global $injector, $notification, $page_output, $registry, $session;
     $imp_mailbox = $this->indices->mailbox->list_ob;
     switch ($mode = $this->vars->get('mode', 'thread')) {
         case 'thread':
             /* THREAD MODE: Make sure we have a valid index. */
             list($m, $u) = $this->indices->getSingle();
             $imp_indices = $imp_mailbox->getFullThread($u, $m);
             break;
         default:
             /* MSGVIEW MODE: Make sure we have a valid list of messages. */
             $imp_indices = $this->indices;
             break;
     }
     if (!count($imp_indices)) {
         $notification->push(_("Could not load message."), 'horde.error');
         $this->indices->mailbox->url('mailbox')->redirect();
     }
     /* Run through action handlers. */
     switch ($this->vars->actionID) {
         case 'add_address':
             try {
                 $contact_link = $injector->getInstance('IMP_Contacts')->addAddress($this->vars->address, $this->vars->name);
                 $notification->push(sprintf(_("Entry \"%s\" was successfully added to the address book"), $contact_link), 'horde.success', array('content.raw'));
             } catch (Horde_Exception $e) {
                 $notification->push($e);
             }
             break;
     }
     $msgs = $tree = array();
     $subject = '';
     $page_label = $this->indices->mailbox->label;
     $imp_ui = $injector->getInstance('IMP_Message_Ui');
     $query = new Horde_Imap_Client_Fetch_Query();
     $query->envelope();
     /* Force images to show in HTML data. */
     $injector->getInstance('IMP_Images')->alwaysShow = true;
     $multiple = count($imp_indices) > 1;
     foreach ($imp_indices as $ob) {
         $imp_imap = $ob->mbox->imp_imap;
         $fetch_res = $imp_imap->fetch($ob->mbox, $query, array('ids' => $imp_imap->getIdsOb($ob->uids)));
         foreach ($ob->uids as $idx) {
             $envelope = $fetch_res[$idx]->getEnvelope();
             /* Get the body of the message. */
             $curr_msg = $curr_tree = array();
             $contents = $injector->getInstance('IMP_Factory_Contents')->create($ob->mbox->getIndicesOb($idx));
             $mime_id = $contents->findBody();
             if ($contents->canDisplay($mime_id, IMP_Contents::RENDER_INLINE)) {
                 $ret = $contents->renderMIMEPart($mime_id, IMP_Contents::RENDER_INLINE);
                 $ret = reset($ret);
                 $curr_msg['body'] = $ret['data'];
                 if (!empty($ret['js'])) {
                     $page_output->addInlineScript($ret['js'], true);
                 }
             } else {
                 $curr_msg['body'] = '<em>' . _("There is no text that can be displayed inline.") . '</em>';
             }
             $curr_msg['idx'] = $idx;
             /* Get headers for the message. */
             $date_ob = new IMP_Message_Date($envelope->date);
             $curr_msg['date'] = $date_ob->format($date_ob::DATE_LOCAL);
             if ($this->indices->mailbox->special_outgoing) {
                 $curr_msg['addr_to'] = true;
                 $curr_msg['addr'] = _("To:") . ' ' . $imp_ui->buildAddressLinks($envelope->to, Horde::selfUrlParams());
                 $addr = _("To:") . ' ' . htmlspecialchars($envelope->to[0]->label, ENT_COMPAT, 'UTF-8');
             } else {
                 $from = $envelope->from;
                 $curr_msg['addr_to'] = false;
                 $curr_msg['addr'] = $imp_ui->buildAddressLinks($from, Horde::selfUrlParams());
                 $addr = htmlspecialchars($from[0]->label, ENT_COMPAT, 'UTF-8');
             }
             $subject_header = htmlspecialchars($envelope->subject, ENT_COMPAT, 'UTF-8');
             switch ($mode) {
                 case 'thread':
                     if (empty($subject)) {
                         $subject = preg_replace('/^re:\\s*/i', '', $subject_header);
                     }
                     $curr_msg['link'] = $multiple ? Horde::widget(array('url' => '#display', 'title' => _("Thread List"), 'nocheck' => true)) : '';
                     $curr_tree['subject'] = $imp_mailbox->getThreadOb($imp_mailbox->getArrayIndex($fetch_res[$idx]->getUid(), $ob->mbox) + 1)->img;
                     break;
                 default:
                     $curr_msg['link'] = Horde::widget(array('url' => '#display', 'title' => _("Back to Multiple Message View Index"), 'nocheck' => true));
                     $curr_tree['subject'] = '';
                     break;
             }
             switch ($registry->getView()) {
                 case $registry::VIEW_BASIC:
                     $curr_msg['link'] .= ' | ' . Horde::widget(array('url' => $this->indices->mailbox->url('message', $idx), 'title' => _("Go to Message"), 'nocheck' => true)) . ' | ' . Horde::widget(array('url' => $this->indices->mailbox->url('mailbox')->add(array('start' => $imp_mailbox->getArrayIndex($idx))), 'title' => sprintf(_("Bac_k to %s"), $page_label)));
                     break;
             }
             $curr_tree['subject'] .= Horde::link('#i' . $idx) . Horde_String::truncate($subject_header, 60) . '</a> (' . $addr . ')';
             $msgs[] = $curr_msg;
             $tree[] = $curr_tree;
         }
     }
     /* Flag messages as seen. */
     $injector->getInstance('IMP_Message')->flag(array('add' => array(Horde_Imap_Client::FLAG_SEEN)), $imp_indices);
     $view = new Horde_View(array('templatePath' => IMP_TEMPLATES . '/thread'));
     if ($mode == 'thread') {
         $view->subject = $subject;
         $view->thread = true;
         switch ($registry->getView()) {
             case $registry::VIEW_BASIC:
                 $uid_list = $imp_indices[strval($this->indices->mailbox)];
                 $delete_link = $this->indices->mailbox->url('mailbox')->add(array('actionID' => 'delete_messages', 'indices' => strval($imp_indices), 'token' => $session->getToken(), 'start' => $imp_mailbox->getArrayIndex(end($uid_list))));
                 $view->delete = Horde::link($delete_link, _("Delete Thread"), null, null, null, null, null, array('id' => 'threaddelete'));
                 $page_output->addInlineScript(array('$("threaddelete").observe("click", function(e) { if (!window.confirm(' . json_encode(_("Are you sure you want to delete all messages in this thread?")) . ')) { e.stop(); } })'), true);
                 break;
         }
     } else {
         $view->subject = sprintf(_("%d Messages"), count($msgs));
     }
     $view->messages = $msgs;
     $view->tree = $tree;
     $page_output->addScriptFile('stripe.js', 'horde');
     $page_output->addScriptFile('toggle_quotes.js', 'horde');
     $page_output->noDnsPrefetch();
     $this->output = $view->render('thread');
     switch ($registry->getView()) {
         case $registry::VIEW_DYNAMIC:
             $page_output->topbar = $page_output->sidebar = false;
             $this->header_params = array('html_id' => 'htmlAllowScroll');
             break;
     }
     $this->title = $mode == 'thread' ? _("Thread View") : _("Multiple Message View");
 }
Esempio n. 18
0
    $headers['count_galleries'] = array('stext' => _("Sort by Albums"), 'text' => _("Albums"));
    $headers['count_video'] = array('stext' => _("Sort by Video"), 'text' => _("Video"));
    $sortImg = $criteria['sort_dir'] == 'DESC' ? 'za.png' : 'az.png';
    $sortText = _("Sort Direction");
    ?>
<table class="striped" style="width: 100%">
<thead>
<tr>
<?php 
    foreach ($headers as $key => $val) {
        echo '<th class="widget leftAlign nowrap">' . "\n";
        if ($criteria['sort_by'] == $key) {
            echo Horde::link($list_url->add('sort_dir', $criteria['sort_dir'] == 'DESC' ? 'ASC' : 'DESC'), $val['text'], null, null, null, $val['text']);
            echo Horde::img($sortImg, $sortText) . '</a>&nbsp;';
        }
        echo Horde::widget(array('url' => $list_url->add('sort_by', $key), 'title' => $val['text']));
        echo '</th>';
    }
    ?>
</tr>
</thead>
<?php 
    foreach ($users as $user) {
        ?>
<tr>
    <td style="text-align: center">
        <a href="<?php 
        echo Folks::getUrlFor('user', $user['user_uid']);
        ?>
">
        <img src="<?php