Exemplo n.º 1
0
 /**
  * @return string
  */
 public function ServiceCss()
 {
     $sResult = '';
     $bAdmin = !empty($this->aPaths[2]) && 'Admin' === $this->aPaths[2];
     $bJson = !empty($this->aPaths[9]) && 'Json' === $this->aPaths[9];
     if ($bJson) {
         @\header('Content-Type: application/json; charset=utf-8');
     } else {
         @\header('Content-Type: text/css; charset=utf-8');
     }
     $sTheme = '';
     if (!empty($this->aPaths[4])) {
         $sTheme = $this->oActions->ValidateTheme($this->aPaths[4]);
         $sRealTheme = $sTheme;
         $bCustomTheme = '@custom' === \substr($sTheme, -7);
         if ($bCustomTheme) {
             $sRealTheme = \substr($sTheme, 0, -7);
         }
         $bCacheEnabled = $this->Config()->Get('labs', 'cache_system_data', true);
         if ($bCacheEnabled) {
             $this->oActions->verifyCacheByKey($this->sQuery);
         }
         $sCacheFileName = '';
         if ($bCacheEnabled) {
             $sCacheFileName = \RainLoop\KeyPathHelper::CssCache($sTheme, $this->oActions->Plugins()->Hash());
             $sResult = $this->Cacher()->Get($sCacheFileName);
         }
         if (0 === \strlen($sResult)) {
             try {
                 include_once APP_VERSION_ROOT_PATH . 'app/libraries/lessphp/ctype.php';
                 include_once APP_VERSION_ROOT_PATH . 'app/libraries/lessphp/lessc.inc.php';
                 $oLess = new \lessc();
                 $oLess->setFormatter('compressed');
                 $aResult = array();
                 $sThemeFile = ($bCustomTheme ? APP_INDEX_ROOT_PATH : APP_VERSION_ROOT_PATH) . 'themes/' . $sRealTheme . '/styles.less';
                 $sThemeExtFile = ($bCustomTheme ? APP_INDEX_ROOT_PATH : APP_VERSION_ROOT_PATH) . 'themes/' . $sRealTheme . '/ext.less';
                 $sThemeValuesFile = APP_VERSION_ROOT_PATH . 'app/templates/Themes/values.less';
                 $sThemeTemplateFile = APP_VERSION_ROOT_PATH . 'app/templates/Themes/template.less';
                 if (\file_exists($sThemeFile) && \file_exists($sThemeTemplateFile) && \file_exists($sThemeValuesFile)) {
                     $aResult[] = '@base: "' . ($bCustomTheme ? \RainLoop\Utils::WebPath() : \RainLoop\Utils::WebVersionPath()) . 'themes/' . $sRealTheme . '/";';
                     $aResult[] = \file_get_contents($sThemeValuesFile);
                     $aResult[] = \file_get_contents($sThemeFile);
                     $aResult[] = \file_get_contents($sThemeTemplateFile);
                     if (\file_exists($sThemeExtFile)) {
                         $aResult[] = \file_get_contents($sThemeExtFile);
                     }
                 }
                 $aResult[] = $this->Plugins()->CompileCss($bAdmin);
                 $sResult = $oLess->compile(\implode("\n", $aResult));
                 if ($bCacheEnabled) {
                     if (0 < \strlen($sCacheFileName)) {
                         $this->Cacher()->Set($sCacheFileName, $sResult);
                     }
                 }
             } catch (\Exception $oException) {
                 $this->Logger()->WriteException($oException, \MailSo\Log\Enumerations\Type::ERROR, 'LESS');
             }
         }
         if ($bCacheEnabled) {
             $this->oActions->cacheByKey($this->sQuery);
         }
     }
     return $bJson ? \MailSo\Base\Utils::Php2js(array($sTheme, $sResult), $this->Logger()) : $sResult;
 }
