diff --git a/modules/comment/comment.item.php b/modules/comment/comment.item.php index 36cb26e38..808f42e4b 100644 --- a/modules/comment/comment.item.php +++ b/modules/comment/comment.item.php @@ -17,7 +17,11 @@ class commentItem extends BaseObject * @var int */ var $comment_srl = 0; - + /** + * grant + * @var bool + */ + var $grant_cache = null; /** * Get the column list int the table * @var array @@ -88,52 +92,85 @@ class commentItem extends BaseObject function isExists() { - return $this->comment_srl ? TRUE : FALSE; + return (bool) $this->comment_srl; } - + function isGranted() { - if($_SESSION['granted_comment'][$this->comment_srl]) + if ($_SESSION['granted_comment'][$this->comment_srl]) { - return TRUE; + return $this->grant_cache = true; } - - if(!Context::get('is_logged')) + + if ($this->grant_cache !== null) { - return FALSE; + return $this->grant_cache; } - + $logged_info = Context::get('logged_info'); - if($logged_info->is_admin == 'Y') + if (!$logged_info->member_srl) { - return TRUE; + return $this->grant_cache = false; } - - $grant = Context::get('grant'); - if($grant->manager) + if ($logged_info->is_admin == 'Y') { - return TRUE; + 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)) + if ($this->get('member_srl') && abs($this->get('member_srl')) == $logged_info->member_srl) { - return TRUE; + return $this->grant_cache = true; } - - return FALSE; + + $oModuleModel = getModel('module'); + $grant = $oModuleModel->getGrant($oModuleModel->getModuleInfoByModuleSrl($this->get('module_srl')), $logged_info); + if ($grant->manager) + { + return $this->grant_cache = true; + } + + return $this->grant_cache = false; } - + function setGrant() { - $this->is_granted = TRUE; + $this->grant_cache = true; } - + function setGrantForSession() { $_SESSION['granted_comment'][$this->comment_srl] = true; $this->setGrant(); } - + + function isAccessible() + { + if ($_SESSION['accessible'][$this->comment_srl] === $this->get('last_update')) + { + return true; + } + + if ($this->get('status') == RX_STATUS_PUBLIC) + { + $this->setAccessible(); + return true; + } + + if ($this->isGranted()) + { + $this->setAccessible(); + return true; + } + + $oDocument = getModel('document')->getDocument($this->get('document_srl')); + if ($oDocument->isExists() && $oDocument->isGranted()) + { + $this->setAccessible(); + return true; + } + + return false; + } + function setAccessible() { if(Context::getSessionStatus()) @@ -141,58 +178,30 @@ class commentItem extends BaseObject $_SESSION['accessible'][$this->comment_srl] = $this->get('last_update'); } } - + function isEditable() { - if($this->isGranted() || !$this->get('member_srl')) - { - return TRUE; - } - return FALSE; + return !$this->get('member_srl') || $this->isGranted(); } - + function isSecret() { - return $this->get('is_secret') == 'Y' ? TRUE : FALSE; + return $this->get('is_secret') == 'Y'; } - + function isDeleted() { return $this->get('status') == RX_STATUS_DELETED || $this->get('status') == RX_STATUS_DELETED_BY_ADMIN; } - + function isDeletedByAdmin() { return $this->get('status') == RX_STATUS_DELETED_BY_ADMIN; } - - function isAccessible() - { - if (isset($_SESSION['accessible'][$this->comment_srl]) && $_SESSION['accessible'][$this->comment_srl] === $this->get('last_update')) - { - return TRUE; - } - - if (!$this->isSecret() || $this->isGranted()) - { - $this->setAccessible(); - return TRUE; - } - - $oDocumentModel = getModel('document'); - $oDocument = $oDocumentModel->getDocument($this->get('document_srl')); - if ($oDocument->isExists() && $oDocument->isGranted()) - { - $this->setAccessible(); - return TRUE; - } - - return FALSE; - } - + function useNotify() { - return $this->get('notify_message') == 'Y' ? TRUE : FALSE; + return $this->get('notify_message') == 'Y'; } /** diff --git a/modules/document/document.class.php b/modules/document/document.class.php index 2d6f17693..43cd110f6 100644 --- a/modules/document/document.class.php +++ b/modules/document/document.class.php @@ -373,8 +373,7 @@ class document extends ModuleObject */ function getConfigStatus($key) { - if(array_key_exists(strtolower($key), $this->statusList)) return $this->statusList[$key]; - else $this->getDefaultStatus(); + return $this->statusList[$key]; } } /* End of file document.class.php */