Updated demo plugin for upcoming v2.12

This commit is contained in:
the-djmaze 2022-01-28 15:43:40 +01:00
parent 221136ce1c
commit f50d848b35
3 changed files with 14 additions and 10 deletions

View file

@ -9,7 +9,7 @@ class DemoStorage extends \RainLoop\Providers\Storage\FileStorage
/**
* @param \RainLoop\Model\Account|string|null $mAccount
*/
protected function generateFileName($mAccount, int $iStorageType, string $sKey, bool $bMkDir = false, bool $bForDeleteAction = false) : string
public function GenerateFilePath($mAccount, int $iStorageType, bool $bMkDir = false, bool $bForDeleteAction = false) : string
{
$sEmail = '';
if ($mAccount instanceof \RainLoop\Model\MainAccount) {
@ -18,7 +18,7 @@ class DemoStorage extends \RainLoop\Providers\Storage\FileStorage
$sEmail = $mAccount;
}
if ($sEmail != $this->sDemoEmail) {
return parent::generateFileName($mAccount, $iStorageType, $sKey, $bMkDir, $bForDeleteAction);
return parent::GenerateFilePath($mAccount, $iStorageType, $bMkDir, $bForDeleteAction);
}
$sDataPath = "{$this->sDataPath}/demo";
@ -36,9 +36,16 @@ class DemoStorage extends \RainLoop\Providers\Storage\FileStorage
$sDataPath .= '/.sign_me';
} else if (StorageType::SESSION === $iStorageType) {
$sDataPath .= '/.sessions';
} else if (StorageType::PGP === $iStorageType) {
$sDataPath = '/.pgp';
}
return $sDataPath . '/' . ($sKey ? \RainLoop\Utils::fixName($sKey) : '');
if ($bMkDir && !\is_dir($sDataPath) && !\mkdir($sDataPath, 0700, true))
{
throw new \RainLoop\Exceptions\Exception('Can\'t make storage directory "'.$sDataPath.'"');
}
return $sDataPath . '/';
}
private $sDemoEmail;