mirror of
https://github.com/the-djmaze/snappymail.git
synced 2024-12-27 01:28:56 +08:00
Move TemproryApcStorage to demo-account plugin
This commit is contained in:
parent
3945ab1349
commit
57dd0f7e2c
2 changed files with 15 additions and 31 deletions
|
@ -37,8 +37,7 @@ class DemoAccountPlugin extends \RainLoop\Plugins\AbstractPlugin
|
|||
*/
|
||||
public function FilterAppData($bAdmin, &$aResult)
|
||||
{
|
||||
if (!$bAdmin && \is_array($aResult) && isset($aResult['Auth']) && !$aResult['Auth'])
|
||||
{
|
||||
if (!$bAdmin && \is_array($aResult) && isset($aResult['Auth']) && !$aResult['Auth']) {
|
||||
$aResult['DevEmail'] = $this->Config()->Get('plugin', 'email', $aResult['DevEmail']);
|
||||
$aResult['DevPassword'] = APP_DUMMY;
|
||||
}
|
||||
|
@ -49,12 +48,11 @@ class DemoAccountPlugin extends \RainLoop\Plugins\AbstractPlugin
|
|||
*/
|
||||
public function FilterActionParams($sMethodName, &$aActionParams)
|
||||
{
|
||||
if ('DoLogin' === $sMethodName && isset($aActionParams['Email']) && isset($aActionParams['Password']))
|
||||
{
|
||||
if ($this->Config()->Get('plugin', 'email') === $aActionParams['Email'])
|
||||
{
|
||||
$aActionParams['Password'] = $this->Config()->Get('plugin', 'password');
|
||||
}
|
||||
if ('DoLogin' === $sMethodName
|
||||
&& isset($aActionParams['Email'])
|
||||
&& isset($aActionParams['Password'])
|
||||
&& $this->Config()->Get('plugin', 'email') === $aActionParams['Email']) {
|
||||
$aActionParams['Password'] = $this->Config()->Get('plugin', 'password');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -70,17 +68,14 @@ class DemoAccountPlugin extends \RainLoop\Plugins\AbstractPlugin
|
|||
|
||||
public function JsonActionPreCall($sAction)
|
||||
{
|
||||
if ('AccountSetup' === $sAction &&
|
||||
$this->isDemoAccount($this->Manager()->Actions()->GetAccount()))
|
||||
{
|
||||
if ('AccountSetup' === $sAction && $this->isDemoAccount($this->Manager()->Actions()->GetAccount())) {
|
||||
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::DemoAccountError);
|
||||
}
|
||||
}
|
||||
|
||||
public function FilterSendMessage($oMessage)
|
||||
{
|
||||
if ($oMessage && $this->isDemoAccount($this->Manager()->Actions()->GetAccount()))
|
||||
{
|
||||
if ($oMessage && $this->isDemoAccount($this->Manager()->Actions()->GetAccount())) {
|
||||
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::DemoSendMessageError);
|
||||
}
|
||||
}
|
||||
|
@ -91,21 +86,12 @@ class DemoAccountPlugin extends \RainLoop\Plugins\AbstractPlugin
|
|||
*/
|
||||
public function MainFabrica($sName, &$oDriver)
|
||||
{
|
||||
switch ($sName)
|
||||
{
|
||||
case 'storage':
|
||||
case 'storage-local':
|
||||
if (\class_exists('\\RainLoop\\Providers\\Storage\\TemproryApcStorage') &&
|
||||
\function_exists('apc_store'))
|
||||
{
|
||||
$oAccount = $this->Manager()->Actions()->GetAccount();
|
||||
if ($this->isDemoAccount($oAccount))
|
||||
{
|
||||
$oDriver = new \RainLoop\Providers\Storage\TemproryApcStorage(APP_PRIVATE_DATA.'storage',
|
||||
$sName === 'storage-local');
|
||||
}
|
||||
}
|
||||
break;
|
||||
if (('storage' === $sName || 'storage-local' === $sName) && \function_exists('apcu_store')) {
|
||||
$oAccount = $this->Manager()->Actions()->GetAccount();
|
||||
if ($this->isDemoAccount($oAccount)) {
|
||||
require_once __DIR__ . '/storage.php';
|
||||
$oDriver = new \DemoStorage(APP_PRIVATE_DATA.'storage', $sName === 'storage-local');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace RainLoop\Providers\Storage;
|
||||
|
||||
class TemproryApcStorage extends \RainLoop\Providers\Storage\FileStorage
|
||||
class DemoStorage extends \RainLoop\Providers\Storage\FileStorage
|
||||
{
|
||||
/**
|
||||
* @param \RainLoop\Model\Account|string|null $oAccount
|
Loading…
Reference in a new issue