diff options
author | dartcafe <github@dartcafe.de> | 2022-04-27 19:51:01 +0300 |
---|---|---|
committer | dartcafe <github@dartcafe.de> | 2022-04-27 19:51:01 +0300 |
commit | f791601b58b9da815910f3a13839af68f57264c8 (patch) | |
tree | f585af865711856ac13716005c1508e11142a308 /lib | |
parent | 8fcd39431d3cf91da9334c6a069f163daab88cdc (diff) |
Some refactoring
Signed-off-by: dartcafe <github@dartcafe.de>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Controller/WatchController.php | 2 | ||||
-rw-r--r-- | lib/Cron/JanitorCron.php | 4 | ||||
-rw-r--r-- | lib/Db/Comment.php | 2 | ||||
-rw-r--r-- | lib/Db/Share.php | 2 | ||||
-rw-r--r-- | lib/Listener/BaseListener.php | 2 | ||||
-rw-r--r-- | lib/Model/Mail/MailBase.php | 8 | ||||
-rw-r--r-- | lib/Model/Settings/AppSettings.php | 275 | ||||
-rw-r--r-- | lib/Service/MailService.php | 3 | ||||
-rw-r--r-- | lib/Service/SettingsService.php | 46 |
9 files changed, 108 insertions, 236 deletions
diff --git a/lib/Controller/WatchController.php b/lib/Controller/WatchController.php index 415c229c..cdb6f9fb 100644 --- a/lib/Controller/WatchController.php +++ b/lib/Controller/WatchController.php @@ -61,7 +61,7 @@ class WatchController extends Controller { $timeout = 30; $offset = $offset ?? $start; - if ($this->appSettings->getUpdateType() === 'longPolling') { + if ($this->appSettings->getStringSetting(AppSettings::SETTING_UPDATE_TYPE) === 'longPolling') { while (empty($updates) && time() <= $start + $timeout) { sleep(1); $updates = $this->watchService->getUpdates($pollId, $offset); diff --git a/lib/Cron/JanitorCron.php b/lib/Cron/JanitorCron.php index 726815f1..90739eca 100644 --- a/lib/Cron/JanitorCron.php +++ b/lib/Cron/JanitorCron.php @@ -67,9 +67,9 @@ class JanitorCron extends TimedJob { $this->logMapper->deleteOldEntries(time() - (86400 * 7)); // delete entries older than 7 days $this->watchMapper->deleteOldEntries(time() - 86400); // delete entries older than 1 day - if ($this->appSettings->getAutoArchive() && $this->appSettings->getAutoArchiveOffset() > 0) { + if ($this->appSettings->getBooleanSetting(AppSettings::SETTING_AUTO_ARCHIVE) && $this->appSettings->getIntegerSetting(AppSettings::SETTING_AUTO_ARCHIVE_OFFSET) > 0) { $this->pollMapper->archiveExpiredPolls( - time() - ($this->appSettings->getAutoArchiveOffset() * 86400) + time() - ($this->appSettings->getIntegerSetting(AppSettings::SETTING_AUTO_ARCHIVE_OFFSET) * 86400) ); // archive polls after defined days after closing date } } diff --git a/lib/Db/Comment.php b/lib/Db/Comment.php index 23acc951..29f23ce4 100644 --- a/lib/Db/Comment.php +++ b/lib/Db/Comment.php @@ -82,7 +82,7 @@ class Comment extends Entity implements JsonSerializable { ]; } - public function addSubComment(Comment $comment) { + public function addSubComment(Comment $comment): void { $this->subComments[] = [ 'id' => $comment->getId(), 'comment' => $comment->getComment(), diff --git a/lib/Db/Share.php b/lib/Db/Share.php index 47fd0bfd..bb072b3b 100644 --- a/lib/Db/Share.php +++ b/lib/Db/Share.php @@ -146,7 +146,7 @@ class Share extends Entity implements JsonSerializable { 'displayName' => $this->getDisplayName(), 'isNoUser' => !(in_array($this->getType(), [self::TYPE_USER, self::TYPE_ADMIN], true)), 'URL' => $this->getURL(), - 'showLogin' => $this->appSettings->getShowLogin(), + 'showLogin' => $this->appSettings->getBooleanSetting(AppSettings::SETTING_SHOW_LOGIN), 'publicPollEmail' => $this->getPublicPollEmail(), ]; } diff --git a/lib/Listener/BaseListener.php b/lib/Listener/BaseListener.php index b76411b3..915277f6 100644 --- a/lib/Listener/BaseListener.php +++ b/lib/Listener/BaseListener.php @@ -85,7 +85,7 @@ abstract class BaseListener implements IEventListener { $this->addLog(); // If addLog throws UniqueConstraintViolationException, avoid spamming activities - if ($this->appSettings->getUseActivity()) { + if ($this->appSettings->getBooleanSetting(AppSettings::SETTING_USE_ACTIVITY)) { $this->addActivity(); } } catch (InvalidClassException $e) { diff --git a/lib/Model/Mail/MailBase.php b/lib/Model/Mail/MailBase.php index 18d1a421..74c4865c 100644 --- a/lib/Model/Mail/MailBase.php +++ b/lib/Model/Mail/MailBase.php @@ -148,12 +148,12 @@ abstract class MailBase { // add footer $footerText = $this->getFooter(); - if ($this->appSettings->getLegalTermsInEmail()) { + if ($this->appSettings->getBooleanSetting(AppSettings::SETTING_LEGAL_TERMS_IN_EMAIL)) { $footerText = $footerText . '<br>' . $this->getLegalLinks(); } - if ($this->appSettings->getDisclaimer()) { - $footerText = $footerText . '<br>' . $this->getParsedMarkDown($this->appSettings->getDisclaimer()); + if ($this->appSettings->getStringSetting(AppSettings::SETTING_DISCLAIMER)) { + $footerText = $footerText . '<br>' . $this->getParsedMarkDown($this->appSettings->getStringSetting(AppSettings::SETTING_DISCLAIMER)); } $this->emailTemplate->addFooter($footerText); @@ -182,7 +182,7 @@ abstract class MailBase { $this->emailTemplate->addBodyText('Sorry. This eMail has no text and this should not happen.'); } - protected function getLegalLinks() { + protected function getLegalLinks(): string { $legal = ''; if ($this->appSettings->getUseImprintUrl()) { diff --git a/lib/Model/Settings/AppSettings.php b/lib/Model/Settings/AppSettings.php index bd3d7ddd..d63dfc88 100644 --- a/lib/Model/Settings/AppSettings.php +++ b/lib/Model/Settings/AppSettings.php @@ -32,6 +32,32 @@ use OCP\IUserSession; class AppSettings implements JsonSerializable { private const APP_NAME = 'polls'; + public const SETTING_ALLOW_PUBLIC_SHARES = 'allowPublicShares'; + public const SETTING_ALLOW_COMBO = 'allowCombo'; + public const SETTING_ALLOW_ALL_ACCESS = 'allowAllAccess'; + public const SETTING_ALLOW_POLL_CREATION = 'allowPollCreation'; + public const SETTING_ALLOW_POLL_DOWNLOAD = 'allowPollDownload'; + public const SETTING_AUTO_ARCHIVE = 'autoArchive'; + public const SETTING_LEGAL_TERMS_IN_EMAIL = 'legalTermsInEmail'; + public const SETTING_SHOW_LOGIN = 'showLogin'; + public const SETTING_USE_ACTIVITY = 'useActivity'; + // new + public const SETTING_ALL_ACCESS_GROUPS = 'allAccessGroups'; + public const SETTING_POLL_CREATION_GROUPS = 'pollCreationGroups'; + public const SETTING_POLL_DOWNLOAD_GROUPS = 'pollDownloadGroups'; + public const SETTING_PUBLIC_SHARES_GROUPS = 'publicSharesGroups'; + public const SETTING_SHOW_MAIL_ADDRESSES_GROUPS = 'showMailAddressesGroups'; + public const SETTING_COMBO_GROUPS = 'comboGroups'; + + public const SETTING_SHOW_MAIL_ADDRESSES = 'showMailAddresses'; + public const SETTING_AUTO_ARCHIVE_OFFSET = 'autoArchiveOffset'; + public const SETTING_UPDATE_TYPE = 'updateType'; + public const SETTING_PRIVACY_URL = 'privacyUrl'; + public const SETTING_IMPRINT_URL = 'imprintUrl'; + public const SETTING_USE_PRIVACY_URL = 'usePrivacyUrl'; + public const SETTING_USE_IMPRINT_URL = 'useImprintUrl'; + public const SETTING_DISCLAIMER = 'disclaimer'; + /** @var IConfig */ private $config; @@ -64,148 +90,72 @@ class AppSettings implements JsonSerializable { return $this->stringToArray($this->config->getAppValue(self::APP_NAME, $key)); } - public function getStringSetting(string $key): string { - return $this->config->getAppValue(self::APP_NAME, $key); - } - - // explicit setters - public function getAllowCombo(): bool { - return $this->stringToBool($this->config->getAppValue(self::APP_NAME, 'allowCombo'), true); - } - - public function getShowMailAddresses(): bool { - return $this->stringToBool($this->config->getAppValue(self::APP_NAME, 'showMailAddresses'), true); - } - - public function getAllowPublicShares(): bool { - return $this->stringToBool($this->config->getAppValue(self::APP_NAME, 'allowPublicShares'), true); - } - - public function getAllowAllAccess(): bool { - return $this->stringToBool($this->config->getAppValue(self::APP_NAME, 'allowAllAccess'), true); - } - - public function getAllowPollCreation(): bool { - return $this->stringToBool($this->config->getAppValue(self::APP_NAME, 'allowPollCreation'), true); + public function getStringSetting(string $key, string $default = ''): string { + return $this->config->getAppValue(self::APP_NAME, $key) ?: $default; } - - public function getAllowPollDownload(): bool { - return $this->stringToBool($this->config->getAppValue(self::APP_NAME, 'allowPollDownload'), true); - } - - public function getPublicSharesGroups(): array { - return $this->stringToArray($this->config->getAppValue(self::APP_NAME, 'publicSharesGroups')); - } - public function getComboGroups(): array { - return $this->stringToArray($this->config->getAppValue(self::APP_NAME, 'comboGroups')); - } - public function getAllAccessGroups(): array { - return $this->stringToArray($this->config->getAppValue(self::APP_NAME, 'allAccessGroups')); - } - - public function getAutoArchive(): bool { - return $this->stringToBool($this->config->getAppValue(self::APP_NAME, 'autoArchive'), false); - } - - public function getAutoArchiveOffset(): int { - return $this->stringToInteger($this->config->getAppValue(self::APP_NAME, 'autoArchiveOffset'), 30); - } - - public function getPollCreationGroups(): array { - return $this->stringToArray($this->config->getAppValue(self::APP_NAME, 'pollCreationGroups')); - } - - public function getPollDownloadGroups(): array { - return $this->stringToArray($this->config->getAppValue(self::APP_NAME, 'pollDownloadGroups')); - } - - public function getShowLogin(): bool { - return $this->stringToBool($this->config->getAppValue(self::APP_NAME, 'showLogin'), true); - } - - public function getUpdateType(): string { - return $this->config->getAppValue(self::APP_NAME, 'updateType') ?: 'longPolling'; - } - - public function getUseActivity(): bool { - return $this->stringToBool($this->config->getAppValue(self::APP_NAME, 'useActivity'), false); + public function getIntegerSetting(string $key, int $default = 0): int { + return $this->stringToInteger($this->config->getAppValue(self::APP_NAME, $key), $default); } // Checks public function getPollCreationAllowed(): bool { if ($this->session->isLoggedIn()) { - return $this->getAllowPollCreation() || $this->isMember($this->getPollCreationGroups()); + return $this->getBooleanSetting(self::SETTING_ALLOW_POLL_CREATION) || $this->isMember($this->$this->getGroupSetting(self::SETTING_POLL_CREATION_GROUPS)); } return false; } public function getAllowSeeMailAddresses(): bool { if ($this->session->isLoggedIn()) { - return $this->getShowMailAddresses() || $this->isMember($this->getGroupSetting('showMailAddressesGroups')); + return $this->getBooleanSetting(self::SETTING_SHOW_MAIL_ADDRESSES) || $this->isMember($this->getGroupSetting(self::SETTING_SHOW_MAIL_ADDRESSES_GROUPS)); } return false; } public function getPollDownloadAllowed(): bool { if ($this->session->isLoggedIn()) { - return $this->getAllowPollDownload() || $this->isMember($this->getPollDownloadGroups()); + return $this->getBooleanSetting(self::SETTING_ALLOW_POLL_DOWNLOAD) || $this->isMember($this->getGroupSetting(self::SETTING_POLL_DOWNLOAD_GROUPS)); } return false; } public function getAllAccessAllowed(): bool { if ($this->session->isLoggedIn()) { - return $this->getAllowAllAccess() || $this->isMember($this->getAllAccessGroups()); + return $this->getBooleanSetting(self::SETTING_ALLOW_ALL_ACCESS) || $this->isMember($this->getGroupSetting(self::SETTING_ALL_ACCESS_GROUPS)); } return false; } public function getPublicSharesAllowed(): bool { if ($this->session->isLoggedIn()) { - return $this->getAllowPublicShares() || $this->isMember($this->getPublicSharesGroups()); + return $this->getBooleanSetting(self::SETTING_ALLOW_PUBLIC_SHARES) || $this->isMember($this->getGroupSetting(self::SETTING_PUBLIC_SHARES_GROUPS)); } return false; } public function getComboAllowed(): bool { if ($this->session->isLoggedIn()) { - return $this->getAllowCombo() || $this->isMember($this->getComboGroups()); + return $this->getBooleanSetting(self::SETTING_ALLOW_COMBO) + || $this->isMember($this->getGroupSetting(self::SETTING_COMBO_GROUPS)); } return false; } - public function getLegalTermsInEmail(): bool { - return $this->stringToBool($this->config->getAppValue(self::APP_NAME, 'legalTermsInEmail'), true); - } - - public function getPrivacyUrl(): string { - return $this->config->getAppValue(self::APP_NAME, 'privacyUrl'); - } - public function getUsePrivacyUrl(): string { - if ($this->config->getAppValue(self::APP_NAME, 'privacyUrl')) { - return $this->config->getAppValue(self::APP_NAME, 'privacyUrl'); + if ($this->config->getAppValue(self::APP_NAME, self::SETTING_PRIVACY_URL)) { + return $this->config->getAppValue(self::APP_NAME, self::SETTING_PRIVACY_URL); } return $this->config->getAppValue('theming', 'privacyUrl'); } - public function getImprintUrl(): string { - return $this->config->getAppValue(self::APP_NAME, 'imprintUrl'); - } - - public function getUseImprintUrl(): string { - if ($this->config->getAppValue(self::APP_NAME, 'imprintUrl')) { - return $this->config->getAppValue(self::APP_NAME, 'imprintUrl'); + if ($this->config->getAppValue(self::APP_NAME, self::SETTING_IMPRINT_URL)) { + return $this->config->getAppValue(self::APP_NAME, self::SETTING_IMPRINT_URL); } return $this->config->getAppValue('theming', 'imprintUrl'); } - - public function getDisclaimer(): string { - return $this->config->getAppValue(self::APP_NAME, 'disclaimer'); - } - + // Setters // generic setters public function setBooleanSetting(string $key, bool $value): void { @@ -216,91 +166,10 @@ class AppSettings implements JsonSerializable { $this->config->setAppValue(self::APP_NAME, $key, json_encode($value)); } - public function setStringSettings(string $key, string $value): void { + public function setStringSetting(string $key, string $value): void { $this->config->setAppValue(self::APP_NAME, $key, $value); } - // explicit setters - public function setAllowPublicShares(bool $value): void { - $this->config->setAppValue(self::APP_NAME, 'allowPublicShares', $this->boolToString($value)); - } - - public function setAllowCombo(bool $value): void { - $this->config->setAppValue(self::APP_NAME, 'allowCombo', $this->boolToString($value)); - } - - public function setShowLogin(bool $value): void { - $this->config->setAppValue(self::APP_NAME, 'showLogin', $this->boolToString($value)); - } - - public function setAllowAllAccess(bool $value): void { - $this->config->setAppValue(self::APP_NAME, 'allowAllAccess', $this->boolToString($value)); - } - - public function setAllowPollCreation(bool $value): void { - $this->config->setAppValue(self::APP_NAME, 'allowPollCreation', $this->boolToString($value)); - } - - public function setAllowPollDownload(bool $value): void { - $this->config->setAppValue(self::APP_NAME, 'allowPollDownload', $this->boolToString($value)); - } - - public function setPublicSharesGroups(array $value): void { - $this->config->setAppValue(self::APP_NAME, 'publicSharesGroups', json_encode($value)); - } - - public function setShowMailAddressesGroups(array $value): void { - $this->config->setAppValue(self::APP_NAME, 'showMailAddressesGroups', json_encode($value)); - } - - public function setComboGroups(array $value): void { - $this->config->setAppValue(self::APP_NAME, 'comboGroups', json_encode($value)); - } - - public function setAllAccessGroups(array $value): void { - $this->config->setAppValue(self::APP_NAME, 'allAccessGroups', json_encode($value)); - } - - public function setPollCreationGroups(array $value): void { - $this->config->setAppValue(self::APP_NAME, 'pollCreationGroups', json_encode($value)); - } - - public function setPollDownloadGroups(array $value): void { - $this->config->setAppValue(self::APP_NAME, 'pollDownloadGroups', json_encode($value)); - } - - public function setAutoArchive(bool $value): void { - $this->config->setAppValue(self::APP_NAME, 'autoArchive', $this->boolToString($value)); - } - - public function setAutoArchiveOffset(int $value): void { - $this->config->setAppValue(self::APP_NAME, 'autoArchiveOffset', strval($value)); - } - - public function setUpdateType(string $value): void { - $this->config->setAppValue(self::APP_NAME, 'updateType', $value); - } - - public function setUseActivity(bool $value): void { - $this->config->setAppValue(self::APP_NAME, 'useActivity', $this->boolToString($value)); - } - - public function setLegalTermsInEmail(bool $value): void { - $this->config->setAppValue(self::APP_NAME, 'legalTermsInEmail', $this->boolToString($value)); - } - - public function setPrivacyUrl(string $value): void { - $this->config->setAppValue(self::APP_NAME, 'privacyUrl', $value); - } - - public function setImprintUrl(string $value): void { - $this->config->setAppValue(self::APP_NAME, 'imprintUrl', $value); - } - - public function setDisclaimer(string $value): void { - $this->config->setAppValue(self::APP_NAME, 'disclaimer', $value); - } - public function jsonSerialize() { // convert group ids to group objects $publicSharesGroups = []; @@ -310,56 +179,56 @@ class AppSettings implements JsonSerializable { $pollDownloadGroups = []; $showMailAddressesGroups = []; - foreach ($this->getPublicSharesGroups() as $group) { + foreach ($this->getGroupSetting(self::SETTING_PUBLIC_SHARES_GROUPS) as $group) { $publicSharesGroups[] = new Group($group); } - foreach ($this->getComboGroups() as $group) { + foreach ($this->getGroupSetting(self::SETTING_COMBO_GROUPS) as $group) { $comboGroups[] = new Group($group); } - foreach ($this->getAllAccessGroups() as $group) { + foreach ($this->getGroupSetting(self::SETTING_ALL_ACCESS_GROUPS) as $group) { $allAccessGroups[] = new Group($group); } - foreach ($this->getPollCreationGroups() as $group) { + foreach ($this->getGroupSetting(self::SETTING_POLL_CREATION_GROUPS) as $group) { $pollCreationGroups[] = new Group($group); } - foreach ($this->getPollDownloadGroups() as $group) { + foreach ($this->getGroupSetting(self::SETTING_POLL_DOWNLOAD_GROUPS) as $group) { $pollDownloadGroups[] = new Group($group); } - foreach ($this->getGroupSetting('showMailAddressesGroups') as $group) { + foreach ($this->getGroupSetting(self::SETTING_SHOW_MAIL_ADDRESSES_GROUPS) as $group) { $showMailAddressesGroups[] = new Group($group); } return [ - 'allowPublicShares' => $this->getAllowPublicShares(), - 'allowCombo' => $this->getAllowCombo(), - 'allowAllAccess' => $this->getAllowAllAccess(), - 'allowPollCreation' => $this->getAllowPollCreation(), - 'allowPollDownload' => $this->getAllowPollDownload(), - 'allAccessGroups' => $allAccessGroups, - 'pollCreationGroups' => $pollCreationGroups, - 'pollDownloadGroups' => $pollDownloadGroups, - 'publicSharesGroups' => $publicSharesGroups, - 'showMailAddressesGroups' => $showMailAddressesGroups, - 'comboGroups' => $comboGroups, - 'showLogin' => $this->getShowLogin(), - 'showMailAddresses' => $this->getShowMailAddresses(), - 'autoArchive' => $this->getAutoArchive(), - 'autoArchiveOffset' => $this->getAutoArchiveOffset(), - 'updateType' => $this->getUpdateType(), - 'useActivity' => $this->getUseActivity(), - 'privacyUrl' => $this->getPrivacyUrl(), - 'legalTermsInEmail' => $this->getLegalTermsInEmail(), - 'imprintUrl' => $this->getImprintUrl(), - 'usePrivacyUrl' => $this->getUsePrivacyUrl(), - 'useImprintUrl' => $this->getUseImprintUrl(), + self::SETTING_ALLOW_PUBLIC_SHARES => $this->getBooleanSetting(self::SETTING_ALLOW_PUBLIC_SHARES), + self::SETTING_ALLOW_COMBO => $this->getBooleanSetting(self::SETTING_ALLOW_COMBO), + self::SETTING_ALLOW_ALL_ACCESS => $this->getBooleanSetting(self::SETTING_ALLOW_ALL_ACCESS), + self::SETTING_ALLOW_POLL_CREATION => $this->getBooleanSetting(self::SETTING_ALLOW_POLL_CREATION), + self::SETTING_ALLOW_POLL_DOWNLOAD => $this->getBooleanSetting(self::SETTING_ALLOW_POLL_DOWNLOAD), + self::SETTING_AUTO_ARCHIVE => $this->getBooleanSetting(self::SETTING_AUTO_ARCHIVE), + self::SETTING_LEGAL_TERMS_IN_EMAIL => $this->getBooleanSetting(self::SETTING_LEGAL_TERMS_IN_EMAIL), + self::SETTING_SHOW_LOGIN => $this->getBooleanSetting(self::SETTING_SHOW_LOGIN), + self::SETTING_SHOW_MAIL_ADDRESSES => $this->getBooleanSetting(self::SETTING_SHOW_MAIL_ADDRESSES), + self::SETTING_USE_ACTIVITY => $this->getBooleanSetting(self::SETTING_USE_ACTIVITY), + self::SETTING_USE_PRIVACY_URL => $this->getBooleanSetting(self::SETTING_USE_PRIVACY_URL), + self::SETTING_USE_IMPRINT_URL => $this->getBooleanSetting(self::SETTING_USE_IMPRINT_URL), + self::SETTING_ALL_ACCESS_GROUPS => $allAccessGroups, + self::SETTING_POLL_CREATION_GROUPS => $pollCreationGroups, + self::SETTING_POLL_DOWNLOAD_GROUPS => $pollDownloadGroups, + self::SETTING_PUBLIC_SHARES_GROUPS => $publicSharesGroups, + self::SETTING_SHOW_MAIL_ADDRESSES_GROUPS => $showMailAddressesGroups, + self::SETTING_COMBO_GROUPS => $comboGroups, + self::SETTING_AUTO_ARCHIVE_OFFSET => $this->getIntegerSetting(self::SETTING_AUTO_ARCHIVE_OFFSET,30), + self::SETTING_DISCLAIMER => $this->getStringSetting(self::SETTING_DISCLAIMER), + self::SETTING_IMPRINT_URL => $this->getStringSetting(self::SETTING_IMPRINT_URL), + self::SETTING_PRIVACY_URL => $this->getStringSetting(self::SETTING_PRIVACY_URL), + self::SETTING_UPDATE_TYPE => $this->getStringSetting(self::SETTING_UPDATE_TYPE, 'longPolling'), 'defaultPrivacyUrl' => $this->config->getAppValue('theming', 'privacyUrl'), 'defaultImprintUrl' => $this->config->getAppValue('theming', 'imprintUrl'), - 'disclaimer' => $this->getDisclaimer(), ]; } diff --git a/lib/Service/MailService.php b/lib/Service/MailService.php index 6d20ecfb..2eb61dfa 100644 --- a/lib/Service/MailService.php +++ b/lib/Service/MailService.php @@ -113,7 +113,8 @@ class MailService { public function resolveEmailAddress(int $pollId, string $userId): string { if ($this->userManager->get($userId) instanceof IUser) { - return $this->config->getUserValue($userId, 'settings', 'email'); + $user = new User($userId); + return $user->getEmailAddressMasked(); } // if $userId is no site user, eval via shares diff --git a/lib/Service/SettingsService.php b/lib/Service/SettingsService.php index c313b568..d1c7ea97 100644 --- a/lib/Service/SettingsService.php +++ b/lib/Service/SettingsService.php @@ -58,27 +58,29 @@ class SettingsService { * Write app settings */ public function writeAppSettings(array $settingsArray): void { - $this->appSettings->setBooleanSetting('showMailAddresses', $settingsArray['showMailAddresses']); - $this->appSettings->setGroupSetting('showMailAddressesGroups', array_column($settingsArray['showMailAddressesGroups'], 'id')); - - $this->appSettings->setAllowPublicShares($settingsArray['allowPublicShares']); - $this->appSettings->setAllowCombo($settingsArray['allowCombo']); - $this->appSettings->setAllowAllAccess($settingsArray['allowAllAccess']); - $this->appSettings->setAllowPollCreation($settingsArray['allowPollCreation']); - $this->appSettings->setAllowPollDownload($settingsArray['allowPollDownload']); - $this->appSettings->setAutoArchive($settingsArray['autoArchive']); - $this->appSettings->setShowLogin($settingsArray['showLogin']); - $this->appSettings->setAutoArchiveOffset($settingsArray['autoArchiveOffset']); - $this->appSettings->setAllAccessGroups(array_column($settingsArray['allAccessGroups'], 'id')); - $this->appSettings->setPublicSharesGroups(array_column($settingsArray['publicSharesGroups'], 'id')); - $this->appSettings->setComboGroups(array_column($settingsArray['comboGroups'], 'id')); - $this->appSettings->setPollCreationGroups(array_column($settingsArray['pollCreationGroups'], 'id')); - $this->appSettings->setPollDownloadGroups(array_column($settingsArray['pollDownloadGroups'], 'id')); - $this->appSettings->setUpdateType($settingsArray['updateType']); - $this->appSettings->setUseActivity($settingsArray['useActivity']); - $this->appSettings->setPrivacyUrl($settingsArray['privacyUrl']); - $this->appSettings->setImprintUrl($settingsArray['imprintUrl']); - $this->appSettings->setLegalTermsInEmail($settingsArray['legalTermsInEmail']); - $this->appSettings->setDisclaimer($settingsArray['disclaimer']); + + $this->appSettings->setBooleanSetting(AppSettings::SETTING_SHOW_MAIL_ADDRESSES, $settingsArray[AppSettings::SETTING_SHOW_MAIL_ADDRESSES]); + $this->appSettings->setBooleanSetting(AppSettings::SETTING_ALLOW_PUBLIC_SHARES, $settingsArray[AppSettings::SETTING_ALLOW_PUBLIC_SHARES]); + $this->appSettings->setBooleanSetting(AppSettings::SETTING_ALLOW_COMBO, $settingsArray[AppSettings::SETTING_ALLOW_COMBO]); + $this->appSettings->setBooleanSetting(AppSettings::SETTING_ALLOW_ALL_ACCESS, $settingsArray[AppSettings::SETTING_ALLOW_ALL_ACCESS]); + $this->appSettings->setBooleanSetting(AppSettings::SETTING_ALLOW_POLL_CREATION, $settingsArray[AppSettings::SETTING_ALLOW_POLL_CREATION]); + $this->appSettings->setBooleanSetting(AppSettings::SETTING_ALLOW_POLL_DOWNLOAD, $settingsArray[AppSettings::SETTING_ALLOW_POLL_DOWNLOAD]); + $this->appSettings->setBooleanSetting(AppSettings::SETTING_AUTO_ARCHIVE, $settingsArray[AppSettings::SETTING_AUTO_ARCHIVE]); + $this->appSettings->setBooleanSetting(AppSettings::SETTING_SHOW_LOGIN, $settingsArray[AppSettings::SETTING_SHOW_LOGIN]); + $this->appSettings->setBooleanSetting(AppSettings::SETTING_USE_ACTIVITY, $settingsArray[AppSettings::SETTING_USE_ACTIVITY]); + $this->appSettings->setBooleanSetting(AppSettings::SETTING_LEGAL_TERMS_IN_EMAIL, $settingsArray[AppSettings::SETTING_LEGAL_TERMS_IN_EMAIL]); + + $this->appSettings->setGroupSetting(AppSettings::SETTING_SHOW_MAIL_ADDRESSES_GROUPS, array_column($settingsArray[AppSettings::SETTING_SHOW_MAIL_ADDRESSES_GROUPS], 'id')); + $this->appSettings->setGroupSetting(AppSettings::SETTING_ALL_ACCESS_GROUPS, array_column($settingsArray[AppSettings::SETTING_ALL_ACCESS_GROUPS], 'id')); + $this->appSettings->setGroupSetting(AppSettings::SETTING_PUBLIC_SHARES_GROUPS, array_column($settingsArray[AppSettings::SETTING_PUBLIC_SHARES_GROUPS], 'id')); + $this->appSettings->setGroupSetting(AppSettings::SETTING_COMBO_GROUPS, array_column($settingsArray[AppSettings::SETTING_COMBO_GROUPS], 'id')); + $this->appSettings->setGroupSetting(AppSettings::SETTING_POLL_CREATION_GROUPS, array_column($settingsArray[AppSettings::SETTING_POLL_CREATION_GROUPS], 'id')); + $this->appSettings->setGroupSetting(AppSettings::SETTING_POLL_DOWNLOAD_GROUPS, array_column($settingsArray[AppSettings::SETTING_POLL_DOWNLOAD_GROUPS], 'id')); + + $this->appSettings->setStringSetting(AppSettings::SETTING_AUTO_ARCHIVE_OFFSET, strval($settingsArray[AppSettings::SETTING_AUTO_ARCHIVE_OFFSET])); + $this->appSettings->setStringSetting(AppSettings::SETTING_UPDATE_TYPE, $settingsArray[AppSettings::SETTING_UPDATE_TYPE]); + $this->appSettings->setStringSetting(AppSettings::SETTING_PRIVACY_URL, $settingsArray[AppSettings::SETTING_PRIVACY_URL]); + $this->appSettings->setStringSetting(AppSettings::SETTING_IMPRINT_URL, $settingsArray[AppSettings::SETTING_IMPRINT_URL]); + $this->appSettings->setStringSetting(AppSettings::SETTING_DISCLAIMER, $settingsArray[AppSettings::SETTING_DISCLAIMER]); } } |