1
0
Fork 0
mirror of https://github.com/Oreolek/ifhub.club.git synced 2024-05-19 17:28:23 +03:00

Рефакторинг работы с куками

This commit is contained in:
Mzhelskiy Maxim 2014-12-28 19:14:21 +07:00
parent e4bcd5391b
commit d9290666e0
5 changed files with 14 additions and 12 deletions

View file

@ -383,7 +383,7 @@ class ActionAjax extends Action
$sTargetType = getRequestStr('target_type');
$sTargetId = getRequestStr('target_id');
$sTargetTmp = empty($_COOKIE['poll_target_tmp_' . $sTargetType]) ? getRequestStr('target_tmp') : $_COOKIE['poll_target_tmp_' . $sTargetType];
$sTargetTmp = $this->Session_GetCookie('poll_target_tmp_' . $sTargetType) ? $this->Session_GetCookie('poll_target_tmp_' . $sTargetType) : getRequestStr('target_tmp');
if ($sTargetId) {
$sTargetTmp = null;
if (!$this->Poll_CheckTarget($sTargetType, $sTargetId)) {
@ -524,7 +524,7 @@ class ActionAjax extends Action
$sTargetType = getRequestStr('target_type');
$sTargetId = getRequestStr('target_id');
$sTargetTmp = empty($_COOKIE['media_target_tmp_' . $sTargetType]) ? getRequestStr('target_tmp') : $_COOKIE['media_target_tmp_' . $sTargetType];
$sTargetTmp = $this->Session_GetCookie('media_target_tmp_' . $sTargetType) ? $this->Session_GetCookie('media_target_tmp_' . $sTargetType) : getRequestStr('target_tmp');
if ($sTargetId) {
$sTargetTmp = null;
if (true !== $res = $this->Media_CheckTarget($sTargetType, $sTargetId,
@ -891,7 +891,7 @@ class ActionAjax extends Action
$sTargetType = getRequestStr('target_type');
$sTargetId = getRequestStr('target_id');
$sTargetTmp = empty($_COOKIE['media_target_tmp_' . $sTargetType]) ? getRequestStr('target_tmp') : $_COOKIE['media_target_tmp_' . $sTargetType];
$sTargetTmp = $this->Session_GetCookie('media_target_tmp_' . $sTargetType) ? $this->Session_GetCookie('media_target_tmp_' . $sTargetType) : getRequestStr('target_tmp');
if ($sTargetId) {
$sTargetTmp = null;
if (true !== $res = $this->Media_CheckTarget($sTargetType, $sTargetId, ModuleMedia::TYPE_CHECK_ALLOW_ADD,

View file

@ -36,7 +36,7 @@ class BlockPollFormItems extends Block
$sTargetType = $this->GetParam('target_type');
$sTargetId = $this->GetParam('target_id');
$sTargetTmp = empty($_COOKIE['poll_target_tmp_' . $sTargetType]) ? $this->GetParam('target_tmp') : $_COOKIE['poll_target_tmp_' . $sTargetType];
$sTargetTmp = $this->Session_GetCookie('poll_target_tmp_' . $sTargetType) ? $this->Session_GetCookie('poll_target_tmp_' . $sTargetType) : $this->GetParam('target_tmp');
$aFilter = array('target_type' => $sTargetType, '#order' => array('id' => 'asc'));
if ($sTargetId) {

View file

@ -681,8 +681,8 @@ class ModuleMedia extends ModuleORM
public function ReplaceTargetTmpById($sTargetType, $sTargetId, $sTargetTmp = null)
{
$sCookieKey = 'media_target_tmp_' . $sTargetType;
if (is_null($sTargetTmp) and isset($_COOKIE[$sCookieKey])) {
$sTargetTmp = $_COOKIE[$sCookieKey];
if (is_null($sTargetTmp) and $this->Session_GetCookie($sCookieKey)) {
$sTargetTmp = $this->Session_GetCookie($sCookieKey);
$this->Session_DropCookie($sCookieKey);
}
if (is_string($sTargetTmp)) {

View file

@ -129,8 +129,8 @@ class ModulePoll extends ModuleORM
public function ReplaceTargetTmpById($sTargetType, $sTargetId, $sTargetTmp = null)
{
$sCookieKey = 'poll_target_tmp_' . $sTargetType;
if (is_null($sTargetTmp) and isset($_COOKIE[$sCookieKey])) {
$sTargetTmp = $_COOKIE[$sCookieKey];
if (is_null($sTargetTmp) and $this->Session_GetCookie($sCookieKey)) {
$sTargetTmp = $this->Session_GetCookie($sCookieKey);
$this->Session_DropCookie($sCookieKey);
}
if (is_string($sTargetTmp)) {
@ -159,8 +159,9 @@ class ModulePoll extends ModuleORM
'#with' => array('answers')
);
if ($this->oUserCurrent) {
$aFilter['#with']['vote_current'] = array('user_id' => $this->oUserCurrent->getId(),
'#value-default' => false
$aFilter['#with']['vote_current'] = array(
'user_id' => $this->oUserCurrent->getId(),
'#value-default' => false
);
} else {
$aFilter['#with']['vote_current'] = array('#value-set' => false);

View file

@ -594,7 +594,8 @@ class ModuleUser extends Module
* Ставим куку
*/
if ($bRemember) {
$this->Session_SetCookie('key', $this->oSession->getKey(), time() + Config::Get('module.user.time_login_remember'), false,
$this->Session_SetCookie('key', $this->oSession->getKey(),
time() + Config::Get('module.user.time_login_remember'), false,
true);
}
return true;
@ -609,7 +610,7 @@ class ModuleUser extends Module
if ($this->oUserCurrent) {
return;
}
if (isset($_COOKIE['key']) and is_string($_COOKIE['key']) and $sKey = $_COOKIE['key']) {
if ($sKey = $this->Session_GetCookie('key') and is_string($sKey)) {
if ($oUser = $this->GetUserBySessionKey($sKey) and $oSession = $this->oMapper->GetSessionByKey($sKey) and $oSession->isActive()) {
$this->Authorization($oUser, true, $oSession->getKey());
} else {