* Mail: keyword actions were not always displayed (eg. never for Dovecot and GMail)

This commit is contained in:
Ralf Becker 2014-08-13 11:47:58 +00:00
parent ea7de50b8f
commit 58bd3b9e60
3 changed files with 48 additions and 19 deletions

View File

@ -63,6 +63,8 @@ class emailadmin_imap extends Horde_Imap_Client_Socket implements defaultimap
* does the server with the serverID support keywords * does the server with the serverID support keywords
* this information is filled/provided by examineMailbox * this information is filled/provided by examineMailbox
* *
* init_static references this to a session-variable, so it persists
*
* @var array of boolean for each known serverID * @var array of boolean for each known serverID
*/ */
static $supports_keywords; static $supports_keywords;
@ -736,13 +738,16 @@ class emailadmin_imap extends Horde_Imap_Client_Socket implements defaultimap
* examineMailbox * examineMailbox
* *
* @param string $mailbox * @param string $mailbox
* @param int $flags=null default Horde_Imap_Client::STATUS_ALL | Horde_Imap_Client::STATUS_FLAGS | Horde_Imap_Client::STATUS_PERMFLAGS
* @return array of counters for mailbox * @return array of counters for mailbox
*/ */
function examineMailbox($mailbox) function examineMailbox($mailbox, $flags=null)
{ {
if ($mailbox=='') return false; if ($mailbox=='') return false;
$mailboxes = $this->listMailboxes($mailbox); $mailboxes = $this->listMailboxes($mailbox);
if (is_null($flags)) $flags = Horde_Imap_Client::STATUS_ALL | Horde_Imap_Client::STATUS_FLAGS | Horde_Imap_Client::STATUS_PERMFLAGS;
$mboxes = new Horde_Imap_Client_Mailbox_List($mailboxes); $mboxes = new Horde_Imap_Client_Mailbox_List($mailboxes);
//_debug_array($mboxes->count()); //_debug_array($mboxes->count());
foreach ($mboxes->getIterator() as $k => $box) foreach ($mboxes->getIterator() as $k => $box)
@ -751,13 +756,17 @@ class emailadmin_imap extends Horde_Imap_Client_Socket implements defaultimap
unset($box); unset($box);
if ($k!='user' && $k != '' && $k==$mailbox) if ($k!='user' && $k != '' && $k==$mailbox)
{ {
$status = $this->status($k, Horde_Imap_Client::STATUS_ALL | Horde_Imap_Client::STATUS_FLAGS | Horde_Imap_Client::STATUS_PERMFLAGS); $status = $this->status($k, $flags);
//error_log(__METHOD__.__LINE__.array2string($status)); //error_log(__METHOD__.__LINE__.array2string($status));
foreach ($status as $key => $v) foreach ($status as $key => $v)
{ {
$_status[strtoupper($key)]=$v; $_status[strtoupper($key)]=$v;
} }
self::$supports_keywords[$this->ImapServerId] = stripos(array2string($_status['FLAGS']),'$label')!==false; if ($flags & (Horde_Imap_Client::STATUS_FLAGS|Horde_Imap_Client::STATUS_PERMFLAGS))
{
self::$supports_keywords[$this->ImapServerId] = stripos(implode('', $status['flags']), '$label') !== false ||
in_array('\\*', $status['permflags']); // arbitrary keyswords also allow keywords
}
return $_status; return $_status;
} }
} }
@ -790,16 +799,19 @@ class emailadmin_imap extends Horde_Imap_Client_Socket implements defaultimap
/** /**
* Query a single capability * Query a single capability
* *
* @deprecated use queryCapability($capability)
* @param string $capability * @param string $capability
* @return boolean * @return boolean
*/ */
function hasCapability($capability) function hasCapability($capability)
{ {
//return $this->queryCapability($capability);
if ($capability=='SUPPORTS_KEYWORDS') if ($capability=='SUPPORTS_KEYWORDS')
{ {
//error_log(__METHOD__.__LINE__.' '.$capability.'->'.array2string(self::$supports_keywords)); // if pseudo-flag is not set, call examineMailbox now to set it (no STATUS_ALL = counters necessary)
if (!isset(self::$supports_keywords[$this->ImapServerId]))
{
$this->examineMailbox('INBOX', Horde_Imap_Client::STATUS_FLAGS|Horde_Imap_Client::STATUS_PERMFLAGS);
}
//error_log(__METHOD__.__LINE__.' '.$capability.'->'.array2string(self::$supports_keywords).' '.function_backtrace());
return self::$supports_keywords[$this->ImapServerId]; return self::$supports_keywords[$this->ImapServerId];
} }
try try
@ -1226,4 +1238,13 @@ class emailadmin_imap extends Horde_Imap_Client_Socket implements defaultimap
{ {
return array(); return array();
} }
/**
* Init static variables
*/
public function init_static()
{
self::$supports_keywords =& egw_cache::getSession (__CLASS__, 'supports_keywords');
}
} }
emailadmin_imap::init_static();

View File

