[TASK] Use constants instead of raw bitmask values 55/37455/13
authorAndreas Fernandez <a.fernandez@scripting-base.de>
Mon, 2 Mar 2015 13:19:51 +0000 (14:19 +0100)
committerFrank Nägler <typo3@naegler.net>
Sun, 15 Mar 2015 17:38:18 +0000 (18:38 +0100)
The used bitmasks of JsConfirmation and Permission are put
into "enums" and their representing constants are used instead
of the raw bitmask values.

Resolves: #65455
Releases: master
Change-Id: I1910bb960b69836ea29c16c91d730ac74c22f929
Reviewed-on: http://review.typo3.org/37455
Reviewed-by: Nicole Cordes <typo3@cordes.co>
Tested-by: Nicole Cordes <typo3@cordes.co>
Reviewed-by: Mathias Brodala <mbrodala@pagemachine.de>
Reviewed-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Reviewed-by: Frank Nägler <typo3@naegler.net>
Tested-by: Frank Nägler <typo3@naegler.net>
24 files changed:
typo3/sysext/backend/Classes/ClickMenu/ClickMenu.php
typo3/sysext/backend/Classes/Clipboard/Clipboard.php
typo3/sysext/backend/Classes/Controller/EditDocumentController.php
typo3/sysext/backend/Classes/Controller/PageLayoutController.php
typo3/sysext/backend/Classes/Controller/Wizard/AbstractWizardController.php
typo3/sysext/backend/Classes/Form/Element/FlexElement.php
typo3/sysext/backend/Classes/Form/Element/InlineElement.php
typo3/sysext/backend/Classes/Form/Element/TreeElement.php
typo3/sysext/backend/Classes/Form/FormEngine.php
typo3/sysext/backend/Classes/Search/LiveSearch/LiveSearch.php
typo3/sysext/backend/Classes/Tree/Pagetree/ExtdirectTreeDataProvider.php
typo3/sysext/backend/Classes/View/PageLayoutView.php
typo3/sysext/backend/Classes/View/ThumbnailView.php
typo3/sysext/core/Classes/Authentication/BackendUserAuthentication.php
typo3/sysext/core/Classes/DataHandling/DataHandler.php
typo3/sysext/core/Classes/FrontendEditing/FrontendEditingController.php
typo3/sysext/core/Classes/Type/Bitmask/JsConfirmation.php [new file with mode: 0644]
typo3/sysext/core/Classes/Type/Bitmask/Permission.php [new file with mode: 0644]
typo3/sysext/feedit/Classes/FrontendEditPanel.php
typo3/sysext/filelist/Classes/FileList.php
typo3/sysext/frontend/Classes/View/AdminPanelView.php
typo3/sysext/recordlist/Classes/RecordList/AbstractDatabaseRecordList.php
typo3/sysext/recordlist/Classes/RecordList/DatabaseRecordList.php
typo3/sysext/recycler/Classes/Utility/RecyclerUtility.php

index 12006da..3f859b4 100644 (file)
@@ -14,14 +14,16 @@ namespace TYPO3\CMS\Backend\ClickMenu;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Backend\Clipboard\Clipboard;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Backend\Utility\IconUtility;
+use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
 use TYPO3\CMS\Core\Resource\Folder;
 use TYPO3\CMS\Core\Resource\ResourceFactory;
+use TYPO3\CMS\Core\Type\Bitmask\JsConfirmation;
+use TYPO3\CMS\Core\Type\Bitmask\Permission;
 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Backend\Clipboard\Clipboard;
