Merged from sub repository (updated ckeditor, filters - step 2)

This commit is contained in:
RainLoop Team 2014-12-01 21:34:21 +04:00
parent a57dc3720e
commit ec7324b061
427 changed files with 10909 additions and 3336 deletions

View file

@ -508,10 +508,10 @@ abstract class NetClient
$iReadedLen = \strlen($this->sResponseBuffer);
if (null === $mReadLen || $bForceLogin)
{
$iLimit = 5000; // 5kb
$iLimit = 5000; // 5KB
if ($iLimit < $iReadedLen)
{
$this->writeLogWithCrlf('[cutted:'.$iReadedLen.'b] < '.\substr($this->sResponseBuffer.'...', 0, $iLimit),
$this->writeLogWithCrlf('[cutted:'.$iReadedLen.'] < '.\substr($this->sResponseBuffer, 0, $iLimit).'...',
\MailSo\Log\Enumerations\Type::INFO);
}
else

View file

@ -70,6 +70,11 @@ class Actions
*/
private $oSettingsProvider;
/**
* @var \RainLoop\Providers\Filters
*/
private $oFiltersProvider;
/**
* @var \RainLoop\Providers\AddressBook
*/
@ -118,6 +123,7 @@ class Actions
$this->oStorageProvider = null;
$this->oFilesProvider = null;
$this->oSettingsProvider = null;
$this->oFiltersProvider = null;
$this->oDomainProvider = null;
$this->oAddressBookProvider = null;
$this->oSuggestionsProvider = null;
@ -242,6 +248,10 @@ class Actions
// \RainLoop\Providers\Domain\DomainAdminInterface
$oResult = new \RainLoop\Providers\Domain\DefaultDomain(APP_PRIVATE_DATA.'domains', $this->Cacher());
break;
case 'filters':
// \RainLoop\Providers\Filters\FiltersInterface
$oResult = new \RainLoop\Providers\Filters\SieveStorage();
break;
case 'address-book':
// \RainLoop\Providers\AddressBook\AddressBookInterface
@ -574,6 +584,20 @@ class Actions
return $this->oSettingsProvider;
}
/**
* @return \RainLoop\Providers\Filters
*/
public function FiltersProvider()
{
if (null === $this->oFiltersProvider)
{
$this->oFiltersProvider = new \RainLoop\Providers\Filters(
$this->fabrica('filters'));
}
return $this->oFiltersProvider;
}
/**
* @return \RainLoop\Providers\ChangePassword
*/
@ -992,6 +1016,14 @@ class Actions
return $bResult;
}
/**
* @return bool
*/
private function UseSieve()
{
return false; // TODO
}
/**
* @param bool $bAdmin
* @param string $sAuthAccountHash = ''
@ -1044,6 +1076,7 @@ class Actions
'ContactsIsAllowed' => false,
'ChangePasswordIsAllowed' => false,
'JsHash' => \md5(\RainLoop\Utils::GetConnectionToken()),
'UseSieve' => $this->UseSieve(),
'UseImapThread' => (bool) $oConfig->Get('labs', 'use_imap_thread', false),
'UseImapSubscribe' => (bool) $oConfig->Get('labs', 'use_imap_list_subscribe', true),
'AllowAppendMessage' => (bool) $oConfig->Get('labs', 'allow_message_append', false),
@ -3188,10 +3221,27 @@ class Actions
return $aResult;
}
/**
* @return string
*/
private function getCoreChannel()
{
$sChannel = \trim(\strtolower($this->Config()->Get('labs', 'update_channel', 'stable')));
if (empty($sChannel) || !\in_array($sChannel, array('stable', 'beta')))
{
$sChannel = 'stable';
}
return $sChannel;
}
private function getCoreData(&$bReal)
{
$bReal = false;
$sRepo = APP_REPO_CORE_FILE;
$sChannel = $this->getCoreChannel();
$sRepo = \str_replace('{{channel}}', $sChannel, APP_REPO_CORE_FILE);
$oHttp = \MailSo\Base\Http::SingletonInstance();
@ -3341,11 +3391,14 @@ class Actions
}
$sVersion = empty($aData['version']) ? '' : $aData['version'];
$sType = empty($aData['channel']) ? 'stable' : $aData['channel'];
return $this->DefaultResponse(__FUNCTION__, array(
'Real' => $bReal,
'Access' => $bRainLoopAccess,
'Updatable' => $bRainLoopUpdatable,
'Channel' => $this->getCoreChannel(),
'Type' => $sType,
'Version' => APP_VERSION,
'RemoteVersion' => $sVersion,
'RemoteRelease' => empty($aData['release']) ? '' : $aData['release'],
@ -6058,19 +6111,19 @@ class Actions
* @param string $sFileName
* @param string $sContentType
* @param string $sMimeIndex
* @param int $iMaxLength = 250
*
* @return string
*/
public function MainClearFileName($sFileName, $sContentType, $sMimeIndex)
public function MainClearFileName($sFileName, $sContentType, $sMimeIndex, $iMaxLength = 250)
{
$sFileName = 0 === strlen($sFileName) ? preg_replace('/[^a-zA-Z0-9]/', '.', (empty($sMimeIndex) ? '' : $sMimeIndex.'.').$sContentType) : $sFileName;
$sClearedFileName = preg_replace('/[\s]+/', ' ', preg_replace('/[\.]+/', '.', $sFileName));
$sFileName = 0 === \strlen($sFileName) ? \preg_replace('/[^a-zA-Z0-9]/', '.', (empty($sMimeIndex) ? '' : $sMimeIndex.'.').$sContentType) : $sFileName;
$sClearedFileName = \preg_replace('/[\s]+/', ' ', \preg_replace('/[\.]+/', '.', $sFileName));
$sExt = \MailSo\Base\Utils::GetFileExtension($sClearedFileName);
$iSize = 50;
if ($iSize < strlen($sClearedFileName) - strlen($sExt))
if (10 < $iMaxLength && $iMaxLength < \strlen($sClearedFileName) - \strlen($sExt))
{
$sClearedFileName = substr($sClearedFileName, 0, $iSize).(empty($sExt) ? '' : '.'.$sExt);
$sClearedFileName = \substr($sClearedFileName, 0, $iMaxLength).(empty($sExt) ? '' : '.'.$sExt);
}
return \MailSo\Base\Utils::ClearFileName(\MailSo\Base\Utils::Utf8Clear($sClearedFileName));
@ -6787,9 +6840,15 @@ class Actions
{
$oConfig = $this->Config();
$aResult = array(
// \RainLoop\Enumerations\Capa::FILTERS
);
$aResult = array();
if ($this->UseSieve())
{
if ($bAdmin || ($oAccount && $oAccount->Domain()->UseSieve()))
{
$aResult[] = \RainLoop\Enumerations\Capa::SIEVE;
}
}
if ($oConfig->Get('webmail', 'allow_additional_accounts', false))
{

View file

@ -97,13 +97,22 @@ class Api
\MailSo\Config::$SystemLogger = \RainLoop\Api::Logger();
$sSslCafile = \RainLoop\Api::Config()->Get('ssl', 'cafile', '');
if (!empty($sSslCafile))
$sSslCapath = \RainLoop\Api::Config()->Get('ssl', 'capath', '');
if (!empty($sSslCafile) || !empty($sSslCapath))
{
\MailSo\Hooks::Add('Net.NetClient.StreamContextSettings/Filter', function (&$aStreamContextSettings) use ($sSslCafile) {
if (isset($aStreamContextSettings['ssl']) && \is_array($aStreamContextSettings['ssl']) &&
empty($aStreamContextSettings['ssl']['cafile']))
\MailSo\Hooks::Add('Net.NetClient.StreamContextSettings/Filter', function (&$aStreamContextSettings) use ($sSslCafile, $sSslCapath) {
if (isset($aStreamContextSettings['ssl']) && \is_array($aStreamContextSettings['ssl']))
{
$aStreamContextSettings['ssl']['cafile'] = $sSslCafile;
if (empty($aStreamContextSettings['ssl']['cafile']) && !empty($sSslCafile))
{
$aStreamContextSettings['ssl']['cafile'] = $sSslCafile;
}
if (empty($aStreamContextSettings['ssl']['capath']) && !empty($sSslCapath))
{
$aStreamContextSettings['ssl']['capath'] = $sSslCapath;
}
}
});
}

View file

@ -119,6 +119,7 @@ class Application extends \RainLoop\Config\AbstractConfig
'ssl' => array(
'verify_certificate' => array(false, 'Require verification of SSL certificate used.'),
'cafile' => array('', 'Location of Certificate Authority file on local filesystem (/etc/ssl/certs/ca-certificates.crt)'),
'capath' => array('', 'capath must be a correctly hashed certificate directory. (/etc/ssl/certs/)'),
),
'login' => array(
@ -233,6 +234,7 @@ Enables caching in the system'),
'Experimental settings. Handle with care.
'),
'check_new_password_strength' => array(true),
'update_channel' => array('stable'),
'allow_gravatar' => array(true),
'allow_prefetch' => array(true),
'allow_smart_html_links' => array(true),

View file

@ -11,7 +11,7 @@ class Capa
const GRAVATAR = 'GRAVATAR';
const THEMES = 'THEMES';
const USER_BACKGROUND = 'USER_BACKGROUND';
const FILTERS = 'FILTERS';
const SIEVE = 'SIEVE';
const ADDITIONAL_ACCOUNTS = 'ADDITIONAL_ACCOUNTS';
const ADDITIONAL_IDENTITIES = 'ADDITIONAL_IDENTITIES';
}

View file

@ -68,11 +68,6 @@ class Domain
*/
private $bUseSieve;
/**
* @var bool
*/
private $bUseImapServerForSieve;
/**
* @var string
*/
@ -100,7 +95,6 @@ class Domain
* @param int $iIncSecure
* @param bool $bIncShortLogin
* @param bool $bUseSieve
* @param bool $bUseImapServerForSieve
* @param string $sSieveHost
* @param int $iSievePort
* @param int $iSieveSecure
@ -114,7 +108,7 @@ class Domain
*/
private function __construct($sName,
$sIncHost, $iIncPort, $iIncSecure, $bIncShortLogin,
$bUseSieve, $bUseImapServerForSieve, $sSieveHost, $iSievePort, $iSieveSecure,
$bUseSieve, $sSieveHost, $iSievePort, $iSieveSecure,
$sOutHost, $iOutPort, $iOutSecure, $bOutShortLogin, $bOutAuth, $bOutUsePhpMail = false,
$sWhiteList = '')
{
@ -132,7 +126,6 @@ class Domain
$this->bOutUsePhpMail = $bOutUsePhpMail;
$this->bUseSieve = $bUseSieve;
$this->bUseImapServerForSieve = $bUseImapServerForSieve;
$this->sSieveHost = $sSieveHost;
$this->iSievePort = $iSievePort;
$this->iSieveSecure = $iSieveSecure;
@ -147,7 +140,6 @@ class Domain
* @param int $iIncSecure
* @param bool $bIncShortLogin
* @param bool $bUseSieve
* @param bool $bUseImapServerForSieve
* @param string $sSieveHost
* @param int $iSievePort
* @param int $iSieveSecure
@ -163,13 +155,13 @@ class Domain
*/
public static function NewInstance($sName,
$sIncHost, $iIncPort, $iIncSecure, $bIncShortLogin,
$bUseSieve, $bUseImapServerForSieve, $sSieveHost, $iSievePort, $iSieveSecure,
$bUseSieve, $sSieveHost, $iSievePort, $iSieveSecure,
$sOutHost, $iOutPort, $iOutSecure, $bOutShortLogin, $bOutAuth, $bOutUsePhpMail,
$sWhiteList = '')
{
return new self($sName,
$sIncHost, $iIncPort, $iIncSecure, $bIncShortLogin,
$bUseSieve, $bUseImapServerForSieve, $sSieveHost, $iSievePort, $iSieveSecure,
$bUseSieve, $sSieveHost, $iSievePort, $iSieveSecure,
$sOutHost, $iOutPort, $iOutSecure, $bOutShortLogin, $bOutAuth, $bOutUsePhpMail,
$sWhiteList);
}
@ -191,6 +183,8 @@ class Domain
$iIncSecure = self::StrConnectionSecurityTypeToCons(
!empty($aDomain['imap_secure']) ? $aDomain['imap_secure'] : '');
$bUseSieve = isset($aDomain['sieve_use']) ? (bool) $aDomain['sieve_use'] : false;
$sSieveHost = empty($aDomain['sieve_host']) ? '' : (string) $aDomain['sieve_host'];
$iSievePort = empty($aDomain['sieve_port']) ? 2000 : (int) $aDomain['sieve_port'];
$iSieveSecure = self::StrConnectionSecurityTypeToCons(
@ -205,15 +199,12 @@ class Domain
$bOutUsePhpMail = isset($aDomain['smtp_php_mail']) ? (bool) $aDomain['smtp_php_mail'] : false;
$sWhiteList = (string) (isset($aDomain['white_list']) ? $aDomain['white_list'] : '');
$bUseSieve = isset($aDomain['sieve_use']) ? (bool) $aDomain['sieve_use'] : false;
$bUseImapServerForSieve = isset($aDomain['sieve_use_imap_server']) ? (bool) $aDomain['sieve_use_imap_server'] : true;
$bIncShortLogin = isset($aDomain['imap_short_login']) ? (bool) $aDomain['imap_short_login'] : false;
$bOutShortLogin = isset($aDomain['smtp_short_login']) ? (bool) $aDomain['smtp_short_login'] : false;
$oDomain = self::NewInstance($sName,
$sIncHost, $iIncPort, $iIncSecure, $bIncShortLogin,
$bUseSieve, $bUseImapServerForSieve, $sSieveHost, $iSievePort, $iSieveSecure,
$bUseSieve, $sSieveHost, $iSievePort, $iSieveSecure,
$sOutHost, $iOutPort, $iOutSecure, $bOutShortLogin, $bOutAuth, $bOutUsePhpMail,
$sWhiteList);
}
@ -266,7 +257,6 @@ class Domain
'imap_secure = "'.self::ConstConnectionSecurityTypeToStr($this->iIncSecure).'"',
'imap_short_login = '.($this->bIncShortLogin ? 'On' : 'Off'),
'sieve_use = '.($this->bUseSieve ? 'On' : 'Off'),
'sieve_use_imap_server = '.($this->bUseImapServerForSieve ? 'On' : 'Off'),
'sieve_host = "'.$this->encodeIniString($this->sSieveHost).'"',
'sieve_port = '.$this->iSievePort,
'sieve_secure = "'.self::ConstConnectionSecurityTypeToStr($this->iSieveSecure).'"',
@ -327,7 +317,6 @@ class Domain
* @param int $iIncSecure
* @param bool $bIncShortLogin
* @param bool $bUseSieve
* @param bool $bUseImapServerForSieve
* @param string $sOutHost
* @param int $iOutPort
* @param int $iOutSecure
@ -340,7 +329,7 @@ class Domain
*/
public function UpdateInstance(
$sIncHost, $iIncPort, $iIncSecure, $bIncShortLogin,
$bUseSieve, $bUseImapServerForSieve, $sSieveHost, $iSievePort, $iSieveSecure,
$bUseSieve, $sSieveHost, $iSievePort, $iSieveSecure,
$sOutHost, $iOutPort, $iOutSecure, $bOutShortLogin, $bOutAuth, $bOutUsePhpMail,
$sWhiteList = '')
{
@ -350,7 +339,6 @@ class Domain
$this->bIncShortLogin = $bIncShortLogin;
$this->bUseSieve = $bUseSieve;
$this->bUseImapServerForSieve = $bUseImapServerForSieve;
$this->sSieveHost = \MailSo\Base\Utils::IdnToAscii($sSieveHost);
$this->iSievePort = $iSievePort;
$this->iSieveSecure = $iSieveSecure;
@ -415,14 +403,6 @@ class Domain
return $this->bUseSieve;
}
/**
* @return bool
*/
public function UseImapServerForSieve()
{
return $this->bUseImapServerForSieve;
}
/**
* @return string
*/
@ -541,7 +521,6 @@ class Domain
'IncSecure' => $this->IncSecure(),
'IncShortLogin' => $this->IncShortLogin(),
'UseSieve' => $this->UseSieve(),
'UseImapServerForSieve' => $this->UseImapServerForSieve(),
'SieveHost' => $bAjax ? \MailSo\Base\Utils::IdnToUtf8($this->SieveHost()) : $this->SieveHost(),
'SievePort' => $this->SievePort(),
'SieveSecure' => $this->SieveSecure(),

View file

@ -130,15 +130,15 @@ abstract class AbstractPlugin
{
return array();
}
/**
* @return string
*/
public function Hash()
{
return \md5($this->sVersion);
return \md5($this->sName.'@'.$this->sVersion);
}
/**
* @return string
*/
@ -146,7 +146,7 @@ abstract class AbstractPlugin
{
return '';
}
/**
* @final
* @return array
@ -161,22 +161,41 @@ abstract class AbstractPlugin
$this->aConfigMap = array();
}
}
return $this->aConfigMap;
}
/**
* @param string $sPath
* @param string $sName
* @param string $sVersion = ''
*
* @return self
*/
public function SetValues($sPath, $sName, $sVersion = '')
public function SetPath($sPath)
{
$this->sName = $sName;
$this->sPath = $sPath;
return $this;
}
/**
* @param string $sName
*
* @return self
*/
public function SetName($sName)
{
$this->sName = $sName;
return $this;
}
/**
* @param string $sVersion
*
* @return self
*/
public function SetVersion($sVersion)
{
if (0 < \strlen($sVersion))
{
$this->sVersion = $sVersion;
@ -222,14 +241,14 @@ abstract class AbstractPlugin
*/
public function Init()
{
}
/**
* @param bool $bAdmin
* @param bool $bAuth
* @param array $aConfig
*
*
* @return void
*/
public function FilterAppDataPluginSection($bAdmin, $bAuth, &$aConfig)

View file

@ -107,13 +107,15 @@ class Manager
}
}
}
$this->RunHook('api.bootstrap.plugins');
}
}
/**
* @param string $sName
*
* @return \RainLoop\Plugins\AbstractPlugin | null
* @return \RainLoop\Plugins\AbstractPlugin|null
*/
public function CreatePluginByName($sName)
{
@ -134,9 +136,10 @@ class Manager
if ($oPlugin instanceof \RainLoop\Plugins\AbstractPlugin)
{
$oPlugin
->SetValues(APP_PLUGINS_PATH.$sName, $sName,
\file_exists(APP_PLUGINS_PATH.$sName.'/VERSION') ?
\file_get_contents(APP_PLUGINS_PATH.$sName.'/VERSION') : '')
->SetName($sName)
->SetPath(APP_PLUGINS_PATH.$sName)
->SetVersion(\file_exists(APP_PLUGINS_PATH.$sName.'/VERSION') ?
\file_get_contents(APP_PLUGINS_PATH.$sName.'/VERSION') : '')
->SetPluginManager($this)
->SetPluginConfig(new \RainLoop\Config\Plugin($sName, $oPlugin->ConfigMap()))
;
@ -167,9 +170,8 @@ class Manager
if (\preg_match('/^[a-z0-9\-]+$/', $sName) &&
\file_exists($sPathName.'/index.php'))
{
$sVersion = @\file_get_contents($sPathName.'/VERSION');
$aList[] = array(
$sName, $sVersion
$sName, @\file_get_contents($sPathName.'/VERSION')
);
}
}
@ -205,7 +207,7 @@ class Manager
}
/**
* @return \RainLoop\Actions
* @return string
*/
public function Hash()
{
@ -231,14 +233,14 @@ class Manager
$aJs = $bAdminScope ? $this->aAdminJs : $this->aJs;
foreach ($aJs as $sFile)
{
if (file_exists($sFile))
if (\file_exists($sFile))
{
$aResult[] = file_get_contents($sFile);
$aResult[] = \file_get_contents($sFile);
}
}
}
return implode("\n", $aResult);
return \implode("\n", $aResult);
}
/**
@ -279,12 +281,13 @@ class Manager
/**
* @param bool $bAdmin
* @param array $aAppData
* @param \RainLoop\Model\Account|null $oAccount = null
*
* @return \RainLoop\Plugins\Manager
*/
public function InitAppData($bAdmin, &$aAppData, $oAccount = null)
{
if ($this->bIsEnabled && isset($aAppData['Plugins']) && is_array($aAppData['Plugins']))
if ($this->bIsEnabled && isset($aAppData['Plugins']) && \is_array($aAppData['Plugins']))
{
$bAuth = isset($aAppData['Auth']) && !!$aAppData['Auth'];
foreach ($this->aPlugins as $oPlugin)
@ -317,6 +320,12 @@ class Manager
}
$this->RunHook('filter.app-data', array($bAdmin, &$aAppData));
$this->RunHook('filter.app-data[2]', array(
'IsAdmin' => $bAdmin,
'AppData' => &$aAppData,
'Account' => $oAccount
));
}
return $this;
@ -330,7 +339,7 @@ class Manager
*/
public function AddHook($sHookName, $mCallbak)
{
if ($this->bIsEnabled && is_callable($mCallbak))
if ($this->bIsEnabled && \is_callable($mCallbak))
{
if (!isset($this->aHooks[$sHookName]))
{
@ -407,9 +416,9 @@ class Manager
$this->WriteLog('Hook: '.$sHookName, \MailSo\Log\Enumerations\Type::NOTE);
}
foreach ($this->aHooks[$sHookName] as $mCallbak)
foreach ($this->aHooks[$sHookName] as $mCallback)
{
call_user_func_array($mCallbak, $aArg);
\call_user_func_array($mCallback, $aArg);
}
}
}
@ -491,11 +500,11 @@ class Manager
if ($bPrepend)
{
array_unshift($this->aProcessTemplate[$sName][$sPlace], $sHtml);
\array_unshift($this->aProcessTemplate[$sName][$sPlace], $sHtml);
}
else
{
array_push($this->aProcessTemplate[$sName][$sPlace], $sHtml);
\array_push($this->aProcessTemplate[$sName][$sPlace], $sHtml);
}
}
@ -510,7 +519,7 @@ class Manager
*/
public function AddAdditionalAjaxAction($sActionName, $mCallbak)
{
if ($this->bIsEnabled && is_callable($mCallbak) && 0 < strlen($sActionName))
if ($this->bIsEnabled && \is_callable($mCallbak) && 0 < \strlen($sActionName))
{
$sActionName = 'Do'.$sActionName;
@ -544,7 +553,7 @@ class Manager
{
if (isset($this->aAdditionalAjax[$sActionName]))
{
return call_user_func($this->aAdditionalAjax[$sActionName]);
return \call_user_func($this->aAdditionalAjax[$sActionName]);
}
}
@ -641,29 +650,29 @@ class Manager
/**
* @param string $sDesc
* @param int $iDescType = \MailSo\Log\Enumerations\Type::INFO
* @param int $iType = \MailSo\Log\Enumerations\Type::INFO
*
* @return void
*/
public function WriteLog($sDesc, $iDescType = \MailSo\Log\Enumerations\Type::INFO)
public function WriteLog($sDesc, $iType = \MailSo\Log\Enumerations\Type::INFO)
{
if ($this->oLogger)
{
$this->oLogger->Write($sDesc, $iDescType, 'PLUGIN');
$this->oLogger->Write($sDesc, $iType, 'PLUGIN');
}
}
/**
* @param string $sDesc
* @param int $iDescType = \MailSo\Log\Enumerations\Type::INFO
* @param int $iType = \MailSo\Log\Enumerations\Type::INFO
*
* @return void
*/
public function WriteException($sDesc, $iDescType = \MailSo\Log\Enumerations\Type::INFO)
public function WriteException($sDesc, $iType = \MailSo\Log\Enumerations\Type::INFO)
{
if ($this->oLogger)
{
$this->oLogger->WriteException($sDesc, $iDescType, 'PLUGIN');
$this->oLogger->WriteException($sDesc, $iType, 'PLUGIN');
}
}
}

View file

@ -1,340 +0,0 @@
<?php
namespace RainLoop\PluginsNext;
abstract class AbstractPlugin
{
/**
* @var \RainLoop\PluginsNext\Manager
*/
private $oPluginManager;
/**
* @var \RainLoop\Config\Plugin
*/
private $oPluginConfig;
/**
* @var bool
*/
private $bLangs;
/**
* @var string
*/
private $sName;
/**
* @var string
*/
private $sPath;
/**
* @var string
*/
private $sVersion;
/**
* @var array
*/
private $aConfigMap;
/**
* @var bool
*/
private $bPluginConfigLoaded;
public function __construct()
{
$this->sName = '';
$this->sPath = '';
$this->sVersion = '0.0';
$this->aConfigMap = null;
$this->oPluginManager = null;
$this->oPluginConfig = null;
$this->bPluginConfigLoaded = false;
$this->bLangs = false;
}
/**
* @return \RainLoop\Config\Plugin
*/
public function Config()
{
if (!$this->bPluginConfigLoaded && $this->oPluginConfig)
{
$this->bPluginConfigLoaded = true;
if ($this->oPluginConfig->IsInited())
{
if (!$this->oPluginConfig->Load())
{
$this->oPluginConfig->Save();
}
}
}
return $this->oPluginConfig;
}
/**
* @return \RainLoop\PluginsNext\Manager
*/
public function Manager()
{
return $this->oPluginManager;
}
/**
* @return string
*/
public function Path()
{
return $this->sPath;
}
/**
* @return string
*/
public function Name()
{
return $this->sName;
}
/**
* @return string
*/
public function Version()
{
return $this->sVersion;
}
/**
* @param bool|null $bLangs = null
* @return bool
*/
public function UseLangs($bLangs = null)
{
if (null !== $bLangs)
{
$this->bLangs = (bool) $bLangs;
}
return $this->bLangs;
}
/**
* @return array
*/
protected function configMapping()
{
return array();
}
/**
* @return string
*/
public function Hash()
{
return \md5($this->sVersion);
}
/**
* @return string
*/
public function Supported()
{
return '';
}
/**
* @final
* @return array
*/
final public function ConfigMap()
{
if (null === $this->aConfigMap)
{
$this->aConfigMap = $this->configMapping();
if (!\is_array($this->aConfigMap))
{
$this->aConfigMap = array();
}
}
return $this->aConfigMap;
}
/**
* @param string $sPath
* @param string $sName
* @param string $sVersion = ''
*
* @return self
*/
public function SetValues($sPath, $sName, $sVersion = '')
{
$this->sName = $sName;
$this->sPath = $sPath;
if (0 < \strlen($sVersion))
{
$this->sVersion = $sVersion;
}
return $this;
}
/**
* @param \RainLoop\PluginsNext\Manager $oPluginManager
*
* @return self
*/
public function SetPluginManager(\RainLoop\PluginsNext\Manager $oPluginManager)
{
$this->oPluginManager = $oPluginManager;
return $this;
}
/**
* @param \RainLoop\Config\Plugin $oPluginConfig
*
* @return self
*/
public function SetPluginConfig(\RainLoop\Config\Plugin $oPluginConfig)
{
$this->oPluginConfig = $oPluginConfig;
return $this;
}
/**
* @return self
*/
public function Init()
{
}
/**
* @param string $sStep
*
* @return self
*/
public function InitStep($sStep)
{
}
/**
* @param bool $bAdmin
* @param bool $bAuth
* @param array $aConfig
*
* @return void
*/
public function FilterAppDataPluginSection($bAdmin, $bAuth, &$aConfig)
{
}
/**
* @param string $sHookName
* @param string $sFunctionName
*
* @return self
*/
protected function addHook($sHookName, $sFunctionName)
{
if ($this->oPluginManager)
{
$this->oPluginManager->AddHook($sHookName, array(&$this, $sFunctionName));
}
return $this;
}
/**
* @param string $sFile
* @param bool $bAdminScope = false
*
* @return self
*/
protected function addJs($sFile, $bAdminScope = false)
{
if ($this->oPluginManager)
{
$this->oPluginManager->AddJs($this->sPath.'/'.$sFile, $bAdminScope);
}
return $this;
}
/**
* @param string $sFile
* @param bool $bAdminScope = false
*
* @return self
*/
protected function addTemplate($sFile, $bAdminScope = false)
{
if ($this->oPluginManager)
{
$this->oPluginManager->AddTemplate($this->sPath.'/'.$sFile, $bAdminScope);
}
return $this;
}
/**
* @param string $sActionName
* @param string $sFunctionName
*
* @return self
*/
protected function addPartHook($sActionName, $sFunctionName)
{
if ($this->oPluginManager)
{
$this->oPluginManager->AddAdditionalPartAction($sActionName, array(&$this, $sFunctionName));
}
return $this;
}
/**
* @param string $sActionName
* @param string $sFunctionName
*
* @return self
*/
protected function addAjaxHook($sActionName, $sFunctionName)
{
if ($this->oPluginManager)
{
$this->oPluginManager->AddAdditionalAjaxAction($sActionName, array(&$this, $sFunctionName));
}
return $this;
}
/**
* @param string $sName
* @param string $sPlace
* @param string $sLocalTemplateName
* @param bool $bPrepend = false
*
* @return self
*/
protected function addTemplateHook($sName, $sPlace, $sLocalTemplateName, $bPrepend = false)
{
if ($this->oPluginManager)
{
$this->oPluginManager->AddProcessTemplateAction($sName, $sPlace,
'<!-- ko template: \''.$sLocalTemplateName.'\' --><!-- /ko -->', $bPrepend);
}
return $this;
}
}

View file

@ -1,685 +0,0 @@
<?php
namespace RainLoop\PluginsNext;
class Manager
{
/**
* @var \RainLoop\Actions
*/
private $oActions;
/**
* @var array
*/
private $aHooks;
/**
* @var array
*/
private $aJs;
/**
* @var array
*/
private $aAdminJs;
/**
* @var array
*/
private $aTemplates;
/**
* @var array
*/
private $aAdminTemplates;
/**
* @var array
*/
private $aProcessTemplate;
/**
* @var array
*/
private $aAdditionalParts;
/**
* @var array
*/
private $aAdditionalAjax;
/**
* @var array
*/
private $aPlugins;
/**
* @var bool
*/
private $bIsEnabled;
/**
* @var \MailSo\Log\Logger
*/
private $oLogger;
/**
* @param \RainLoop\Actions $oActions
*/
public function __construct(\RainLoop\Actions $oActions)
{
$this->oLogger = null;
$this->oActions = $oActions;
$this->aPlugins = array();
$this->aHooks = array();
$this->aJs = array();
$this->aAdminJs = array();
$this->aTemplates = array();
$this->aAdminTemplates = array();
$this->aAjaxFilters = array();
$this->aAdditionalAjax = array();
$this->aProcessTemplate = array();
$this->bIsEnabled = (bool) $this->oActions->Config()->Get('plugins', 'enable', false);
if ($this->bIsEnabled)
{
$sList = \strtolower($this->oActions->Config()->Get('plugins', 'enabled_list', ''));
if (0 < \strlen($sList))
{
$aList = \explode(',', $sList);
$aList = \array_map('trim', $aList);
foreach ($aList as $sName)
{
if (0 < \strlen($sName))
{
$oPlugin = $this->CreatePluginByName($sName);
if ($oPlugin)
{
$oPlugin->InitStep('step1');
$oPlugin->Init();
$oPlugin->InitStep('step2');
$this->aPlugins[] = $oPlugin;
$oPlugin->InitStep('spep3');
}
}
}
}
$this->RunHook('api.bootstrap.plugins');
}
}
/**
* @param string $sName
*
* @return \RainLoop\Plugins\AbstractPlugin|null
*/
public function CreatePluginByName($sName)
{
$oPlugin = null;
if (\preg_match('/^[a-z0-9\-]+$/', $sName) &&
\file_exists(APP_PLUGINS_PATH.$sName.'/index.php'))
{
$sClassName = $this->convertPluginFolderNameToClassName($sName);
if (!\class_exists($sClassName))
{
include APP_PLUGINS_PATH.$sName.'/index.php';
}
if (\class_exists($sClassName))
{
$oPlugin = new $sClassName();
if ($oPlugin instanceof \RainLoop\PluginsNext\AbstractPlugin)
{
$oPlugin
->SetValues(APP_PLUGINS_PATH.$sName, $sName,
\file_exists(APP_PLUGINS_PATH.$sName.'/VERSION') ?
\file_get_contents(APP_PLUGINS_PATH.$sName.'/VERSION') : '')
->SetPluginManager($this)
->SetPluginConfig(new \RainLoop\Config\Plugin($sName, $oPlugin->ConfigMap()))
;
}
else
{
$oPlugin = null;
}
}
}
return $oPlugin;
}
/**
* @return array
*/
public function InstalledPlugins()
{
$aList = array();
$aGlob = @\glob(APP_PLUGINS_PATH.'*', GLOB_ONLYDIR|GLOB_NOSORT);
if (\is_array($aGlob))
{
foreach ($aGlob as $sPathName)
{
$sName = \basename($sPathName);
if (\preg_match('/^[a-z0-9\-]+$/', $sName) &&
\file_exists($sPathName.'/index.php'))
{
$aList[] = array(
$sName, @\file_get_contents($sPathName.'/VERSION')
);
}
}
}
else
{
$this->Actions()->Logger()->Write('Cannot get installed plugins from '.APP_PLUGINS_PATH,
\MailSo\Log\Enumerations\Type::ERROR);
}
return $aList;
}
/**
* @param string $sFolderName
*
* @return string
*/
private function convertPluginFolderNameToClassName($sFolderName)
{
$aParts = \array_map('ucfirst', \array_map('strtolower',
\explode(' ', \preg_replace('/[^a-z0-9]+/', ' ', $sFolderName))));
return \implode($aParts).'Plugin';
}
/**
* @return \RainLoop\Actions
*/
public function Actions()
{
return $this->oActions;
}
/**
* @return string
*/
public function Hash()
{
$sResult = \md5(APP_VERSION);
foreach ($this->aPlugins as $oPlugin)
{
$sResult = \md5($sResult.$oPlugin->Path().$oPlugin->Hash());
}
return $sResult;
}
/**
* @param bool $bAdminScope = false
*
* @return string
*/
public function CompileJs($bAdminScope = false)
{
$aResult = array();
if ($this->bIsEnabled)
{
$aJs = $bAdminScope ? $this->aAdminJs : $this->aJs;
foreach ($aJs as $sFile)
{
if (\file_exists($sFile))
{
$aResult[] = \file_get_contents($sFile);
}
}
}
return \implode("\n", $aResult);
}
/**
* @todo
* @param bool $bAdminScope = false
*
* @return string
*/
public function CompileCss($bAdminScope = false)
{
return '';
}
/**
* @param bool $bAdminScope = false
* @return string
*/
public function CompileTemplate($bAdminScope = false)
{
$sResult = '';
if ($this->bIsEnabled)
{
foreach ($bAdminScope ? $this->aAdminTemplates : $this->aTemplates as $sFile)
{
if (\file_exists($sFile))
{
$sTemplateName = \substr(\basename($sFile), 0, -5);
$sResult .= '<script id="'.\preg_replace('/[^a-zA-Z0-9]/', '', $sTemplateName).'" type="text/html" data-cfasync="false">'.
$this->Actions()->ProcessTemplate($sTemplateName, \file_get_contents($sFile)).'</script>';
}
}
}
return $sResult;
}
/**
* @param bool $bAdmin
* @param array $aAppData
* @param \RainLoop\Model\Account|null $oAccount = null
*
* @return \RainLoop\PluginsNext\Manager
*/
public function InitAppData($bAdmin, &$aAppData, $oAccount = null)
{
if ($this->bIsEnabled && isset($aAppData['Plugins']) && \is_array($aAppData['Plugins']))
{
$bAuth = isset($aAppData['Auth']) && !!$aAppData['Auth'];
foreach ($this->aPlugins as $oPlugin)
{
if ($oPlugin)
{
$aConfig = array();
$aMap = $oPlugin->ConfigMap();
if (\is_array($aMap))
{
foreach ($aMap as /* @var $oPluginProperty \RainLoop\PluginsNext\Property */$oPluginProperty)
{
if ($oPluginProperty && $oPluginProperty->AllowedInJs())
{
$aConfig[$oPluginProperty->Name()] =
$oPlugin->Config()->Get('plugin',
$oPluginProperty->Name(),
$oPluginProperty->DefaultValue());
}
}
}
$oPlugin->FilterAppDataPluginSection($bAdmin, $bAuth, $aConfig);
if (0 < \count($aConfig))
{
$aAppData['Plugins'][$oPlugin->Name()] = $aConfig;
}
}
}
$this->RunHook('filter.app-data', array(
'IsAdmin' => $bAdmin,
'AppData' => &$aAppData
), $oAccount);
}
return $this;
}
/**
* @param string $sHookName
* @param mixed $mCallbak
*
* @return \RainLoop\PluginsNext\Manager
*/
public function AddHook($sHookName, $mCallbak)
{
if ($this->bIsEnabled && \is_callable($mCallbak))
{
if (!isset($this->aHooks[$sHookName]))
{
$this->aHooks[$sHookName] = array();
}
$this->aHooks[$sHookName][] = $mCallbak;
}
return $this;
}
/**
* @param string $sFile
* @param bool $bAdminScope = false
*
* @return \RainLoop\PluginsNext\Manager
*/
public function AddJs($sFile, $bAdminScope = false)
{
if ($this->bIsEnabled)
{
if ($bAdminScope)
{
$this->aAdminJs[$sFile] = $sFile;
}
else
{
$this->aJs[$sFile] = $sFile;
}
}
return $this;
}
/**
* @param string $sFile
* @param bool $bAdminScope = false
*
* @return \RainLoop\PluginsNext\Manager
*/
public function AddTemplate($sFile, $bAdminScope = false)
{
if ($this->bIsEnabled)
{
if ($bAdminScope)
{
$this->aAdminTemplates[$sFile] = $sFile;
}
else
{
$this->aTemplates[$sFile] = $sFile;
}
}
return $this;
}
/**
* @param string $sHookName
* @param array $aArg = array()
* @param \RainLoop\Model\Account|null $oAccount = null
* @param bool $bLogHook = true
*
* @return \RainLoop\PluginsNext\Manager
*/
public function RunHook($sHookName, $aArg = array(), $oAccount = null, $bLogHook = true)
{
if ($this->bIsEnabled)
{
if (isset($this->aHooks[$sHookName]))
{
if ($bLogHook)
{
$this->WriteLog('Hook: '.$sHookName, \MailSo\Log\Enumerations\Type::NOTE);
}
$bArgArray = 0 < \count($aArg);
foreach ($this->aHooks[$sHookName] as $mCallbak)
{
if ($bArgArray)
{
\call_user_func_array($mCallbak, array($aArg));
}
else
{
\call_user_func($mCallbak);
}
}
}
}
return $this;
}
/**
* @param string $sActionName
* @param mixed $mCallbak
*
* @return \RainLoop\PluginsNext\Manager
*/
public function AddAdditionalPartAction($sActionName, $mCallbak)
{
if ($this->bIsEnabled && \is_callable($mCallbak))
{
$sActionName = \strtolower($sActionName);
if (!isset($this->aAdditionalParts[$sActionName]))
{
$this->aAdditionalParts[$sActionName] = array();
}
$this->aAdditionalParts[$sActionName][] = $mCallbak;
}
return $this;
}
/**
* @param string $sActionName
* @param array $aParts = array()
*
* @return \RainLoop\PluginsNext\Manager
*/
public function RunAdditionalPart($sActionName, $aParts = array())
{
$bResult = false;
if ($this->bIsEnabled)
{
$sActionName = \strtolower($sActionName);
if (isset($this->aAdditionalParts[$sActionName]))
{
foreach ($this->aAdditionalParts[$sActionName] as $mCallbak)
{
$bCallResult = \call_user_func_array($mCallbak, $aParts);
if ($bCallResult && !$bResult)
{
$bResult = true;
}
}
}
}
return $bResult;
}
/**
* @param string $sName
* @param string $sPlace
* @param string $sHtml
* @param bool $bPrepend = false
*
* @return \RainLoop\PluginsNext\Manager
*/
public function AddProcessTemplateAction($sName, $sPlace, $sHtml, $bPrepend = false)
{
if ($this->bIsEnabled)
{
if (!isset($this->aProcessTemplate[$sName]))
{
$this->aProcessTemplate[$sName] = array();
}
if (!isset($this->aProcessTemplate[$sName][$sPlace]))
{
$this->aProcessTemplate[$sName][$sPlace] = array();
}
if ($bPrepend)
{
\array_unshift($this->aProcessTemplate[$sName][$sPlace], $sHtml);
}
else
{
\array_push($this->aProcessTemplate[$sName][$sPlace], $sHtml);
}
}
return $this;
}
/**
* @param string $sActionName
* @param mixed $mCallbak
*
* @return \RainLoop\Plugins\Manager
*/
public function AddAdditionalAjaxAction($sActionName, $mCallbak)
{
if ($this->bIsEnabled && \is_callable($mCallbak) && 0 < \strlen($sActionName))
{
$sActionName = 'Do'.$sActionName;
if (!isset($this->aAdditionalAjax[$sActionName]))
{
$this->aAdditionalAjax[$sActionName] = $mCallbak;
}
}
return $this;
}
/**
* @param string $sActionName
*
* @return bool
*/
public function HasAdditionalAjax($sActionName)
{
return $this->bIsEnabled && isset($this->aAdditionalAjax[$sActionName]);
}
/**
* @param string $sActionName
*
* @return mixed
*/
public function RunAdditionalAjax($sActionName)
{
if ($this->bIsEnabled)
{
if (isset($this->aAdditionalAjax[$sActionName]))
{
return \call_user_func($this->aAdditionalAjax[$sActionName]);
}
}
return false;
}
/**
* @param string $sLang
* @param array $sActionName
*
* @return \RainLoop\PluginsNext\Manager
*/
public function ReadLang($sLang, &$aLang)
{
if ($this->bIsEnabled)
{
foreach ($this->aPlugins as $oPlugin)
{
if ($oPlugin->UseLangs())
{
$sPath = $oPlugin->Path();
\RainLoop\Utils::ReadAndAddLang($sPath.'/langs/en.ini', $aLang);
if ('en' !== $sLang)
{
\RainLoop\Utils::ReadAndAddLang($sPath.'/langs/'.$sLang.'.ini', $aLang);
}
}
}
}
return $this;
}
/**
* @param string $sName
* @param string $sHtml
*
* @return string
*/
public function ProcessTemplate($sName, $sHtml)
{
if (isset($this->aProcessTemplate[$sName]))
{
foreach ($this->aProcessTemplate[$sName] as $sPlace => $aAddHtml)
{
if (\is_array($aAddHtml) && 0 < \count($aAddHtml))
{
foreach ($aAddHtml as $sAddHtml)
{
$sHtml = \str_replace('{{INCLUDE/'.$sPlace.'/PLACE}}', $sAddHtml.'{{INCLUDE/'.$sPlace.'/PLACE}}', $sHtml);
}
}
}
}
return $sHtml;
}
/**
* @return bool
*/
public function bIsEnabled()
{
return $this->bIsEnabled;
}
/**
* @return int
*/
public function Count()
{
return $this->bIsEnabled ? \count($this->aPlugins) : 0;
}
/**
* @param \MailSo\Log\Logger $oLogger
*
* @return \RainLoop\PluginsNext\Manager
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
*/
public function SetLogger($oLogger)
{
if (!($oLogger instanceof \MailSo\Log\Logger))
{
throw new \MailSo\Base\Exceptions\InvalidArgumentException();
}
$this->oLogger = $oLogger;
return $this;
}
/**
* @param string $sDesc
* @param int $iType = \MailSo\Log\Enumerations\Type::INFO
*
* @return void
*/
public function WriteLog($sDesc, $iType = \MailSo\Log\Enumerations\Type::INFO)
{
if ($this->oLogger)
{
$this->oLogger->Write($sDesc, $iType, 'PLUGIN');
}
}
/**
* @param string $sDesc
* @param int $iType = \MailSo\Log\Enumerations\Type::INFO
*
* @return void
*/
public function WriteException($sDesc, $iType = \MailSo\Log\Enumerations\Type::INFO)
{
if ($this->oLogger)
{
$this->oLogger->WriteException($sDesc, $iType, 'PLUGIN');
}
}
}

View file

@ -1,179 +0,0 @@
<?php
namespace RainLoop\PluginsNext;
class Property
{
/**
* @var string
*/
private $sName;
/**
* @var string
*/
private $sLabel;
/**
* @var string
*/
private $sDesc;
/**
* @var int
*/
private $iType;
/**
* @var bool
*/
private $bAllowedInJs;
/**
* @var mixed
*/
private $mDefaultValue;
private function __construct($sName)
{
$this->sName = $sName;
$this->iType = \RainLoop\Enumerations\PluginPropertyType::STRING;
$this->mDefaultValue = '';
$this->sLabel = '';
$this->sDesc = '';
$this->bAllowedInJs = false;
}
/**
* @param string $sName
*
* @return \RainLoop\PluginsNext\Property
*/
public static function NewInstance($sName)
{
return new self($sName);
}
/**
* @param int $iType
*
* @return \RainLoop\PluginsNext\Property
*/
public function SetType($iType)
{
$this->iType = (int) $iType;
return $this;
}
/**
* @param mixed $mDefaultValue
*
* @return \RainLoop\PluginsNext\Property
*/
public function SetDefaultValue($mDefaultValue)
{
$this->mDefaultValue = $mDefaultValue;
return $this;
}
/**
* @param string $sLabel
*
* @return \RainLoop\PluginsNext\Property
*/
public function SetLabel($sLabel)
{
$this->sLabel = $sLabel;
return $this;
}
/**
* @param string $sDesc
*
* @return \RainLoop\PluginsNext\Property
*/
public function SetDescription($sDesc)
{
$this->sDesc = $sDesc;
return $this;
}
/**
* @param bool $bValue = true
*
* @return \RainLoop\PluginsNext\Property
*/
public function SetAllowedInJs($bValue = true)
{
$this->bAllowedInJs = !!$bValue;
return $this;
}
/**
* @return string
*/
public function Name()
{
return $this->sName;
}
/**
* @return bool
*/
public function AllowedInJs()
{
return $this->bAllowedInJs;
}
/**
* @return string
*/
public function Description()
{
return $this->sDesc;
}
/**
* @return string
*/
public function Label()
{
return $this->sLabel;
}
/**
* @return int
*/
public function Type()
{
return $this->iType;
}
/**
* @return mixed
*/
public function DefaultValue()
{
return $this->mDefaultValue;
}
/**
* @return array
*/
public function ToArray()
{
return array(
'',
$this->sName,
$this->iType,
$this->sLabel,
$this->mDefaultValue,
$this->sDesc
);
}
}

View file

@ -130,7 +130,6 @@ class Domain extends \RainLoop\Providers\AbstractProvider
$iIncSecure = (int) $oActions->GetActionParam('IncSecure', \MailSo\Net\Enumerations\ConnectionSecurityType::NONE);
$bIncShortLogin = '1' === (string) $oActions->GetActionParam('IncShortLogin', '0');
$bUseSieve = '1' === (string) $oActions->GetActionParam('UseSieve', '0');
$bUseImapServerForSieve = '1' === (string) $oActions->GetActionParam('UseImapServerForSieve', '1');
$sSieveHost = (string) $oActions->GetActionParam('SieveHost', '');
$iSievePort = (int) $oActions->GetActionParam('SievePort', 2000);
$iSieveSecure = (int) $oActions->GetActionParam('SieveSecure', \MailSo\Net\Enumerations\ConnectionSecurityType::NONE);
@ -160,7 +159,7 @@ class Domain extends \RainLoop\Providers\AbstractProvider
{
$oDomain->UpdateInstance(
$sIncHost, $iIncPort, $iIncSecure, $bIncShortLogin,
$bUseSieve, $bUseImapServerForSieve, $sSieveHost, $iSievePort, $iSieveSecure,
$bUseSieve, $sSieveHost, $iSievePort, $iSieveSecure,
$sOutHost, $iOutPort, $iOutSecure, $bOutShortLogin, $bOutAuth, $bOutUsePhpMail,
$sWhiteList);
}
@ -169,7 +168,7 @@ class Domain extends \RainLoop\Providers\AbstractProvider
{
$oDomain = \RainLoop\Model\Domain::NewInstance(0 < strlen($sNameForTest) ? $sNameForTest : $sName,
$sIncHost, $iIncPort, $iIncSecure, $bIncShortLogin,
$bUseSieve, $bUseImapServerForSieve, $sSieveHost, $iSievePort, $iSieveSecure,
$bUseSieve, $sSieveHost, $iSievePort, $iSieveSecure,
$sOutHost, $iOutPort, $iOutSecure, $bOutShortLogin, $bOutAuth, $bOutUsePhpMail,
$sWhiteList);
}

View file

@ -0,0 +1,45 @@
<?php
namespace RainLoop\Providers;
class Filters extends \RainLoop\Providers\AbstractProvider
{
/**
* @var \RainLoop\Providers\Filters\FiltersInterface
*/
private $oDriver;
/**
* @return void
*/
public function __construct($oDriver)
{
$this->oDriver = $oDriver instanceof \RainLoop\Providers\Filters\FiltersInterface ? $oDriver : null;
}
/**
* @return array
*/
public function Load()
{
return $this->IsActive() ? $this->oDriver->Load() : array();
}
/**
* @param array $aFilters
*
* @return bool
*/
public function Save($aFilters)
{
return $this->IsActive() ? $this->oDriver->Save($aFilters) : false;
}
/**
* @return bool
*/
public function IsActive()
{
return $this->oDriver instanceof \RainLoop\Providers\Filters\FiltersInterface;
}
}

View file

@ -0,0 +1,150 @@
<?php
namespace RainLoop\Providers\Filters\Classes;
class Filter
{
/**
* @var string
*/
private $sName;
/**
* @var array
*/
private $aConditions;
/**
* @var string
*/
private $sActionType;
/**
* @var string
*/
private $sActionValue;
/**
* @var bool
*/
private $bMarkAsRead;
/**
* @var bool
*/
private $bSkipOthers;
public function __construct()
{
$this->Clear();
}
public function Clear()
{
$this->sName = '';
$this->aConditions = array();
$this->sFilterRulesType = \RainLoop\Providers\Filters\Enumerations\FilterRulesType::ALL;
$this->sActionType = \RainLoop\Providers\Filters\Enumerations\ActionType::MOVE_TO;
$this->sActionValue = '';
$this->bMarkAsRead = false;
$this->bSkipOthers = false;
}
/**
* @return string
*/
public function Name()
{
return $this->sName;
}
/**
* @return array
*/
public function Conditions()
{
return $this->aConditions;
}
/**
* @return string
*/
public function FilterRulesType()
{
return $this->sFilterRulesType;
}
/**
* @return string
*/
public function ActionType()
{
return $this->sActionType;
}
/**
* @return string
*/
public function ActionValue()
{
return $this->sActionValue;
}
/**
* @return bool
*/
public function MarkAsRead()
{
return $this->bMarkAsRead;
}
/**
* @return bool
*/
public function SkipOthers()
{
return $this->bSkipOthers;
}
/**
* @return string
*/
public function serializeToJson()
{
return \json_encode($this->ToSimpleJSON());
}
/**
* @param string $sFilterJson
*/
public function unserializeFromJson($sFilterJson)
{
$sFilterJson = \json_decode(\trim($sFilterJson));
if (!empty($sFilterJson))
{
}
}
/**
* @param bool $bAjax = false
*
* @return array
*/
public function ToSimpleJSON($bAjax = false)
{
$aConditions = $this->Conditions();
return array(
'Name' => $this->Name(),
'Conditions' => $aConditions,
'FilterRulesType' => $this->FilterRulesType(),
'ActionType' => $this->ActionType(),
'ActionValue' => $this->ActionValue(),
'MarkAsRead' => $this->MarkAsRead(),
'SkipOthers' => $this->SkipOthers()
);
}
}

View file

@ -0,0 +1,10 @@
<?php
namespace RainLoop\Providers\Filters\Enumerations;
class ActionType
{
const NONE = 'None';
const MOVE_TO = 'MoveTo';
const DISCARD = 'Discard';
}

View file

@ -0,0 +1,10 @@
<?php
namespace RainLoop\Providers\Filters\Enumerations;
class ConditionField
{
const FROM = 'From';
const RECIPIENT = 'Recipient';
const SUBJECT = 'Subject';
}

View file

@ -0,0 +1,11 @@
<?php
namespace RainLoop\Providers\Filters\Enumerations;
class ConditionType
{
const EQUAL_TO = 'EqualTo';
const NOT_EQUAL_TO = 'NotEqualTo';
const CONTAINS = 'Contains';
const NOT_CONTAINS = 'NotContains';
}

View file

@ -0,0 +1,9 @@
<?php
namespace RainLoop\Providers\Filters\Enumerations;
class FilterRulesType
{
const ALL = 'All';
const ANY = 'Any';
}

View file

@ -0,0 +1,18 @@
<?php
namespace RainLoop\Providers\Filters;
interface FiltersInterface
{
/**
* @return array
*/
public function Load();
/**
* @param array $aFilters
*
* @return bool
*/
public function Save($aFilters);
}

View file

@ -0,0 +1,67 @@
<?php
namespace RainLoop\Providers\Filters;
class SieveStorage implements \RainLoop\Providers\Filters\FiltersInterface
{
/**
* @return void
*/
public function __construct()
{
}
/**
* @return array
*/
public function Load()
{
// TODO
return $this->fileStringToCollection(@\file_get_contents('e:/sieve.txt'));
}
/**
* @param array $aFilters
*
* @return bool
*/
public function Save($aFilters)
{
return @\file_put_contents('e:/sieve.txt', $this->collectionToFileString($aFilters));
}
/**
* @param array $aFilters
*
* @return string
*/
private function collectionToFileString($aFilters)
{
$aParts = array();
foreach ($aFilters as /* @var $oItem \RainLoop\Providers\Filters\Classes\Filter */ $oItem)
{
$sItem = $oItem->serializeToJson();
$sItem = \chunk_split(\base64_encode($sItem), 74, "\n");
$aParts[] = $sItem;
}
return \implode("\n", $aParts);
}
/**
* @param string $sFileString
*
* @return array
*/
private function fileStringToCollection($sFileString)
{
if (!empty($sFileString))
{
}
return array();
}
}

View file

@ -84,24 +84,33 @@
__simplePace(10);
window.$LAB
.script('{{BaseAppLibsScriptLink}}')
.script(window.rainloopAppData['TemplatesLink'])
.script(window.rainloopAppData['LangLink'])
.script(function () {
return [
{'src': '{{BaseAppLibsScriptLink}}', 'type': 'text/javascript', 'charset': 'utf-8'},
{'src': window.rainloopAppData['TemplatesLink'], 'type': 'text/javascript', 'charset': 'utf-8'},
{'src': window.rainloopAppData['LangLink'], 'type': 'text/javascript', 'charset': 'utf-8'}
];
})
.wait(function () {
__simplePace(30);
})
.script('{{BaseAppMainScriptLink}}')
.script(function () {
return {'src': '{{BaseAppMainScriptLink}}', 'type': 'text/javascript', 'charset': 'utf-8'};
})
.wait(function () {
__simplePace(20);
})
.script(function () {
return window.rainloopAppData['PluginsLink'] || null;
return window.rainloopAppData['PluginsLink'] ?
{'src': '{{BaseAppMainScriptLink}}', 'type': 'text/javascript', 'charset': 'utf-8'} : null;
})
.wait(function () {
__simplePace(5);
__runBoot(false);
})
.script('{{BaseAppEditorScriptLink}}')
.script(function () {
return {'src': '{{BaseAppEditorScriptLink}}', 'type': 'text/javascript', 'charset': 'utf-8'};
})
.wait(function () {
if (window.CKEDITOR && window.__initEditor) {
window.__initEditor();

View file

@ -25,7 +25,12 @@
<div data-bind="visible: 'available' === statusType()">
<i class="icon-bolt" style="color: red"></i>
&nbsp;&nbsp;
New <b data-bind="text: coreRemoteVersion"></b> version is available.
New
<b data-bind="text: coreRemoteVersion"></b>
<span data-bind="visible: 'stable' !== coreType()" style="color:red">
(<span data-bind="text: coreType"></span>)
</span>
version is available.
<span data-bind="visible: '' !== coreRemoteRelease()">
(<span data-bind="text: coreRemoteRelease"></span>)
</span>
@ -56,7 +61,11 @@
<div data-bind="visible: 'up-to-date' === statusType()">
<i class="icon-ok" style="color: green"></i>
&nbsp;&nbsp;
RainLoop is up to date.
RainLoop
<span data-bind="visible: 'stable' !== coreType()" style="color:red">
(<span data-bind="text: coreType"></span>)
</span>
is up to date.
</div>
<div data-bind="visible: 'updating' === statusType()">
<i class="icon-spinner animated"></i>

View file

@ -20,8 +20,8 @@
<div class="row">
<div class="span5" data-bind="css: { 'testing-done': testingDone, 'testing-error': testingImapError }">
<div class="legend imap-header">
<span data-placement="bottom" data-bind="tooltip3: testingImapErrorDesc">
<span data-bind="text: sieveSettings() ? 'SIEVE' : 'IMAP'">IMAP</span>
<span data-placement="bottom" data-bind="tooltipForTest: testingImapErrorDesc">
<span data-bind="text: sieveSettings() ? 'SIEVE (Filters)' : 'IMAP'">IMAP</span>
</span>
</div>
<div data-bind="visible: !sieveSettings()">
@ -73,7 +73,7 @@
<span data-bind="command: sieveCommand">
<i class="icon-filter"></i>
&nbsp;
<a href="#" class="g-ui-link">Sieve configuration</a>
<a href="#" class="g-ui-link">Sieve (Filetrs) configuration</a>
</span>
</div>
</div>
@ -90,18 +90,7 @@
}"></div>
</div>
</div>
<div class="row" data-bind="visible: useSieve">
<div class="span5">
<div data-bind="component: {
name: 'Checkbox',
params: {
label: 'use IMAP Server',
value: useImapServerForSieve
}
}"></div>
</div>
</div>
<div data-bind="visible: !useImapServerForSieve() && useSieve()">
<div data-bind="visible: useSieve">
<br />
<div class="row">
<div class="span3">
@ -144,7 +133,7 @@
</div>
<div class="span5" data-bind="css: { 'testing-done': testingDone, 'testing-error': testingSmtpError }">
<div class="legend smtp-header">
<span data-placement="bottom" data-bind="tooltip3: testingSmtpErrorDesc">
<span data-placement="bottom" data-bind="tooltipForTest: testingSmtpErrorDesc">
SMTP
</span>
</div>

View file

@ -77,7 +77,7 @@
<tr><td class="i18n" data-i18n-text="SHORTCUTS_HELP/LABEL_OPEN_COMPOSE_POPUP"></td><td>W, C</td></tr>
<tr><td class="i18n" data-i18n-text="SHORTCUTS_HELP/LABEL_OPEN_IDENTITIES_DROPDOWN"></td><td>Ctrl + Q, Command + Q</td></tr>
<tr><td class="i18n" data-i18n-text="SHORTCUTS_HELP/LABEL_SAVE_MESSAGE"></td><td>Ctrl + S, Command + S</td></tr>
<tr><td class="i18n" data-i18n-text="SHORTCUTS_HELP/LABEL_SEND_MESSAGE"></td><td>Ctrl + Enter, Command + Enter</td></tr>
<!--<tr><td class="i18n" data-i18n-text="SHORTCUTS_HELP/LABEL_SEND_MESSAGE"></td><td>Ctrl + Enter, Command + Enter</td></tr>-->
<tr><td class="i18n" data-i18n-text="SHORTCUTS_HELP/LABEL_CLOSE_COMPOSE"></td><td>Esc</td></tr>
</tbody>
</table>

View file

@ -8,8 +8,8 @@
</div>
<div class="modal-body">
<div data-bind="foreach: languages">
<label class="lang-item" data-tooltip-placement="left" data-bind="click: function () { $root.changeLanguage(key); }, css: {'selected': selected},
tooltip2: function () { return $root.languageEnName(key); }">
<label class="lang-item" data-tooltip-i18n="off" data-tooltip-placement="left" data-bind="click: function () { $root.changeLanguage(key); }, css: {'selected': selected},
tooltip: function () { return $root.languageEnName(key); }">
<span class="flag-wrapper">
<span data-bind="css: 'flag flag-' + key" style=""></span>
</span>

View file

@ -165,7 +165,7 @@
</div>
<div class="mainDelimiter footerDelimiter"></div>
<div class="b-footer thm-message-list-bottom-toolbar">
<span data-bind="visible: 0 < userUsageProc(), tooltip2: quotaTooltip" class="e-quota">
<span data-tooltip-i18n="off" data-bind="visible: 0 < userUsageProc(), tooltip: quotaTooltip" class="e-quota">
<span data-bind="text: userUsageProc"></span>%
</span>
<div class="pull-right">

View file

@ -4,29 +4,28 @@
<div class="modal-header">
<button type="button" class="close" data-bind="command: cancelCommand">&times;</button>
<h3>
<span class="i18n" data-i18n-text="POPUPS_CREATE_FOLDER/TITLE_CREATE_FOLDER"></span>
<span class="i18n" data-i18n-text="SETTINGS_FILTERS/TITLE_CREATE_FILTER"></span>
</h3>
</div>
<div class="modal-body">
<div class="row filter" data-bind="with: filter">
<div class="span9">
<br />
<input type="text" class="span4" data-bind="value: name" placeholder="Description" />
<hr />
<input type="text" class="span5" data-bind="value: name" placeholder="Name" />
<br />
<br />
<div class="legend">
<span>
Conditions
</span>
</div>
<div>
<a class="btn" data-bind="click: addCondition">
<i class="icon-plus"></i>
&nbsp;&nbsp;
<span class="i18n" data-i18n-text="SETTINGS_FILTERS/BUTTON_ADD_CONDITION"></span>
</a>
<br />
<br />
<div data-bind="visible: 1 < conditions().length">
<select class="span4" data-bind="value: conditionsType">
<option value="And">
<option value="All">
Matching all of the following rules
</option>
<option value="Or">
<option value="Any">
Matching any of the following rules
</option>
</select>
@ -35,13 +34,24 @@
<div data-bind="template: {'name': template(), 'data': $data}"></div>
</div>
<div data-bind="visible: 0 === conditions().length">
All messages
All incoming messages
</div>
<br />
<a class="btn" data-bind="click: addCondition, i18nInit: true">
<i class="icon-plus"></i>
&nbsp;&nbsp;
<span class="i18n" data-i18n-text="SETTINGS_FILTERS/BUTTON_ADD_CONDITION"></span>
</a>
</div>
<br />
<div class="legend">
<span>
Actions
</span>
</div>
<hr />
<div data-bind="template: {'name': actionTemplate()}"></div>
<div data-bind="visible: actionMarkAsReadVisiblity, component: {
<br />
<div data-bind="component: {
name: 'Checkbox',
params: {
label: 'Mark as read',
@ -53,8 +63,9 @@
name: 'Checkbox',
params: {
label: 'Skip other filters',
value: actionSkipOtherFilters
actionSkipOtherFilters
enable: enableSkipOtherFilters,
value: actionSkipOtherFiltersResult
}
}"></div>
</div>
</div>
@ -63,7 +74,7 @@
<a class="btn buttonSave">
<i class="icon-folder-add"></i>
&nbsp;&nbsp;
<span class="i18n" data-i18n-text="POPUPS_CREATE_FOLDER/BUTTON_CREATE"></span>
<span class="i18n" data-i18n-text="SETTINGS_FILTERS/BUTTON_CREATE"></span>
</a>
</div>
</div>

View file

@ -4,6 +4,6 @@
&nbsp;
<input class="span3" type="text" data-bind="value: value" />
&nbsp;
<span class="delete-action pull-right" data-bind="click: removeSelf">
<span class="delete-action button-delete pull-right" data-bind="click: removeSelf">
<i class="icon-trash"></i>
</span>

View file

@ -3,8 +3,8 @@
<div class="btn-toolbar">
<div class="btn-group pull-right dropdown colored-toggle" data-bind="registrateBootstrapDropdown: true, openDropdownTrigger: accountMenuDropdownTrigger">
<a id="top-system-dropdown-id" href="#" tabindex="-1" class="btn btn-ellipsis btn-block dropdown-toggle system-dropdown"
data-toggle="dropdown" data-tooltip-placement="left"
data-tooltip-class="tooltip-big" data-bind="tooltip2: emailTitle">
data-toggle="dropdown" data-tooltip-placement="left" data-tooltip-i18n="off"
data-tooltip-class="tooltip-big" data-bind="tooltip: emailTitle">
<i data-bind="css: {'icon-user': !loading(), 'icon-spinner animated': loading()}"></i>
&nbsp;&nbsp;