mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-06 16:07:03 +03:00
Welcome page branding option
This commit is contained in:
parent
acb013fbb5
commit
351c12c002
50 changed files with 531 additions and 160 deletions
|
|
@ -232,7 +232,7 @@ class HtmlUtils
|
|||
{
|
||||
if ($oElement)
|
||||
{
|
||||
if (\preg_match('/http[s]?:\/\//i', $sUrl))
|
||||
if (\preg_match('/http[s]?:\/\//i', $sUrl) || '//' === \substr($sUrl, 0, 2))
|
||||
{
|
||||
$bHasExternals = true;
|
||||
if (!$bDoNotReplaceExternalUrl)
|
||||
|
|
@ -452,7 +452,7 @@ class HtmlUtils
|
|||
foreach ($aNodes as /* @var $oElement \DOMElement */ $oElement)
|
||||
{
|
||||
if (\in_array(\strtolower($oElement->tagName), array('svg', 'head', 'link',
|
||||
'base', 'meta', 'title', 'style', 'script', 'bgsound', 'keygen', 'source',
|
||||
'base', 'meta', 'title', 'style', 'x-script', 'script', 'bgsound', 'keygen', 'source',
|
||||
'object', 'embed', 'applet', 'mocha', 'iframe', 'frame', 'frameset', 'video', 'audio')) && isset($oElement->parentNode))
|
||||
{
|
||||
@$oElement->parentNode->removeChild($oElement);
|
||||
|
|
@ -546,8 +546,8 @@ class HtmlUtils
|
|||
// }
|
||||
|
||||
foreach (array(
|
||||
'id', 'class', 'contenteditable', 'designmode', 'formaction', 'data-bind', 'xmlns',
|
||||
'srcset'
|
||||
'id', 'class', 'contenteditable', 'designmode', 'formaction',
|
||||
'data-bind', 'xmlns', 'srcset'
|
||||
) as $sAttr)
|
||||
{
|
||||
@$oElement->removeAttribute($sAttr);
|
||||
|
|
@ -566,7 +566,8 @@ class HtmlUtils
|
|||
if ($oElement->hasAttribute('href'))
|
||||
{
|
||||
$sHref = \trim($oElement->getAttribute('href'));
|
||||
if (!\preg_match('/^(http[s]?|ftp|skype|mailto):/i', $sHref))
|
||||
if (!\preg_match('/^(http[s]?|ftp|skype|mailto):/i', $sHref) ||
|
||||
'//' !== \substr($sHref, 0, 2))
|
||||
{
|
||||
$oElement->setAttribute('data-x-broken-href', $sHref);
|
||||
$oElement->setAttribute('href', 'javascript:false');
|
||||
|
|
@ -594,7 +595,8 @@ class HtmlUtils
|
|||
}
|
||||
else
|
||||
{
|
||||
if (\preg_match('/http[s]?:\/\//i', $sSrc))
|
||||
if (\preg_match('/^http[s]?:\/\//i', $sSrc) ||
|
||||
'//' === \substr($sSrc, 0, 2))
|
||||
{
|
||||
if ($bDoNotReplaceExternalUrl)
|
||||
{
|
||||
|
|
@ -615,7 +617,7 @@ class HtmlUtils
|
|||
|
||||
$bHasExternals = true;
|
||||
}
|
||||
else if ('data:image/' === \strtolower(\substr(\trim($sSrc), 0, 11)))
|
||||
else if ('data:image/' === \strtolower(\substr($sSrc, 0, 11)))
|
||||
{
|
||||
$oElement->setAttribute('src', $sSrc);
|
||||
}
|
||||
|
|
@ -745,7 +747,7 @@ class HtmlUtils
|
|||
{
|
||||
$oElement->removeAttribute('data-x-additional-src');
|
||||
}
|
||||
|
||||
|
||||
if ($oElement->hasAttribute('data-x-additional-style-url'))
|
||||
{
|
||||
$oElement->removeAttribute('data-x-additional-style-url');
|
||||
|
|
|
|||
|
|
@ -1286,6 +1286,8 @@ class Actions
|
|||
'LoginCss' => '',
|
||||
'UserLogo' => '',
|
||||
'UserCss' => '',
|
||||
'WelcomePageUrl' => '',
|
||||
'WelcomePageDisplay' => 'none',
|
||||
'IncludeCss' => '',
|
||||
'IncludeBackground' => '',
|
||||
'Token' => $oConfig->Get('security', 'csrf_protection', false) ? \RainLoop\Utils::GetCsrfToken() : '',
|
||||
|
|
@ -1352,6 +1354,8 @@ class Actions
|
|||
$aResult['LoginPowered'] = !!$oConfig->Get('branding', 'login_powered', true);
|
||||
$aResult['UserLogo'] = $oConfig->Get('branding', 'user_logo', '');
|
||||
$aResult['UserCss'] = $oConfig->Get('branding', 'user_css', '');
|
||||
$aResult['WelcomePageUrl'] = $oConfig->Get('branding', 'welcome_page_url', '');
|
||||
$aResult['WelcomePageDisplay'] = \strtolower($oConfig->Get('branding', 'welcome_page_display', 'none'));
|
||||
}
|
||||
|
||||
$aResult['LoadingDescriptionEsc'] = \htmlspecialchars($aResult['LoadingDescription'], ENT_QUOTES|ENT_IGNORE, 'UTF-8');
|
||||
|
|
@ -1414,6 +1418,24 @@ class Actions
|
|||
|
||||
$oSettings = $this->SettingsProvider()->Load($oAccount);
|
||||
$oSettingsLocal = $this->SettingsProvider(true)->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'] = '';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -1424,6 +1446,9 @@ class Actions
|
|||
|
||||
$aResult['DevEmail'] = $oConfig->Get('labs', 'dev_email', '');
|
||||
$aResult['DevPassword'] = $oConfig->Get('labs', 'dev_password', '');
|
||||
|
||||
$aResult['WelcomePageUrl'] = '';
|
||||
$aResult['WelcomePageDisplay'] = '';
|
||||
}
|
||||
|
||||
$aResult['AllowGoogleSocial'] = (bool) $oConfig->Get('social', 'google_enable', false);
|
||||
|
|
@ -3247,7 +3272,11 @@ class Actions
|
|||
$this->setConfigFromParams($oConfig, 'Title', 'webmail', 'title', 'string');
|
||||
$this->setConfigFromParams($oConfig, 'LoadingDescription', 'webmail', 'loading_description', 'string');
|
||||
|
||||
if ($this->HasOneOfActionParams(array('LoginLogo', 'LoginBackground', 'LoginDescription', 'LoginCss', 'LoginPowered', 'UserLogo', 'UserCss')) && $this->PremType())
|
||||
if ($this->HasOneOfActionParams(array(
|
||||
'LoginLogo', 'LoginBackground', 'LoginDescription', 'LoginCss', 'LoginPowered',
|
||||
'UserLogo', 'UserCss',
|
||||
'WelcomePageUrl', 'WelcomePageDisplay'
|
||||
)) && $this->PremType())
|
||||
{
|
||||
$this->setConfigFromParams($oConfig, 'LoginLogo', 'branding', 'login_logo', 'string');
|
||||
$this->setConfigFromParams($oConfig, 'LoginBackground', 'branding', 'login_background', 'string');
|
||||
|
|
@ -3257,6 +3286,9 @@ class Actions
|
|||
|
||||
$this->setConfigFromParams($oConfig, 'UserLogo', 'branding', 'user_logo', 'string');
|
||||
$this->setConfigFromParams($oConfig, 'UserCss', 'branding', 'user_css', 'string');
|
||||
|
||||
$this->setConfigFromParams($oConfig, 'WelcomePageUrl', 'branding', 'welcome_page_url', 'string');
|
||||
$this->setConfigFromParams($oConfig, 'WelcomePageDisplay', 'branding', 'welcome_page_display', 'string');
|
||||
}
|
||||
|
||||
$this->setConfigFromParams($oConfig, 'TokenProtection', 'security', 'csrf_protection', 'bool');
|
||||
|
|
@ -4810,6 +4842,25 @@ class Actions
|
|||
return $this->DefaultResponse(__FUNCTION__, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function DoWelcomeClose()
|
||||
{
|
||||
$oAccount = $this->getAccountFromToken();
|
||||
if ($oAccount && !$oAccount->IsAdditionalAccount())
|
||||
{
|
||||
$oSettings = $this->SettingsProvider()->Load($oAccount);
|
||||
$oSettings->SetConf('LastWelcomePage',
|
||||
$this->Config()->Get('branding', 'welcome_page_url', ''));
|
||||
|
||||
return $this->DefaultResponse(__FUNCTION__,
|
||||
$this->SettingsProvider()->Save($oAccount, $oSettings));
|
||||
}
|
||||
|
||||
return $this->FalseResponse(__FUNCTION__);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
|
|
@ -8509,6 +8560,9 @@ class Actions
|
|||
$sHtml = $this->Plugins()->ProcessTemplate($sName, $sHtml);
|
||||
$sHtml = \preg_replace('/\{\{INCLUDE\/([a-zA-Z]+)\/PLACE\}\}/', '', $sHtml);
|
||||
|
||||
$sHtml = \preg_replace('/<script/i', '<x-script', $sHtml);
|
||||
$sHtml = \preg_replace('/<\/script>/i', '</x-script>', $sHtml);
|
||||
|
||||
return \RainLoop\Utils::ClearHtmlOutput($sHtml);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -88,8 +88,10 @@ class Application extends \RainLoop\Config\AbstractConfig
|
|||
'login_desc' => array(''),
|
||||
'login_css' => array(''),
|
||||
'login_powered' => array(true),
|
||||
'user_logo' => array(''),
|
||||
'user_css' => array('')
|
||||
'user_logo' => array(''),
|
||||
'user_css' => array(''),
|
||||
'welcome_page_url' => array(''),
|
||||
'welcome_page_display' => array('none')
|
||||
),
|
||||
|
||||
'contacts' => array(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue