From f50d848b3505c1fb614a617a63b51aaaea061bc7 Mon Sep 17 00:00:00 2001 From: the-djmaze <> Date: Fri, 28 Jan 2022 15:43:40 +0100 Subject: [PATCH] Updated demo plugin for upcoming v2.12 --- plugins/demo-account/storage.php | 13 ++++++++++--- .../RainLoop/Providers/Storage/FileStorage.php | 7 ++----- snappymail/v/0.0.0/app/localization/nl-NL/user.json | 4 ++-- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/plugins/demo-account/storage.php b/plugins/demo-account/storage.php index aafb26e4c..37db89310 100644 --- a/plugins/demo-account/storage.php +++ b/plugins/demo-account/storage.php @@ -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; diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/Providers/Storage/FileStorage.php b/snappymail/v/0.0.0/app/libraries/RainLoop/Providers/Storage/FileStorage.php index ccc703151..223abff40 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/Providers/Storage/FileStorage.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/Providers/Storage/FileStorage.php @@ -139,12 +139,9 @@ class FileStorage implements \RainLoop\Providers\Storage\IStorage 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; diff --git a/snappymail/v/0.0.0/app/localization/nl-NL/user.json b/snappymail/v/0.0.0/app/localization/nl-NL/user.json index d09ea26c7..477a35b63 100644 --- a/snappymail/v/0.0.0/app/localization/nl-NL/user.json +++ b/snappymail/v/0.0.0/app/localization/nl-NL/user.json @@ -257,7 +257,7 @@ "POPUP_IMPORT_BUTTON": "Importeer", "POPUP_VIEW_TITLE": "Bekijk OpenPGP sleutel", "POPUP_VIEW_BUTTON": "Selecteer", - "POPUP_GENERATE_TITLE": "Genereer OpenPGP sleutels", + "POPUP_GENERATE_TITLE": "Genereer OpenPGP sleutel", "POPUP_GENERATE_BUTTON": "Genereer", "LABEL_KEY_TYPE": "Type", "LABEL_SIGN": "Ondertekenen", @@ -450,7 +450,7 @@ }, "SETTINGS_OPEN_PGP": { "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_PUBLIC": "Publieke sleutel", "LABEL_ALLOW_DRAFT_AUTOSAVE": "Automatically save draft"