public function isAllowed($int, $row)
{
if ($this->isAdmin) {
return true;
}
// Inherit CHMOD settings
if (!$row['includeChmod']) {
$pid = $row['pid'];
$row['chmod'] = false;
$row['cuser'] = false;
$row['cgroup'] = false;
$objParentPage = $this->Database->prepare("SELECT * FROM tl_page WHERE id=?")->limit(1)->execute($pid);
while ($row['chmod'] === false && $pid > 0 && $objParentPage->numRows) {
$pid = $objParentPage->pid;
$row['chmod'] = $objParentPage->includeChmod ? $objParentPage->chmod : false;
$row['cuser'] = $objParentPage->includeChmod ? $objParentPage->cuser : false;
$row['cgroup'] = $objParentPage->includeChmod ? $objParentPage->cgroup : false;
$objParentPage = $this->Database->prepare("SELECT * FROM tl_page WHERE id=?")->limit(1)->execute($pid);
}
// Set default values
if ($row['chmod'] === false) {
$row['chmod'] = \Config::get('defaultChmod');
}
if ($row['cuser'] === false) {
$row['cuser'] = intval(\Config::get('defaultUser'));
}
if ($row['cgroup'] === false) {
$row['cgroup'] = intval(\Config::get('defaultGroup'));
}
}
// Set permissions
$chmod = \StringUtil::deserialize($row['chmod']);
$chmod = is_array($chmod) ? $chmod : array($chmod);
$permission = array('w' . $int);
if (in_array($row['cgroup'], $this->groups)) {
$permission[] = 'g' . $int;
}
if ($row['cuser'] == $this->id) {
$permission[] = 'u' . $int;
}
return count(array_intersect($permission, $chmod)) > 0;
}