/**
  * @test
  */
 public function addDataWithInlineTypeAndModifyRightsWillAddChildren()
 {
     $input = ['processedTca' => ['columns' => ['aField' => ['config' => ['type' => 'inline', 'foreign_table' => 'aForeignTableName']]]]];
     $this->beUserProphecy->check('tables_modify', $input['processedTca']['columns']['aField']['config']['foreign_table'])->shouldBeCalled()->willReturn(true);
     $expected = $this->defaultConfig;
     $expected['processedTca']['columns']['aField']['children'] = [];
     $this->assertEquals($expected, $this->subject->addData($input));
 }
示例#2
0
 /**
  * Returns TRUE if the internal BE_USER has access to the module $name with $MCONF (based on security level set for that module)
  *
  * @param string $name Module name
  * @param array $MCONF MCONF array (module configuration array) from the modules conf.php file (contains settings about what access level the module has)
  * @return boolean TRUE if access is granted for $this->BE_USER
  * @todo Define visibility
  */
 public function checkModAccess($name, $MCONF)
 {
     if ($MCONF['access']) {
         $access = strtolower($MCONF['access']);
         // Checking if admin-access is required
         // If admin-permissions is required then return TRUE if user is admin
         if (strstr($access, 'admin')) {
             if ($this->BE_USER->isAdmin()) {
                 return TRUE;
             }
         }
         // This will add modules to the select-lists of user and groups
         if (strstr($access, 'user')) {
             $this->modListUser[] = $name;
         }
         if (strstr($access, 'group')) {
             $this->modListGroup[] = $name;
         }
         // This checks if a user is permitted to access the module
         if ($this->BE_USER->isAdmin() || $this->BE_USER->check('modules', $name)) {
             return TRUE;
         }
     } else {
         return TRUE;
     }
 }
 /**
  * @test
  */
 public function addDataThrowsExceptionForNewRecordsOnRootLevelWithoutAdminPermissions()
 {
     $input = ['tableName' => 'pages', 'command' => 'new', 'vanillaUid' => 123, 'parentPageRow' => null];
     $this->beUserProphecy->isAdmin()->willReturn(false);
     $this->beUserProphecy->check('tables_modify', $input['tableName'])->willReturn(true);
     $this->setExpectedException(\RuntimeException::class, $this->anything(), 1437745221);
     $this->subject->addData($input);
 }
