Commit 7d09e999 authored by Benni Mack's avatar Benni Mack Committed by Georg Ringer
Browse files

[CLEANUP] Use Permission constants consistently

Instead of integers, the permission constants
should be used throughout the TYPO3 Core.

Resolves: #83383
Releases: master
Change-Id: I00c10f97fc800d9533866c98284bbd22cd1bb575
Reviewed-on: https://review.typo3.org/55156

Tested-by: default avatarTYPO3com <no-reply@typo3.com>
Reviewed-by: Tymoteusz Motylewski's avatarTymoteusz Motylewski <t.motylewski@gmail.com>
Tested-by: Tymoteusz Motylewski's avatarTymoteusz Motylewski <t.motylewski@gmail.com>
Reviewed-by: Georg Ringer's avatarGeorg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer's avatarGeorg Ringer <georg.ringer@gmail.com>
parent 2cd01388
......@@ -18,6 +18,7 @@ use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
use TYPO3\CMS\Core\Database\Query\Restriction\HiddenRestriction;
use TYPO3\CMS\Core\Database\QueryGenerator;
use TYPO3\CMS\Core\Type\Bitmask\Permission;
use TYPO3\CMS\Core\TypoScript\TemplateService;
use TYPO3\CMS\Core\Utility\ArrayUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
......@@ -258,7 +259,7 @@ class BackendConfigurationManager extends AbstractConfigurationManager
$recursiveStoragePids = '';
$storagePids = GeneralUtility::intExplode(',', $storagePid);
$permsClause = $this->getBackendUser()->getPagePermsClause(1);
$permsClause = $this->getBackendUser()->getPagePermsClause(Permission::PAGE_SHOW);
$queryGenerator = GeneralUtility::makeInstance(QueryGenerator::class);
foreach ($storagePids as $startPid) {
$pids = $queryGenerator->getTreeList($startPid, $recursionDepth, 0, $permsClause);
......
......@@ -17,6 +17,7 @@ namespace TYPO3\CMS\Fluid\ViewHelpers\Be;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Imaging\IconFactory;
use TYPO3\CMS\Core\Type\Bitmask\Permission;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
......@@ -68,7 +69,7 @@ class PageInfoViewHelper extends AbstractBackendViewHelper
public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
{
$id = GeneralUtility::_GP('id');
$pageRecord = BackendUtility::readPageAccess($id, $GLOBALS['BE_USER']->getPagePermsClause(1));
$pageRecord = BackendUtility::readPageAccess($id, $GLOBALS['BE_USER']->getPagePermsClause(Permission::PAGE_SHOW));
// Add icon with context menu, etc:
/** @var IconFactory $iconFactory */
$iconFactory = GeneralUtility::makeInstance(IconFactory::class);
......
......@@ -15,6 +15,7 @@ namespace TYPO3\CMS\Fluid\ViewHelpers\Be;
*/
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Type\Bitmask\Permission;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
......@@ -66,7 +67,7 @@ class PagePathViewHelper extends AbstractBackendViewHelper
public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
{
$id = GeneralUtility::_GP('id');
$pageRecord = BackendUtility::readPageAccess($id, $GLOBALS['BE_USER']->getPagePermsClause(1));
$pageRecord = BackendUtility::readPageAccess($id, $GLOBALS['BE_USER']->getPagePermsClause(Permission::PAGE_SHOW));
// Is this a real page
if ($pageRecord['uid']) {
$title = $pageRecord['_thePathFull'];
......
......@@ -15,6 +15,7 @@ namespace TYPO3\CMS\Fluid\ViewHelpers\Be;
*/
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Type\Bitmask\Permission;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
......@@ -107,7 +108,7 @@ class TableListViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Be\AbstractBacken
$this->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Recordlist/Recordlist');
$pageinfo = BackendUtility::readPageAccess(GeneralUtility::_GP('id'), $GLOBALS['BE_USER']->getPagePermsClause(1));
$pageinfo = BackendUtility::readPageAccess(GeneralUtility::_GP('id'), $GLOBALS['BE_USER']->getPagePermsClause(Permission::PAGE_SHOW));
/** @var $dblist \TYPO3\CMS\Recordlist\RecordList\DatabaseRecordList */
$dblist = GeneralUtility::makeInstance(\TYPO3\CMS\Recordlist\RecordList\DatabaseRecordList::class);
$dblist->pageRow = $pageinfo;
......
......@@ -40,6 +40,7 @@ use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Resource\StorageRepository;
use TYPO3\CMS\Core\Service\DependencyOrderingService;
use TYPO3\CMS\Core\TimeTracker\TimeTracker;
use TYPO3\CMS\Core\Type\Bitmask\Permission;
use TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser;
use TYPO3\CMS\Core\TypoScript\TemplateService;
use TYPO3\CMS\Core\Utility\ArrayUtility;
......@@ -1626,7 +1627,7 @@ class TypoScriptFrontendController implements LoggerAwareInterface
'uid',
$queryBuilder->createNamedParameter($this->id, \PDO::PARAM_INT)
),
$this->getBackendUser()->getPagePermsClause(1)
$this->getBackendUser()->getPagePermsClause(Permission::PAGE_SHOW)
)
->execute()
->fetch();
......
......@@ -165,7 +165,7 @@ class AdminPanelView
'clearCacheLevels'
),
0,
$beUser->getPagePermsClause(1)
$beUser->getPagePermsClause(Permission::PAGE_SHOW)
) . $theStartId
);
}
......@@ -480,7 +480,7 @@ class AdminPanelView
->from('pages')
->where(
$queryBuilder->expr()->eq('pages.uid', $queryBuilder->quoteIdentifier('fe_groups.pid')),
$this->getBackendUser()->getPagePermsClause(1)
$this->getBackendUser()->getPagePermsClause(Permission::PAGE_SHOW)
)
->execute()
->fetchColumn(0);
......@@ -490,7 +490,7 @@ class AdminPanelView
->from('pages')
->where(
$queryBuilder->expr()->eq('pages.uid', $queryBuilder->quoteIdentifier('fe_groups.pid')),
$this->getBackendUser()->getPagePermsClause(1)
$this->getBackendUser()->getPagePermsClause(Permission::PAGE_SHOW)
)
->orderBy('fe_groups.title')
->execute();
......
......@@ -21,6 +21,7 @@ use TYPO3\CMS\Core\Imaging\IconFactory;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Resource\Exception\InsufficientFolderAccessPermissionsException;
use TYPO3\CMS\Core\Resource\ResourceFactory;
use TYPO3\CMS\Core\Type\Bitmask\Permission;
use TYPO3\CMS\Core\Utility\DebugUtility;
use TYPO3\CMS\Core\Utility\DiffUtility;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
......@@ -1088,7 +1089,7 @@ abstract class ImportExport
public function getRecordPath($pid)
{
if (!isset($this->cache_getRecordPath[$pid])) {
$clause = $this->getBackendUser()->getPagePermsClause(1);
$clause = $this->getBackendUser()->getPagePermsClause(Permission::PAGE_SHOW);
$this->cache_getRecordPath[$pid] = (string)BackendUtility::getRecordPath($pid, $clause, 20);
}
return $this->cache_getRecordPath[$pid];
......
......@@ -19,6 +19,7 @@ use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Messaging\FlashMessage;
use TYPO3\CMS\Core\Messaging\FlashMessageService;
use TYPO3\CMS\Core\Resource\Exception;
use TYPO3\CMS\Core\Type\Bitmask\Permission;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Taskcenter\Controller\TaskModuleController;
use TYPO3\CMS\Taskcenter\TaskInterface;
......@@ -104,7 +105,7 @@ class ImportExportTask implements TaskInterface
// Header
$lang = $this->getLanguageService();
$content .= $this->taskObject->description($lang->getLL('.alttitle'), $lang->getLL('.description'));
$clause = $this->getBackendUser()->getPagePermsClause(1);
$clause = $this->getBackendUser()->getPagePermsClause(Permission::PAGE_SHOW);
$usernames = BackendUtility::getUserNames();
// Create preset links:
$presets = $this->getPresets();
......
......@@ -18,6 +18,7 @@ use TYPO3\CMS\Backend\Tree\View\BrowseTreeView;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Imaging\IconFactory;
use TYPO3\CMS\Core\Type\Bitmask\Permission;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
......@@ -84,7 +85,7 @@ class ExportPageTreeView extends BrowseTreeView
public function ext_tree($pid, $clause = '')
{
// Initialize:
$this->init(' AND ' . $this->BE_USER->getPagePermsClause(1) . $clause);
$this->init(' AND ' . $this->BE_USER->getPagePermsClause(Permission::PAGE_SHOW) . $clause);
// Get stored tree structure:
$this->stored = unserialize($this->BE_USER->uc['browseTrees']['browsePages'], ['allowed_classes' => false]);
$treeArr = [];
......
......@@ -20,6 +20,7 @@ use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Type\Bitmask\Permission;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
use TYPO3\CMS\Extbase\Mvc\View\ViewInterface;
......@@ -89,7 +90,7 @@ class AdministrationController extends ActionController
if ($view instanceof BackendTemplateView) {
/** @var BackendTemplateView $view */
parent::initializeView($view);
$permissionClause = $this->getBackendUserAuthentication()->getPagePermsClause(1);
$permissionClause = $this->getBackendUserAuthentication()->getPagePermsClause(Permission::PAGE_SHOW);
$pageRecord = BackendUtility::readPageAccess($this->pageUid, $permissionClause);
if ($pageRecord) {
$view->getModuleTemplate()->getDocHeaderComponent()->setMetaInformation($pageRecord);
......
......@@ -25,6 +25,7 @@ use TYPO3\CMS\Core\Database\Query\QueryHelper;
use TYPO3\CMS\Core\DataHandling\DataHandler;
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Imaging\IconFactory;
use TYPO3\CMS\Core\Type\Bitmask\Permission;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\IndexedSearch\FileContentParser;
......@@ -464,7 +465,7 @@ class AdministrationRepository
}
/** @var PageTreeView $tree */
$tree = GeneralUtility::makeInstance(PageTreeView::class);
$perms_clause = $this->getBackendUserAuthentication()->getPagePermsClause(1);
$perms_clause = $this->getBackendUserAuthentication()->getPagePermsClause(Permission::PAGE_SHOW);
$tree->init('AND ' . $perms_clause);
$iconFactory = GeneralUtility::makeInstance(IconFactory::class);
$HTML = '<span title="' . htmlspecialchars($pageRecord['title']) . '">' . $iconFactory->getIconForRecord('pages', $pageRecord, Icon::SIZE_SMALL)->render() . '</span>';
......
......@@ -22,6 +22,7 @@ use TYPO3\CMS\Core\Database\Query\Restriction\BackendWorkspaceRestriction;
use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Imaging\IconFactory;
use TYPO3\CMS\Core\Type\Bitmask\Permission;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
......@@ -95,7 +96,7 @@ class TranslationStatusController extends \TYPO3\CMS\Backend\Module\AbstractFunc
$depth = $this->pObj->MOD_SETTINGS['depth'];
// Initialize tree object:
$tree = GeneralUtility::makeInstance(PageTreeView::class);
$tree->init('AND ' . $this->getBackendUser()->getPagePermsClause(1));
$tree->init('AND ' . $this->getBackendUser()->getPagePermsClause(Permission::PAGE_SHOW));
$tree->addField('l18n_cfg');
// Creating top icon; the current page
$HTML = $this->iconFactory->getIconForRecord('pages', $treeStartingRecord, Icon::SIZE_SMALL)->render();
......
......@@ -25,6 +25,7 @@ use TYPO3\CMS\Core\Imaging\IconFactory;
use TYPO3\CMS\Core\Messaging\FlashMessage;
use TYPO3\CMS\Core\Messaging\FlashMessageService;
use TYPO3\CMS\Core\Service\MarkerBasedTemplateService;
use TYPO3\CMS\Core\Type\Bitmask\Permission;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Linkvalidator\LinkAnalyzer;
......@@ -240,7 +241,7 @@ class LinkValidatorReport extends \TYPO3\CMS\Backend\Module\AbstractFunctionModu
$this->doc = GeneralUtility::makeInstance(DocumentTemplate::class);
$this->doc->setModuleTemplate('EXT:linkvalidator/Resources/Private/Templates/mod_template.html');
$this->pageRecord = BackendUtility::readPageAccess($this->pObj->id, $this->getBackendUser()->getPagePermsClause(1));
$this->pageRecord = BackendUtility::readPageAccess($this->pObj->id, $this->getBackendUser()->getPagePermsClause(Permission::PAGE_SHOW));
if ($this->pObj->id && is_array($this->pageRecord) || !$this->pObj->id && $this->isCurrentUserAdmin()) {
$this->isAccessibleForCurrentUser = true;
}
......@@ -279,7 +280,7 @@ class LinkValidatorReport extends \TYPO3\CMS\Backend\Module\AbstractFunctionModu
$this->pObj->id,
$this->searchLevel,
0,
$this->getBackendUser()->getPagePermsClause(1),
$this->getBackendUser()->getPagePermsClause(Permission::PAGE_SHOW),
$this->modTS['checkhidden']
);
if ($this->pObj->pageinfo['hidden'] == 0 || $this->modTS['checkhidden']) {
......@@ -431,7 +432,7 @@ class LinkValidatorReport extends \TYPO3\CMS\Backend\Module\AbstractFunctionModu
$currentPageUid,
$this->searchLevel,
0,
$this->getBackendUser()->getPagePermsClause(1),
$this->getBackendUser()->getPagePermsClause(Permission::PAGE_SHOW),
$this->modTS['checkhidden']
);
// Always add the current page, because we are just displaying the results
......
......@@ -17,6 +17,7 @@ namespace TYPO3\CMS\Recordlist\Browser;
use TYPO3\CMS\Backend\RecordList\ElementBrowserRecordList;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Type\Bitmask\Permission;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\MathUtility;
use TYPO3\CMS\Recordlist\Tree\View\ElementBrowserPageTreeView;
......@@ -230,7 +231,7 @@ class DatabaseBrowser extends AbstractElementBrowser implements ElementBrowserIn
$out .= '<br />';
}
$permsClause = $backendUser->getPagePermsClause(1);
$permsClause = $backendUser->getPagePermsClause(Permission::PAGE_SHOW);
$pageInfo = BackendUtility::readPageAccess($this->expandPage, $permsClause);
/** @var ElementBrowserRecordList $dbList */
......
......@@ -215,7 +215,7 @@ class RecordList
{
$this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
$backendUser = $this->getBackendUserAuthentication();
$this->perms_clause = $backendUser->getPagePermsClause(1);
$this->perms_clause = $backendUser->getPagePermsClause(Permission::PAGE_SHOW);
// Get session data
$sessionData = $backendUser->getSessionData(__CLASS__);
$this->search_field = !empty($sessionData['search_field']) ? $sessionData['search_field'] : '';
......
......@@ -433,7 +433,7 @@ class AbstractDatabaseRecordList extends AbstractRecordList
$expressionBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('pages')
->expr();
$permsClause = $expressionBuilder->andX($backendUser->getPagePermsClause(1));
$permsClause = $expressionBuilder->andX($backendUser->getPagePermsClause(Permission::PAGE_SHOW));
// This will hide records from display - it has nothing to do with user rights!!
if ($pidList = $backendUser->getTSConfigVal('options.hideRecords.pages')) {
$pidList = GeneralUtility::intExplode(',', $pidList, true);
......
......@@ -2863,7 +2863,7 @@ class DatabaseRecordList
$expressionBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('pages')
->expr();
$permsClause = $expressionBuilder->andX($backendUser->getPagePermsClause(1));
$permsClause = $expressionBuilder->andX($backendUser->getPagePermsClause(Permission::PAGE_SHOW));
// This will hide records from display - it has nothing to do with user rights!!
if ($pidList = $backendUser->getTSConfigVal('options.hideRecords.pages')) {
$pidList = GeneralUtility::intExplode(',', $pidList, true);
......
......@@ -17,6 +17,7 @@ namespace TYPO3\CMS\Recycler\Controller;
use TYPO3\CMS\Backend\Template\Components\ButtonBar;
use TYPO3\CMS\Backend\View\BackendTemplateView;
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Type\Bitmask\Permission;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
use TYPO3\CMS\Extbase\Mvc\View\ViewInterface;
......@@ -80,7 +81,7 @@ class RecyclerModuleController extends ActionController
{
$this->id = (int)GeneralUtility::_GP('id');
$backendUser = $this->getBackendUser();
$this->perms_clause = $backendUser->getPagePermsClause(1);
$this->perms_clause = $backendUser->getPagePermsClause(Permission::PAGE_SHOW);
$this->pageRecord = \TYPO3\CMS\Backend\Utility\BackendUtility::readPageAccess($this->id, $this->perms_clause);
$this->isAccessibleForCurrentUser = $this->id && is_array($this->pageRecord) || !$this->id && $this->getBackendUser()->isAdmin();
......
......@@ -25,6 +25,7 @@ use TYPO3\CMS\Core\Database\Query\Restriction\BackendWorkspaceRestriction;
use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
use TYPO3\CMS\Core\DataHandling\DataHandler;
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Type\Bitmask\Permission;
use TYPO3\CMS\Core\TypoScript\ExtendedTemplateService;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\MathUtility;
......@@ -131,7 +132,7 @@ class TypoScriptTemplateModuleController extends BaseScriptClass
$this->id = (int)GeneralUtility::_GP('id');
$this->sObj = GeneralUtility::_GP('sObj');
$this->edit = GeneralUtility::_GP('edit');
$this->perms_clause = $this->getBackendUser()->getPagePermsClause(1);
$this->perms_clause = $this->getBackendUser()->getPagePermsClause(Permission::PAGE_SHOW);
}
/**
......
......@@ -23,6 +23,7 @@ use TYPO3\CMS\Core\Database\Query\Restriction\HiddenRestriction;
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Imaging\IconFactory;
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Type\Bitmask\Permission;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
use TYPO3\CMS\Extbase\Mvc\View\ViewInterface;
......@@ -167,7 +168,7 @@ class ViewModuleController extends ActionController
{
$pageIdToShow = (int)GeneralUtility::_GP('id');
$permissionClause = $this->getBackendUser()->getPagePermsClause(1);
$permissionClause = $this->getBackendUser()->getPagePermsClause(Permission::PAGE_SHOW);
$pageRecord = BackendUtility::readPageAccess($pageIdToShow, $permissionClause);
if ($pageRecord) {
$this->view->getModuleTemplate()->getDocHeaderComponent()->setMetaInformation($pageRecord);
......@@ -212,7 +213,7 @@ class ViewModuleController extends ActionController
protected function getAdminCommand($pageId)
{
// The page will show only if there is a valid page and if this page may be viewed by the user
$pageinfo = BackendUtility::readPageAccess($pageId, $this->getBackendUser()->getPagePermsClause(1));
$pageinfo = BackendUtility::readPageAccess($pageId, $this->getBackendUser()->getPagePermsClause(Permission::PAGE_SHOW));
$addCommand = '';
if (is_array($pageinfo)) {
$addCommand = '&ADMCMD_editIcons=1' . BackendUtility::ADMCMD_previewCmds($pageinfo);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment