mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-07 16:37:02 +03:00
Resolve #64
This commit is contained in:
parent
72815f842e
commit
3648b3eb60
7 changed files with 83 additions and 119 deletions
|
|
@ -29,7 +29,7 @@ class NamespaceResult implements \JsonSerializable
|
|||
if (\is_array($entry) && 2 <= \count($entry)) {
|
||||
$this->aPersonal[] = [
|
||||
'prefix' => \array_shift($entry),
|
||||
'separator' => \array_shift($entry),
|
||||
'delimiter' => \array_shift($entry),
|
||||
'extension' => $entry
|
||||
];
|
||||
}
|
||||
|
|
@ -40,7 +40,7 @@ class NamespaceResult implements \JsonSerializable
|
|||
if (\is_array($entry) && 2 <= \count($entry)) {
|
||||
$this->aOtherUsers[] = [
|
||||
'prefix' => \array_shift($entry),
|
||||
'separator' => \array_shift($entry),
|
||||
'delimiter' => \array_shift($entry),
|
||||
'extension' => $entry
|
||||
];
|
||||
}
|
||||
|
|
@ -51,7 +51,7 @@ class NamespaceResult implements \JsonSerializable
|
|||
if (\is_array($entry) && 2 <= \count($entry)) {
|
||||
$this->aShared[] = [
|
||||
'prefix' => \array_shift($entry),
|
||||
'separator' => \array_shift($entry),
|
||||
'delimiter' => \array_shift($entry),
|
||||
'extension' => $entry
|
||||
];
|
||||
}
|
||||
|
|
@ -64,9 +64,9 @@ class NamespaceResult implements \JsonSerializable
|
|||
$sPrefix = '';
|
||||
if (isset($this->aPersonal[0])) {
|
||||
$sPrefix = $this->aPersonal[0]['prefix'];
|
||||
$sSeparator = $this->aPersonal[0]['separator'];
|
||||
if ('INBOX'.$sSeparator === \substr(\strtoupper($sPrefix), 0, 6)) {
|
||||
$sPrefix = 'INBOX'.$sSeparator.\substr($sPrefix, 6);
|
||||
$sDelimiter = $this->aPersonal[0]['delimiter'];
|
||||
if ('INBOX'.$sDelimiter === \substr(\strtoupper($sPrefix), 0, 6)) {
|
||||
$sPrefix = 'INBOX'.$sDelimiter.\substr($sPrefix, 6);
|
||||
};
|
||||
}
|
||||
return $sPrefix;
|
||||
|
|
|
|||
|
|
@ -947,50 +947,22 @@ class MailClient
|
|||
/**
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function FolderMove(string $sPrevFolderFullName, string $sNextFolderFullNameInUtf, bool $bSubscribeOnMove = true) : self
|
||||
{
|
||||
if (!$this->oImapClient->FolderHierarchyDelimiter($sPrevFolderFullName)) {
|
||||
// TODO: Translate
|
||||
throw new \MailSo\RuntimeException('Cannot move non-existent folder.');
|
||||
}
|
||||
return $this->folderModify($sPrevFolderFullName, $sNextFolderFullNameInUtf, $bSubscribeOnMove);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function FolderRename(string $sPrevFolderFullName, string $sNewTopFolderNameInUtf, bool $bSubscribeOnRename = true) : string
|
||||
{
|
||||
$sDelimiter = $this->oImapClient->FolderHierarchyDelimiter($sPrevFolderFullName);
|
||||
if (!$sDelimiter) {
|
||||
// TODO: Translate
|
||||
throw new \MailSo\RuntimeException('Cannot rename non-existent folder.');
|
||||
}
|
||||
|
||||
if (\strlen($sDelimiter) && false !== \strpos($sNewTopFolderNameInUtf, $sDelimiter)) {
|
||||
// TODO: Translate
|
||||
throw new \MailSo\RuntimeException('New folder name contains delimiter.');
|
||||
}
|
||||
|
||||
$iLast = \strrpos($sPrevFolderFullName, $sDelimiter);
|
||||
$sNewFolderFullName = (false === $iLast ? '' : \substr($sPrevFolderFullName, 0, $iLast + 1))
|
||||
. $sNewTopFolderNameInUtf;
|
||||
|
||||
$this->folderModify($sPrevFolderFullName, $sNewFolderFullName, $bSubscribeOnRename);
|
||||
|
||||
return $sNewFolderFullName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \ValueError
|
||||
* @throws \MailSo\RuntimeException
|
||||
*/
|
||||
protected function folderModify(string $sPrevFolderFullName, string $sNewFolderFullName, bool $bSubscribe) : self
|
||||
public function FolderRename(string $sPrevFolderFullName, string $sNewFolderFullName, bool $bSubscribe = true) : self
|
||||
{
|
||||
if (!\strlen($sPrevFolderFullName) || !\strlen($sNewFolderFullName)) {
|
||||
throw new \ValueError;
|
||||
}
|
||||
|
||||
if (!$this->oImapClient->FolderHierarchyDelimiter($sPrevFolderFullName)) {
|
||||
// TODO: Translate
|
||||
throw new \MailSo\RuntimeException('Cannot rename non-existent folder.');
|
||||
}
|
||||
/*
|
||||
if (\strlen($sDelimiter) && false !== \strpos($sNewFolderFullName, $sDelimiter)) {
|
||||
// TODO: Translate
|
||||
throw new \MailSo\RuntimeException('New folder name contains delimiter.');
|
||||
}
|
||||
*/
|
||||
$oSubscribedFolders = array();
|
||||
if ($bSubscribe) {
|
||||
$oSubscribedFolders = $this->oImapClient->FolderSubscribeList($sPrevFolderFullName, '*');
|
||||
|
|
|
|||
|
|
@ -190,15 +190,15 @@ trait Folders
|
|||
/**
|
||||
* @throws \MailSo\RuntimeException
|
||||
*/
|
||||
public function DoFolderMove() : array
|
||||
public function DoFolderRename() : array
|
||||
{
|
||||
$this->initMailClientConnection();
|
||||
|
||||
try
|
||||
{
|
||||
$this->MailClient()->FolderMove(
|
||||
$this->GetActionParam('folder', ''),
|
||||
$this->GetActionParam('newFolder', ''),
|
||||
$sFullName = $this->MailClient()->FolderRename(
|
||||
$this->GetActionParam('oldName', ''),
|
||||
$this->GetActionParam('newName', ''),
|
||||
!empty($this->GetActionParam('subscribe', 1))
|
||||
);
|
||||
}
|
||||
|
|
@ -210,34 +210,6 @@ trait Folders
|
|||
return $this->TrueResponse();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \MailSo\RuntimeException
|
||||
*/
|
||||
public function DoFolderRename() : array
|
||||
{
|
||||
$this->initMailClientConnection();
|
||||
|
||||
$sName = $this->GetActionParam('newFolderName', '');
|
||||
try
|
||||
{
|
||||
$sFullName = $this->MailClient()->FolderRename(
|
||||
$this->GetActionParam('folder', ''),
|
||||
$sName,
|
||||
!empty($this->GetActionParam('subscribe', 1))
|
||||
);
|
||||
}
|
||||
catch (\Throwable $oException)
|
||||
{
|
||||
throw new ClientException(Notifications::CantRenameFolder, $oException);
|
||||
}
|
||||
|
||||
// FolderInformation(string $sFolderName, int $iPrevUidNext = 0, array $aUids = array())
|
||||
return $this->DefaultResponse(array(
|
||||
'name' => $sName,
|
||||
'fullName' => $sFullName,
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \MailSo\RuntimeException
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -3,13 +3,31 @@
|
|||
<h3 data-bind="text: folder()?.fullName"></h3>
|
||||
</header>
|
||||
<form id="folderform" class="modal-body form-horizontal" autocomplete="off" spellcheck="false" data-bind="submit: submitForm">
|
||||
<div class="control-group" data-bind="if: editing">
|
||||
<label data-i18n="POPUPS_CREATE_FOLDER/LABEL_PARENT"></label>
|
||||
<select name="parent" data-bind="options: parentFolderSelectList, value: parentFolder,
|
||||
optionsText: 'name', optionsValue: 'id', optionsAfterRender: defaultOptionsAfterRender"></select>
|
||||
</div>
|
||||
<div class="control-group" data-bind="if: editing">
|
||||
<label data-i18n="GLOBAL/NAME"></label>
|
||||
<input name="folder" type="text"
|
||||
autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"
|
||||
required="" data-bind="textInput: name">
|
||||
</div>
|
||||
<div data-bind="with: folder">
|
||||
<div class="control-group" data-bind="if: editing">
|
||||
<label data-i18n="GLOBAL/NAME"></label>
|
||||
<input name="folder" type="text"
|
||||
autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"
|
||||
required="" data-bind="textInput: nameForEdit">
|
||||
<!-- ko if: canBeSubscribed -->
|
||||
<div class="control-group">
|
||||
<label></label>
|
||||
<div data-bind="component: {
|
||||
name: 'Checkbox',
|
||||
params: {
|
||||
name: 'subscribe',
|
||||
label: 'SETTINGS_FOLDERS/BUTTON_SUBSCRIBE',
|
||||
value: isSubscribed
|
||||
}
|
||||
}"></div>
|
||||
</div>
|
||||
<!-- /ko -->
|
||||
<div class="control-group">
|
||||
<label data-i18n="POPUPS_FILTER/SELECT_FIELD_SIZE"></label>
|
||||
<span data-bind="text: friendlySize"></span>
|
||||
|
|
@ -19,16 +37,6 @@
|
|||
<span data-bind="text: unreadEmails"></span>
|
||||
/ <span style="margin:0" data-bind="text: totalEmails"></span>
|
||||
</div>
|
||||
<!-- ko if: canBeSubscribed -->
|
||||
<div class="control-group" data-bind="component: {
|
||||
name: 'Checkbox',
|
||||
params: {
|
||||
name: 'subscribe',
|
||||
label: 'SETTINGS_FOLDERS/BUTTON_SUBSCRIBE',
|
||||
value: isSubscribed
|
||||
}
|
||||
}"></div>
|
||||
<!-- /ko -->
|
||||
</div>
|
||||
<div class="control-group" data-bind="if: ACLAllowed">
|
||||
<label>ACL</label>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue