protected function checkAccessToElement($id, $pagemounts, $blnIsPid = false)
{
if ($blnIsPid) {
$objPage = $this->Database->prepare("SELECT p.id, p.pid, p.includeChmod, p.chmod, p.cuser, p.cgroup, a.id AS aid FROM tl_article a, tl_page p WHERE a.id=? AND a.pid=p.id")->limit(1)->execute($id);
} else {
$objPage = $this->Database->prepare("SELECT p.id, p.pid, p.includeChmod, p.chmod, p.cuser, p.cgroup, a.id AS aid FROM tl_content c, tl_article a, tl_page p WHERE c.id=? AND c.pid=a.id AND a.pid=p.id")->limit(1)->execute($id);
}
// Invalid ID
if ($objPage->numRows < 1) {
throw new Contao\CoreBundle\Exception\AccessDeniedException('Invalid content element ID ' . $id . '.');
}
// The page is not mounted
if (!in_array($objPage->id, $pagemounts)) {
throw new Contao\CoreBundle\Exception\AccessDeniedException('Not enough permissions to modify article ID ' . $objPage->aid . ' on page ID ' . $objPage->id . '.');
}
// Not enough permissions to modify the article
if (!$this->User->isAllowed(BackendUser::CAN_EDIT_ARTICLES, $objPage->row())) {
throw new Contao\CoreBundle\Exception\AccessDeniedException('Not enough permissions to modify article ID ' . $objPage->aid . '.');
}
}