@ -1328,6 +1328,9 @@ class mail_ui
'caption' => 'Set / Remove Labels', 'caption' => 'Set / Remove Labels',
'icon' => 'tag_message', 'icon' => 'tag_message',
'group' => ++$group, 'group' => ++$group,
// note this one is NOT a real CAPABILITY reported by the server, but added by selectMailbox
'enabled' => $this->mail_bo->icServer->hasCapability('SUPPORTS_KEYWORDS'),
'hideOnDisabled' => true,
'children' => array( 'children' => array(
'unlabel' => array( 'unlabel' => array(
'group' => ++$group, 'group' => ++$group,
@ -1423,12 +1426,6 @@ class mail_ui
{ {
unset($actions['tracker']); unset($actions['tracker']);
} }
// note this one is NOT a real CAPABILITY reported by the server, but added by selectMailbox
if (!$this->mail_bo->icServer->hasCapability('SUPPORTS_KEYWORDS'))
{
unset($actions['mark']['children']['setLabel']);
unset($actions['mark']['children']['unsetLabel']);
}
return $actions; return $actions;
} }
@ -1439,9 +1436,9 @@ class mail_ui
* @param array &$rows * @param array &$rows
* @param array &$readonlys * @param array &$readonlys
*/ */
function get_rows($query,&$rows,&$readonlys) function get_rows(&$query,&$rows,&$readonlys)
{ {
unset($query['actions']); // unset($query['actions']);
//error_log(__METHOD__.__LINE__.' SelectedFolder:'.$query['selectedFolder'].' Start:'.$query['start'].' NumRows:'.$query['num_rows'].array2string($query['order']).'->'.array2string($query['sort'])); //error_log(__METHOD__.__LINE__.' SelectedFolder:'.$query['selectedFolder'].' Start:'.$query['start'].' NumRows:'.$query['num_rows'].array2string($query['order']).'->'.array2string($query['sort']));
if (mail_bo::$debugTimes) $starttime = microtime(true); if (mail_bo::$debugTimes) $starttime = microtime(true);
//$query['search'] is the phrase in the searchbox //$query['search'] is the phrase in the searchbox
@ -1467,6 +1464,7 @@ class mail_ui
try try
{ {
$this->changeProfile($_profileID); $this->changeProfile($_profileID);
$query['actions'] = $this->get_actions();
} }
catch(Exception $e) catch(Exception $e)
{ {
@ -2038,7 +2036,6 @@ class mail_ui
$actionsenabled = self::get_actions(); $actionsenabled = self::get_actions();
unset($actionsenabled['open']); unset($actionsenabled['open']);
unset($actionsenabled['mark']['children']['setLabel']); unset($actionsenabled['mark']['children']['setLabel']);
unset($actionsenabled['mark']['children']['unsetLabel']);
unset($actionsenabled['mark']['children']['read']); unset($actionsenabled['mark']['children']['read']);
unset($actionsenabled['mark']['children']['unread']); unset($actionsenabled['mark']['children']['unread']);
unset($actionsenabled['mark']['children']['undelete']); unset($actionsenabled['mark']['children']['undelete']);
@ -3869,7 +3866,7 @@ class mail_ui
* @param bool $getFolders The client needs the folders for the profile * @param bool $getFolders The client needs the folders for the profile
* @return nothing * @return nothing
*/ */
function ajax_changeProfile($icServerID, $getFolders = true) function ajax_changeProfile($icServerID, $getFolders = true, $exec_id=null)
{ {
$response = egw_json_response::get(); $response = egw_json_response::get();
@ -3877,7 +3874,18 @@ class mail_ui
{ {
try try
{ {
if ($exec_id) $old_actions = $this->get_actions();
$this->changeProfile($icServerID); $this->changeProfile($icServerID);
// if we have an eTemplate exec_id, also send changed actions
if ($exec_id && ($actions = $this->get_actions()) != $old_actions)
{
$response->generic('assign', array(
'etemplate_exec_id' => $exec_id,
'id' => 'nm',
'key' => 'actions',
'value' => $actions,
));
}
} }
catch (Exception $e) { catch (Exception $e) {
self::callWizard($e->getMessage(),true, 'error'); self::callWizard($e->getMessage(),true, 'error');

View File

@ -97,7 +97,7 @@ app.classes.mail = AppJS.extend(
$j(nm).off('refresh'); $j(nm).off('refresh');
} }
} }
// Unregister client side cache // Unregister client side cache
this.egw.dataCacheUnregister('mail'); this.egw.dataCacheUnregister('mail');
@ -1474,7 +1474,7 @@ app.classes.mail = AppJS.extend(
var server = _senders[0].iface.id.split('::'); var server = _senders[0].iface.id.split('::');
var activeFilters = this.mail_getActiveFilters(); var activeFilters = this.mail_getActiveFilters();
var self = this; var self = this;
this.egw.message(this.egw.lang('empty trash')); this.egw.message(this.egw.lang('empty trash'));
egw.json('mail.mail_ui.ajax_emptyTrash',[server[0], activeFilters['selectedFolder']? activeFilters['selectedFolder']:null],function(){self.unlock_tree()}) egw.json('mail.mail_ui.ajax_emptyTrash',[server[0], activeFilters['selectedFolder']? activeFilters['selectedFolder']:null],function(){self.unlock_tree()})
.sendRequest(true); .sendRequest(true);
@ -1514,7 +1514,7 @@ app.classes.mail = AppJS.extend(
this.egw.message(this.egw.lang('Connect to Profile %1',_widget.getSelectedLabel().replace(this._unseen_regexp, ''))); this.egw.message(this.egw.lang('Connect to Profile %1',_widget.getSelectedLabel().replace(this._unseen_regexp, '')));
this.lock_tree(); this.lock_tree();
egw.json('mail.mail_ui.ajax_changeProfile',[folder, getFolders], jQuery.proxy(function() { egw.json('mail.mail_ui.ajax_changeProfile',[folder, getFolders, this.et2._inst.etemplate_exec_id], jQuery.proxy(function() {
// Profile changed, select inbox // Profile changed, select inbox
var inbox = folder + '::INBOX'; var inbox = folder + '::INBOX';
_widget.reSelectItem(inbox); _widget.reSelectItem(inbox);