mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
ownCloud integration improvements
This commit is contained in:
parent
c0d016293d
commit
d30292d500
9 changed files with 170 additions and 59 deletions
|
|
@ -512,6 +512,7 @@ class Actions
|
|||
*/
|
||||
public function SetAuthLogoutToken()
|
||||
{
|
||||
@\header('X-RainLoop-Action: Logout');
|
||||
\RainLoop\Utils::SetCookie(self::AUTH_SPEC_LOGOUT_TOKEN_KEY, \md5(APP_START_TIME), 0, '/', null, null, true);
|
||||
}
|
||||
|
||||
|
|
@ -941,6 +942,7 @@ class Actions
|
|||
'][APC:'.(\MailSo\Base\Utils::FunctionExistsAndEnabled('apc_fetch') ? 'on' : 'off').
|
||||
'][MB:'.(\MailSo\Base\Utils::FunctionExistsAndEnabled('mb_convert_encoding') ? 'on' : 'off').
|
||||
'][PDO:'.$sPdo.
|
||||
(\RainLoop\Utils::IsOwnCloud() ? '][ownCloud:true' : '').
|
||||
'][Streams:'.\implode(',', \stream_get_transports()).
|
||||
']');
|
||||
|
||||
|
|
@ -1218,7 +1220,8 @@ class Actions
|
|||
'Version' => APP_VERSION,
|
||||
'Auth' => false,
|
||||
'AccountHash' => '',
|
||||
'StaticPrefix' => 'rainloop/v/'.APP_VERSION.'/static/',
|
||||
'WebPath' => \RainLoop\Utils::WebPath(),
|
||||
'WebVersionPath' => \RainLoop\Utils::WebVersionPath(),
|
||||
'AccountSignMe' => false,
|
||||
'AuthAccountHash' => '',
|
||||
'MailToEmail' => '',
|
||||
|
|
|
|||
|
|
@ -187,6 +187,12 @@ class Service
|
|||
$sResult .= '][cached:'.($bCached ? 'true' : 'false');
|
||||
$sResult .= '][hash:'.$aTemplateParameters['{{BaseHash}}'];
|
||||
$sResult .= '][session:'.\md5(\RainLoop\Utils::GetShortToken());
|
||||
|
||||
if (\RainLoop\Utils::IsOwnCloud())
|
||||
{
|
||||
$sResult .= '][owncloud:true';
|
||||
}
|
||||
|
||||
$sResult .= '] -->';
|
||||
}
|
||||
|
||||
|
|
@ -219,7 +225,7 @@ class Service
|
|||
$bAppJsDebug = !!$this->oActions->Config()->Get('labs', 'use_app_debug_js', false);
|
||||
$bAppCssDebug = !!$this->oActions->Config()->Get('labs', 'use_app_debug_css', false);
|
||||
|
||||
$sStaticPrefix = $this->oServiceActions->WebStaticPath();
|
||||
$sStaticPrefix = \RainLoop\Utils::WebStaticPath();
|
||||
|
||||
$aData = array(
|
||||
'Language' => $sLanguage,
|
||||
|
|
@ -257,7 +263,7 @@ class Service
|
|||
\implode('~', array(
|
||||
\md5($this->oActions->Config()->Get('cache', 'index', '')),
|
||||
$this->oActions->Plugins()->Hash(),
|
||||
$this->oServiceActions->WebVersionPath(), APP_VERSION
|
||||
\RainLoop\Utils::WebVersionPath(), APP_VERSION
|
||||
)).
|
||||
\implode('~', $aTemplateParameters)
|
||||
);
|
||||
|
|
|
|||
|
|
@ -221,6 +221,45 @@ class ServiceActions
|
|||
return $sResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function ServiceOwnCloudAuth()
|
||||
{
|
||||
if (!\RainLoop\Utils::IsOwnCloud() ||
|
||||
empty($_ENV['___rainloop_owncloud_email']) &&
|
||||
!isset($_ENV['___rainloop_owncloud_password'])
|
||||
)
|
||||
{
|
||||
$this->oActions->SetAuthLogoutToken();
|
||||
$this->oActions->Location('./');
|
||||
return '';
|
||||
}
|
||||
|
||||
$sEmail = $_ENV['___rainloop_owncloud_email'];
|
||||
$sPassword = $_ENV['___rainloop_owncloud_password'];
|
||||
|
||||
try
|
||||
{
|
||||
$oAccount = $this->oActions->LoginProcess($sEmail, $sPassword);
|
||||
$this->oActions->AuthToken($oAccount);
|
||||
|
||||
$bLogout = !($oAccount instanceof \RainLoop\Model\Account);
|
||||
}
|
||||
catch (\Exception $oException)
|
||||
{
|
||||
$this->oActions->Logger()->WriteException($oException);
|
||||
}
|
||||
|
||||
if ($bLogout)
|
||||
{
|
||||
$this->oActions->SetAuthLogoutToken();
|
||||
}
|
||||
|
||||
$this->oActions->Location('./');
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
|
|
@ -675,7 +714,10 @@ class ServiceActions
|
|||
|
||||
if (\file_exists($sThemeFile) && \file_exists($sThemeTemplateFile) && \file_exists($sThemeValuesFile))
|
||||
{
|
||||
$aResult[] = '@base: "'.($bCustomTheme ? $this->WebPath() : $this->WebVersionPath()).'themes/'.$sRealTheme.'/";';
|
||||
$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);
|
||||
|
|
@ -779,7 +821,7 @@ class ServiceActions
|
|||
|
||||
@\header('Content-Type: text/html; charset=utf-8');
|
||||
return \strtr(\file_get_contents(APP_VERSION_ROOT_PATH.'app/templates/BadBrowser.html'), array(
|
||||
'{{BaseWebStaticPath}}' => $this->WebStaticPath(),
|
||||
'{{BaseWebStaticPath}}' => \RainLoop\Utils::WebStaticPath(),
|
||||
'{{ErrorTitle}}' => $sTitle,
|
||||
'{{ErrorHeader}}' => $sTitle,
|
||||
'{{ErrorDesc}}' => $sDesc
|
||||
|
|
@ -1060,7 +1102,7 @@ class ServiceActions
|
|||
public function ErrorTemplates($sTitle, $sDesc, $bShowBackLink = true)
|
||||
{
|
||||
return strtr(file_get_contents(APP_VERSION_ROOT_PATH.'app/templates/Error.html'), array(
|
||||
'{{BaseWebStaticPath}}' => $this->WebStaticPath(),
|
||||
'{{BaseWebStaticPath}}' => \RainLoop\Utils::WebStaticPath(),
|
||||
'{{ErrorTitle}}' => $sTitle,
|
||||
'{{ErrorHeader}}' => $sTitle,
|
||||
'{{ErrorDesc}}' => $sDesc,
|
||||
|
|
@ -1070,39 +1112,6 @@ class ServiceActions
|
|||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function WebPath()
|
||||
{
|
||||
if (isset($_ENV['RAINLOOP_OWNCLOUD']) && $_ENV['RAINLOOP_OWNCLOUD'])
|
||||
{
|
||||
$sUrl = $this->oHttp->GetUrl();
|
||||
if ($sUrl && \preg_match('/\/index\.php\/apps\/rainloop/', $sUrl))
|
||||
{
|
||||
$sUrl = \preg_replace('/\/index\.php\/apps\/rainloop.+$/', '/', $sUrl);
|
||||
return \rtrim(\trim($sUrl), '\//').'/apps/rainloop/app/';
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function WebVersionPath()
|
||||
{
|
||||
return $this->WebPath().'rainloop/v/'.APP_VERSION.'/';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function WebStaticPath()
|
||||
{
|
||||
return $this->WebVersionPath().'static/';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sTitle
|
||||
* @param string $sDesc
|
||||
|
|
|
|||
|
|
@ -307,6 +307,57 @@ class Utils
|
|||
@\setcookie($sName, '', \time() - 3600 * 24 * 30, '/');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public static function IsOwnCloud()
|
||||
{
|
||||
return isset($_ENV['RAINLOOP_OWNCLOUD']) && $_ENV['RAINLOOP_OWNCLOUD'] &&
|
||||
\class_exists('\\OC');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function WebPath()
|
||||
{
|
||||
$sAppPath = '';
|
||||
if (\RainLoop\Utils::IsOwnCloud())
|
||||
{
|
||||
if (\class_exists('\\OC_App'))
|
||||
{
|
||||
$sAppPath = \rtrim(\trim(\OC_App::getAppWebPath('rainloop')), '\\/').'/app/';
|
||||
}
|
||||
|
||||
if (empty($sAppPath))
|
||||
{
|
||||
$sUrl = \MailSo\Base\Http::SingletonInstance()->GetUrl();
|
||||
if ($sUrl && \preg_match('/\/index\.php\/apps\/rainloop/', $sUrl))
|
||||
{
|
||||
$sAppPath = \preg_replace('/\/index\.php\/apps\/rainloop.+$/',
|
||||
'/apps/rainloop/app/', $sUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $sAppPath;
|
||||
}
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function WebVersionPath()
|
||||
{
|
||||
return self::WebPath().'rainloop/v/'.APP_VERSION.'/';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function WebStaticPath()
|
||||
{
|
||||
return self::WebVersionPath().'static/';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sFileName
|
||||
* @param bool $bProcessSections = false
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue