mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-29 03:59:21 +03:00
Added "custom-system-folders" plugin
Small fixes
This commit is contained in:
parent
085095b717
commit
2b3889392d
7 changed files with 202 additions and 13 deletions
20
plugins/custom-system-folders/LICENSE
Normal file
20
plugins/custom-system-folders/LICENSE
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 RainLoop Team
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
1
plugins/custom-system-folders/README
Normal file
1
plugins/custom-system-folders/README
Normal file
|
|
@ -0,0 +1 @@
|
|||
custom-sytem-folders
|
||||
1
plugins/custom-system-folders/VERSION
Normal file
1
plugins/custom-system-folders/VERSION
Normal file
|
|
@ -0,0 +1 @@
|
|||
1.0
|
||||
139
plugins/custom-system-folders/index.php
Normal file
139
plugins/custom-system-folders/index.php
Normal file
|
|
@ -0,0 +1,139 @@
|
|||
<?php
|
||||
|
||||
class CustomSystemFoldersPlugin extends \RainLoop\Plugins\AbstractPlugin
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $sSentFolder = '';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $sDraftsFolder = '';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $sSpamFolder = '';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $sTrashFolder = '';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $sArchiveFolder = '';
|
||||
|
||||
public function Init()
|
||||
{
|
||||
$this->sSentFolder = \trim($this->Config()->Get('plugin', 'sent_folder', ''));
|
||||
$this->sDraftsFolder = \trim($this->Config()->Get('plugin', 'drafts_folder', ''));
|
||||
$this->sSpamFolder = \trim($this->Config()->Get('plugin', 'spam_folder', ''));
|
||||
$this->sTrashFolder = \trim($this->Config()->Get('plugin', 'trash_folder', ''));
|
||||
$this->sArchiveFolder = \trim($this->Config()->Get('plugin', 'archive_folder', ''));
|
||||
|
||||
$this->addHook('filter.system-folders-names', 'FilterSystemFoldersNames');
|
||||
$this->addHook('filter.folders-system-types', 'FilterFoldersSystemTypes');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \RainLoop\Account $oAccount
|
||||
* @param array $aSystemTypes
|
||||
*/
|
||||
public function FilterFoldersSystemTypes($oAccount, &$aSystemTypes)
|
||||
{
|
||||
if ($oAccount)
|
||||
{
|
||||
$aSystemTypes = array();
|
||||
if (0 < \strlen($this->sSentFolder))
|
||||
{
|
||||
$aSystemTypes[] = \MailSo\Imap\Enumerations\FolderType::SENT;
|
||||
}
|
||||
|
||||
if (0 < \strlen($this->sDraftsFolder))
|
||||
{
|
||||
$aSystemTypes[] = \MailSo\Imap\Enumerations\FolderType::DRAFTS;
|
||||
}
|
||||
|
||||
if (0 < \strlen($this->sSpamFolder))
|
||||
{
|
||||
$aSystemTypes[] = \MailSo\Imap\Enumerations\FolderType::JUNK;
|
||||
}
|
||||
|
||||
if (0 < \strlen($this->sTrashFolder))
|
||||
{
|
||||
$aSystemTypes[] = \MailSo\Imap\Enumerations\FolderType::TRASH;
|
||||
}
|
||||
|
||||
if (0 < \strlen($this->sArchiveFolder))
|
||||
{
|
||||
$aSystemTypes[] = \MailSo\Imap\Enumerations\FolderType::ALL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function helperFolderType($sFolderName, $iType, &$aPrepend, &$aSystemFolderNames)
|
||||
{
|
||||
if (0 < \strlen($sFolderName) && '{@system@}' !== $sFolderName)
|
||||
{
|
||||
$aPrepend[$sFolderName] = $iType;
|
||||
if (isset($aSystemFolderNames[$sFolderName]))
|
||||
{
|
||||
unset($aSystemFolderNames[$sFolderName]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \RainLoop\Account $oAccount
|
||||
* @param array $aSystemFolderNames
|
||||
*/
|
||||
public function FilterSystemFoldersNames($oAccount, &$aSystemFolderNames)
|
||||
{
|
||||
$aPrepend = array();
|
||||
if ($oAccount && \is_array($aSystemFolderNames))
|
||||
{
|
||||
$this->helperFolderType($this->sSentFolder, \MailSo\Imap\Enumerations\FolderType::SENT,
|
||||
$aPrepend, $aSystemFolderNames);
|
||||
|
||||
$this->helperFolderType($this->sDraftsFolder, \MailSo\Imap\Enumerations\FolderType::DRAFTS,
|
||||
$aPrepend, $aSystemFolderNames);
|
||||
|
||||
$this->helperFolderType($this->sSpamFolder, \MailSo\Imap\Enumerations\FolderType::JUNK,
|
||||
$aPrepend, $aSystemFolderNames);
|
||||
|
||||
$this->helperFolderType($this->sTrashFolder, \MailSo\Imap\Enumerations\FolderType::TRASH,
|
||||
$aPrepend, $aSystemFolderNames);
|
||||
|
||||
$this->helperFolderType($this->sArchiveFolder, \MailSo\Imap\Enumerations\FolderType::ALL,
|
||||
$aPrepend, $aSystemFolderNames);
|
||||
|
||||
if (0 < \count($aPrepend))
|
||||
{
|
||||
$aSystemFolderNames = \array_merge($aPrepend, $aSystemFolderNames);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function configMapping()
|
||||
{
|
||||
return array(
|
||||
\RainLoop\Plugins\Property::NewInstance('sent_folder')->SetLabel('Sent')
|
||||
->SetDefaultValue('Sent'),
|
||||
\RainLoop\Plugins\Property::NewInstance('drafts_folder')->SetLabel('Drafts')
|
||||
->SetDefaultValue('Drafts'),
|
||||
\RainLoop\Plugins\Property::NewInstance('spam_folder')->SetLabel('Spam')
|
||||
->SetDefaultValue('Spam'),
|
||||
\RainLoop\Plugins\Property::NewInstance('trash_folder')->SetLabel('Trash')
|
||||
->SetDefaultValue('Trash'),
|
||||
\RainLoop\Plugins\Property::NewInstance('archive_folder')->SetLabel('Archive')
|
||||
->SetDefaultValue('Archive')
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue