/**
  * Pre-processing of the whole TCEform
  *
  * @param string $table
  * @param array $row
  * @param \TYPO3\CMS\Backend\Form\FormEngine $parentObject
  * @todo this hook won't work, do we need it?
  */
 public function getMainFields_preProcess($table, $row, $parentObject)
 {
     if ($table !== 'tx_news_domain_model_news') {
         return;
     }
     if (!AccessControlService::userHasCategoryPermissionsForRecord($row)) {
         if (method_exists($parentObject, 'setRenderReadonly')) {
             $parentObject->setRenderReadonly(true);
         } else {
             $parentObject->renderReadonly = true;
         }
         $flashMessageContent = $GLOBALS['LANG']->sL(self::LLPATH . 'record.savingdisabled.content', true);
         $flashMessageContent .= '<ul>';
         $accessDeniedCategories = AccessControlService::getAccessDeniedCategories($row);
         foreach ($accessDeniedCategories as $accessDeniedCategory) {
             $flashMessageContent .= '<li>' . htmlspecialchars($accessDeniedCategory['title']) . ' [' . $accessDeniedCategory['uid'] . ']</li>';
         }
         $flashMessageContent .= '</ul>';
         /** @var FlashMessage $flashMessage */
         $flashMessage = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $flashMessageContent, $GLOBALS['LANG']->sL(self::LLPATH . 'record.savingdisabled.header', true), FlashMessage::WARNING);
         /** @var FlashMessageService $flashMessageService */
         $flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class);
         /** @var $defaultFlashMessageQueue \TYPO3\CMS\Core\Messaging\FlashMessageQueue */
         $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
         $defaultFlashMessageQueue->enqueue($flashMessage);
     }
 }
Exemple #2
0
 /**
  * Prevent deleting/moving of a news record if the editor doesn't have access to all categories of the news record
  *
  * @param string $command
  * @param string $table
  * @param int $id
  * @param string $value
  * @param $parentObject \TYPO3\CMS\Core\DataHandling\DataHandler
  */
 public function processCmdmap_preProcess($command, &$table, $id, $value, $parentObject)
 {
     if ($table === 'tx_news_domain_model_news' && !$this->getBackendUser()->isAdmin() && is_integer($id) && $command !== 'undelete') {
         $newsRecord = BackendUtilityCore::getRecord($table, $id);
         if (!AccessControlService::userHasCategoryPermissionsForRecord($newsRecord)) {
             $parentObject->log($table, $id, 2, 0, 1, 'processCmdmap: Attempt to ' . $command . " a record from table '%s' without permission. Reason: the record has one or more categories assigned that are not defined in the BE usergroup.", 1, [$table]);
             // unset table to prevent saving
             $table = '';
         }
     }
 }