Fix unexpected desktop mode on mobile devices + small fixes (#1514)

This commit is contained in:
RainLoop 2017-09-24 19:14:48 +03:00
parent 677a5f2e35
commit ed5685314e
10 changed files with 115 additions and 88 deletions

View file

@ -67,7 +67,10 @@ class SubStreams
$sHashName = \MailSo\Base\Utils::Md5Rand();
self::$aStreams[$sHashName] = $aSubStreams;
self::$aStreams[$sHashName] = array_map(function($mItem) {
return \is_resource($mItem) ? $mItem :
\MailSo\Base\ResourceRegistry::CreateMemoryResourceFromString($mItem);
}, $aSubStreams);
\MailSo\Base\Loader::IncStatistic('CreateStream/SubStreams');
@ -181,26 +184,6 @@ class SubStreams
$this->iIndex++;
}
}
else if (\is_string($mCurrentPart))
{
$sReadResult = \substr($mCurrentPart, 0, $iCount);
$sReturn .= $sReadResult;
$iLen = \strlen($sReadResult);
if ($iCount < $iLen)
{
$this->sBuffer = \substr($sReturn, $iCount);
$sReturn = \substr($sReturn, 0, $iCount);
$iCount = 0;
}
else
{
$iCount -= $iLen;
}
$this->iIndex++;
}
}
}

View file

@ -14,7 +14,7 @@ class Actions
const AUTH_SPEC_LOGOUT_TOKEN_KEY = 'rlspeclogout';
const AUTH_SPEC_LOGOUT_CUSTOM_MSG_KEY = 'rlspeclogoutcmk';
const AUTH_ADMIN_TOKEN_KEY = 'rlaauth';
const RL_SKIP_MOBILE_KEY = 'rlmobile';
const RL_MOBILE_TYPE = 'rlmobiletype';
/**
* @var \MailSo\Base\Http

View file

@ -162,18 +162,20 @@ class Service
$bMobileDevice = $oMobileDetect->isMobile() &&
($bUseMobileVersionForTablets ? true : !$oMobileDetect->isTablet());
$bMobile = (0 < \count($aPaths) && !empty($aPaths[0]) && 'mobile' === \strtolower($aPaths[0]));
}
if ($bIndex && !$bMobile)
{
$iMobileKey = (int) \RainLoop\Utils::GetCookie(\RainLoop\Actions::RL_SKIP_MOBILE_KEY, 0);
if (1 !== $iMobileKey)
if ($bIndex)
{
if ($bMobileDevice)
{
$this->oActions->Location('./?/Mobile/');
return $this;
$sMobileType = (string) \RainLoop\Utils::GetCookie(\RainLoop\Actions::RL_MOBILE_TYPE, '');
switch ($sMobileType) {
default:
$sMobileType = '';
$bMobile = $bMobileDevice;
break;
case 'mobile':
$bMobile = true;
break;
case 'desktop':
$bMobile = false;
break;
}
}
}

View file

@ -829,9 +829,9 @@ class ServiceActions
/**
* @return string
*/
public function ServiceSkipMobile()
public function ServiceMobileVersion()
{
\RainLoop\Utils::SetCookie(\RainLoop\Actions::RL_SKIP_MOBILE_KEY, 1);
\RainLoop\Utils::SetCookie(\RainLoop\Actions::RL_MOBILE_TYPE, 'mobile');
$this->oActions->Location('./');
return '';
}
@ -839,9 +839,9 @@ class ServiceActions
/**
* @return string
*/
public function ServiceClearSkipMobile()
public function ServiceDesktopVersion()
{
\RainLoop\Utils::ClearCookie(\RainLoop\Actions::RL_SKIP_MOBILE_KEY);
\RainLoop\Utils::SetCookie(\RainLoop\Actions::RL_MOBILE_TYPE, 'desktop');
$this->oActions->Location('./');
return '';
}
@ -1183,16 +1183,6 @@ class ServiceActions
}
}
/**
* @return string
*/
public function ServiceChangeMobile()
{
$this->changeAction();
$this->oActions->Location('./?/Mobile/');
return '';
}
/**
* @return string
*/