Refresh isAccessible() if document or comment is updated

https://www.xetown.com/qna/510717
This commit is contained in:
Kijin Sung 2017-02-24 15:46:52 +09:00
parent 3d16272d01
commit 6df32746c3
2 changed files with 57 additions and 25 deletions

View file

@ -133,7 +133,7 @@ class commentItem extends Object
{ {
if(Context::getSessionStatus()) if(Context::getSessionStatus())
{ {
$_SESSION['accessibled_comment'][$this->comment_srl] = TRUE; $_SESSION['accessible'][$this->comment_srl] = $this->get('last_update');
} }
} }
@ -163,12 +163,12 @@ class commentItem extends Object
function isAccessible() function isAccessible()
{ {
if($_SESSION['accessibled_comment'][$this->comment_srl]) if (isset($_SESSION['accessible'][$this->comment_srl]) && $_SESSION['accessible'][$this->comment_srl] === $this->get('last_update'))
{ {
return TRUE; return TRUE;
} }
if($this->isGranted() || !$this->isSecret()) if (!$this->isSecret() || $this->isGranted())
{ {
$this->setAccessible(); $this->setAccessible();
return TRUE; return TRUE;
@ -176,7 +176,7 @@ class commentItem extends Object
$oDocumentModel = getModel('document'); $oDocumentModel = getModel('document');
$oDocument = $oDocumentModel->getDocument($this->get('document_srl')); $oDocument = $oDocumentModel->getDocument($this->get('document_srl'));
if($oDocument->isGranted()) if ($oDocument->isExists() && $oDocument->isGranted())
{ {
$this->setAccessible(); $this->setAccessible();
return TRUE; return TRUE;

View file

@ -204,7 +204,55 @@ class documentItem extends Object
function isAccessible() function isAccessible()
{ {
return $_SESSION['accessible'][$this->document_srl]==true?true:false; if (isset($_SESSION['accessible'][$this->document_srl]) && $_SESSION['accessible'][$this->document_srl] === $this->get('last_update'))
{
return true;
}
if ($this->grant_cache === true)
{
$this->setAccessible();
return true;
}
$logged_info = Context::get('logged_info');
if ($logged_info->is_admin == 'Y')
{
$this->setAccessible();
return true;
}
$status = $this->get('status');
if (empty($status))
{
return false;
}
$configStatusList = getModel('document')->getStatusList();
if ($status == $configStatusList['public'] || $status == $configStatusList['publish'])
{
$this->setAccessible();
return true;
}
elseif ($status == $configStatusList['private'] || $status == $configStatusList['secret'])
{
if ($this->get('member_srl') == $logged_info->member_srl)
{
$this->setAccessible();
return true;
}
}
return false;
}
function setAccessible()
{
if(Context::getSessionStatus())
{
$_SESSION['accessible'][$this->document_srl] = $this->get('last_update');
}
} }
function allowComment() function allowComment()
@ -444,7 +492,7 @@ class documentItem extends Object
$result = $this->_checkAccessibleFromStatus(); $result = $this->_checkAccessibleFromStatus();
if($result && Context::getSessionStatus()) if($result && Context::getSessionStatus())
{ {
$_SESSION['accessible'][$this->document_srl] = true; $this->setAccessible();
} }
$content = $this->get('content'); $content = $this->get('content');
@ -506,9 +554,9 @@ class documentItem extends Object
if($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) return lang('msg_is_secret'); if($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) return lang('msg_is_secret');
$result = $this->_checkAccessibleFromStatus(); $result = $this->_checkAccessibleFromStatus();
if($result && Context::getSessionStatus()) if($result)
{ {
$_SESSION['accessible'][$this->document_srl] = true; $this->setAccessible();
} }
$content = $this->get('content'); $content = $this->get('content');
@ -1252,23 +1300,7 @@ class documentItem extends Object
*/ */
function _checkAccessibleFromStatus() function _checkAccessibleFromStatus()
{ {
$logged_info = Context::get('logged_info'); return $this->isAccessible();
if($logged_info->is_admin == 'Y') return true;
$status = $this->get('status');
if(empty($status)) return false;
$oDocumentModel = getModel('document');
$configStatusList = $oDocumentModel->getStatusList();
if($status == $configStatusList['public'] || $status == $configStatusList['publish'])
return true;
else if($status == $configStatusList['private'] || $status == $configStatusList['secret'])
{
if($this->get('member_srl') == $logged_info->member_srl)
return true;
}
return false;
} }
function getTranslationLangCodes() function getTranslationLangCodes()