Exemplo n.º 2
0
 /**
  * @param bool $bAdmin
  * @param string $sAuthAccountHash = ''
  *
  * @return array
  */
 public function AppData($bAdmin, $sAuthAccountHash = '')
 {
     if (0 < \strlen($sAuthAccountHash) && \preg_match('/[^_\\-\\.a-zA-Z0-9]/', $sAuthAccountHash)) {
         $sAuthAccountHash = '';
     }
     $oAccount = null;
     $oConfig = $this->Config();
     $oPremProvider = $this->PremProvider();
     $aResult = array('Version' => APP_VERSION, 'Auth' => false, 'AccountHash' => '', 'WebPath' => \RainLoop\Utils::WebPath(), 'WebVersionPath' => \RainLoop\Utils::WebVersionPath(), 'AccountSignMe' => false, 'AuthAccountHash' => '', 'MailToEmail' => '', 'Email' => '', 'DevEmail' => '', 'DevPassword' => '', 'Title' => 'RainLoop Webmail', 'LoadingDescription' => 'RainLoop', 'LoadingDescriptionEsc' => 'RainLoop', 'FaviconUrl' => '', 'LoginDescription' => '', 'LoginPowered' => true, 'LoginLogo' => '', 'LoginBackground' => '', 'LoginCss' => '', 'UserLogo' => '', 'UserLogoTitle' => '', 'UserLogoMessage' => '', 'UserCss' => '', 'WelcomePageUrl' => '', 'WelcomePageDisplay' => 'none', 'IncludeCss' => '', 'IncludeBackground' => '', 'Token' => $oConfig->Get('security', 'csrf_protection', false) ? \RainLoop\Utils::GetCsrfToken() : '', 'InIframe' => (bool) $oConfig->Get('labs', 'in_iframe', false), 'AllowAdminPanel' => (bool) $oConfig->Get('security', 'allow_admin_panel', true), 'AllowHtmlEditorSourceButton' => (bool) $oConfig->Get('labs', 'allow_html_editor_source_button', false), 'AllowHtmlEditorBitiButtons' => (bool) $oConfig->Get('labs', 'allow_html_editor_biti_buttons', false), 'AllowCtrlEnterOnCompose' => (bool) $oConfig->Get('labs', 'allow_ctrl_enter_on_compose', false), 'UseRsaEncryption' => (bool) $oConfig->Get('security', 'use_rsa_encryption', false), 'RsaPublicKey' => '', 'CustomLoginLink' => $oConfig->Get('labs', 'custom_login_link', ''), 'CustomLogoutLink' => $oConfig->Get('labs', 'custom_logout_link', ''), 'LoginDefaultDomain' => $oConfig->Get('login', 'default_domain', ''), 'DetermineUserLanguage' => (bool) $oConfig->Get('login', 'determine_user_language', true), 'DetermineUserDomain' => (bool) $oConfig->Get('login', 'determine_user_domain', false), 'UseLoginWelcomePage' => (bool) $oConfig->Get('login', 'welcome_page', false), 'ForgotPasswordLinkUrl' => \trim($oConfig->Get('login', 'forgot_password_link_url', '')), 'RegistrationLinkUrl' => \trim($oConfig->Get('login', 'registration_link_url', '')), 'ContactsIsAllowed' => false, 'ChangePasswordIsAllowed' => false, 'RequireTwoFactor' => false, 'JsHash' => \md5(\RainLoop\Utils::GetConnectionToken()), 'UseImapThread' => (bool) $oConfig->Get('labs', 'use_imap_thread', false), 'UseImapSubscribe' => (bool) $oConfig->Get('labs', 'use_imap_list_subscribe', true), 'AllowAppendMessage' => (bool) $oConfig->Get('labs', 'allow_message_append', false), 'MaterialDesign' => (bool) $oConfig->Get('labs', 'use_material_design', true), 'FolderSpecLimit' => (int) $oConfig->Get('labs', 'folders_spec_limit', 50), 'StartupUrl' => \trim(\ltrim(\trim($oConfig->Get('labs', 'startup_url', '')), '#/')), 'FaviconStatus' => (bool) $oConfig->Get('labs', 'favicon_status', true), 'Filtered' => '' !== \trim(\RainLoop\Api::Config()->Get('labs', 'imap_message_list_permanent_filter', '')), 'Community' => true, 'PremType' => false, 'Admin' => array(), 'Capa' => array(), 'AttachmentsActions' => array(), 'Plugins' => array());
     if ($this->GetCapa(false, \RainLoop\Enumerations\Capa::ATTACHMENTS_ACTIONS)) {
         if (!!\class_exists('ZipArchive')) {
             $aResult['AttachmentsActions'][] = 'zip';
         }
         if (\RainLoop\Utils::IsOwnCloudLoggedIn() && \class_exists('OCP\\Files')) {
             $aResult['AttachmentsActions'][] = 'owncloud';
         }
         if ($oConfig->Get('social', 'dropbox_enable', false) && 0 < \strlen(\trim($oConfig->Get('social', 'dropbox_api_key', '')))) {
             $aResult['AttachmentsActions'][] = 'dropbox';
         }
     }
     $aResult['AllowDropboxSocial'] = (bool) $oConfig->Get('social', 'dropbox_enable', false);
     $aResult['DropboxApiKey'] = \trim($oConfig->Get('social', 'dropbox_api_key', ''));
     if ($aResult['UseRsaEncryption'] && \file_exists(APP_PRIVATE_DATA . 'rsa/public') && \file_exists(APP_PRIVATE_DATA . 'rsa/private')) {
         $aResult['RsaPublicKey'] = \file_get_contents(APP_PRIVATE_DATA . 'rsa/public');
         $aResult['RsaPublicKey'] = $aResult['RsaPublicKey'] ? $aResult['RsaPublicKey'] : '';
         if (false === \strpos($aResult['RsaPublicKey'], 'PUBLIC KEY')) {
             $aResult['RsaPublicKey'] = '';
         }
     }
     if (0 === \strlen($aResult['RsaPublicKey'])) {
         $aResult['UseRsaEncryption'] = false;
     }
     if (0 < \strlen($sAuthAccountHash)) {
         $aResult['AuthAccountHash'] = $sAuthAccountHash;
     }
     $aResult['Title'] = $oConfig->Get('webmail', 'title', '');
     $aResult['LoadingDescription'] = $oConfig->Get('webmail', 'loading_description', '');
     $aResult['FaviconUrl'] = $oConfig->Get('webmail', 'favicon_url', '');
     if ($oPremProvider) {
         $oPremProvider->PopulateAppData($aResult);
     }
     if ('' !== $aResult['LoadingDescription'] && 'RainLoop' !== $aResult['LoadingDescription']) {
         $aResult['LoadingDescriptionEsc'] = @\htmlspecialchars($aResult['LoadingDescription'], ENT_QUOTES | ENT_IGNORE, 'UTF-8');
     }
     $oSettings = null;
     if (!$bAdmin) {
         $oAccount = $this->getAccountFromToken(false);
         if ($oAccount instanceof \RainLoop\Model\Account) {
             $aResult['IncludeCss'] = $aResult['UserCss'];
             $oAddressBookProvider = $this->AddressBookProvider($oAccount);
             $aResult['Auth'] = true;
             $aResult['Email'] = $oAccount->Email();
             $aResult['IncLogin'] = $oAccount->IncLogin();
             $aResult['OutLogin'] = $oAccount->OutLogin();
             $aResult['AccountHash'] = $oAccount->Hash();
             $aResult['AccountSignMe'] = $oAccount->SignMe();
             $aResult['ChangePasswordIsAllowed'] = $this->ChangePasswordProvider()->PasswordChangePossibility($oAccount);
             $aResult['ContactsIsAllowed'] = $oAddressBookProvider->IsActive();
             $aResult['ContactsSharingIsAllowed'] = $oAddressBookProvider->IsSharingAllowed();
             $aResult['ContactsSyncIsAllowed'] = (bool) $oConfig->Get('contacts', 'allow_sync', false);
             $aResult['ContactsSyncInterval'] = (int) $oConfig->Get('contacts', 'sync_interval', 20);
             $aResult['EnableContactsSync'] = false;
             $aResult['ContactsSyncUrl'] = '';
             $aResult['ContactsSyncUser'] = '';
             $aResult['ContactsSyncPassword'] = '';
             if ($aResult['ContactsIsAllowed'] && $aResult['ContactsSyncIsAllowed']) {
                 $mData = $this->getContactsSyncData($oAccount);
                 if (\is_array($mData)) {
                     $aResult['EnableContactsSync'] = isset($mData['Enable']) ? !!$mData['Enable'] : false;
                     $aResult['ContactsSyncUrl'] = isset($mData['Url']) ? \trim($mData['Url']) : '';
                     $aResult['ContactsSyncUser'] = isset($mData['User']) ? \trim($mData['User']) : '';
                     $aResult['ContactsSyncPassword'] = APP_DUMMY;
                 }
             }
             if ($aResult['AccountSignMe']) {
                 $sToken = \RainLoop\Utils::GetCookie(self::AUTH_MAILTO_TOKEN_KEY, null);
                 if (null !== $sToken) {
                     \RainLoop\Utils::ClearCookie(self::AUTH_MAILTO_TOKEN_KEY);
                     $mMailToData = \RainLoop\Utils::DecodeKeyValuesQ($sToken);
                     if (\is_array($mMailToData) && !empty($mMailToData['MailTo']) && 'MailTo' === $mMailToData['MailTo'] && !empty($mMailToData['To'])) {
                         $aResult['MailToEmail'] = $mMailToData['To'];
                     }
                 }
             }
             $oSettings = $this->SettingsProvider()->Load($oAccount);
             if (!$oAccount->IsAdditionalAccount() && !empty($aResult['WelcomePageUrl']) && ('once' === $aResult['WelcomePageDisplay'] || 'always' === $aResult['WelcomePageDisplay'])) {
                 if ('once' === $aResult['WelcomePageDisplay']) {
                     if ($aResult['WelcomePageUrl'] === $oSettings->GetConf('LastWelcomePage', '')) {
                         $aResult['WelcomePageUrl'] = '';
                         $aResult['WelcomePageDisplay'] = '';
                     }
                 }
             } else {
                 $aResult['WelcomePageUrl'] = '';
                 $aResult['WelcomePageDisplay'] = '';
             }
             if (!empty($aResult['StartupUrl'])) {
                 $aResult['StartupUrl'] = $this->compileLogParams($aResult['StartupUrl'], $oAccount, true);
             }
             if (!empty($aResult['UserIframeMessage'])) {
                 $aResult['UserIframeMessage'] = $this->compileLogParams($aResult['UserIframeMessage'], $oAccount, true);
             }
         } else {
             $oAccount = null;
             $aResult['IncludeBackground'] = $aResult['LoginBackground'];
             $aResult['IncludeCss'] = $aResult['LoginCss'];
             $aResult['DevEmail'] = $oConfig->Get('labs', 'dev_email', '');
             $aResult['DevPassword'] = $oConfig->Get('labs', 'dev_password', '');
             $aResult['WelcomePageUrl'] = '';
             $aResult['WelcomePageDisplay'] = '';
             $aResult['StartupUrl'] = '';
         }
         $aResult['AllowGoogleSocial'] = (bool) $oConfig->Get('social', 'google_enable', false);
         $aResult['AllowGoogleSocialAuth'] = (bool) $oConfig->Get('social', 'google_enable_auth', true);
         $aResult['AllowGoogleSocialAuthFast'] = (bool) $oConfig->Get('social', 'google_enable_auth_fast', true);
         $aResult['AllowGoogleSocialDrive'] = (bool) $oConfig->Get('social', 'google_enable_drive', true);
         $aResult['AllowGoogleSocialPreview'] = (bool) $oConfig->Get('social', 'google_enable_preview', true);
         $aResult['GoogleClientID'] = \trim($oConfig->Get('social', 'google_client_id', ''));
         $aResult['GoogleApiKey'] = \trim($oConfig->Get('social', 'google_api_key', ''));
         if (!$aResult['AllowGoogleSocial'] || $aResult['AllowGoogleSocial'] && ('' === \trim($oConfig->Get('social', 'google_client_id', '')) || '' === \trim($oConfig->Get('social', 'google_client_secret', '')))) {
             $aResult['AllowGoogleSocialAuth'] = false;
             $aResult['AllowGoogleSocialAuthFast'] = false;
             $aResult['AllowGoogleSocialDrive'] = false;
             $aResult['GoogleClientID'] = '';
             $aResult['GoogleApiKey'] = '';
         }
         if (!$aResult['AllowGoogleSocial']) {
             $aResult['AllowGoogleSocialPreview'] = false;
         }
         if ($aResult['AllowGoogleSocial'] && !$aResult['AllowGoogleSocialAuth'] && !$aResult['AllowGoogleSocialAuthFast'] && !$aResult['AllowGoogleSocialDrive'] && !$aResult['AllowGoogleSocialPreview']) {
             $aResult['AllowGoogleSocial'] = false;
         }
         $aResult['AllowFacebookSocial'] = (bool) $oConfig->Get('social', 'fb_enable', false);
         if ($aResult['AllowFacebookSocial'] && ('' === \trim($oConfig->Get('social', 'fb_app_id', '')) || '' === \trim($oConfig->Get('social', 'fb_app_secret', '')))) {
             $aResult['AllowFacebookSocial'] = false;
         }
         $aResult['AllowTwitterSocial'] = (bool) $oConfig->Get('social', 'twitter_enable', false);
         if ($aResult['AllowTwitterSocial'] && ('' === \trim($oConfig->Get('social', 'twitter_consumer_key', '')) || '' === \trim($oConfig->Get('social', 'twitter_consumer_secret', '')))) {
             $aResult['AllowTwitterSocial'] = false;
         }
         $aResult['AllowDropboxSocial'] = (bool) $oConfig->Get('social', 'dropbox_enable', false);
         $aResult['DropboxApiKey'] = \trim($oConfig->Get('social', 'dropbox_api_key', ''));
         if (!$aResult['AllowDropboxSocial']) {
             $aResult['DropboxApiKey'] = '';
         } else {
             if (0 === strlen($aResult['DropboxApiKey'])) {
                 $aResult['AllowDropboxSocial'] = false;
             }
         }
         $aResult['Capa'] = $this->Capa(false, $oAccount);
         if ($aResult['Auth'] && !$aResult['RequireTwoFactor']) {
             if ($this->GetCapa(false, \RainLoop\Enumerations\Capa::TWO_FACTOR, $oAccount) && $this->GetCapa(false, \RainLoop\Enumerations\Capa::TWO_FACTOR_FORCE, $oAccount) && $this->TwoFactorAuthProvider()->IsActive()) {
                 $aData = $this->getTwoFactorInfo($oAccount, true);
                 $aResult['RequireTwoFactor'] = !$aData || !isset($aData['User'], $aData['IsSet'], $aData['Enable']) || !($aData['IsSet'] && $aData['Enable']);
             }
         }
     } else {
         $aResult['Auth'] = $this->IsAdminLoggined(false);
         if ($aResult['Auth']) {
             $aResult['AdminDomain'] = APP_SITE;
             $aResult['AdminLogin'] = (string) $oConfig->Get('security', 'admin_login', '');
             $aResult['UseTokenProtection'] = (bool) $oConfig->Get('security', 'csrf_protection', true);
             $aResult['EnabledPlugins'] = (bool) $oConfig->Get('plugins', 'enable', false);
             $aResult['VerifySslCertificate'] = (bool) $oConfig->Get('ssl', 'verify_certificate', false);
             $aResult['AllowSelfSigned'] = (bool) $oConfig->Get('ssl', 'allow_self_signed', true);
             $aDrivers = \class_exists('PDO') ? \PDO::getAvailableDrivers() : null;
             $aResult['MySqlIsSupported'] = \is_array($aDrivers) ? \in_array('mysql', $aDrivers) : false;
             $aResult['SQLiteIsSupported'] = \is_array($aDrivers) ? \in_array('sqlite', $aDrivers) : false;
             $aResult['PostgreSqlIsSupported'] = \is_array($aDrivers) ? \in_array('pgsql', $aDrivers) : false;
             $aResult['ContactsEnable'] = (bool) $oConfig->Get('contacts', 'enable', false);
             $aResult['ContactsSharing'] = (bool) $oConfig->Get('contacts', 'allow_sharing', false);
             $aResult['ContactsSync'] = (bool) $oConfig->Get('contacts', 'allow_sync', false);
             $aResult['ContactsPdoType'] = (string) $this->ValidateContactPdoType(\trim($this->Config()->Get('contacts', 'type', 'sqlite')));
             $aResult['ContactsPdoDsn'] = (string) $oConfig->Get('contacts', 'pdo_dsn', '');
             $aResult['ContactsPdoType'] = (string) $oConfig->Get('contacts', 'type', '');
             $aResult['ContactsPdoUser'] = (string) $oConfig->Get('contacts', 'pdo_user', '');
             $aResult['ContactsPdoPassword'] = (string) APP_DUMMY;
             $aResult['AllowGoogleSocial'] = (bool) $oConfig->Get('social', 'google_enable', false);
             $aResult['AllowGoogleSocialAuth'] = (bool) $oConfig->Get('social', 'google_enable_auth', true);
             $aResult['AllowGoogleSocialAuthFast'] = (bool) $oConfig->Get('social', 'google_enable_auth_fast', true);
             $aResult['AllowGoogleSocialDrive'] = (bool) $oConfig->Get('social', 'google_enable_drive', true);
             $aResult['AllowGoogleSocialPreview'] = (bool) $oConfig->Get('social', 'google_enable_preview', true);
             $aResult['GoogleClientID'] = (string) $oConfig->Get('social', 'google_client_id', '');
             $aResult['GoogleClientSecret'] = (string) $oConfig->Get('social', 'google_client_secret', '');
             $aResult['GoogleApiKey'] = (string) $oConfig->Get('social', 'google_api_key', '');
             $aResult['AllowFacebookSocial'] = (bool) $oConfig->Get('social', 'fb_enable', false);
             $aResult['FacebookAppID'] = (string) $oConfig->Get('social', 'fb_app_id', '');
             $aResult['FacebookAppSecret'] = (string) $oConfig->Get('social', 'fb_app_secret', '');
             $aResult['AllowTwitterSocial'] = (bool) $oConfig->Get('social', 'twitter_enable', false);
             $aResult['TwitterConsumerKey'] = (string) $oConfig->Get('social', 'twitter_consumer_key', '');
             $aResult['TwitterConsumerSecret'] = (string) $oConfig->Get('social', 'twitter_consumer_secret', '');
             $aResult['AllowDropboxSocial'] = (bool) $oConfig->Get('social', 'dropbox_enable', false);
             $aResult['DropboxApiKey'] = (string) $oConfig->Get('social', 'dropbox_api_key', '');
             $aResult['SubscriptionEnabled'] = (bool) \MailSo\Base\Utils::ValidateDomain($aResult['AdminDomain']);
             //					|| \MailSo\Base\Utils::ValidateIP($aResult['AdminDomain']);
             $aResult['WeakPassword'] = (bool) $oConfig->ValidatePassword('12345');
             $aResult['CoreAccess'] = (bool) $this->rainLoopCoreAccess();
             $aResult['PhpUploadSizes'] = array('upload_max_filesize' => \ini_get('upload_max_filesize'), 'post_max_size' => \ini_get('post_max_size'));
         }
         $aResult['Capa'] = $this->Capa(true);
     }
     $aResult['SupportedFacebookSocial'] = (bool) \version_compare(PHP_VERSION, '5.4.0', '>=');
     if (!$aResult['SupportedFacebookSocial']) {
         $aResult['AllowFacebookSocial'] = false;
         $aResult['FacebookAppID'] = '';
         $aResult['FacebookAppSecret'] = '';
     }
     $aResult['ProjectHash'] = \md5($aResult['AccountHash'] . APP_VERSION . $this->Plugins()->Hash());
     $sLanguage = $oConfig->Get('webmail', 'language', 'en');
     $sLanguageAdmin = $oConfig->Get('webmail', 'language_admin', 'en');
     $sTheme = $oConfig->Get('webmail', 'theme', 'Default');
     $aResult['Themes'] = $this->GetThemes();
     $aResult['Languages'] = $this->GetLanguages(false);
     $aResult['LanguagesAdmin'] = $this->GetLanguages(true);
     $aResult['AllowLanguagesOnSettings'] = (bool) $oConfig->Get('webmail', 'allow_languages_on_settings', true);
     $aResult['AllowLanguagesOnLogin'] = (bool) $oConfig->Get('login', 'allow_languages_on_login', true);
     $aResult['AttachmentLimit'] = (int) $oConfig->Get('webmail', 'attachment_size_limit', 10) * 1024 * 1024;
     $aResult['SignMe'] = (string) $oConfig->Get('login', 'sign_me_auto', \RainLoop\Enumerations\SignMeType::DEFAILT_OFF);
     $aResult['UseLocalProxyForExternalImages'] = (bool) $oConfig->Get('labs', 'use_local_proxy_for_external_images', false);
     // user
     $aResult['ShowImages'] = (bool) $oConfig->Get('defaults', 'show_images', false);
     $aResult['MPP'] = (int) $oConfig->Get('webmail', 'messages_per_page', 25);
     $aResult['SoundNotification'] = false;
     $aResult['DesktopNotifications'] = false;
     $aResult['Layout'] = (int) $oConfig->Get('defaults', 'view_layout', \RainLoop\Enumerations\Layout::SIDE_PREVIEW);
     $aResult['EditorDefaultType'] = (string) $oConfig->Get('defaults', 'view_editor_type', '');
     $aResult['UseCheckboxesInList'] = (bool) $oConfig->Get('defaults', 'view_use_checkboxes', true);
     $aResult['AutoLogout'] = (int) $oConfig->Get('defaults', 'autologout', 30);
     $aResult['UseThreads'] = (bool) $oConfig->Get('defaults', 'mail_use_threads', false);
     $aResult['ReplySameFolder'] = (bool) $oConfig->Get('defaults', 'mail_reply_same_folder', false);
     $aResult['ContactsAutosave'] = (bool) $oConfig->Get('defaults', 'contacts_autosave', true);
     $aResult['EnableTwoFactor'] = false;
     $aResult['ParentEmail'] = '';
     $aResult['InterfaceAnimation'] = true;
     $aResult['UserBackgroundName'] = '';
     $aResult['UserBackgroundHash'] = '';
     if (!$bAdmin && $oAccount instanceof \RainLoop\Model\Account) {
         $aResult['ParentEmail'] = $oAccount->ParentEmail();
         $oSettingsLocal = $this->SettingsProvider(true)->Load($oAccount);
         if ($oSettingsLocal instanceof \RainLoop\Settings) {
             // if ($this->GetCapa(false, \RainLoop\Enumerations\Capa::FOLDERS, $oAccount))
             $aResult['SentFolder'] = (string) $oSettingsLocal->GetConf('SentFolder', '');
             $aResult['DraftFolder'] = (string) $oSettingsLocal->GetConf('DraftFolder', '');
             $aResult['SpamFolder'] = (string) $oSettingsLocal->GetConf('SpamFolder', '');
             $aResult['TrashFolder'] = (string) $oSettingsLocal->GetConf('TrashFolder', '');
             $aResult['ArchiveFolder'] = (string) $oSettingsLocal->GetConf('ArchiveFolder', '');
             $aResult['NullFolder'] = (string) $oSettingsLocal->GetConf('NullFolder', '');
         }
         if ($this->GetCapa(false, \RainLoop\Enumerations\Capa::SETTINGS, $oAccount)) {
             if ($oSettings instanceof \RainLoop\Settings) {
                 if ($oConfig->Get('webmail', 'allow_languages_on_settings', true)) {
                     $sLanguage = (string) $oSettings->GetConf('Language', $sLanguage);
                 }
                 $aResult['EditorDefaultType'] = (string) $oSettings->GetConf('EditorDefaultType', $aResult['EditorDefaultType']);
                 $aResult['ShowImages'] = (bool) $oSettings->GetConf('ShowImages', $aResult['ShowImages']);
                 $aResult['ContactsAutosave'] = (bool) $oSettings->GetConf('ContactsAutosave', $aResult['ContactsAutosave']);
                 $aResult['MPP'] = (int) $oSettings->GetConf('MPP', $aResult['MPP']);
                 $aResult['SoundNotification'] = (bool) $oSettings->GetConf('SoundNotification', $aResult['SoundNotification']);
                 $aResult['DesktopNotifications'] = (bool) $oSettings->GetConf('DesktopNotifications', $aResult['DesktopNotifications']);
                 $aResult['UseCheckboxesInList'] = (bool) $oSettings->GetConf('UseCheckboxesInList', $aResult['UseCheckboxesInList']);
                 $aResult['AutoLogout'] = (int) $oSettings->GetConf('AutoLogout', $aResult['AutoLogout']);
                 $aResult['Layout'] = (int) $oSettings->GetConf('Layout', $aResult['Layout']);
                 if (!$this->GetCapa(false, \RainLoop\Enumerations\Capa::AUTOLOGOUT, $oAccount)) {
                     $aResult['AutoLogout'] = 0;
                 }
                 if ($this->GetCapa(false, \RainLoop\Enumerations\Capa::USER_BACKGROUND, $oAccount)) {
                     $aResult['UserBackgroundName'] = (string) $oSettings->GetConf('UserBackgroundName', $aResult['UserBackgroundName']);
                     $aResult['UserBackgroundHash'] = (string) $oSettings->GetConf('UserBackgroundHash', $aResult['UserBackgroundHash']);
                     //					if (!empty($aResult['UserBackgroundName']) && !empty($aResult['UserBackgroundHash']))
                     //					{
                     //						$aResult['IncludeBackground'] = './?/Raw/&q[]=/{{USER}}/UserBackground/&q[]=/'.
                     //							$aResult['UserBackgroundHash'].'/';
                     //					}
                 }
                 $aResult['EnableTwoFactor'] = (bool) $oSettings->GetConf('EnableTwoFactor', $aResult['EnableTwoFactor']);
             }
             if ($oSettingsLocal instanceof \RainLoop\Settings) {
                 $aResult['UseThreads'] = (bool) $oSettingsLocal->GetConf('UseThreads', $aResult['UseThreads']);
                 $aResult['ReplySameFolder'] = (bool) $oSettingsLocal->GetConf('ReplySameFolder', $aResult['ReplySameFolder']);
                 if ($this->GetCapa(false, \RainLoop\Enumerations\Capa::THEMES, $oAccount)) {
                     $sTheme = (string) $oSettingsLocal->GetConf('Theme', $sTheme);
                 }
             }
         }
     }
     $sStaticCache = \md5(APP_VERSION . $this->Plugins()->Hash());
     $sTheme = $this->ValidateTheme($sTheme);
     $sNewThemeLink = './?/Css/0/' . ($bAdmin ? 'Admin' : 'User') . '/-/' . $sTheme . '/-/' . $sStaticCache . '/Hash/-/';
     if (!$aResult['Auth']) {
         if (!$bAdmin) {
             if ($oConfig->Get('login', 'allow_languages_on_login', true) && $oConfig->Get('login', 'determine_user_language', true)) {
                 $sLanguage = $this->ValidateLanguage($this->detectUserLanguage($bAdmin), $sLanguage, false);
             }
         }
     }
     $sPluginsLink = '';
     if (0 < $this->Plugins()->Count() && $this->Plugins()->HaveJs($bAdmin)) {
         $sPluginsLink = './?/Plugins/0/' . ($bAdmin ? 'Admin' : 'User') . '/' . $sStaticCache . '/';
     }
     $aResult['Theme'] = $sTheme;
     $aResult['NewThemeLink'] = $sNewThemeLink;
     $aResult['Language'] = $this->ValidateLanguage($sLanguage, '', false);
     $aResult['LanguageAdmin'] = $this->ValidateLanguage($sLanguageAdmin, '', true);
     $aResult['UserLanguageRaw'] = $this->detectUserLanguage($bAdmin);
     $aResult['UserLanguage'] = $this->ValidateLanguage($aResult['UserLanguageRaw'], '', false, true);
     $aResult['UserLanguageAdmin'] = $this->ValidateLanguage($aResult['UserLanguageRaw'], '', true, true);
     $aResult['LangLink'] = './?/Lang/0/' . ($bAdmin ? 'Admin' : 'App') . '/' . ($bAdmin ? $aResult['LanguageAdmin'] : $aResult['Language']) . '/' . $sStaticCache . '/';
     $aResult['TemplatesLink'] = './?/Templates/0/' . ($bAdmin ? 'Admin' : 'App') . '/' . $sStaticCache . '/';
     $aResult['PluginsLink'] = $sPluginsLink;
     $aResult['EditorDefaultType'] = \in_array($aResult['EditorDefaultType'], array('Plain', 'Html', 'HtmlForced', 'PlainForced')) ? $aResult['EditorDefaultType'] : 'Plain';
     // IDN
     $aResult['Email'] = \MailSo\Base\Utils::IdnToUtf8($aResult['Email']);
     $aResult['ParentEmail'] = \MailSo\Base\Utils::IdnToUtf8($aResult['ParentEmail']);
     $aResult['MailToEmail'] = \MailSo\Base\Utils::IdnToUtf8($aResult['MailToEmail']);
     $aResult['DevEmail'] = \MailSo\Base\Utils::IdnToUtf8($aResult['DevEmail']);
     $this->Plugins()->InitAppData($bAdmin, $aResult, $oAccount);
     return $aResult;
 }
Exemplo n.º 3
0
 /**
  * @param bool $bAdmin = false
  *
  * @return array
  */
 private function indexTemplateParameters($bAdmin = false)
 {
     $sLanguage = 'en';
     $sTheme = 'Default';
     list($sLanguage, $sTheme) = $this->oActions->GetLanguageAndTheme($bAdmin);
     $bAppJsDebug = !!$this->oActions->Config()->Get('labs', 'use_app_debug_js', false);
     $bAppCssDebug = !!$this->oActions->Config()->Get('labs', 'use_app_debug_css', false);
     $sFaviconUrl = (string) $this->oActions->Config()->Get('webmail', 'favicon_url', '');
     $sStaticPrefix = \RainLoop\Utils::WebStaticPath();
     $aData = array('Language' => $sLanguage, 'Theme' => $sTheme, 'FaviconPngLink' => $sFaviconUrl ? $sFaviconUrl : $sStaticPrefix . 'favicon.png', 'AppleTouchLink' => $sFaviconUrl ? '' : $sStaticPrefix . 'apple-touch-icon.png', 'AppCssLink' => $sStaticPrefix . 'css/app' . ($bAppCssDebug ? '' : '.min') . '.css', 'BootJsLink' => $sStaticPrefix . 'js/min/boot.js', 'ComponentsJsLink' => $sStaticPrefix . 'js/' . ($bAppJsDebug ? '' : 'min/') . 'components.js', 'LibJsLink' => $sStaticPrefix . 'js/min/libs.js', 'EditorJsLink' => $sStaticPrefix . 'ckeditor/ckeditor.js', 'OpenPgpJsLink' => $sStaticPrefix . 'js/min/openpgp.min.js', 'AppJsCommonLink' => $sStaticPrefix . 'js/' . ($bAppJsDebug ? '' : 'min/') . 'common.js', 'AppJsLink' => $sStaticPrefix . 'js/' . ($bAppJsDebug ? '' : 'min/') . ($bAdmin ? 'admin' : 'app') . '.js');
     $aTemplateParameters = array('{{BaseAppDataScriptLink}}' => $bAdmin ? './?/AdminAppData/' : './?/AppData/', '{{BaseAppFaviconPngLinkTag}}' => $aData['FaviconPngLink'] ? '<link rel="shortcut icon" href="' . $aData['FaviconPngLink'] . '" type="image/png" />' : '', '{{BaseAppFaviconTouchLinkTag}}' => $aData['AppleTouchLink'] ? '<link rel="apple-touch-icon" href="' . $aData['AppleTouchLink'] . '" type="image/png" />' : '', '{{BaseAppAppleTouchFile}}' => $aData['AppleTouchLink'], '{{BaseAppMainCssLink}}' => $aData['AppCssLink'], '{{BaseAppBootScriptLink}}' => $aData['BootJsLink'], '{{BaseAppComponentsScriptLink}}' => $aData['ComponentsJsLink'], '{{BaseAppLibsScriptLink}}' => $aData['LibJsLink'], '{{BaseAppEditorScriptLink}}' => $aData['EditorJsLink'], '{{BaseAppOpenPgpScriptLink}}' => $aData['OpenPgpJsLink'], '{{BaseAppMainCommonScriptLink}}' => $aData['AppJsCommonLink'], '{{BaseAppMainScriptLink}}' => $aData['AppJsLink'], '{{BaseVersion}}' => APP_VERSION, '{{BaseDir}}' => 'ltr');
     $aTemplateParameters['{{BaseHash}}'] = \md5(\implode('~', array($bAdmin ? '1' : '0', \md5($this->oActions->Config()->Get('cache', 'index', '')), $this->oActions->Plugins()->Hash(), \RainLoop\Utils::WebVersionPath(), APP_VERSION)) . \implode('~', $aTemplateParameters));
     return $aTemplateParameters;
 }
Exemplo n.º 4
0
 /**
  * @param bool $bAdmin
  *
  * @return array
  */
 private function indexTemplateParameters($bAdmin)
 {
     $sLanguage = 'en';
     $sTheme = 'Default';
     if (!$bAdmin) {
         list($sLanguage, $sTheme) = $this->oActions->GetLanguageAndTheme();
     }
     $sLanguage = $this->oActions->ValidateLanguage($sLanguage);
     $sTheme = $this->oActions->ValidateTheme($sTheme);
     $bAppJsDebug = !!$this->oActions->Config()->Get('labs', 'use_app_debug_js', false);
     $bAppCssDebug = !!$this->oActions->Config()->Get('labs', 'use_app_debug_css', false);
     $sStaticPrefix = \RainLoop\Utils::WebStaticPath();
     $aData = array('Language' => $sLanguage, 'Theme' => $sTheme, 'FaviconIcoLink' => $sStaticPrefix . 'favicon.ico', 'FaviconPngLink' => $sStaticPrefix . 'favicon.png', 'AppleTouchLink' => $sStaticPrefix . 'apple-touch-icon.png', 'AppCssLink' => $sStaticPrefix . 'css/app' . ($bAppCssDebug ? '' : '.min') . '.css', 'BootJsLink' => $sStaticPrefix . 'js/min/boot.js', 'ComponentsJsLink' => $sStaticPrefix . 'js/' . ($bAppJsDebug ? '' : 'min/') . 'components.js', 'LibJsLink' => $sStaticPrefix . 'js/min/libs.js', 'EditorJsLink' => $sStaticPrefix . 'ckeditor/ckeditor.js', 'OpenPgpJsLink' => $sStaticPrefix . 'js/min/openpgp.min.js', 'AppJsCommonLink' => $sStaticPrefix . 'js/' . ($bAppJsDebug ? '' : 'min/') . 'common.js', 'AppJsLink' => $sStaticPrefix . 'js/' . ($bAppJsDebug ? '' : 'min/') . ($bAdmin ? 'admin' : 'app') . '.js');
     $aTemplateParameters = array('{{BaseAppDataScriptLink}}' => $bAdmin ? './?/AdminAppData/' : './?/AppData/', '{{BaseAppFaviconIcoFile}}' => $aData['FaviconIcoLink'], '{{BaseAppFaviconPngFile}}' => $aData['FaviconPngLink'], '{{BaseAppAppleTouchFile}}' => $aData['AppleTouchLink'], '{{BaseAppMainCssLink}}' => $aData['AppCssLink'], '{{BaseAppBootScriptLink}}' => $aData['BootJsLink'], '{{BaseAppComponentsScriptLink}}' => $aData['ComponentsJsLink'], '{{BaseAppLibsScriptLink}}' => $aData['LibJsLink'], '{{BaseAppEditorScriptLink}}' => $aData['EditorJsLink'], '{{BaseAppOpenPgpScriptLink}}' => $aData['OpenPgpJsLink'], '{{BaseAppMainCommonScriptLink}}' => $aData['AppJsCommonLink'], '{{BaseAppMainScriptLink}}' => $aData['AppJsLink'], '{{BaseDir}}' => \in_array($aData['Language'], array('ar', 'he', 'ur')) ? 'rtl' : 'ltr');
     $aTemplateParameters['{{BaseHash}}'] = \md5(\implode('~', array(\md5($this->oActions->Config()->Get('cache', 'index', '')), $this->oActions->Plugins()->Hash(), \RainLoop\Utils::WebVersionPath(), APP_VERSION)) . \implode('~', $aTemplateParameters));
     return $aTemplateParameters;
 }