* Mail: fix problem on not applied but possibly set status filter on all message actions for flagging

This commit is contained in:
Klaus Leithoff 2014-08-14 13:51:57 +00:00
parent 9afa8acaae
commit d84b700517
2 changed files with 120 additions and 91 deletions

View File

@ -3366,19 +3366,36 @@ class emailadmin_imapbase
if (self::$debug) error_log(__METHOD__." no messages Message(s): ".implode(',',$_messageUID)); if (self::$debug) error_log(__METHOD__." no messages Message(s): ".implode(',',$_messageUID));
return false; return false;
} }
elseif ($_messageUID==='all') $this->icServer->openMailbox(($_folder?$_folder:$this->sessionData['mailbox']));
$folder = $this->icServer->getCurrentMailbox();
if (is_array($_messageUID)&& count($_messageUID)>50)
{ {
$uidsToModify= null; $count = $this->getMailBoxCounters($folder,true);
if ($count->messages == count($_messageUID)) $_messageUID='all';
}
if ($_messageUID==='all')
{
$messageUIDs = array('all');
}
else
{
if (!(is_object($_messageUID) || is_array($_messageUID))) $_messageUID = (array)$_messageUID;
$messageUIDs = array_chunk($_messageUID,50,true);
}
try
{
foreach($messageUIDs as $k => $uids)
{
if ($uids==='all')
{
$uidsToModify=null;
} }
else else
{ {
$uidsToModify = new Horde_Imap_Client_Ids(); $uidsToModify = new Horde_Imap_Client_Ids();
if (!(is_object($_messageUID) || is_array($_messageUID))) $_messageUID = (array)$_messageUID; $uidsToModify->add($uids);
$uidsToModify->add($_messageUID);
} }
$this->icServer->openMailbox(($_folder?$_folder:$this->sessionData['mailbox']));
$folder = $this->icServer->getCurrentMailbox();;
switch($_flag) { switch($_flag) {
case "delete": case "delete":
$ret = $this->icServer->store($folder, array('add'=>array('\\Deleted'), 'ids'=> $uidsToModify)); $ret = $this->icServer->store($folder, array('add'=>array('\\Deleted'), 'ids'=> $uidsToModify));
@ -3459,7 +3476,12 @@ class emailadmin_imapbase
$ret = $this->icServer->store($folder, array('remove'=>array('$label5'), 'ids'=> $uidsToModify)); $ret = $this->icServer->store($folder, array('remove'=>array('$label5'), 'ids'=> $uidsToModify));
break; break;
} }
}
}
catch(Exception $e)
{
error_log(__METHOD__.__LINE__.' Error, could not flag messages in folder '.$folder.' Reason:'.$e->getMessage());
}
self::$folderStatusCache[$this->profileID][(!empty($_folder)?$_folder: $this->sessionData['mailbox'])]['uidValidity'] = 0; self::$folderStatusCache[$this->profileID][(!empty($_folder)?$_folder: $this->sessionData['mailbox'])]['uidValidity'] = 0;
//error_log(__METHOD__.' ('.__LINE__.') '.'->' .$_flag." ".array2string($_messageUID).",".($_folder?$_folder:$this->sessionData['mailbox'])); //error_log(__METHOD__.' ('.__LINE__.') '.'->' .$_flag." ".array2string($_messageUID).",".($_folder?$_folder:$this->sessionData['mailbox']));

View File

@ -4203,13 +4203,13 @@ class mail_ui
if (count($messageListForToggle)>0) if (count($messageListForToggle)>0)
{ {
$flag2set = (strtolower($_flag)); $flag2set = (strtolower($_flag));
//error_log(__METHOD__.__LINE__." toggle un$_flag -> $flag2set ".array2string($filter2toggle).array2string($messageListForToggle)); if(mail_bo::$debug) error_log(__METHOD__.__LINE__." toggle un$_flag -> $flag2set ".array2string($filter2toggle).array2string($messageListForToggle));
$this->mail_bo->flagMessages($flag2set, $messageListForToggle,$folder); $this->mail_bo->flagMessages($flag2set, $messageListForToggle,$folder);
} }
if (count($messageList)>0) if (count($messageList)>0)
{ {
$flag2set = 'un'.$_flag; $flag2set = 'un'.$_flag;
//error_log(__METHOD__.__LINE__." $_flag -> $flag2set ".array2string($filter).array2string($messageList)); if(mail_bo::$debug) error_log(__METHOD__.__LINE__." $_flag -> $flag2set ".array2string($filter).array2string($messageList));
$this->mail_bo->flagMessages($flag2set, $messageList,$folder); $this->mail_bo->flagMessages($flag2set, $messageList,$folder);
} }
$alreadyFlagged=true; $alreadyFlagged=true;
@ -4219,6 +4219,13 @@ class mail_ui
(in_array($_flag,array('read','flagged','label1','label2','label3','label4','label5')) && (in_array($_flag,array('read','flagged','label1','label2','label3','label4','label5')) &&
($flag2check==$query['filter'] || stripos($query['filter'],$flag2check)!==false)))) ($flag2check==$query['filter'] || stripos($query['filter'],$flag2check)!==false))))
{ {
if ($query['filter'] && $query['filter'] !='any')
{
$filter['status'] = $query['filter'];
// since we toggle and we toggle by the filtered flag we must must change _flag
$_flag = ($query['filter']=='unseen' && $_flag=='read' ? 'read' : ($query['filter']=='seen'&& $_flag=='read'?'unread':($_flag==$query['filter']?'un'.$_flag:$_flag)));
}
if(mail_bo::$debug) error_log(__METHOD__.__LINE__." flag all with $_flag on filter used:".array2string($filter));
$_sR = $this->mail_bo->getSortedList( $_sR = $this->mail_bo->getSortedList(
$folder, $folder,
$sort=0, $sort=0,
@ -4233,7 +4240,7 @@ class mail_ui
} }
else else
{ {
//error_log(__METHOD__.__LINE__." $_flag all ".array2string($filter)); if(mail_bo::$debug) error_log(__METHOD__.__LINE__." $_flag all ".array2string($filter));
$alreadyFlagged=true; $alreadyFlagged=true;
$uidA = self::splitRowID($_messageList['msg'][0]); $uidA = self::splitRowID($_messageList['msg'][0]);
$folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder $folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder
@ -4253,7 +4260,7 @@ class mail_ui
$hA = self::splitRowID($rowID); $hA = self::splitRowID($rowID);
$messageList[] = $hA['msgUID']; $messageList[] = $hA['msgUID'];
} }
//error_log(__METHOD__.__LINE__." $_flag in $folder:".array2string(((isset($_messageList['all']) && $_messageList['all']) ? 'all':$messageList))); if(mail_bo::$debug) error_log(__METHOD__.__LINE__." $_flag in $folder:".array2string(((isset($_messageList['all']) && $_messageList['all']) ? 'all':$messageList)));
$this->mail_bo->flagMessages($_flag, ((isset($_messageList['all']) && $_messageList['all']) ? 'all':$messageList),$folder); $this->mail_bo->flagMessages($_flag, ((isset($_messageList['all']) && $_messageList['all']) ? 'all':$messageList),$folder);
} }
} }