示例#4
0
 /**
  * Make 1st level clickmenu:
  *
  * @param string $combinedIdentifier The combined identifier
  * @return string HTML content
  * @see \TYPO3\CMS\Core\Resource\ResourceFactory::retrieveFileOrFolderObject()
  */
 public function printFileClickMenu($combinedIdentifier)
 {
     $identifier = '';
     $menuItems = array();
     $combinedIdentifier = rawurldecode($combinedIdentifier);
     $fileObject = ResourceFactory::getInstance()->retrieveFileOrFolderObject($combinedIdentifier);
     if ($fileObject) {
         $folder = false;
         $isStorageRoot = false;
         $isOnline = true;
         $userMayViewStorage = false;
         $userMayEditStorage = false;
         $identifier = $fileObject->getCombinedIdentifier();
         if ($fileObject instanceof Folder) {
             $folder = true;
             if ($fileObject->getIdentifier() === $fileObject->getStorage()->getRootLevelFolder()->getIdentifier()) {
                 $isStorageRoot = true;
                 if ($this->backendUser->check('tables_select', 'sys_file_storage')) {
                     $userMayViewStorage = true;
                 }
                 if ($this->backendUser->check('tables_modify', 'sys_file_storage')) {
                     $userMayEditStorage = true;
                 }
             }
             if (!$fileObject->getStorage()->isOnline()) {
                 $isOnline = false;
             }
         }
         // Hide
         if (!in_array('hide', $this->disabledItems, true) && $isStorageRoot && $userMayEditStorage) {
             $record = BackendUtility::getRecord('sys_file_storage', $fileObject->getStorage()->getUid());
             $menuItems['hide'] = $this->DB_changeFlag('sys_file_storage', $record, 'is_online', $this->label($record['is_online'] ? 'offline' : 'online'));
         }
         // Edit
         if (!in_array('edit', $this->disabledItems, true) && $fileObject->checkActionPermission('write')) {
             if (!$folder && !$isStorageRoot && $fileObject->isIndexed() && $this->backendUser->check('tables_modify', 'sys_file_metadata')) {
                 $metaData = $fileObject->_getMetaData();
                 $menuItems['edit2'] = $this->DB_edit('sys_file_metadata', $metaData['uid']);
             }
             if (!$folder && GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['SYS']['textfile_ext'], $fileObject->getExtension()) && $fileObject->checkActionPermission('write')) {
                 $menuItems['edit'] = $this->FILE_launch($identifier, 'file_edit', 'editcontent', 'actions-page-open');
             } elseif ($isStorageRoot && $userMayEditStorage) {
                 $menuItems['edit'] = $this->DB_edit('sys_file_storage', $fileObject->getStorage()->getUid());
             }
         }
         // Rename
         if (!in_array('rename', $this->disabledItems, true) && !$isStorageRoot && $fileObject->checkActionPermission('rename')) {
             $menuItems['rename'] = $this->FILE_launch($identifier, 'file_rename', 'rename', 'actions-edit-rename');
         }
         // Upload
         if (!in_array('upload', $this->disabledItems, true) && $folder && $isOnline && $fileObject->checkActionPermission('write')) {
             $menuItems['upload'] = $this->FILE_launch($identifier, 'file_upload', 'upload', 'actions-edit-upload');
         }
         // New
         if (!in_array('new', $this->disabledItems, true) && $folder && $isOnline && $fileObject->checkActionPermission('write')) {
             $menuItems['new'] = $this->FILE_launch($identifier, 'file_newfolder', 'new', 'actions-document-new');
         }
         // Info
         if (!in_array('info', $this->disabledItems, true) && $fileObject->checkActionPermission('read')) {
             if ($isStorageRoot && $userMayViewStorage) {
                 $menuItems['info'] = $this->DB_info('sys_file_storage', $fileObject->getStorage()->getUid());
             } elseif (!$folder) {
                 $menuItems['info'] = $this->fileInfo($identifier);
             }
         }
         $menuItems[] = 'spacer';
         // Copy:
         if (!in_array('copy', $this->disabledItems, true) && !$isStorageRoot && $fileObject->checkActionPermission('read')) {
             $menuItems['copy'] = $this->FILE_copycut($identifier, 'copy');
         }
         // Cut:
         if (!in_array('cut', $this->disabledItems, true) && !$isStorageRoot && $fileObject->checkActionPermission('move')) {
             $menuItems['cut'] = $this->FILE_copycut($identifier, 'cut');
         }
         // Paste:
         $elFromAllTables = count($this->clipObj->elFromTable('_FILE'));
         if (!in_array('paste', $this->disabledItems, true) && $elFromAllTables && $folder && $fileObject->checkActionPermission('write')) {
             $elArr = $this->clipObj->elFromTable('_FILE');
             $selItem = reset($elArr);
             $clickedFileOrFolder = ResourceFactory::getInstance()->retrieveFileOrFolderObject($combinedIdentifier);
             $fileOrFolderInClipBoard = ResourceFactory::getInstance()->retrieveFileOrFolderObject($selItem);
             $elInfo = array($fileOrFolderInClipBoard->getName(), $clickedFileOrFolder->getName(), $this->clipObj->currentMode());
             if (!$fileOrFolderInClipBoard instanceof Folder || !$fileOrFolderInClipBoard->getStorage()->isWithinFolder($fileOrFolderInClipBoard, $clickedFileOrFolder)) {
                 $menuItems['pasteinto'] = $this->FILE_paste($identifier, $selItem, $elInfo);
             }
         }
         $menuItems[] = 'spacer';
         // Delete:
         if (!in_array('delete', $this->disabledItems, true) && $fileObject->checkActionPermission('delete')) {
             if ($isStorageRoot && $userMayEditStorage) {
                 $elInfo = array(GeneralUtility::fixed_lgd_cs($fileObject->getStorage()->getName(), $this->backendUser->uc['titleLen']));
                 $menuItems['delete'] = $this->DB_delete('sys_file_storage', $fileObject->getStorage()->getUid(), $elInfo);
             } elseif (!$isStorageRoot) {
                 $menuItems['delete'] = $this->FILE_delete($identifier);
             }
         }
     }
     // Adding external elements to the menuItems array
     $menuItems = $this->processingByExtClassArray($menuItems, $identifier, 0);
     // Processing by external functions?
     $menuItems = $this->externalProcessingOfFileMenuItems($menuItems);
     // Return the printed elements:
     return $this->printItems($menuItems);
 }