mirror of
https://github.com/the-djmaze/snappymail.git
synced 2024-11-10 09:02:45 +08:00
ownCloud integration improvements
This commit is contained in:
parent
c0d016293d
commit
d30292d500
9 changed files with 170 additions and 59 deletions
|
@ -6,5 +6,29 @@ if (@file_exists(__DIR__.'/app/index.php'))
|
|||
|
||||
OC_RainLoop_Helper::regRainLoopDataFunction();
|
||||
|
||||
if (isset($_GET['OwnCloudAuth']))
|
||||
{
|
||||
$sEmail = '';
|
||||
$sEncodedPassword = '';
|
||||
|
||||
$sUser = OCP\User::getUser();
|
||||
|
||||
if ($bAutologin)
|
||||
{
|
||||
$sEmail = $sUser;
|
||||
$sEncodedPassword = OCP\Config::getUserValue($sUser, 'rainloop', 'rainloop-autologin-password', '');
|
||||
}
|
||||
else
|
||||
{
|
||||
$sEmail = OCP\Config::getUserValue($sUser, 'rainloop', 'rainloop-email', '');
|
||||
$sEncodedPassword = OCP\Config::getUserValue($sUser, 'rainloop', 'rainloop-password', '');
|
||||
}
|
||||
|
||||
$sDecodedPassword = OC_RainLoop_Helper::decodePassword($sEncodedPassword, md5($sEmail));
|
||||
|
||||
$_ENV['___rainloop_owncloud_email'] = $sEmail;
|
||||
$_ENV['___rainloop_owncloud_password'] = $sDecodedPassword;
|
||||
}
|
||||
|
||||
include __DIR__.'/app/index.php';
|
||||
}
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
<info>
|
||||
<id>rainloop</id>
|
||||
<name>RainLoop</name>
|
||||
<description>Simple, modern & fast web-based email client.
|
||||
|
||||
Modest system requirements, decent performance, simple installation and upgrade, no database required -
|
||||
all these make RainLoop Webmail a perfect choice for your email solution.</description>
|
||||
<description>Simple, modern and fast web-based email client.</description>
|
||||
<version>0.0</version>
|
||||
<licence>CC BY-NC-SA 3.0</licence>
|
||||
<author>RainLoop Team</author>
|
||||
<require>6.0</require>
|
||||
<dependencies>
|
||||
<php min-version="5.3"/>
|
||||
</dependencies>
|
||||
</info>
|
|
@ -38,25 +38,32 @@ if ('' === $sUrl || '' === $sPath)
|
|||
}
|
||||
else
|
||||
{
|
||||
$sUser = OCP\User::getUser();
|
||||
|
||||
if ($bAutologin)
|
||||
$sUrl = OC_RainLoop_Helper::normalizeUrl($sUrl);
|
||||
if ($bInstalledLocaly)
|
||||
{
|
||||
$sEmail = $sUser;
|
||||
$sEncodedPassword = OCP\Config::getUserValue($sUser, 'rainloop', 'rainloop-autologin-password', '');
|
||||
$sResultUrl = $sUrl.'?OwnCloudAuth';
|
||||
}
|
||||
else
|
||||
{
|
||||
$sEmail = OCP\Config::getUserValue($sUser, 'rainloop', 'rainloop-email', '');
|
||||
$sEncodedPassword = OCP\Config::getUserValue($sUser, 'rainloop', 'rainloop-password', '');
|
||||
$sUser = OCP\User::getUser();
|
||||
|
||||
if ($bAutologin)
|
||||
{
|
||||
$sEmail = $sUser;
|
||||
$sEncodedPassword = OCP\Config::getUserValue($sUser, 'rainloop', 'rainloop-autologin-password', '');
|
||||
}
|
||||
else
|
||||
{
|
||||
$sEmail = OCP\Config::getUserValue($sUser, 'rainloop', 'rainloop-email', '');
|
||||
$sEncodedPassword = OCP\Config::getUserValue($sUser, 'rainloop', 'rainloop-password', '');
|
||||
}
|
||||
|
||||
$sDecodedPassword = OC_RainLoop_Helper::decodePassword($sEncodedPassword, md5($sEmail));
|
||||
|
||||
$sSsoHash = OC_RainLoop_Helper::getSsoHash($sPath, $sEmail, $sDecodedPassword);
|
||||
$sResultUrl = empty($sSsoHash) ? $sUrl.'?sso' : $sUrl.'?sso&hash='.$sSsoHash;
|
||||
}
|
||||
|
||||
$sDecodedPassword = OC_RainLoop_Helper::decodePassword($sEncodedPassword, md5($sEmail));
|
||||
$sSsoHash = OC_RainLoop_Helper::getSsoHash($sPath, $sEmail, $sDecodedPassword);
|
||||
|
||||
$sUrl = OC_RainLoop_Helper::normalizeUrl($sUrl);
|
||||
$sResultUrl = empty($sSsoHash) ? $sUrl.'?sso' : $sUrl.'?sso&hash='.$sSsoHash;
|
||||
|
||||
$oTemplate = new OCP\Template('rainloop', 'index', 'user');
|
||||
$oTemplate->assign('rainloop-url', $sResultUrl);
|
||||
}
|
||||
|
|
|
@ -7,6 +7,15 @@ class OC_RainLoop_Helper
|
|||
*/
|
||||
public static function getAppUrl()
|
||||
{
|
||||
if (class_exists('\\OC\\URLGenerator') && isset(\OC::$server))
|
||||
{
|
||||
$oUrlGenerator = new \OC\URLGenerator(\OC::$server->getConfig());
|
||||
if ($oUrlGenerator)
|
||||
{
|
||||
return $oUrlGenerator->linkToRoute('rainloop_app');
|
||||
}
|
||||
}
|
||||
|
||||
$sRequestUri = empty($_SERVER['REQUEST_URI']) ? '': trim($_SERVER['REQUEST_URI']);
|
||||
$sRequestUri = preg_replace('/index.php\/.+$/', 'index.php/', $sRequestUri);
|
||||
$sRequestUri = $sRequestUri.'apps/rainloop/app/';
|
||||
|
|
|
@ -21,7 +21,9 @@
|
|||
this.sSubSubQuery = '&ss=/';
|
||||
this.sVersion = Settings.settingsGet('Version');
|
||||
this.sSpecSuffix = Settings.settingsGet('AuthAccountHash') || '0';
|
||||
this.sStaticPrefix = Settings.settingsGet('StaticPrefix') || 'rainloop/v/' + this.sVersion + '/static/';
|
||||
this.sWebPrefix = Settings.settingsGet('WebPath') || '';
|
||||
this.sVersionPrefix = Settings.settingsGet('WebVersionPath') || 'rainloop/v/' + this.sVersion + '/';
|
||||
this.sStaticPrefix = this.sVersionPrefix + 'static/';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -330,11 +332,11 @@
|
|||
*/
|
||||
Links.prototype.themePreviewLink = function (sTheme)
|
||||
{
|
||||
var sPrefix = 'rainloop/v/' + this.sVersion + '/';
|
||||
var sPrefix = this.sVersionPrefix;
|
||||
if ('@custom' === sTheme.substr(-7))
|
||||
{
|
||||
sTheme = Utils.trim(sTheme.substring(0, sTheme.length - 7));
|
||||
sPrefix = '';
|
||||
sPrefix = this.sWebPrefix;
|
||||
}
|
||||
|
||||
return sPrefix + 'themes/' + window.encodeURI(sTheme) + '/images/preview.png';
|
||||
|
|
|
@ -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…
Reference in a new issue