Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Checks if user may insert a record from $insertTable on $pid
- * Does not check for workspace, use BE_USER->workspaceAllowLiveRecordsInPID for this in addition to this function call.
- *
- * @param string $insertTable Tablename to check
- * @param integer $pid Integer PID
- * @param integer $action For logging: Action number.
- * @return boolean Returns TRUE if the user may insert a record from table $insertTable on page $pid
- * @todo Define visibility
- */
- public function checkRecordInsertAccess($insertTable, $pid, $action = 1) {
- $res = 0;
- $pid = intval($pid);
- if ($pid >= 0) {
- // If information is cached, return it
- if (isset($this->recInsertAccessCache[$insertTable][$pid])) {
- return $this->recInsertAccessCache[$insertTable][$pid];
- } else {
- // If either admin and root-level or if page record exists and 1) if 'pages' you may create new ones 2) if page-content, new content items may be inserted on the $pid page
- if (!$pid && $this->admin || $this->doesRecordExist('pages', $pid, ($insertTable == 'pages' ? $this->pMap['new'] : $this->pMap['editcontent']))) {
- // Check permissions
- if ($this->isTableAllowedForThisPage($pid, $insertTable)) {
- $res = 1;
- // Cache the result
- $this->recInsertAccessCache[$insertTable][$pid] = $res;
- } else {
- $propArr = $this->getRecordProperties('pages', $pid);
- $this->log($insertTable, $pid, $action, 0, 1, 'Attempt to insert record on page \'%s\' (%s) where this table, %s, is not allowed', 11, array($propArr['header'], $pid, $insertTable), $propArr['event_pid']);
- }
- } else {
- if ($pid === 0 && \TYPO3\CMS\Backend\Utility\BackendUtility::isRootLevelRestrictionIgnored($insertTable)) {
- $res = 1;
- // Cache the result
- $this->recInsertAccessCache[$insertTable][$pid] = $res;
- } else {
- $propArr = $this->getRecordProperties('pages', $pid);
- $this->log($insertTable, $pid, $action, 0, 1, 'Attempt to insert a record on page \'%s\' (%s) from table \'%s\' without permissions. Or non-existing page.', 12, array($propArr['header'], $pid, $insertTable), $propArr['event_pid']);
- }
- }
- }
- }
- return $res;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement