diff --git a/rainloop/v/0.0.0/app/libraries/MailSo/Imap/ImapClient.php b/rainloop/v/0.0.0/app/libraries/MailSo/Imap/ImapClient.php index be7811139..f22afa172 100644 --- a/rainloop/v/0.0.0/app/libraries/MailSo/Imap/ImapClient.php +++ b/rainloop/v/0.0.0/app/libraries/MailSo/Imap/ImapClient.php @@ -966,6 +966,18 @@ class ImapClient extends \MailSo\Net\NetClient return $this->selectOrExamineFolder($sFolderName, $this->__FORCE_SELECT_ON_EXAMINE__, $bReSelectSameFolders); } + /** + * @return \MailSo\Imap\ImapClient + * + * @throws \MailSo\Net\Exceptions\Exception + * @throws \MailSo\Imap\Exceptions\Exception + */ + public function FolderUnSelect() + { + return $this->IsSelected() && $this->IsSupported('UNSELECT') ? + $this->SendRequestWithCheck('UNSELECT') : $this; + } + /** * @param array $aInputFetchItems * @param string $sIndexRange diff --git a/rainloop/v/0.0.0/app/libraries/MailSo/Mail/MailClient.php b/rainloop/v/0.0.0/app/libraries/MailSo/Mail/MailClient.php index fff39332f..b0d7b5f3f 100644 --- a/rainloop/v/0.0.0/app/libraries/MailSo/Mail/MailClient.php +++ b/rainloop/v/0.0.0/app/libraries/MailSo/Mail/MailClient.php @@ -637,6 +637,22 @@ class MailClient return $this; } + /** + * @return \MailSo\Mail\MailClient + * + * @throws \MailSo\Net\Exceptions\Exception + * @throws \MailSo\Imap\Exceptions\Exception + */ + public function FolderUnSelect() + { + if ($this->oImapClient->IsSelected()) + { + $this->oImapClient->FolderUnSelect(); + } + + return $this; + } + /** * @param resource $rMessageStream * @param int $iMessageStreamSize diff --git a/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php b/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php index 68ebea07a..7f65c596c 100644 --- a/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php +++ b/rainloop/v/0.0.0/app/libraries/RainLoop/Actions.php @@ -7205,14 +7205,35 @@ class Actions { $this->MailClient()->MessageDelete($sFolder, $aFilteredUids, true, true, !!$this->Config()->Get('labs', 'use_imap_expunge_all_on_delete', false)); - - $sHash = $this->MailClient()->FolderHash($sFolder); } catch (\Exception $oException) { throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::CantDeleteMessage, $oException); } + if ($this->Config()->Get('labs', 'use_imap_unselect', true)) + { + try + { + $this->MailClient()->FolderUnSelect(); + } + catch (\Exception $oException) + { + unset($oException); + } + } + + $sHash = ''; + + try + { + $sHash = $this->MailClient()->FolderHash($sFromFolder); + } + catch (\Exception $oException) + { + unset($oException); + } + return $this->DefaultResponse(__FUNCTION__, '' === $sHash ? false : array($sFolder, $sHash)); } @@ -7253,16 +7274,36 @@ class Actions !!$this->Config()->Get('labs', 'use_imap_move', true), !!$this->Config()->Get('labs', 'use_imap_expunge_all_on_delete', false) ); - - $sHash = $this->MailClient()->FolderHash($sFromFolder); } catch (\Exception $oException) { throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::CantMoveMessage, $oException); } - return $this->DefaultResponse(__FUNCTION__, - '' === $sHash ? false : array($sFromFolder, $sHash)); + if ($this->Config()->Get('labs', 'use_imap_unselect', true)) + { + try + { + $this->MailClient()->FolderUnSelect(); + } + catch (\Exception $oException) + { + unset($oException); + } + } + + $sHash = ''; + + try + { + $sHash = $this->MailClient()->FolderHash($sFromFolder); + } + catch (\Exception $oException) + { + unset($oException); + } + + return $this->DefaultResponse(__FUNCTION__, '' === $sHash ? false : array($sFromFolder, $sHash)); } /**