mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-30 20:49:20 +03:00
ckeditor fixes
demo-plugin TemproryApcStorage
This commit is contained in:
parent
000711086a
commit
844afadd6f
40 changed files with 2371 additions and 197 deletions
|
|
@ -56,7 +56,8 @@ class File implements \MailSo\Cache\DriverInterface
|
|||
*/
|
||||
public function Set($sKey, $sValue)
|
||||
{
|
||||
return false !== \file_put_contents($sPath = $this->generateCachedFileName($sKey, true), $sValue);
|
||||
$sPath = $this->generateCachedFileName($sKey, true);
|
||||
return '' === $sPath ? false : false !== \file_put_contents($sPath, $sValue);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -68,7 +69,7 @@ class File implements \MailSo\Cache\DriverInterface
|
|||
{
|
||||
$sValue = '';
|
||||
$sPath = $this->generateCachedFileName($sKey);
|
||||
if (\file_exists($sPath))
|
||||
if ('' !== $sPath && \file_exists($sPath))
|
||||
{
|
||||
$sValue = \file_get_contents($sPath);
|
||||
}
|
||||
|
|
@ -84,7 +85,7 @@ class File implements \MailSo\Cache\DriverInterface
|
|||
public function Delete($sKey)
|
||||
{
|
||||
$sPath = $this->generateCachedFileName($sKey);
|
||||
if (\file_exists($sPath))
|
||||
if ('' !== $sPath && \file_exists($sPath))
|
||||
{
|
||||
\unlink($sPath);
|
||||
}
|
||||
|
|
@ -92,7 +93,7 @@ class File implements \MailSo\Cache\DriverInterface
|
|||
|
||||
/**
|
||||
* @param int $iTimeToClearInHours = 24
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function GC($iTimeToClearInHours = 24)
|
||||
|
|
@ -102,7 +103,7 @@ class File implements \MailSo\Cache\DriverInterface
|
|||
\MailSo\Base\Utils::RecTimeDirRemove($this->sCacheFolder, 60 * 60 * $iTimeToClearInHours, \time());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -120,7 +121,7 @@ class File implements \MailSo\Cache\DriverInterface
|
|||
$sKeyPath = \sha1($sKey);
|
||||
$sKeyPath = \substr($sKeyPath, 0, 2).'/'.\substr($sKeyPath, 2, 2).'/'.$sKeyPath;
|
||||
|
||||
$sFilePath = $this->sCacheFolder.'/'.$sKeyPath;
|
||||
$sFilePath = $this->sCacheFolder.$sKeyPath;
|
||||
if ($bMkDir && !\is_dir(\dirname($sFilePath)))
|
||||
{
|
||||
if (!\mkdir(\dirname($sFilePath), 0755, true))
|
||||
|
|
|
|||
|
|
@ -246,23 +246,23 @@ class Actions
|
|||
switch ($sName)
|
||||
{
|
||||
case 'files':
|
||||
// RainLoop\Providers\Files\FilesInterface
|
||||
$oResult = new \RainLoop\Providers\Files\DefaultStorage(APP_PRIVATE_DATA.'storage/files');
|
||||
// RainLoop\Providers\Files\IFiles
|
||||
$oResult = new \RainLoop\Providers\Files\FileStorage(APP_PRIVATE_DATA.'storage/files');
|
||||
break;
|
||||
case 'storage':
|
||||
// RainLoop\Providers\Storage\StorageInterface
|
||||
$oResult = new \RainLoop\Providers\Storage\DefaultStorage(APP_PRIVATE_DATA.'storage');
|
||||
// RainLoop\Providers\Storage\IStorage
|
||||
$oResult = new \RainLoop\Providers\Storage\FileStorage(APP_PRIVATE_DATA.'storage');
|
||||
break;
|
||||
case 'storage-local':
|
||||
// RainLoop\Providers\Storage\StorageInterface
|
||||
$oResult = new \RainLoop\Providers\Storage\DefaultStorage(APP_PRIVATE_DATA.'storage', true);
|
||||
// RainLoop\Providers\Storage\IStorage
|
||||
$oResult = new \RainLoop\Providers\Storage\FileStorage(APP_PRIVATE_DATA.'storage', true);
|
||||
break;
|
||||
case 'settings':
|
||||
// RainLoop\Providers\Settings\SettingsInterface
|
||||
// RainLoop\Providers\Settings\ISettings
|
||||
$oResult = new \RainLoop\Providers\Settings\DefaultSettings($this->StorageProvider());
|
||||
break;
|
||||
case 'settings-local':
|
||||
// RainLoop\Providers\Settings\SettingsInterface
|
||||
// RainLoop\Providers\Settings\ISettings
|
||||
$oResult = new \RainLoop\Providers\Settings\DefaultSettings($this->StorageProvider(true));
|
||||
break;
|
||||
case 'login':
|
||||
|
|
@ -301,7 +301,7 @@ class Actions
|
|||
}
|
||||
break;
|
||||
case 'suggestions':
|
||||
// \RainLoop\Providers\Suggestions\SuggestionsInterface
|
||||
// \RainLoop\Providers\Suggestions\ISuggestions
|
||||
// $oResult = new \RainLoop\Providers\Suggestions\TestSuggestions();
|
||||
|
||||
if (\RainLoop\Utils::IsOwnCloud())
|
||||
|
|
@ -7721,7 +7721,7 @@ class Actions
|
|||
$self = $this;
|
||||
return $this->MailClient()->MessageMimeStream(
|
||||
function($rResource, $sContentType, $sFileName, $sMimeIndex = '') use ($self, $oAccount, $sRawKey, $sContentTypeIn, $sFileNameIn, $bDownload, $bThumbnail) {
|
||||
if (\is_resource($rResource))
|
||||
if ($oAccount && \is_resource($rResource))
|
||||
{
|
||||
$sContentTypeOut = $sContentTypeIn;
|
||||
if (empty($sContentTypeOut))
|
||||
|
|
|
|||
|
|
@ -627,13 +627,8 @@ class PdoAddressBook
|
|||
if (0 < \strlen($sSearch))
|
||||
{
|
||||
$sCustomSearch = $this->specialConvertSearchValueCustomPhone($sSearch);
|
||||
if ('%%' === $sCustomSearch)
|
||||
{
|
||||
// TODO fix this
|
||||
$sCustomSearch = '';
|
||||
}
|
||||
|
||||
$sSearchTypes = implode(',', array(
|
||||
$sSearchTypes = \implode(',', array(
|
||||
PropertyType::EMAIl, PropertyType::FIRST_NAME, PropertyType::LAST_NAME, PropertyType::NICK_NAME,
|
||||
PropertyType::PHONE, PropertyType::WEB_PAGE
|
||||
));
|
||||
|
|
@ -1501,7 +1496,8 @@ SQLITEINITIAL;
|
|||
*/
|
||||
private function specialConvertSearchValueCustomPhone($sSearch)
|
||||
{
|
||||
return '%'.\preg_replace('/[^\d]/', '', $sSearch).'%';
|
||||
$sResult = '%'.\preg_replace('/[^\d]/', '', $sSearch).'%';
|
||||
return '%%' === $sResult ? '' : $sResult;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -5,14 +5,14 @@ namespace RainLoop\Providers;
|
|||
class Files extends \RainLoop\Providers\AbstractProvider
|
||||
{
|
||||
/**
|
||||
* @var \RainLoop\Providers\Files\FilesInterface
|
||||
* @var \RainLoop\Providers\Files\IFiles
|
||||
*/
|
||||
private $oDriver;
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(\RainLoop\Providers\Files\FilesInterface $oDriver)
|
||||
public function __construct(\RainLoop\Providers\Files\IFiles $oDriver)
|
||||
{
|
||||
$this->oDriver = $oDriver;
|
||||
}
|
||||
|
|
@ -121,6 +121,6 @@ class Files extends \RainLoop\Providers\AbstractProvider
|
|||
*/
|
||||
public function IsActive()
|
||||
{
|
||||
return $this->oDriver instanceof \RainLoop\Providers\Files\FilesInterface;
|
||||
return $this->oDriver instanceof \RainLoop\Providers\Files\IFiles;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace RainLoop\Providers\Files;
|
||||
|
||||
class DefaultStorage implements \RainLoop\Providers\Files\FilesInterface
|
||||
class FileStorage implements \RainLoop\Providers\Files\IFiles
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace RainLoop\Providers\Files;
|
||||
|
||||
interface FilesInterface
|
||||
interface IFiles
|
||||
{
|
||||
/**
|
||||
* @param \RainLoop\Model\Account $oAccount
|
||||
|
|
@ -5,16 +5,16 @@ namespace RainLoop\Providers;
|
|||
class Settings extends \RainLoop\Providers\AbstractProvider
|
||||
{
|
||||
/**
|
||||
* @var \RainLoop\Providers\Settings\SettingsInterface
|
||||
* @var \RainLoop\Providers\Settings\ISettings
|
||||
*/
|
||||
private $oDriver;
|
||||
|
||||
/**
|
||||
* @param \RainLoop\Providers\Settings\SettingsInterface $oDriver
|
||||
* @param \RainLoop\Providers\Settings\ISettings $oDriver
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(\RainLoop\Providers\Settings\SettingsInterface $oDriver)
|
||||
public function __construct(\RainLoop\Providers\Settings\ISettings $oDriver)
|
||||
{
|
||||
$this->oDriver = $oDriver;
|
||||
}
|
||||
|
|
@ -47,6 +47,6 @@ class Settings extends \RainLoop\Providers\AbstractProvider
|
|||
*/
|
||||
public function IsActive()
|
||||
{
|
||||
return $this->oDriver instanceof \RainLoop\Providers\Settings\SettingsInterface;
|
||||
return $this->oDriver instanceof \RainLoop\Providers\Settings\ISettings;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace RainLoop\Providers\Settings;
|
||||
|
||||
class DefaultSettings implements \RainLoop\Providers\Settings\SettingsInterface
|
||||
class DefaultSettings implements \RainLoop\Providers\Settings\ISettings
|
||||
{
|
||||
const FILE_NAME = 'settings';
|
||||
const FILE_NAME_LOCAL = 'settings_local';
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace RainLoop\Providers\Settings;
|
||||
|
||||
interface SettingsInterface
|
||||
interface ISettings
|
||||
{
|
||||
/**
|
||||
* @param \RainLoop\Model\Account $oAccount
|
||||
|
|
@ -5,14 +5,14 @@ namespace RainLoop\Providers;
|
|||
class Storage extends \RainLoop\Providers\AbstractProvider
|
||||
{
|
||||
/**
|
||||
* @var \RainLoop\Providers\Storage\StorageInterface
|
||||
* @var \RainLoop\Providers\Storage\IStorage
|
||||
*/
|
||||
private $oDriver;
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(\RainLoop\Providers\Storage\StorageInterface $oDriver)
|
||||
public function __construct(\RainLoop\Providers\Storage\IStorage $oDriver)
|
||||
{
|
||||
$this->oDriver = $oDriver;
|
||||
}
|
||||
|
|
@ -102,7 +102,7 @@ class Storage extends \RainLoop\Providers\AbstractProvider
|
|||
*/
|
||||
public function IsActive()
|
||||
{
|
||||
return $this->oDriver instanceof \RainLoop\Providers\Storage\StorageInterface;
|
||||
return $this->oDriver instanceof \RainLoop\Providers\Storage\IStorage;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -110,7 +110,7 @@ class Storage extends \RainLoop\Providers\AbstractProvider
|
|||
*/
|
||||
public function IsLocal()
|
||||
{
|
||||
return $this->oDriver instanceof \RainLoop\Providers\Storage\StorageInterface &&
|
||||
return $this->oDriver instanceof \RainLoop\Providers\Storage\IStorage &&
|
||||
$this->oDriver->IsLocal();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace RainLoop\Providers\Storage;
|
||||
|
||||
class DefaultStorage implements \RainLoop\Providers\Storage\StorageInterface
|
||||
class FileStorage implements \RainLoop\Providers\Storage\IStorage
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
|
|
@ -14,6 +14,11 @@ class DefaultStorage implements \RainLoop\Providers\Storage\StorageInterface
|
|||
*/
|
||||
private $bLocal;
|
||||
|
||||
/**
|
||||
* @var \MailSo\Log\Logger
|
||||
*/
|
||||
protected $oLogger;
|
||||
|
||||
/**
|
||||
* @param string $sStoragePath
|
||||
* @param bool $bLocal = false
|
||||
|
|
@ -24,6 +29,7 @@ class DefaultStorage implements \RainLoop\Providers\Storage\StorageInterface
|
|||
{
|
||||
$this->sDataPath = \rtrim(\trim($sStoragePath), '\\/');
|
||||
$this->bLocal = !!$bLocal;
|
||||
$this->oLogger = null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -122,7 +128,7 @@ class DefaultStorage implements \RainLoop\Providers\Storage\StorageInterface
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
private function generateFileName($mAccount, $iStorageType, $sKey, $bMkDir = false, $bForDeleteAction = false)
|
||||
public function generateFileName($mAccount, $iStorageType, $sKey, $bMkDir = false, $bForDeleteAction = false)
|
||||
{
|
||||
if (null === $mAccount)
|
||||
{
|
||||
|
|
@ -186,4 +192,12 @@ class DefaultStorage implements \RainLoop\Providers\Storage\StorageInterface
|
|||
|
||||
return $sFilePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \MailSo\Log\Logger $oLogger
|
||||
*/
|
||||
public function SetLogger($oLogger)
|
||||
{
|
||||
$this->oLogger = $oLogger instanceof \MailSo\Log\Logger ? $oLogger : null;
|
||||
}
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace RainLoop\Providers\Storage;
|
||||
|
||||
interface StorageInterface
|
||||
interface IStorage
|
||||
{
|
||||
/**
|
||||
* @param \RainLoop\Model\Account|null $oAccount
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
<?php
|
||||
|
||||
namespace RainLoop\Providers\Storage;
|
||||
|
||||
class TemproryApcStorage extends \RainLoop\Providers\Storage\FileStorage
|
||||
{
|
||||
/**
|
||||
* @param \RainLoop\Model\Account|string|null $oAccount
|
||||
* @param int $iStorageType
|
||||
* @param string $sKey
|
||||
* @param string $sValue
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function Put($oAccount, $iStorageType, $sKey, $sValue)
|
||||
{
|
||||
return !!@\apc_store($this->generateFileName($oAccount, $iStorageType, $sKey, true), $sValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \RainLoop\Model\Account|string|null $oAccount
|
||||
* @param int $iStorageType
|
||||
* @param string $sKey
|
||||
* @param mixed $mDefault = false
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function Get($oAccount, $iStorageType, $sKey, $mDefault = false)
|
||||
{
|
||||
$bValue = false;
|
||||
$mValue = @\apc_fetch($this->generateFileName($oAccount, $iStorageType, $sKey), $bValue);
|
||||
if (!$bValue)
|
||||
{
|
||||
$mValue = $mDefault;
|
||||
}
|
||||
|
||||
return $mValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \RainLoop\Model\Account|string|null $oAccount
|
||||
* @param int $iStorageType
|
||||
* @param string $sKey
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function Clear($oAccount, $iStorageType, $sKey)
|
||||
{
|
||||
@\apc_delete($this->generateFileName($oAccount, $iStorageType, $sKey));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \RainLoop\Model\Account|string $oAccount
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function DeleteStorage($oAccount)
|
||||
{
|
||||
return !!$oAccount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \RainLoop\Model\Account|string|null $mAccount
|
||||
* @param int $iStorageType
|
||||
* @param string $sKey
|
||||
* @param bool $bMkDir = false
|
||||
* @param bool $bForDeleteAction = false
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function generateFileName($mAccount, $iStorageType, $sKey, $bMkDir = false, $bForDeleteAction = false)
|
||||
{
|
||||
$sFileName = parent::generateFileName($mAccount, $iStorageType, $sKey, false, false);
|
||||
return $sFileName.'/'.\RainLoop\Utils::GetConnectionToken().'/';
|
||||
}
|
||||
}
|
||||
|
|
@ -5,12 +5,12 @@ namespace RainLoop\Providers;
|
|||
class Suggestions extends \RainLoop\Providers\AbstractProvider
|
||||
{
|
||||
/**
|
||||
* @var \RainLoop\Providers\Suggestions\SuggestionsInterface
|
||||
* @var \RainLoop\Providers\Suggestions\ISuggestions
|
||||
*/
|
||||
private $oDriver;
|
||||
|
||||
/**
|
||||
* @param \RainLoop\Providers\Suggestions\SuggestionsInterface|null $oDriver = null
|
||||
* @param \RainLoop\Providers\Suggestions\ISuggestions|null $oDriver = null
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
|
@ -37,6 +37,6 @@ class Suggestions extends \RainLoop\Providers\AbstractProvider
|
|||
*/
|
||||
public function IsActive()
|
||||
{
|
||||
return $this->oDriver instanceof \RainLoop\Providers\Suggestions\SuggestionsInterface;
|
||||
return $this->oDriver instanceof \RainLoop\Providers\Suggestions\ISuggestions;
|
||||
}
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace RainLoop\Providers\Suggestions;
|
||||
|
||||
interface SuggestionsInterface
|
||||
interface ISuggestions
|
||||
{
|
||||
/**
|
||||
* @param \RainLoop\Model\Account $oAccount
|
||||
|
|
@ -2,12 +2,12 @@
|
|||
|
||||
namespace RainLoop\Providers\Suggestions;
|
||||
|
||||
class OwnCloudSuggestions implements \RainLoop\Providers\Suggestions\SuggestionsInterface
|
||||
class OwnCloudSuggestions implements \RainLoop\Providers\Suggestions\ISuggestions
|
||||
{
|
||||
/**
|
||||
* @var \MailSo\Log\Logger
|
||||
*/
|
||||
private $oLogger;
|
||||
protected $oLogger;
|
||||
|
||||
/**
|
||||
* @param \RainLoop\Model\Account $oAccount
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace RainLoop\Providers\Suggestions;
|
||||
|
||||
class TestSuggestions implements \RainLoop\Providers\Suggestions\SuggestionsInterface
|
||||
class TestSuggestions implements \RainLoop\Providers\Suggestions\ISuggestions
|
||||
{
|
||||
/**
|
||||
* @param \RainLoop\Model\Account $oAccount
|
||||
|
|
|
|||
|
|
@ -156,6 +156,16 @@ class Service
|
|||
@header('Content-Type: text/html; charset=utf-8');
|
||||
$this->oHttp->ServerNoCache();
|
||||
|
||||
if (!@\is_dir(APP_DATA_FOLDER_PATH) || !@\is_writable(APP_DATA_FOLDER_PATH))
|
||||
{
|
||||
echo $this->oServiceActions->ErrorTemplates(
|
||||
'Permission denied!',
|
||||
'RainLoop Webmail cannot access to the data folder "'.APP_DATA_FOLDER_PATH.'"'
|
||||
);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
$aTemplateParameters = $this->indexTemplateParameters($bAdmin);
|
||||
|
||||
$sCacheFileName = '';
|
||||
|
|
@ -187,7 +197,7 @@ class Service
|
|||
$sResult .= '][cached:'.($bCached ? 'true' : 'false');
|
||||
$sResult .= '][hash:'.$aTemplateParameters['{{BaseHash}}'];
|
||||
$sResult .= '][session:'.\md5(\RainLoop\Utils::GetShortToken());
|
||||
|
||||
|
||||
if (\RainLoop\Utils::IsOwnCloud())
|
||||
{
|
||||
$sResult .= '][owncloud:true';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue