Add an option to check the permissions of modules linked to documents or comments

This commit is contained in:
conory 2022-08-04 11:06:23 +09:00
parent 7c963d0ac3
commit 0dd567bc00
3 changed files with 21 additions and 3 deletions

View file

@ -188,13 +188,22 @@ class commentItem extends BaseObject
}
}
function isAccessible()
function isAccessible($strict = false)
{
if(!$this->isExists())
{
return false;
}
if ($strict)
{
$grant = ModuleModel::getGrant(ModuleModel::getModuleInfoByModuleSrl($this->get('module_srl')), Context::get('logged_info'));
if (isset($grant->list) && isset($grant->view) && ($grant->list !== true || $grant->view !== true))
{
return false;
}
}
if (isset($_SESSION['accessible'][$this->comment_srl]) && $_SESSION['accessible'][$this->comment_srl] === $this->get('last_update'))
{
return true;

View file

@ -237,13 +237,22 @@ class documentItem extends BaseObject
$this->setGrant();
}
function isAccessible()
function isAccessible($strict = false)
{
if(!$this->isExists())
{
return false;
}
if ($strict)
{
$grant = ModuleModel::getGrant(ModuleModel::getModuleInfoByModuleSrl($this->get('module_srl')), Context::get('logged_info'));
if (isset($grant->list) && isset($grant->view) && ($grant->list !== true || $grant->view !== true))
{
return false;
}
}
if (isset($_SESSION['accessible'][$this->document_srl]) && $_SESSION['accessible'][$this->document_srl] === $this->get('last_update'))
{
return true;

View file

@ -32,7 +32,7 @@ class documentView extends document
$oDocument = DocumentModel::getDocument($document_srl);
if(!$oDocument->isExists()) throw new Rhymix\Framework\Exceptions\TargetNotFound;
// Check permissions
if(!$oDocument->isAccessible()) throw new Rhymix\Framework\Exceptions\NotPermitted;
if(!$oDocument->isAccessible(true)) throw new Rhymix\Framework\Exceptions\NotPermitted;
// Information setting module
//Context::set('module_info', $module_info); //module_info not use in UI
// Browser title settings