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 * @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 = ''; $sEmail = '';
if ($mAccount instanceof \RainLoop\Model\MainAccount) { if ($mAccount instanceof \RainLoop\Model\MainAccount) {
@ -18,7 +18,7 @@ class DemoStorage extends \RainLoop\Providers\Storage\FileStorage
$sEmail = $mAccount; $sEmail = $mAccount;
} }
if ($sEmail != $this->sDemoEmail) { if ($sEmail != $this->sDemoEmail) {
return parent::generateFileName($mAccount, $iStorageType, $sKey, $bMkDir, $bForDeleteAction); return parent::GenerateFilePath($mAccount, $iStorageType, $bMkDir, $bForDeleteAction);
} }
$sDataPath = "{$this->sDataPath}/demo"; $sDataPath = "{$this->sDataPath}/demo";
@ -36,9 +36,16 @@ class DemoStorage extends \RainLoop\Providers\Storage\FileStorage
$sDataPath .= '/.sign_me'; $sDataPath .= '/.sign_me';
} else if (StorageType::SESSION === $iStorageType) { } else if (StorageType::SESSION === $iStorageType) {
$sDataPath .= '/.sessions'; $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; private $sDemoEmail;

View file

@ -139,12 +139,9 @@ class FileStorage implements \RainLoop\Providers\Storage\IStorage
throw new \Exception("Invalid storage type {$iStorageType}"); throw new \Exception("Invalid storage type {$iStorageType}");
} }
if ($bMkDir && !empty($sFilePath) && !\is_dir(\dirname($sFilePath))) if ($bMkDir && !empty($sFilePath) && !\is_dir($sFilePath) && !\mkdir($sFilePath, 0700, true))
{ {
if (!\mkdir(\dirname($sFilePath), 0700, true)) throw new \RainLoop\Exceptions\Exception('Can\'t make storage directory "'.$sFilePath.'"');
{
throw new \RainLoop\Exceptions\Exception('Can\'t make storage directory "'.$sFilePath.'"');
}
} }
return $sFilePath; return $sFilePath;

View file

@ -257,7 +257,7 @@
"POPUP_IMPORT_BUTTON": "Importeer", "POPUP_IMPORT_BUTTON": "Importeer",
"POPUP_VIEW_TITLE": "Bekijk OpenPGP sleutel", "POPUP_VIEW_TITLE": "Bekijk OpenPGP sleutel",
"POPUP_VIEW_BUTTON": "Selecteer", "POPUP_VIEW_BUTTON": "Selecteer",
"POPUP_GENERATE_TITLE": "Genereer OpenPGP sleutels", "POPUP_GENERATE_TITLE": "Genereer OpenPGP sleutel",
"POPUP_GENERATE_BUTTON": "Genereer", "POPUP_GENERATE_BUTTON": "Genereer",
"LABEL_KEY_TYPE": "Type", "LABEL_KEY_TYPE": "Type",
"LABEL_SIGN": "Ondertekenen", "LABEL_SIGN": "Ondertekenen",
@ -450,7 +450,7 @@
}, },
"SETTINGS_OPEN_PGP": { "SETTINGS_OPEN_PGP": {
"BUTTON_ADD_OPEN_PGP_KEY": "Importeer OpenPGP sleutel", "BUTTON_ADD_OPEN_PGP_KEY": "Importeer OpenPGP sleutel",
"BUTTON_GENERATE_OPEN_PGP_KEYS": "Genereer OpenPGP sleutels", "BUTTON_GENERATE_OPEN_PGP_KEYS": "Genereer OpenPGP sleutel",
"TITLE_PRIVATE": "Privé sleutel", "TITLE_PRIVATE": "Privé sleutel",
"TITLE_PUBLIC": "Publieke sleutel", "TITLE_PUBLIC": "Publieke sleutel",
"LABEL_ALLOW_DRAFT_AUTOSAVE": "Automatically save draft" "LABEL_ALLOW_DRAFT_AUTOSAVE": "Automatically save draft"