From: Michael M Slusarz Date: Fri, 5 Mar 2010 19:07:37 +0000 (-0700) Subject: DIMP now honors the 'allow_resume_all' configuration option X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=36b2aecb9606dde5cf936f73132ae8c19a87c746;p=horde.git DIMP now honors the 'allow_resume_all' configuration option --- diff --git a/imp/docs/CHANGES b/imp/docs/CHANGES index 4bb209389..24c1e9eab 100644 --- a/imp/docs/CHANGES +++ b/imp/docs/CHANGES @@ -2,6 +2,7 @@ v5.0-git -------- +[mms] DIMP now honors the 'allow_resume_all' configuration option. [mms] Remove 'sort_limit' configuration option. [mms] Mobile view no longer supports WML output. [jan] Implement iTip viewer actions in DIMP (Request #8061). diff --git a/imp/js/DimpBase.js b/imp/js/DimpBase.js index 9b8d201ef..2a10dc4e7 100644 --- a/imp/js/DimpBase.js +++ b/imp/js/DimpBase.js @@ -546,7 +546,7 @@ var DimpBase = { e.memo.each(function(row) { // Add context menu - this._addMouseEvents({ id: row.VP_domid, type: row.menutype }); + this._addMouseEvents({ id: row.VP_domid, type: 'message' }); new Drag(row.VP_domid, this._msgDragConfig); }, this); @@ -590,10 +590,7 @@ var DimpBase = { } /* Read-only changes. 'oa_setflag' is handled elsewhere. */ - tmp = [ $('button_deleted') ].compact().invoke('up', 'SPAN'); - [ 'ctx_message_', 'ctx_draft_' ].each(function(c) { - tmp = tmp.concat($(c + 'deleted', c + 'setflag', c + 'undeleted')); - }); + tmp = [ $('button_deleted') ].compact().invoke('up', 'SPAN').concat($('ctx_message_deleted', 'ctx_message_setflag', 'ctx_message_undeleted')); if (this.viewport.getMetaData('readonly')) { tmp.compact().invoke('hide'); @@ -612,7 +609,7 @@ var DimpBase = { /* Context menu: generate the list of settable flags for this * mailbox. */ flags = this.viewport.getMetaData('flags'); - $('ctx_draft_setflag', 'ctx_message_setflag', 'oa_setflag').invoke('up').invoke(flags.size() ? 'show' : 'hide'); + $('ctx_message_setflag', 'oa_setflag').invoke('up').invoke(flags.size() ? 'show' : 'hide'); if (flags.size()) { $('ctx_flag').childElements().each(function(c) { [ c ].invoke(flags.include(c.readAttribute('flag')) ? 'show' : 'hide'); @@ -785,7 +782,6 @@ var DimpBase = { this.blacklist(id == 'ctx_message_blacklist'); break; - case 'ctx_draft_deleted': case 'ctx_message_deleted': this.deleteMsg(); break; @@ -801,7 +797,7 @@ var DimpBase = { }, this); break; - case 'ctx_draft_resume': + case 'ctx_message_resume': this.composeMailbox('resume'); break; @@ -836,7 +832,6 @@ var DimpBase = { this.blacklist(id == 'oa_blacklist'); break; - case 'ctx_draft_undeleted': case 'ctx_message_undeleted': case 'oa_undeleted': this.flag('\\deleted', false); @@ -976,6 +971,8 @@ var DimpBase = { case 'ctx_message': [ $('ctx_message_source').up() ].invoke(DIMP.conf.preview_pref ? 'hide' : 'show'); + sel = this.viewport.getSelected(); + [ $('ctx_message_resume') ].invoke(sel.size() == 1 && sel.get('dataob').first().draft ? 'show' : 'hide'); break; default: @@ -1917,9 +1914,11 @@ var DimpBase = { if (elt) { tmp = this.viewport.createSelection('domid', elt.identify()).get('dataob').first(); - tmp.draft - ? DimpCore.compose('resume', { folder: tmp.view, uid: tmp.imapuid }) - : this.msgWindow(tmp); + if (tmp.draft && this.viewport.getMetaData('drafts')) { + DimpCore.compose('resume', { folder: tmp.view, uid: tmp.imapuid }) + } else { + this.msgWindow(tmp); + } e.stop(); } }, @@ -2956,7 +2955,7 @@ var DimpBase = { if ($('ctx_forward')) { DM.addSubMenu('ctx_message_forward', 'ctx_forward'); } - [ 'ctx_message_', 'oa_', 'ctx_draft_' ].each(function(i) { + [ 'ctx_message_', 'oa_' ].each(function(i) { if ($(i + 'setflag')) { DM.addSubMenu(i + 'setflag', 'ctx_flag'); DM.addSubMenu(i + 'unsetflag', 'ctx_flag'); diff --git a/imp/lib/Ui/Mailbox.php b/imp/lib/Ui/Mailbox.php index e7c33c22c..c36c196c3 100644 --- a/imp/lib/Ui/Mailbox.php +++ b/imp/lib/Ui/Mailbox.php @@ -256,4 +256,18 @@ class IMP_Ui_Mailbox return empty($new_subject) ? $subject : $new_subject; } + /** + * Determines if a message is a draft and can be resumed. + * + * @param array $flags The list of IMAP flags. + * + * @return boolean True if the message is a draft. + */ + public function isDraft($flags = array()) + { + return in_array('\\draft', $flags) || + !empty($GLOBALS['conf']['user']['allow_resume_all']) || + ($this->_mailbox == IMP::folderPref($GLOBALS['prefs']->getValue('drafts_folder'), true)); + } + } diff --git a/imp/lib/Views/ListMessages.php b/imp/lib/Views/ListMessages.php index 9db94496f..3b73f9b5e 100644 --- a/imp/lib/Views/ListMessages.php +++ b/imp/lib/Views/ListMessages.php @@ -119,6 +119,9 @@ class IMP_Views_ListMessages if ($args['initial']) { if (IMP::isSpecialFolder($mbox)) { $md->special = 1; + if ($mbox == IMP::folderPref($GLOBALS['prefs']->getValue('drafts_folder'))) { + $md->drafts = 1; + } } if ($is_search) { $md->search = 1; @@ -370,7 +373,6 @@ class IMP_Views_ListMessages /* Initialize the header fields. */ $msg = array( 'imapuid' => intval($ob['uid']), - 'menutype' => 'message', 'view' => $ob['mailbox'], ); @@ -397,9 +399,8 @@ class IMP_Views_ListMessages } } - /* Specific flag checking. */ - if (in_array('\\draft', $ob['flags'])) { - $msg['menutype'] = 'draft'; + /* Drafts. */ + if ($imp_ui->isDraft($ob['flags'])) { $msg['draft'] = 1; } diff --git a/imp/message.php b/imp/message.php index ea76b3e9a..042d78c32 100644 --- a/imp/message.php +++ b/imp/message.php @@ -513,10 +513,7 @@ if (!empty($conf['user']['allow_view_source'])) { $a_template->set('view_source', $imp_contents->linkViewJS($imp_contents->getMIMEMessage(), 'view_source', _("_Message Source"), array('jstext' => _("Message Source"), 'css' => 'widget', 'widget' => true))); } -if (!$disable_compose && - (in_array('\\draft', $flags) || - !empty($conf['user']['allow_resume_all']) || - ($mailbox_name == IMP::folderPref($prefs->getValue('drafts_folder'), true)))) { +if (!$disable_compose && $imp_ui->isDraft($flags)) { $a_template->set('resume', Horde::widget(IMP::composeLink(array(), array('actionID' => 'draft') + $compose_params), _("Resume"), 'widget', '', '', _("Resume"), true)); } diff --git a/imp/templates/index/index-dimp.inc b/imp/templates/index/index-dimp.inc index 6c15d88fe..dca5bdeb8 100644 --- a/imp/templates/index/index-dimp.inc +++ b/imp/templates/index/index-dimp.inc @@ -364,6 +364,7 @@ function _simpleButton($id, $text, $image, $nodisplay = false) - -