mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-02-24 14:57:26 +08:00
+ Updated contacts sql shema (breaking changes) + Fixes - Removed SabreDAV Server - Removed Contacts Sharing (awhile, code refactoring)
97 lines
1.9 KiB
PHP
97 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace RainLoop\Providers;
|
|
|
|
class Storage extends \RainLoop\Providers\AbstractProvider
|
|
{
|
|
/**
|
|
* @var \RainLoop\Providers\Storage\StorageInterface
|
|
*/
|
|
private $oDriver;
|
|
|
|
/**
|
|
* @return void
|
|
*/
|
|
public function __construct(\RainLoop\Providers\Storage\StorageInterface $oDriver)
|
|
{
|
|
$this->oDriver = $oDriver;
|
|
}
|
|
|
|
/**
|
|
* @param \RainLoop\Account|string|null $oAccount
|
|
* @param int $iStorageType
|
|
*
|
|
* @return bool
|
|
*/
|
|
public function verifyAccount($oAccount, $iStorageType)
|
|
{
|
|
if (\RainLoop\Providers\Storage\Enumerations\StorageType::NOBODY !== $iStorageType &&
|
|
!($oAccount instanceof \RainLoop\Account || \is_string($oAccount)))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* @param \RainLoop\Account|string|null $oAccount
|
|
* @param int $iStorageType
|
|
* @param string $sKey
|
|
* @param string $sValue
|
|
*
|
|
* @return bool
|
|
*/
|
|
public function Put($oAccount, $iStorageType, $sKey, $sValue)
|
|
{
|
|
if (!$this->verifyAccount($oAccount, $iStorageType))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return $this->oDriver->Put($oAccount, $iStorageType, $sKey, $sValue);
|
|
}
|
|
|
|
/**
|
|
* @param \RainLoop\Account|string|null $oAccount
|
|
* @param int $iStorageType
|
|
* @param string $sKey
|
|
* @param mixed $mDefault = false
|
|
*
|
|
* @return mixed
|
|
*/
|
|
public function Get($oAccount, $iStorageType, $sKey, $mDefault = false)
|
|
{
|
|
if (!$this->verifyAccount($oAccount, $iStorageType))
|
|
{
|
|
return $mDefault;
|
|
}
|
|
|
|
return $this->oDriver->Get($oAccount, $iStorageType, $sKey, $mDefault);
|
|
}
|
|
|
|
/**
|
|
* @param \RainLoop\Account|string|null $oAccount
|
|
* @param int $iStorageType
|
|
* @param string $sKey
|
|
*
|
|
* @return bool
|
|
*/
|
|
public function Clear($oAccount, $iStorageType, $sKey)
|
|
{
|
|
if (!$this->verifyAccount($oAccount, $iStorageType))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return $this->oDriver->Clear($oAccount, $iStorageType, $sKey);
|
|
}
|
|
|
|
/**
|
|
* @return bool
|
|
*/
|
|
public function IsActive()
|
|
{
|
|
return $this->oDriver instanceof \RainLoop\Providers\Storage\StorageInterface;
|
|
}
|
|
}
|