Cache grant information for modules and documents

https://www.xetown.com/qna/374223
http://sejin7940.co.kr/xe_tips/108198
This commit is contained in:
Kijin Sung 2016-09-16 16:44:29 +09:00
parent 4175535bc3
commit 9d594526b4
2 changed files with 43 additions and 9 deletions

View file

@ -20,6 +20,11 @@ class documentItem extends Object
* @var string
*/
var $lang_code = null;
/**
* grant
* @var bool
*/
var $grant_cache = null;
/**
* Status of allow trackback
* @var bool
@ -157,25 +162,44 @@ class documentItem extends Object
function isGranted()
{
if($_SESSION['own_document'][$this->document_srl]) return true;
if(!Context::get('is_logged')) return false;
if ($this->grant_cache !== null)
{
return $this->grant_cache;
}
if ($_SESSION['own_document'][$this->document_srl])
{
return $this->grant_cache = true;
}
$logged_info = Context::get('logged_info');
if($logged_info->is_admin == 'Y') return true;
if (!$logged_info->member_srl)
{
return $this->grant_cache = false;
}
if ($logged_info->is_admin == 'Y')
{
return $this->grant_cache = true;
}
if ($this->get('member_srl') && abs($this->get('member_srl')) == $logged_info->member_srl)
{
return $this->grant_cache = true;
}
$oModuleModel = getModel('module');
$grant = $oModuleModel->getGrant($oModuleModel->getModuleInfoByModuleSrl($this->get('module_srl')), $logged_info);
if($grant->manager) return true;
if ($grant->manager)
{
return $this->grant_cache = true;
}
if($this->get('member_srl') && ($this->get('member_srl') == $logged_info->member_srl || $this->get('member_srl')*-1 == $logged_info->member_srl)) return true;
return false;
return $this->grant_cache = false;
}
function setGrant()
{
$_SESSION['own_document'][$this->document_srl] = true;
$this->grant_cache = true;
}
function isAccessible()