/** * @param bool $bAdmin * @param \RainLoop\Model\Account $oAccount = null * * @return array */ public function Capa($bAdmin, $oAccount = null) { $oConfig = $this->Config(); $aResult = array(); if ($oConfig->Get('capa', 'folders', true)) { $aResult[] = \RainLoop\Enumerations\Capa::FOLDERS; if ($oConfig->Get('capa', 'messagelist_actions', true)) { $aResult[] = \RainLoop\Enumerations\Capa::MESSAGELIST_ACTIONS; if ($oConfig->Get('capa', 'dangerous_actions', true)) { $aResult[] = \RainLoop\Enumerations\Capa::DANGEROUS_ACTIONS; } } } if ($oConfig->Get('capa', 'reload', true)) { $aResult[] = \RainLoop\Enumerations\Capa::RELOAD; } if ($oConfig->Get('capa', 'quota', true)) { $aResult[] = \RainLoop\Enumerations\Capa::QUOTA; } if ($oConfig->Get('capa', 'settings', true)) { $aResult[] = \RainLoop\Enumerations\Capa::SETTINGS; if ($oConfig->Get('webmail', 'allow_additional_accounts', false)) { $aResult[] = \RainLoop\Enumerations\Capa::ADDITIONAL_ACCOUNTS; } if ($oConfig->Get('webmail', 'allow_additional_identities', false)) { $aResult[] = \RainLoop\Enumerations\Capa::IDENTITIES; } if ($oConfig->Get('capa', 'x-templates', true)) { $aResult[] = \RainLoop\Enumerations\Capa::TEMPLATES; } if ($oConfig->Get('webmail', 'allow_themes', false)) { $aResult[] = \RainLoop\Enumerations\Capa::THEMES; } if ($oConfig->Get('webmail', 'allow_user_background', false)) { $aResult[] = \RainLoop\Enumerations\Capa::USER_BACKGROUND; } if ($oConfig->Get('security', 'openpgp', false)) { $aResult[] = \RainLoop\Enumerations\Capa::OPEN_PGP; } if ($oConfig->Get('capa', 'filters', false)) { $aResult[] = \RainLoop\Enumerations\Capa::FILTERS; if ($bAdmin || $oAccount && $oAccount->Domain()->UseSieve()) { $aResult[] = \RainLoop\Enumerations\Capa::SIEVE; } } } if ($oConfig->Get('security', 'allow_two_factor_auth', false) && ($bAdmin || $oAccount && !$oAccount->IsAdditionalAccount())) { $aResult[] = \RainLoop\Enumerations\Capa::TWO_FACTOR; if ($oConfig->Get('security', 'force_two_factor_auth', false) && ($bAdmin || $oAccount && !$oAccount->IsAdditionalAccount())) { $aResult[] = \RainLoop\Enumerations\Capa::TWO_FACTOR_FORCE; } } if ($oConfig->Get('capa', 'help', true)) { $aResult[] = \RainLoop\Enumerations\Capa::HELP; } if ($oConfig->Get('capa', 'attachments_actions', false)) { $aResult[] = \RainLoop\Enumerations\Capa::ATTACHMENTS_ACTIONS; } if ($oConfig->Get('capa', 'message_actions', true)) { $aResult[] = \RainLoop\Enumerations\Capa::MESSAGE_ACTIONS; } if ($oConfig->Get('capa', 'composer', true)) { $aResult[] = \RainLoop\Enumerations\Capa::COMPOSER; if ($oConfig->Get('capa', 'contacts', true)) { $aResult[] = \RainLoop\Enumerations\Capa::CONTACTS; } } if ($oConfig->Get('capa', 'search', true)) { $aResult[] = \RainLoop\Enumerations\Capa::SEARCH; if ($oConfig->Get('capa', 'search_adv', true)) { $aResult[] = \RainLoop\Enumerations\Capa::SEARCH_ADV; } } if ($oConfig->Get('labs', 'allow_gravatar', false)) { $aResult[] = \RainLoop\Enumerations\Capa::GRAVATAR; } if ($oConfig->Get('interface', 'show_attachment_thumbnail', true)) { $aResult[] = \RainLoop\Enumerations\Capa::ATTACHMENT_THUMBNAILS; } if ($oConfig->Get('labs', 'allow_prefetch', false)) { $aResult[] = \RainLoop\Enumerations\Capa::PREFETCH; } if (!\RainLoop\Utils::IsOwnCloud()) { $aResult[] = \RainLoop\Enumerations\Capa::AUTOLOGOUT; } return $aResult; }
/** * @param \RainLoop\Model\Account $oAccount * @param string $sKey * @param bool $bMkDir = false * * @return string */ private function generateFileName($oAccount, $sKey, $bMkDir = false) { $sEmail = $sSubEmail = ''; if ($oAccount instanceof \RainLoop\Model\Account) { $sEmail = \preg_replace('/[^a-z0-9\\-\\.@]+/', '_', $oAccount->ParentEmailHelper()); if ($oAccount->IsAdditionalAccount()) { $sSubEmail = \preg_replace('/[^a-z0-9\\-\\.@]+/', '_', $oAccount->Email()); } } if (empty($sEmail)) { $sEmail = '__unknown__'; } $sKeyPath = \sha1($sKey); $sKeyPath = \substr($sKeyPath, 0, 2) . '/' . \substr($sKeyPath, 2, 2) . '/' . $sKeyPath; $sFilePath = $this->sDataPath . '/' . \str_pad(\rtrim(\substr($sEmail, 0, 2), '@'), 2, '_') . '/' . $sEmail . '/' . (0 < \strlen($sSubEmail) ? $sSubEmail . '/' : '') . $sKeyPath; if ($bMkDir && !empty($sFilePath) && !@\is_dir(\dirname($sFilePath))) { if (!@\mkdir(\dirname($sFilePath), 0755, true)) { throw new \RainLoop\Exceptions\Exception('Can\'t make storage directory "' . $sFilePath . '"'); } } return $sFilePath; }
/** * @param \RainLoop\Model\Account|string|null $mAccount * @param int $iStorageType * @param string $sKey * @param bool $bMkDir = false * @param bool $bForDeleteAction = false * * @return string */ public function generateFileName($mAccount, $iStorageType, $sKey, $bMkDir = false, $bForDeleteAction = false) { if (null === $mAccount) { $iStorageType = \RainLoop\Providers\Storage\Enumerations\StorageType::NOBODY; } $sEmail = $sSubEmail = ''; if ($mAccount instanceof \RainLoop\Model\Account) { $sEmail = $mAccount->ParentEmailHelper(); if ($this->bLocal && $mAccount->IsAdditionalAccount() && !$bForDeleteAction) { $sSubEmail = $mAccount->Email(); } } if (\is_string($mAccount) && empty($sEmail)) { $sEmail = $mAccount; } $sEmail = \preg_replace('/[^a-z0-9\\-\\.@]+/', '_', $sEmail); $sSubEmail = \preg_replace('/[^a-z0-9\\-\\.@]+/', '_', $sSubEmail); $sTypePath = $sKeyPath = ''; switch ($iStorageType) { default: case \RainLoop\Providers\Storage\Enumerations\StorageType::USER: case \RainLoop\Providers\Storage\Enumerations\StorageType::NOBODY: $sTypePath = 'data'; $sKeyPath = \md5($sKey); $sKeyPath = \substr($sKeyPath, 0, 2) . '/' . $sKeyPath; break; case \RainLoop\Providers\Storage\Enumerations\StorageType::CONFIG: $sTypePath = 'cfg'; $sKeyPath = \preg_replace('/[_]+/', '_', \preg_replace('/[^a-zA-Z0-9\\/]/', '_', $sKey)); break; } $sFilePath = ''; if (\RainLoop\Providers\Storage\Enumerations\StorageType::NOBODY === $iStorageType) { $sFilePath = $this->sDataPath . '/' . $sTypePath . '/__nobody__/' . $sKeyPath; } else { if (!empty($sEmail)) { $sFilePath = $this->sDataPath . '/' . $sTypePath . '/' . \str_pad(\rtrim(\substr($sEmail, 0, 2), '@'), 2, '_') . '/' . $sEmail . '/' . (0 < \strlen($sSubEmail) ? $sSubEmail . '/' : '') . ($bForDeleteAction ? '' : $sKeyPath); } } if ($bMkDir && !$bForDeleteAction && !empty($sFilePath) && !@\is_dir(\dirname($sFilePath))) { if (!@\mkdir(\dirname($sFilePath), 0755, true)) { throw new \RainLoop\Exceptions\Exception('Can\'t make storage directory "' . $sFilePath . '"'); } } return $sFilePath; }
/** * @param bool $bAdmin * @param \RainLoop\Model\Account $oAccount = null * * @return array */ public function Capa($bAdmin, $oAccount = null) { $oConfig = $this->Config(); $aResult = array(); if ($oConfig->Get('capa', 'filters', false)) { $aResult[] = \RainLoop\Enumerations\Capa::FILTERS; if ($bAdmin || $oAccount && $oAccount->Domain()->UseSieve()) { $aResult[] = \RainLoop\Enumerations\Capa::SIEVE; } } // if ($oConfig->Get('capa', 'templates', true)) // { // $aResult[] = \RainLoop\Enumerations\Capa::TEMPLATES; // } if ($oConfig->Get('webmail', 'allow_additional_accounts', false)) { $aResult[] = \RainLoop\Enumerations\Capa::ADDITIONAL_ACCOUNTS; } if ($oConfig->Get('security', 'allow_two_factor_auth', false) && ($bAdmin || $oAccount && !$oAccount->IsAdditionalAccount())) { $aResult[] = \RainLoop\Enumerations\Capa::TWO_FACTOR; } if ($oConfig->Get('labs', 'allow_gravatar', false)) { $aResult[] = \RainLoop\Enumerations\Capa::GRAVATAR; } if ($oConfig->Get('interface', 'show_attachment_thumbnail', true)) { $aResult[] = \RainLoop\Enumerations\Capa::ATTACHMENT_THUMBNAILS; } if ($oConfig->Get('labs', 'allow_prefetch', false)) { $aResult[] = \RainLoop\Enumerations\Capa::PREFETCH; } if ($oConfig->Get('webmail', 'allow_themes', false)) { $aResult[] = \RainLoop\Enumerations\Capa::THEMES; } if ($oConfig->Get('webmail', 'allow_user_background', false)) { $aResult[] = \RainLoop\Enumerations\Capa::USER_BACKGROUND; } if ($oConfig->Get('security', 'openpgp', false)) { $aResult[] = \RainLoop\Enumerations\Capa::OPEN_PGP; } if (!\RainLoop\Utils::IsOwnCloud()) { $aResult[] = \RainLoop\Enumerations\Capa::AUTOLOGOUT; } return $aResult; }