v5.0-git
--------
+[mms] Honor nav_expanded preference (DIMP).
[mms] Allow admin to define list of safe e-mail addresses that will not
experience HTML image blocking (Request #9129).
[mms] HTML compose editor uses Horde language for UI (Request #9084;
var DimpBase = {
// Vars used and defaulting to null/false:
- // cfolderaction, folder, folderswitch, pollPE, pp, preview_replace,
- // resize, rownum, search, splitbar, template, uid, viewport
+ // cfolderaction, expandfolder, folder, folderswitch, pollPE, pp,
+ // preview_replace, resize, rownum, search, splitbar, template, uid,
+ // viewport
// msglist_template_horiz and msglist_template_vert set via
// js/mailbox-dimp.js
cacheids: {},
_folderLoadCallback: function(r, callback)
{
+ if (r.response.expand) {
+ this.expandfolder = true;
+ }
+
this.mailboxCallback(r);
+ this.expandfolder = false;
+
if (callback) {
callback();
}
_toggleSubFolder: function(base, mode, noeffect)
{
- var need = [], subs = [];
+ var collapse = [], need = [], subs = [];
if (mode == 'expall' || mode == 'colall') {
if (base.hasClassName('subfolders')) {
((mode == 'col' || mode == 'colall') && s.visible())) {
s.previous().down().toggleClassName('exp').toggleClassName('col');
+ if (mode == 'col' ||
+ ((mode == 'tog') && s.visible())) {
+ collapse.push(s.previous().retrieve('mbox'));
+ }
+
if (noeffect) {
s.toggle();
} else {
}
}
});
+
+ if (DIMP.conf.mbox_expand) {
+ if (collapse.size()) {
+ DimpCore.doAction('collapseMailboxes', { mboxes: collapse.toJSON() });
+ } else if (mode == 'colall') {
+ DimpCore.doAction('collapseMailboxes', { all: 1 });
+ }
+ }
},
_listFolders: function(params)
// Folder actions.
// For format of the ob object, see IMP_Dimp::_createFolderElt().
+ // If this.expandfolder is set, expand folder list on initial display.
createFolder: function(ob)
{
var div, f_node, ftype, li, ll, parent_e, tmp,
f_node.insert({ before: li });
} else {
parent_e.insert(li);
+ if (this.expandfolder && !parent_e.hasClassName('folderlist')) {
+ parent_e.up('LI').show().previous().down().removeClassName('exp').addClassName('col');
+ }
}
// Make sure the sub<mbox> ul is created if necessary.
if (!ob.s && ob.ch) {
- li.insert({ after: new Element('LI', { className: 'subfolders', id: submboxid }).insert(new Element('UL')).hide() });
+ li.insert({ after: Element('LI', { className: 'subfolders', id: submboxid }).insert(new Element('UL')).hide() });
+ li.insert({ after: tmp });
}
}
* @return mixed False on failure, or an object with the following
* entries:
* <pre>
+ * 'expand' - (integer) Expand subfolders on load.
* 'mailbox' - (object) Mailboxes that were altered. Contains the
* following properties:
* 'a' - (array) Mailboxes that were added.
public function listMailboxes()
{
$imptree = $GLOBALS['injector']->getInstance('IMP_Imap_Tree');
+ $initreload = ($this->_vars->initial || $this->_vars->reload);
+ $result = new stdClass;
$mask = IMP_Imap_Tree::FLIST_CONTAINER | IMP_Imap_Tree::FLIST_VFOLDER | IMP_Imap_Tree::FLIST_ELT;
if ($this->_vars->unsub) {
}
if (!$this->_vars->all) {
- $mask |= IMP_Imap_Tree::FLIST_NOCHILDREN;
- if ($this->_vars->initial || $this->_vars->reload) {
+ if ($initreload) {
$mask |= IMP_Imap_Tree::FLIST_ANCESTORS | IMP_Imap_Tree::FLIST_SAMELEVEL;
+ if ($GLOBALS['prefs']->getValue('nav_expanded')) {
+ $result->expand = 1;
+ $mask |= IMP_Imap_Tree::FLIST_EXPANDED;
+ } else {
+ $mask |= IMP_Imap_Tree::FLIST_NOCHILDREN;
+ }
+ } else {
+ $mask |= IMP_Imap_Tree::FLIST_NOCHILDREN;
}
}
if (!empty($this->_vars->mboxes)) {
foreach (Horde_Serialize::unserialize($this->_vars->mboxes, Horde_Serialize::JSON) as $val) {
$folder_list += $imptree->folderList($mask, $val);
+
+ if (!$initreload) {
+ $imptree->expand($val);
+ }
}
- if (($this->_vars->initial || $this->_vars->reload) && empty($folder_list)) {
+ if ($initreload && empty($folder_list)) {
$folder_list = $imptree->folderList($mask, 'INBOX');
}
}
/* Add special folders explicitly to the initial folder list, since
* they are ALWAYS displayed and may appear outside of the folder
* slice requested. */
- if ($this->_vars->initial || $this->_vars->reload) {
+ if ($initreload) {
foreach ($imptree->getSpecialMailboxes() as $val) {
if (!is_array($val)) {
$val = array($val);
}
}
- $result = new stdClass;
$result->mailbox = $this->_getMailboxResponse($imptree, array(
'a' => array_values($folder_list),
'c' => array(),
}
/**
+ * AJAX action: Collapse mailboxes.
+ *
+ * Variables used:
+ * <pre>
+ * 'all' - (integer) 1 to show all mailboxes.
+ * 'mboxes' - (string) The list of mailboxes to process (JSON encoded
+ * array) if 'all' is 0.
+ * </pre>
+ *
+ * @return boolean True.
+ */
+ public function collapseMailboxes()
+ {
+ $imptree = $GLOBALS['injector']->getInstance('IMP_Imap_Tree');
+
+ if ($this->_vars->all) {
+ $imptree->collapseAll();
+ } elseif (!empty($this->_vars->mboxes)) {
+ foreach (Horde_Serialize::unserialize($this->_vars->mboxes, Horde_Serialize::JSON) as $val) {
+ $imptree->collapse($val);
+ }
+ }
+
+ return true;
+ }
+
+ /**
* AJAX action: Poll mailboxes.
*
* See the list of variables needed for _changed() and _viewPortData().
const FLIST_NOCHILDREN = 32;
const FLIST_ANCESTORS = 64;
const FLIST_SAMELEVEL = 128;
+ const FLIST_EXPANDED = 256;
/* Add null to folder key since it allows us to sort by name but
* never conflict with an IMAP mailbox. */
* IMP_Imap_Tree::FLIST_ANCESTORS - Include ancestors.
* IMP_Imap_Tree::FLIST_SAMELEVEL - Also return mailboxes at the same
* level as $base.
+ * IMP_Imap_Tree::FLIST_EXPANDED - Only included expanded folders.
+ * </pre>
* </pre>
* @param string $base Return all mailboxes below this element.
*
}
}
- $nextmask = self::NEXT_SHOWCLOSED;
+ $nextmask = ($mask & self::FLIST_EXPANDED)
+ ? 0
+ : self::NEXT_SHOWCLOSED;
if ($mask & self::FLIST_NOCHILDREN) {
$nextmask |= self::NEXT_NOCHILDREN;
}
'fsearchid' => IMP_Search::MBOX_PREFIX . IMP_Search::DIMP_FILTERSEARCH,
'ham_spammbox' => intval(!empty($GLOBALS['conf']['notspam']['spamfolder'])),
'login_view' => $GLOBALS['prefs']->getValue('dimp_login_view'),
+ 'mbox_expand' => intval($GLOBALS['prefs']->getValue('nav_expanded') == 2),
'name' => $GLOBALS['registry']->get('name', 'imp'),
'popup_height' => 610,
'popup_width' => 820,
'qsearchfield' => $GLOBALS['prefs']->getValue('dimp_qsearch_field'),
'refresh_time' => intval($GLOBALS['prefs']->getValue('refresh_time')),
'searchprefix' => IMP_Search::MBOX_PREFIX,
- 'sidebar_width' => max((int)$GLOBALS['prefs']->getValue('sidebar_width'), 150) . 'px',
+ 'sidebar_width' => max(intval($GLOBALS['prefs']->getValue('sidebar_width')), 150) . 'px',
'sort' => array(
'sequence' => array(
't' => '',