-use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
 use TYPO3\CMS\Lang\LanguageService;
 
 /**
@@ -287,7 +289,7 @@ class ClickMenu {
                                        $root ? $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'] : GeneralUtility::fixed_lgd_cs(BackendUtility::getRecordTitle($table, $this->rec), $this->backendUser->uc['titleLen']),
                                        $this->clipObj->currentMode()
                                );
-                               if ($table === 'pages' && $lCP & 8) {
+                               if ($table === 'pages' && $lCP & Permission::PAGE_NEW) {
                                        if ($elFromAllTables) {
                                                $menuItems['pasteinto'] = $this->DB_paste('', $uid, 'into', $elInfo);
                                        }
@@ -528,7 +530,7 @@ class ClickMenu {
         */
        public function DB_paste($table, $uid, $type, $elInfo) {
                $loc = 'top.content.list_frame';
-               if ($this->backendUser->jsConfirmation(2)) {
+               if ($this->backendUser->jsConfirmation(JsConfirmation::COPY_MOVE_PASTE)) {
                        $conf = $loc . ' && confirm(' . GeneralUtility::quoteJSvalue(sprintf($this->languageService->sL(('LLL:EXT:lang/locallang_core.xlf:mess.' . ($elInfo[2] === 'copy' ? 'copy' : 'move') . '_' . $type)), $elInfo[0], $elInfo[1])) . ')';
                } else {
                        $conf = $loc;
@@ -727,7 +729,7 @@ class ClickMenu {
         */
        public function DB_delete($table, $uid, $elInfo) {
                $loc = 'top.content.list_frame';
-               if ($this->backendUser->jsConfirmation(4)) {
+               if ($this->backendUser->jsConfirmation(JsConfirmation::DELETE)) {
                        $conf = 'confirm(' . GeneralUtility::quoteJSvalue((sprintf($this->languageService->sL('LLL:EXT:lang/locallang_core.xlf:mess.delete'), $elInfo[0]) . BackendUtility::referenceCount($table, $uid, ' (There are %s reference(s) to this record!)') . BackendUtility::translationCount($table, $uid, (' ' . $this->languageService->sL('LLL:EXT:lang/locallang_core.xlf:labels.translationsOfRecord'))))) . ')';
                } else {
                        $conf = '1==1';
@@ -1053,7 +1055,7 @@ class ClickMenu {
         */
        public function FILE_paste($path, $target, $elInfo) {
                $loc = 'top.content.list_frame';
-               if ($this->backendUser->jsConfirmation(2)) {
+               if ($this->backendUser->jsConfirmation(JsConfirmation::COPY_MOVE_PASTE)) {
                        $conf = $loc . ' && confirm(' . GeneralUtility::quoteJSvalue(sprintf($this->languageService->sL(('LLL:EXT:lang/locallang_core.xlf:mess.' . ($elInfo[2] === 'copy' ? 'copy' : 'move') . '_into')), $elInfo[0], $elInfo[1])) . ')';
                } else {
                        $conf = $loc;
index d599d77..6fe3fd4 100644 (file)
@@ -17,6 +17,7 @@ namespace TYPO3\CMS\Backend\Clipboard;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Backend\Utility\IconUtility;
 use TYPO3\CMS\Core\Resource\ResourceFactory;
+use TYPO3\CMS\Core\Type\Bitmask\JsConfirmation;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
 use TYPO3\CMS\Core\Utility\MathUtility;
@@ -270,7 +271,7 @@ class Clipboard {
                // Delete:
                if ($elCount) {
                        $deleteLink = '<a class="btn btn-danger" href="' . htmlspecialchars($rmall_url) . '#clip_head">' . IconUtility::getSpriteIcon('actions-document-close', array('title' => $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:buttons.clear', TRUE))) . '</a>';
-                       if ($this->getBackendUser()->jsConfirmation(4)) {
+                       if ($this->getBackendUser()->jsConfirmation(JsConfirmation::DELETE)) {
                                $js = '
                        if (confirm(' . GeneralUtility::quoteJSvalue(sprintf($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:mess.deleteClip'), $elCount)) . ')){
                                window.location.href=\'' . $this->deleteUrl(0, ($this->fileMode ? 1 : 0)) . '&redirect=\'+top.rawurlencode(window.location.href);
@@ -630,7 +631,7 @@ class Clipboard {
         * @return string JavaScript "confirm" message
         */
        public function confirmMsg($table, $rec, $type, $clElements, $columnLabel = '') {
-               if ($this->getBackendUser()->jsConfirmation(2)) {
+               if ($this->getBackendUser()->jsConfirmation(JsConfirmation::COPY_MOVE_PASTE)) {
                        $labelKey = 'LLL:EXT:lang/locallang_core.xlf:mess.' . ($this->currentMode() == 'copy' ? 'copy' : 'move') . ($this->current == 'normal' ? '' : 'cb') . '_' . $type;
                        $msg = $this->getLanguageService()->sL($labelKey . ($columnLabel ? '_colPos': ''));
                        if ($table == '_FILE') {
index 08a5f88..f211589 100644 (file)
@@ -18,6 +18,8 @@ use TYPO3\CMS\Backend\Form\FormEngine;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Backend\Utility\IconUtility;
 use TYPO3\CMS\Core\Html\HtmlParser;
+use TYPO3\CMS\Core\Type\Bitmask\JsConfirmation;
+use TYPO3\CMS\Core\Type\Bitmask\Permission;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\HttpUtility;
 use TYPO3\CMS\Core\Utility\MathUtility;
@@ -697,7 +699,7 @@ class EditDocumentController {
                        }
                        function deleteRecord(table,id,url) {   //
                                if (
-                                       ' . ($GLOBALS['BE_USER']->jsConfirmation(4) ? 'confirm(' . GeneralUtility::quoteJSvalue($GLOBALS['LANG']->getLL('deleteWarning')) . ')' : '1==1') . '
+                                       ' . ($GLOBALS['BE_USER']->jsConfirmation(JsConfirmation::DELETE) ? 'confirm(' . GeneralUtility::quoteJSvalue($GLOBALS['LANG']->getLL('deleteWarning')) . ')' : '1==1') . '
                                )       {
                                        window.location.href = ' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('tce_db') . '&cmd[') . '+table+"]["+id+"][delete]=1' . BackendUtility::getUrlToken('tceAction') . '&redirect="+escape(url)+"&vC=' . $GLOBALS['BE_USER']->veriCode() . '&prErr=1&uPT=1";
                                }
@@ -833,10 +835,10 @@ class EditDocumentController {
                                                                                $CALC_PERMS = $GLOBALS['BE_USER']->calcPerms($calcPRec);
                                                                                if ($table == 'pages') {
                                                                                        // If pages:
-                                                                                       $hasAccess = $CALC_PERMS & 8 ? 1 : 0;
+                                                                                       $hasAccess = $CALC_PERMS & Permission::PAGE_NEW ? 1 : 0;
                                                                                        $this->viewId = 0;
                                                                                } else {
-                                                                                       $hasAccess = $CALC_PERMS & 16 ? 1 : 0;
+                                                                                       $hasAccess = $CALC_PERMS & Permission::CONTENT_EDIT ? 1 : 0;
                                                                                        $this->viewId = $calcPRec['uid'];
                                                                                }
                                                                        }
@@ -850,14 +852,14 @@ class EditDocumentController {
                                                                if (is_array($calcPRec)) {
                                                                        if ($table == 'pages') { // If pages:
                                                                                $CALC_PERMS = $GLOBALS['BE_USER']->calcPerms($calcPRec);
-                                                                               $hasAccess = $CALC_PERMS & 2 ? 1 : 0;
-                                                                               $deleteAccess = $CALC_PERMS & 4 ? 1 : 0;
+                                                                               $hasAccess = $CALC_PERMS & Permission::PAGE_EDIT ? 1 : 0;
+                                                                               $deleteAccess = $CALC_PERMS & Permission::PAGE_DELETE ? 1 : 0;
                                                                                $this->viewId = $calcPRec['uid'];
                                                                        } else {
                                                                                // Fetching pid-record first
                                                                                $CALC_PERMS = $GLOBALS['BE_USER']->calcPerms(BackendUtility::getRecord('pages', $calcPRec['pid']));
-                                                                               $hasAccess = $CALC_PERMS & 16 ? 1 : 0;
-                                                                               $deleteAccess = $CALC_PERMS & 16 ? 1 : 0;
+                                                                               $hasAccess = $CALC_PERMS & Permission::CONTENT_EDIT ? 1 : 0;
+                                                                               $deleteAccess = $CALC_PERMS & Permission::CONTENT_EDIT ? 1 : 0;
                                                                                $this->viewId = $calcPRec['pid'];
                                                                                // Adding "&L=xx" if the record being edited has a languageField with a value larger than zero!
                                                                                if ($GLOBALS['TCA'][$table]['ctrl']['languageField'] && $calcPRec[$GLOBALS['TCA'][$table]['ctrl']['languageField']] > 0) {
index 1a5c1c1..2244934 100644 (file)
@@ -16,6 +16,7 @@ namespace TYPO3\CMS\Backend\Controller;
 
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Backend\Utility\IconUtility;
+use TYPO3\CMS\Core\Type\Bitmask\Permission;
 use TYPO3\CMS\Core\Messaging\FlashMessage;
 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -449,7 +450,7 @@ class PageLayoutController {
                if ($this->id && $access) {
                        // Initialize permission settings:
                        $this->CALC_PERMS = $GLOBALS['BE_USER']->calcPerms($this->pageinfo);
-                       $this->EDIT_CONTENT = $this->CALC_PERMS & 16 ? 1 : 0;
+                       $this->EDIT_CONTENT = $this->CALC_PERMS & Permission::CONTENT_EDIT ? 1 : 0;
                        // Start document template object:
                        $this->doc = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Template\DocumentTemplate::class);
                        $this->doc->backPath = $GLOBALS['BACK_PATH'];
@@ -730,7 +731,7 @@ class PageLayoutController {
                // Splitting the edit-record cmd value into table/uid:
                $this->eRParts = explode(':', $edit_record);
                // Delete-button flag?
-               $this->deleteButton = MathUtility::canBeInterpretedAsInteger($this->eRParts[1]) && $edit_record && ($this->eRParts[0] != 'pages' && $this->EDIT_CONTENT || $this->eRParts[0] == 'pages' && $this->CALC_PERMS & 4);
+               $this->deleteButton = MathUtility::canBeInterpretedAsInteger($this->eRParts[1]) && $edit_record && ($this->eRParts[0] != 'pages' && $this->EDIT_CONTENT || $this->eRParts[0] == 'pages' && $this->CALC_PERMS & Permission::PAGE_DELETE);
                // If undo-button should be rendered (depends on available items in sys_history)
                $this->undoButton = 0;
                $undoRes = $GLOBALS['TYPO3_DB']->exec_SELECTquery('tstamp', 'sys_history', 'tablename=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($this->eRParts[0], 'sys_history') . ' AND recuid=' . (int)$this->eRParts[1], '', 'tstamp DESC', '1');
@@ -757,7 +758,7 @@ class PageLayoutController {
                        BackendUtility::getModuleUrl('web_layout') . '&id=' . $this->id . '&edit_record='
                ) . '+escape(this.options[this.selectedIndex].value)' . $retUrlStr . ',this);') . '">' . implode('', $opt) . '</select>';
                // Creating editing form:
-               if ($GLOBALS['BE_USER']->check('tables_modify', $this->eRParts[0]) && $edit_record && ($this->eRParts[0] !== 'pages' && $this->EDIT_CONTENT || $this->eRParts[0] === 'pages' && $this->CALC_PERMS & 1)) {
+               if ($GLOBALS['BE_USER']->check('tables_modify', $this->eRParts[0]) && $edit_record && ($this->eRParts[0] !== 'pages' && $this->EDIT_CONTENT || $this->eRParts[0] === 'pages' && $this->CALC_PERMS & Permission::PAGE_SHOW)) {
                        // Splitting uid parts for special features, if new:
                        list($uidVal, $ex_pid, $ex_colPos) = explode('/', $this->eRParts[1]);
                        // Convert $uidVal to workspace version if any:
@@ -1082,7 +1083,7 @@ class PageLayoutController {
                        }
 
                        // Edit page properties and page language overlay icons
-                       if ($this->CALC_PERMS & 2) {
+                       if ($this->CALC_PERMS & Permission::PAGE_EDIT) {
 
                                // Edit localized page_language_overlay only when one specific language is selected
                                if ($this->MOD_SETTINGS['function'] == 1 && $this->current_sys_language > 0) {
index de680de..0512b87 100644 (file)
@@ -18,6 +18,7 @@ use TYPO3\CMS\Backend\Template\DocumentTemplate;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
 use TYPO3\CMS\Core\Database\DatabaseConnection;
+use TYPO3\CMS\Core\Type\Bitmask\Permission;
 use TYPO3\CMS\Lang\LanguageService;
 
 /**
@@ -39,12 +40,12 @@ class AbstractWizardController {
                        // If pages:
                        if ($table === 'pages') {
                                $calculatedPermissions = $this->getBackendUserAuthentication()->calcPerms($calcPermissionRecord);
-                               $hasAccess = $calculatedPermissions & 2;
+                               $hasAccess = $calculatedPermissions & Permission::PAGE_EDIT;
                        } else {
                                // Fetching pid-record first.
                                $calculatedPermissions = $this->getBackendUserAuthentication()->calcPerms(
                                        BackendUtility::getRecord('pages', $calcPermissionRecord['pid']));
-                               $hasAccess = $calculatedPermissions & 16;
+                               $hasAccess = $calculatedPermissions & Permission::CONTENT_EDIT;
                        }
                        // Check internals regarding access:
                        if ($hasAccess) {
index 6657514..68182db 100644 (file)
@@ -17,6 +17,7 @@ namespace TYPO3\CMS\Backend\Form\Element;
 use TYPO3\CMS\Backend\Form\Utility\FormEngineUtility;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Backend\Utility\IconUtility;
+use TYPO3\CMS\Core\Type\Bitmask\JsConfirmation;
 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
@@ -485,7 +486,7 @@ class FlexElement extends AbstractFormElement {
                                                                        || !empty($GLOBALS['TCA'][$table]['ctrl']['requestUpdate'])
                                                                        && GeneralUtility::inList($GLOBALS['TCA'][$table]['ctrl']['requestUpdate'], $key)
                                                                ) {
-                                                                       if ($this->getBackendUserAuthentication()->jsConfirmation(1)) {
+                                                                       if ($this->getBackendUserAuthentication()->jsConfirmation(JsConfirmation::TYPE_CHANGE)) {
                                                                                $alertMsgOnChange = 'if (confirm(TBE_EDITOR.labels.onChangeAlert) && TBE_EDITOR.checkSubmit(-1)){ TBE_EDITOR.submitForm() };';
                                                                        } else {
                                                                                $alertMsgOnChange = 'if(TBE_EDITOR.checkSubmit(-1)){ TBE_EDITOR.submitForm();}';
index bed861a..8e54625 100644 (file)
@@ -20,6 +20,7 @@ use TYPO3\CMS\Backend\Form\DataPreprocessor;
 use TYPO3\CMS\Core\Database\DatabaseConnection;
 use TYPO3\CMS\Core\Database\RelationHandler;
 use TYPO3\CMS\Core\Messaging\FlashMessage;
+use TYPO3\CMS\Core\Type\Bitmask\Permission;
 use TYPO3\CMS\Core\Utility\ArrayUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\MathUtility;
@@ -671,7 +672,7 @@ class InlineElement {
                        $localCalcPerms = $GLOBALS['BE_USER']->calcPerms(BackendUtility::getRecord('pages', $rec['uid']));
                }
                // This expresses the edit permissions for this particular element:
-               $permsEdit = $isPagesTable && $localCalcPerms & 2 || !$isPagesTable && $calcPerms & 16;
+               $permsEdit = $isPagesTable && $localCalcPerms & Permission::PAGE_EDIT || !$isPagesTable && $calcPerms & Permission::CONTENT_EDIT;
                // Controls: Defines which controls should be shown
                $enabledControls = $config['appearance']['enabledControls'];
                // Hook: Can disable/enable single controls for specific child records:
@@ -701,7 +702,7 @@ class InlineElement {
                if (!$tcaTableCtrl['readOnly'] && !$isVirtualRecord) {
                        // "New record after" link (ONLY if the records in the table are sorted by a "sortby"-row or if default values can depend on previous record):
                        if ($enabledControls['new'] && ($enableManualSorting || $tcaTableCtrl['useColumnsForDefaultValues'])) {
-                               if (!$isPagesTable && $calcPerms & 16 || $isPagesTable && $calcPerms & 8) {
+                               if (!$isPagesTable && $calcPerms & Permission::CONTENT_EDIT || $isPagesTable && $calcPerms & Permission::PAGE_NEW) {
                                        $onClick = 'return inline.createNewRecord(\'' . $nameObjectFt . '\',\'' . $rec['uid'] . '\')';
                                        if ($config['inline']['inlineNewButtonStyle']) {
                                                $style = ' style="' . $config['inline']['inlineNewButtonStyle'] . '"';
@@ -749,7 +750,7 @@ class InlineElement {
                                }
                        }
                        // "Delete" link:
-                       if ($enabledControls['delete'] && ($isPagesTable && $localCalcPerms & 4 || !$isPagesTable && $calcPerms & 16)) {
+                       if ($enabledControls['delete'] && ($isPagesTable && $localCalcPerms & Permission::PAGE_DELETE || !$isPagesTable && $calcPerms & Permission::CONTENT_EDIT)) {
                                $onClick = 'inline.deleteRecord(' . GeneralUtility::quoteJSvalue($nameObjectFtId) . ');';
                                $cells['delete'] = '
                                        <a class="btn btn-default" href="#" onclick="' . htmlspecialchars(('if (confirm(' . GeneralUtility::quoteJSvalue($languageService->getLL('deleteWarning')) . ')) {      ' . $onClick . ' } return false;')) . '">
@@ -2207,10 +2208,10 @@ class InlineElement {
                                // If pages:
                                if ($table == 'pages') {
                                        // Are we allowed to create new subpages?
-                                       $hasAccess = $CALC_PERMS & 8 ? 1 : 0;
+                                       $hasAccess = $CALC_PERMS & Permission::PAGE_NEW ? 1 : 0;
                                } else {
                                        // Are we allowed to edit content on this page?
-                                       $hasAccess = $CALC_PERMS & 16 ? 1 : 0;
+                                       $hasAccess = $CALC_PERMS & Permission::CONTENT_EDIT ? 1 : 0;
                                }
                        } else {
                                $hasAccess = 1;
@@ -2223,11 +2224,11 @@ class InlineElement {
                                // If pages:
                                if ($table == 'pages') {
                                        $CALC_PERMS = $GLOBALS['BE_USER']->calcPerms($calcPRec);
-                                       $hasAccess = $CALC_PERMS & 2 ? 1 : 0;
+                                       $hasAccess = $CALC_PERMS & Permission::PAGE_EDIT ? 1 : 0;
                                } else {
                                        // Fetching pid-record first.
                                        $CALC_PERMS = $GLOBALS['BE_USER']->calcPerms(BackendUtility::getRecord('pages', $calcPRec['pid']));
-                                       $hasAccess = $CALC_PERMS & 16 ? 1 : 0;
+                                       $hasAccess = $CALC_PERMS & Permission::CONTENT_EDIT ? 1 : 0;
                                }
                                // Check internals regarding access:
                                if ($hasAccess) {
index d6f662f..e0b3ce1 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Backend\Form\Element;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Type\Bitmask\JsConfirmation;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
 /**
@@ -116,7 +117,7 @@ class TreeElement extends AbstractFormElement {
                        || !empty($GLOBALS['TCA'][$table]['ctrl']['requestUpdate'])
                        && GeneralUtility::inList(str_replace(' ', '', $GLOBALS['TCA'][$table]['ctrl']['requestUpdate']), $field)
                ) {
-                       if ($GLOBALS['BE_USER']->jsConfirmation(1)) {
+                       if ($GLOBALS['BE_USER']->jsConfirmation(JsConfirmation::TYPE_CHANGE)) {
                                $onChange .= 'if (confirm(TBE_EDITOR.labels.onChangeAlert) && ' . 'TBE_EDITOR.checkSubmit(-1)){ TBE_EDITOR.submitForm() };';
                        } else {
                                $onChange .= 'if (TBE_EDITOR.checkSubmit(-1)){ TBE_EDITOR.submitForm() };';
index 90d6858..d1fd91c 100644 (file)
@@ -29,6 +29,7 @@ use TYPO3\CMS\Core\Html\HtmlParser;
 use TYPO3\CMS\Core\Messaging\FlashMessage;
 use TYPO3\CMS\Core\Messaging\FlashMessageQueue;
 use TYPO3\CMS\Core\Messaging\FlashMessageService;
+use TYPO3\CMS\Core\Type\Bitmask\JsConfirmation;
 use TYPO3\CMS\Core\Utility\DiffUtility;
 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -876,7 +877,7 @@ class FormEngine {
                                        || !empty($GLOBALS['TCA'][$table]['ctrl']['requestUpdate'])
                                        && GeneralUtility::inList(str_replace(' ', '', $GLOBALS['TCA'][$table]['ctrl']['requestUpdate']), $field)
                                ) {
-                                       if ($backendUser->jsConfirmation(1)) {
+                                       if ($backendUser->jsConfirmation(JsConfirmation::TYPE_CHANGE)) {
                                                $alertMsgOnChange = 'if (confirm(TBE_EDITOR.labels.onChangeAlert) && TBE_EDITOR.checkSubmit(-1)){ TBE_EDITOR.submitForm() };';
                                        } else {
                                                $alertMsgOnChange = 'if (TBE_EDITOR.checkSubmit(-1)){ TBE_EDITOR.submitForm() };';
@@ -2948,7 +2949,7 @@ class FormEngine {
                $tCells = array();
                $pct = round(100 / count($sArr));
                foreach ($sArr as $sKey => $sheetCfg) {
-                       if ($this->getBackendUserAuthentication()->jsConfirmation(1)) {
+                       if ($this->getBackendUserAuthentication()->jsConfirmation(JsConfirmation::TYPE_CHANGE)) {
                                $onClick = 'if (confirm(TBE_EDITOR.labels.onChangeAlert) && TBE_EDITOR.checkSubmit(-1)){'
                                        . 'document.editform[\'' . $elName . '\'].value=\'' . $sKey . '\'; TBE_EDITOR.submitForm()};';
                        } else {
index b4ff451..62d16f7 100644 (file)
@@ -16,6 +16,7 @@ namespace TYPO3\CMS\Backend\Search\LiveSearch;
 
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Backend\Utility\IconUtility;
+use TYPO3\CMS\Core\Type\Bitmask\Permission;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\MathUtility;
 
@@ -239,9 +240,9 @@ class LiveSearch {
                $editLink = '';
                if ($tableName == 'pages') {
                        $localCalcPerms = $GLOBALS['BE_USER']->calcPerms(BackendUtility::getRecord('pages', $row['uid']));
-                       $permsEdit = $localCalcPerms & 2;
+                       $permsEdit = $localCalcPerms & Permission::PAGE_EDIT;
                } else {
-                       $permsEdit = $calcPerms & 16;
+                       $permsEdit = $calcPerms & Permission::CONTENT_EDIT;
                }
                // "Edit" link: ( Only if permissions to edit the page-record of the content of the parent page ($this->id)
                // @todo Is there an existing function to generate this link?
index e538445..bedd864 100644 (file)
@@ -15,6 +15,7 @@ namespace TYPO3\CMS\Backend\Tree\Pagetree;
  */
 
 use TYPO3\CMS\Backend\Utility\IconUtility;
+use TYPO3\CMS\Core\Type\Bitmask\JsConfirmation;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
 /**
@@ -175,7 +176,7 @@ class ExtdirectTreeDataProvider extends \TYPO3\CMS\Backend\Tree\AbstractExtJsTre
                        ),
                        'Configuration' => array(
                                'hideFilter' => $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.hideFilter'),
-                               'displayDeleteConfirmation' => $GLOBALS['BE_USER']->jsConfirmation(4),
+                               'displayDeleteConfirmation' => $GLOBALS['BE_USER']->jsConfirmation(JsConfirmation::DELETE),
                                'canDeleteRecursivly' => $GLOBALS['BE_USER']->uc['recursiveDelete'] == TRUE,
                                'disableIconLinkToContextmenu' => $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.disableIconLinkToContextmenu'),
                                'indicator' => $indicators['html'],
index 8fbc43a..a33cf16 100644 (file)
@@ -20,6 +20,7 @@ use TYPO3\CMS\Backend\Utility\IconUtility;
 use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
 use TYPO3\CMS\Core\Database\DatabaseConnection;
 use TYPO3\CMS\Core\Messaging\FlashMessage;
+use TYPO3\CMS\Core\Type\Bitmask\Permission;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Versioning\VersionState;
 
@@ -844,7 +845,7 @@ class PageLayoutView extends \TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRe
                if ($this->option_showBigButtons) {
                        $bArray = array();
                        if (!$this->getPageLayoutController()->current_sys_language) {
-                               if ($this->ext_CALC_PERMS & 2) {
+                               if ($this->ext_CALC_PERMS & Permission::PAGE_EDIT) {
                                        $bArray[0] = $this->getPageLayoutController()->doc->t3Button(
                                                BackendUtility::editOnClick('&edit[pages][' . $id . ']=edit', $this->backPath, ''),
                                                $this->getLanguageService()->getLL('editPageProperties')
@@ -865,14 +866,14 @@ class PageLayoutView extends \TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRe
                                        );
                                }
                        }
-                       if ($this->ext_CALC_PERMS & 4 || $this->ext_CALC_PERMS & 2) {
+                       if ($this->ext_CALC_PERMS & Permission::PAGE_DELETE || $this->ext_CALC_PERMS & Permission::PAGE_EDIT) {
                                $bArray[1] = $this->getPageLayoutController()->doc->t3Button(
                                        'window.location.href=' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('move_element', array(), $this->backPath) . '&table=pages&uid=' . $id
                                                . '&returnUrl=' . rawurlencode(GeneralUtility::getIndpEnv('REQUEST_URI'))) . ';',
                                        $this->getLanguageService()->getLL('move_page')
                                );
                        }
-                       if ($this->ext_CALC_PERMS & 8) {
+                       if ($this->ext_CALC_PERMS & Permission::PAGE_NEW) {
                                $parameters = [
                                        'id' => $id,
                                        'pagesOnly' => 1,
index 972f0d8..64d7110 100644 (file)
@@ -16,6 +16,7 @@ namespace TYPO3\CMS\Backend\View;
 
 use TYPO3\CMS\Core\Resource\File;
 use TYPO3\CMS\Core\Resource\ResourceFactory;
+use TYPO3\CMS\Core\Type\Bitmask\Permission;
 use TYPO3\CMS\Core\Utility\CommandUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\MathUtility;
@@ -204,7 +205,7 @@ class ThumbnailView {
                        // Should be - ? 'png' : 'gif' - , but doesn't work (ImageMagick prob.?)
                        // René: png work for me
                        $thmMode = MathUtility::forceIntegerInRange($GLOBALS['TYPO3_CONF_VARS']['GFX']['thumbnails_png'], 0);
-                       $outext = $this->image->getExtension() != 'jpg' || $thmMode & 2 ? ($thmMode & 1 ? 'png' : 'gif') : 'jpg';
+                       $outext = $this->image->getExtension() != 'jpg' || $thmMode & Permission::PAGE_EDIT ? ($thmMode & 1 ? 'png' : 'gif') : 'jpg';
                        $outfile = 'tmb_' . substr(md5(($this->image->getName() . $this->mtime . $this->size)), 0, 10) . '.' . $outext;
                        $this->output = $outpath . $outfile;
                        if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['im']) {
index 5dafdd1..85d5b75 100644 (file)
@@ -15,6 +15,7 @@ namespace TYPO3\CMS\Core\Authentication;
  */
 
 use TYPO3\CMS\Core\Resource\ResourceStorage;
+use TYPO3\CMS\Core\Type\Bitmask\Permission;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 
@@ -521,13 +522,13 @@ class BackendUserAuthentication extends \TYPO3\CMS\Core\Authentication\AbstractU
        public function calcPerms($row) {
                // Return 31 for admin users.
                if ($this->isAdmin()) {
-                       return 31;
+                       return Permission::ALL;
                }
                // Return 0 if page is not within the allowed web mount
                if (!$this->isInWebMount($row['uid'])) {
-                       return 0;
+                       return Permission::NOTHING;
                }
-               $out = 0;
+               $out = Permission::NOTHING;
                if (
                        isset($row['perms_userid']) && isset($row['perms_user']) && isset($row['perms_groupid'])
                        && isset($row['perms_group']) && isset($row['perms_everybody']) && isset($this->groupList)
@@ -845,23 +846,23 @@ class BackendUserAuthentication extends \TYPO3\CMS\Core\Authentication\AbstractU
                } elseif ($tableName == 'pages') {
                        switch ($actionType) {
                                case 'edit':
-                                       $result = ($compiledPermissions & 2) !== 0;
+                                       $result = ($compiledPermissions & Permission::PAGE_EDIT) !== 0;
                                        break;
                                case 'new':
                                        // Create new page OR page content
-                                       $result = ($compiledPermissions & 8 + 16) !== 0;
+                                       $result = ($compiledPermissions & Permission::PAGE_NEW + Permission::CONTENT_EDIT) !== 0;
                                        break;
                                case 'delete':
-                                       $result = ($compiledPermissions & 4) !== 0;
+                                       $result = ($compiledPermissions & Permission::PAGE_DELETE) !== 0;
                                        break;
                                case 'editcontent':
-                                       $result = ($compiledPermissions & 16) !== 0;
+                                       $result = ($compiledPermissions & Permission::CONTENT_EDIT) !== 0;
                                        break;
                                default:
                                        $result = FALSE;
                        }
                } else {
-                       $result = ($compiledPermissions & 16) !== 0;
+                       $result = ($compiledPermissions & Permission::CONTENT_EDIT) !== 0;
                }
                return $result;
        }
@@ -1123,7 +1124,7 @@ class BackendUserAuthentication extends \TYPO3\CMS\Core\Authentication\AbstractU
                                        break;
                                default:
                                        // Custom workspace
-                                       $retVal = $wsAccess['_ACCESS'] === 'owner' || $this->checkWorkspace(0) && !($wsAccess['publish_access'] & 2);
+                                       $retVal = $wsAccess['_ACCESS'] === 'owner' || $this->checkWorkspace(0) && !($wsAccess['publish_access'] & Permission::PAGE_EDIT);
                                        // Either be an adminuser OR have access to online
                                        // workspace which is OK as well as long as publishing
                                        // access is not limited by workspace option.
@@ -1231,13 +1232,8 @@ class BackendUserAuthentication extends \TYPO3\CMS\Core\Authentication\AbstractU
 
        /**
         * Returns TRUE or FALSE, depending if an alert popup (a javascript confirmation) should be shown
-        * call like $GLOBALS['BE_USER']->jsConfirmation($BITMASK)
-        *
-        * 1 - typeChange
-        * 2 - copy/move/paste
-        * 4 - delete
-        * 8 - frontend editing
-        * 128 - other (not used yet)
+        * call like $GLOBALS['BE_USER']->jsConfirmation($BITMASK).
+        * See \TYPO3\CMS\Core\Type\Bitmask\JsConfirmation.
         *
         * @param int $bitmask Bitmask
         * @return bool TRUE if the confirmation should be shown
@@ -1434,11 +1430,11 @@ class BackendUserAuthentication extends \TYPO3\CMS\Core\Authentication\AbstractU
                                $this->includeHierarchy[] = $idList;
                                $this->TSdataArray[] = $this->addTScomment('Group "' . $row['title'] . '" [' . $row['uid'] . '] TSconfig field:') . $row['TSconfig'];
                                // Mount group database-mounts
-                               if (($this->user['options'] & 1) == 1) {
+                               if (($this->user['options'] & Permission::PAGE_SHOW) == 1) {
                                        $this->dataLists['webmount_list'] .= ',' . $row['db_mountpoints'];
                                }
                                // Mount group file-mounts
-                               if (($this->user['options'] & 2) == 2) {
+                               if (($this->user['options'] & Permission::PAGE_EDIT) == 2) {
                                        $this->dataLists['filemount_list'] .= ',' . $row['file_mountpoints'];
                                }
                                // The lists are made: groupMods, tables_select, tables_modify, pagetypes_select, non_exclude_fields, explicit_allowdeny, allowed_languages, custom_options
@@ -1649,7 +1645,7 @@ class BackendUserAuthentication extends \TYPO3\CMS\Core\Authentication\AbstractU
                        }
 
                        // Mount group home-dirs
-                       if ((is_array($this->user) && $this->user['options'] & 2) == 2 && $GLOBALS['TYPO3_CONF_VARS']['BE']['groupHomePath'] != '') {
+                       if ((is_array($this->user) && $this->user['options'] & Permission::PAGE_EDIT) == 2 && $GLOBALS['TYPO3_CONF_VARS']['BE']['groupHomePath'] != '') {
                                // If groupHomePath is set, we attempt to mount it
                                list($groupHomeStorageUid, $groupHomeFilter) = explode(':', $GLOBALS['TYPO3_CONF_VARS']['BE']['groupHomePath'], 2);
                                $groupHomeStorageUid = (int)$groupHomeStorageUid;
@@ -1987,7 +1983,7 @@ class BackendUserAuthentication extends \TYPO3\CMS\Core\Authentication\AbstractU
                        } else {
                                switch ((string)$wsRec['uid']) {
                                        case '0':
-                                               $retVal = $this->groupData['workspace_perms'] & 1
+                                               $retVal = $this->groupData['workspace_perms'] & Permission::PAGE_SHOW
                                                        ? array_merge($wsRec, array('_ACCESS' => 'online'))
                                                        : FALSE;
                                                break;
index 6fcc6b2..eb9bc4f 100644 (file)
@@ -25,6 +25,7 @@ use TYPO3\CMS\Core\Database\RelationHandler;
 use TYPO3\CMS\Core\Messaging\FlashMessage;
 use TYPO3\CMS\Core\Messaging\FlashMessageService;
 use TYPO3\CMS\Core\Resource\ResourceFactory;
+use TYPO3\CMS\Core\Type\Bitmask\Permission;
 use TYPO3\CMS\Core\Utility\ArrayUtility;
 use TYPO3\CMS\Core\Utility\File\BasicFileUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -5645,7 +5646,7 @@ class DataHandler {
         * @see doesRecordExist()
         */
        public function doesRecordExist_pageLookUp($id, $perms) {
-               return $this->databaseConnection->exec_SELECTquery('uid', 'pages', 'uid=' . (int)$id . $this->deleteClause('pages') . ($perms && !$this->admin ? ' AND ' . $this->BE_USER->getPagePermsClause($perms) : '') . (!$this->admin && $GLOBALS['TCA']['pages']['ctrl']['editlock'] && $perms & 2 + 4 + 16 ? ' AND ' . $GLOBALS['TCA']['pages']['ctrl']['editlock'] . '=0' : ''));
+               return $this->databaseConnection->exec_SELECTquery('uid', 'pages', 'uid=' . (int)$id . $this->deleteClause('pages') . ($perms && !$this->admin ? ' AND ' . $this->BE_USER->getPagePermsClause($perms) : '') . (!$this->admin && $GLOBALS['TCA']['pages']['ctrl']['editlock'] && $perms & Permission::PAGE_EDIT + Permission::PAGE_DELETE + Permission::CONTENT_EDIT ? ' AND ' . $GLOBALS['TCA']['pages']['ctrl']['editlock'] . '=0' : ''));
        }
 
        /**
index bdcd9af..0842f1f 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Core\FrontendEditing;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Type\Bitmask\Permission;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
 /**
@@ -483,7 +484,7 @@ class FrontendEditingController {
                                                $mayEdit = TRUE;
                                        }
                                } else {
-                                       $mayEdit = count($allow) && $perms & 16;
+                                       $mayEdit = count($allow) && $perms & Permission::CONTENT_EDIT;
                                }
                        }
                }
@@ -516,15 +517,15 @@ class FrontendEditingController {
                                        unset($allow['hide']);
                                        unset($allow['delete']);
                                }
-                               if (!($perms & 2)) {
+                               if (!($perms & Permission::PAGE_EDIT)) {
                                        unset($allow['edit']);
                                        unset($allow['move']);
                                        unset($allow['hide']);
                                }
-                               if (!($perms & 4)) {
+                               if (!($perms & Permission::PAGE_DELETE)) {
                                        unset($allow['delete']);
                                }
-                               if (!($perms & 8)) {
+                               if (!($perms & Permission::PAGE_NEW)) {
                                        unset($allow['new']);
                                }
                        }
diff --git a/typo3/sysext/core/Classes/Type/Bitmask/JsConfirmation.php b/typo3/sysext/core/Classes/Type/Bitmask/JsConfirmation.php
new file mode 100644 (file)
index 0000000..4bd9fab
--- /dev/null
@@ -0,0 +1,46 @@
+<?php
+namespace TYPO3\CMS\Core\Type\Bitmask;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+/**
+ * A class providing constants for bitwise operations on javascript confirmation popups
+ */
+class JsConfirmation extends \TYPO3\CMS\Core\Type\Enumeration {
+
+       /**
+        * @var int
+        */
+       const TYPE_CHANGE = 1;
+
+       /**
+        * @var int
+        */
+       const COPY_MOVE_PASTE = 2;
+
+       /**
+        * @var int
+        */
+       const DELETE = 4;
+
+       /**
+        * @var int
+        */
+       const FE_EDIT = 8;
+
+       /**
+        * @var int
+        */
+       const OTHER = 128;
+}
diff --git a/typo3/sysext/core/Classes/Type/Bitmask/Permission.php b/typo3/sysext/core/Classes/Type/Bitmask/Permission.php
new file mode 100644 (file)
index 0000000..242b15a
--- /dev/null
@@ -0,0 +1,56 @@
+<?php
+namespace TYPO3\CMS\Core\Type\Bitmask;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+/**
+ * A class providing constants for bitwise operations on page access check
+ */
+class Permission extends \TYPO3\CMS\Core\Type\Enumeration {
+
+       /**
+        * @var int
+        */
+       const NOTHING = 0;
+
+       /**
+        * @var int
+        */
+       const PAGE_SHOW = 1;
+
+       /**
+        * @var int
+        */
+       const PAGE_EDIT = 2;
+
+       /**
+        * @var int
+        */
+       const PAGE_DELETE = 4;
+
+       /**
+        * @var int
+        */
+       const PAGE_NEW = 8;
+
+       /**
+        * @var int
+        */
+       const CONTENT_EDIT = 16;
+
+       /**
+        * @var int
+        */
+       const ALL = 31;
+}
index e631e9a..1be54e7 100644 (file)
@@ -18,6 +18,7 @@ use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Backend\Utility\IconUtility;
 use TYPO3\CMS\Backend\FrontendBackendUserAuthentication;
 use TYPO3\CMS\Core\Database\DatabaseConnection;
+use TYPO3\CMS\Core\Type\Bitmask\JsConfirmation;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\MathUtility;
 use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
@@ -252,7 +253,7 @@ class FrontendEditPanel {
                                $out = $this->editPanelLinkWrap_doWrap($string, $adminURL . 'alt_doc.php?edit[' . $rParts[0] . '][' . $nPid . ']=new&noView=' . $nV, $currentRecord);
                        }
                } else {
-                       if ($confirm && $this->backendUser->jsConfirmation(8)) {
+                       if ($confirm && $this->backendUser->jsConfirmation(JsConfirmation::FE_EDIT)) {
                                // Gets htmlspecialchared later
                                $cf1 = 'if (confirm(' . GeneralUtility::quoteJSvalue($confirm, TRUE) . ')) {';
                                $cf2 = '}';
index c0180a8..c6034b9 100644 (file)
@@ -27,6 +27,7 @@ use TYPO3\CMS\Core\Resource\InaccessibleFolder;
 use TYPO3\CMS\Core\Resource\ProcessedFile;
 use TYPO3\CMS\Core\Resource\ResourceFactory;
 use TYPO3\CMS\Core\Resource\Utility\ListUtility;
+use TYPO3\CMS\Core\Type\Bitmask\JsConfirmation;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Resource\FolderInterface;
 
@@ -906,7 +907,7 @@ class FileList extends AbstractRecordList {
                                $referenceCountText = BackendUtility::referenceCount('sys_file', $fileOrFolderObject->getUid(), ' (There are %s reference(s) to this file!)');
                        }
 
-                       if ($this->getBackendUser()->jsConfirmation(4)) {
+                       if ($this->getBackendUser()->jsConfirmation(JsConfirmation::DELETE)) {
                                $confirmationCheck = 'confirm(' . GeneralUtility::quoteJSvalue(sprintf($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:mess.delete'), $fileOrFolderObject->getName()) . $referenceCountText) . ')';
                        } else {
                                $confirmationCheck = '1 == 1';
index 3230d77..69c0a7a 100644 (file)
@@ -16,6 +16,7 @@ namespace TYPO3\CMS\Frontend\View;
 
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Backend\Utility\IconUtility;
+use TYPO3\CMS\Core\Type\Bitmask\Permission;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
 /**
@@ -604,7 +605,7 @@ class AdminPanelView {
 
                $icon = IconUtility::getSpriteIcon('actions-document-history-open', array('title' => $this->extGetLL('edit_recordHistory', FALSE)));
                $toolBar = '<a href="' . htmlspecialchars(TYPO3_mainDir . BackendUtility::getModuleUrl('record_history', array('element' => 'pages:' . $id, 'returnUrl' => $returnUrl))) . '#latest">' . $icon . '</a>';
-               if ($perms & 16 && $langAllowed) {
+               if ($perms & Permission::CONTENT_EDIT && $langAllowed) {
                        $params = '';
                        if ($GLOBALS['TSFE']->sys_language_uid) {
                                $params = '&sys_language_uid=' . $GLOBALS['TSFE']->sys_language_uid;
@@ -612,15 +613,15 @@ class AdminPanelView {
                        $icon = IconUtility::getSpriteIcon('actions-document-new', array('title' => $this->extGetLL('edit_newContentElement', FALSE)));
                        $toolBar .= '<a href="' . htmlspecialchars($newContentWizScriptPath . 'id=' . $id . $params . '&returnUrl=' . rawurlencode($returnUrl)) . '">' . $icon . '</a>';
                }
-               if ($perms & 2) {
+               if ($perms & Permission::PAGE_EDIT) {
                        $icon = IconUtility::getSpriteIcon('actions-document-move', array('title' => $this->extGetLL('edit_move_page', FALSE)));
                        $toolBar .= '<a href="' . htmlspecialchars(TYPO3_mainDir . BackendUtility::getModuleUrl('move_element', ['table' => 'pages', 'uid' => $id, 'returnUrl' => $returnUrl])) . '">' . $icon . '</a>';
                }
-               if ($perms & 8) {
+               if ($perms & Permission::PAGE_NEW) {
                        $icon = IconUtility::getSpriteIcon('actions-page-new', array('title' => $this->extGetLL('edit_newPage', FALSE)));
                        $toolBar .= '<a href="' . htmlspecialchars(TYPO3_mainDir . BackendUtility::getModuleUrl('db_new', ['id' => $id, 'pagesOnly' => 1, 'returnUrl' => $returnUrl])) . '">' . $icon . '</a>';
                }
-               if ($perms & 2) {
+               if ($perms & Permission::PAGE_EDIT) {
                        $params = '&edit[pages][' . $id . ']=edit';
                        $icon = IconUtility::getSpriteIcon('actions-document-open', array('title' => $this->extGetLL('edit_editPageProperties', FALSE)));
                        $toolBar .= '<a href="' . htmlspecialchars(TYPO3_mainDir . 'alt_doc.php?' . $params . '&noView=1&returnUrl=' . rawurlencode($returnUrl)) . '">' . $icon . '</a>';
index 0905216..ced8fb7 100644 (file)
@@ -19,6 +19,7 @@ use TYPO3\CMS\Backend\Tree\View\PageTreeView;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
 use TYPO3\CMS\Core\Database\DatabaseConnection;
+use TYPO3\CMS\Core\Type\Bitmask\Permission;
 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\HttpUtility;
@@ -796,9 +797,9 @@ class AbstractDatabaseRecordList extends AbstractRecordList {
                                // If the listed table is 'pages' we have to request the permission settings for each page:
                                if ($table == 'pages') {
                                        $localCalcPerms = $this->getBackendUserAuthentication()->calcPerms(BackendUtility::getRecord('pages', $row['uid']));
-                                       $permsEdit = $localCalcPerms & 2;
+                                       $permsEdit = $localCalcPerms & Permission::PAGE_EDIT;
                                } else {
-                                       $permsEdit = $this->calcPerms & 16;
+                                       $permsEdit = $this->calcPerms & Permission::CONTENT_EDIT;
                                }
                                // "Edit" link: ( Only if permissions to edit the page-record of the content of the parent page ($this->id)
                                if ($permsEdit) {
index e69a839..19002b6 100644 (file)
@@ -20,6 +20,7 @@ use TYPO3\CMS\Backend\Template\DocumentTemplate;
 use TYPO3\CMS\Core\Database\DatabaseConnection;
 use TYPO3\CMS\Core\Messaging\FlashMessage;
 use TYPO3\CMS\Core\Messaging\FlashMessageService;
+use TYPO3\CMS\Core\Type\Bitmask\Permission;
 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
@@ -248,7 +249,7 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
                        }
                        // If edit permissions are set, see
                        // \TYPO3\CMS\Core\Authentication\BackendUserAuthentication
-                       if ($localCalcPerms & 2 && !empty($this->id)) {
+                       if ($localCalcPerms & Permission::PAGE_EDIT && !empty($this->id)) {
                                // Edit
                                $params = '&edit[pages][' . $this->pageRow['uid'] . ']=edit';
                                $onClick = htmlspecialchars(BackendUtility::editOnClick($params, $this->backPath, -1));
@@ -257,7 +258,7 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
                                        . IconUtility::getSpriteIcon('actions-page-open') . '</a>';
                        }
                        // Paste
-                       if ($localCalcPerms & 8 || $localCalcPerms & 16) {
+                       if ($localCalcPerms & Permission::PAGE_NEW || $localCalcPerms & Permission::CONTENT_EDIT) {
                                $elFromTable = $this->clipObj->elFromTable('');
                                if (count($elFromTable)) {
                                        $onClick = htmlspecialchars(('return ' . $this->clipObj->confirmMsg('pages', $this->pageRow, 'into', $elFromTable)));
@@ -1187,7 +1188,7 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
                        $localCalcPerms = $this->getBackendUserAuthentication()->calcPerms(BackendUtility::getRecord('pages', $row['uid']));
                }
                // This expresses the edit permissions for this particular element:
-               $permsEdit = $table === 'pages' && $localCalcPerms & 2 || $table !== 'pages' && $this->calcPerms & 16;
+               $permsEdit = $table === 'pages' && $localCalcPerms & Permission::PAGE_EDIT || $table !== 'pages' && $this->calcPerms & Permission::CONTENT_EDIT;
                // "Show" link (only pages and tt_content elements)
                if ($table == 'pages' || $table == 'tt_content') {
                        $viewAction = '<a class="btn btn-default" href="#" onclick="'
@@ -1261,7 +1262,7 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
                        // "New record after" link (ONLY if the records in the table are sorted by a "sortby"-row
                        // or if default values can depend on previous record):
                        if ($GLOBALS['TCA'][$table]['ctrl']['sortby'] || $GLOBALS['TCA'][$table]['ctrl']['useColumnsForDefaultValues']) {
-                               if ($table !== 'pages' && $this->calcPerms & 16 || $table === 'pages' && $this->calcPerms & 8) {
+                               if ($table !== 'pages' && $this->calcPerms & Permission::CONTENT_EDIT || $table === 'pages' && $this->calcPerms & Permission::PAGE_NEW) {
                                        if ($this->showNewRecLink($table)) {
                                                $params = '&edit[' . $table . '][' . -($row['_MOVE_PLH'] ? $row['_MOVE_PLH_uid'] : $row['uid']) . ']=new';
                                                $newAction = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars(BackendUtility::editOnClick($params, $this->backPath, -1))
@@ -1324,7 +1325,7 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
                                $this->addActionToCellGroup($cells, $hideAction, 'hide');
                        }
                        // "Delete" link:
-                       if ($table === 'pages' && $localCalcPerms & 4 || $table !== 'pages' && $this->calcPerms & 16) {
+                       if ($table === 'pages' && $localCalcPerms & Permission::PAGE_DELETE || $table !== 'pages' && $this->calcPerms & Permission::CONTENT_EDIT) {
                                // Check if the record version is in "deleted" state, because that will switch the action to "restore"
                                if ($this->getBackendUserAuthentication()->workspace > 0 && isset($row['t3ver_state']) && (int)$row['t3ver_state'] === 2) {
                                        $actionName = 'restore';
@@ -1361,7 +1362,7 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
                        // "Levels" links: Moving pages into new levels...
                        if ($permsEdit && $table == 'pages' && !$this->searchLevels) {
                                // Up (Paste as the page right after the current parent page)
-                               if ($this->calcPerms & 8) {
+                               if ($this->calcPerms & Permission::PAGE_NEW) {
                                        $params = '&cmd[' . $table . '][' . $row['uid'] . '][move]=' . -$this->id;
                                        $moveLeftAction = '<a class="btn btn-default" href="#" onclick="'
                                                . htmlspecialchars('return jumpToUrl(\'' . $module->doc->issueCommand($params, -1) . '\');')
@@ -1372,7 +1373,7 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
                                // Down (Paste as subpage to the page right above)
                                if ($this->currentTable['prevUid'][$row['uid']]) {
                                        $localCalcPerms = $this->getBackendUserAuthentication()->calcPerms(BackendUtility::getRecord('pages', $this->currentTable['prevUid'][$row['uid']]));
-                                       if ($localCalcPerms & 8) {
+                                       if ($localCalcPerms & Permission::PAGE_NEW) {
                                                $params = '&cmd[' . $table . '][' . $row['uid'] . '][move]=' . $this->currentTable['prevUid'][$row['uid']];
                                                $moveRightAction = '<a class="btn btn-default" href="#" onclick="'
                                                        . htmlspecialchars('return jumpToUrl(\'' . $module->doc->issueCommand($params, -1) . '\');')
index 49b1462..0b96c3c 100644 (file)
@@ -15,6 +15,7 @@ namespace TYPO3\CMS\Recycler\Utility;
  */
 
 use TYPO3\CMS\Backend\Utility\BackendUtility;
+use TYPO3\CMS\Core\Type\Bitmask\Permission;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
 /**
@@ -49,11 +50,11 @@ class RecyclerUtility {
                        if ($table === 'pages') {
                                // If pages:
                                $calculatedPermissions = $backendUser->calcPerms($calcPRec);
-                               $hasAccess = $calculatedPermissions & 2 ? TRUE : FALSE;
+                               $hasAccess = $calculatedPermissions & Permission::PAGE_EDIT ? TRUE : FALSE;
                        } else {
                                $calculatedPermissions = $backendUser->calcPerms(BackendUtility::getRecord('pages', $calcPRec['pid']));
                                // Fetching pid-record first.
-                               $hasAccess = $calculatedPermissions & 16 ? TRUE : FALSE;
+                               $hasAccess = $calculatedPermissions & Permission::CONTENT_EDIT ? TRUE : FALSE;
                        }
                        // Check internals regarding access:
                        if ($hasAccess) {