/**
  * @param array|string $allowed
  * @param array|string $disallowed
  * @param array|string $values
  * @test
  * @dataProvider invalidInlineChildrenFilterParametersDataProvider
  */
 public function areInlineChildrenFilteredWithInvalidParameters($allowed, $disallowed, $values)
 {
     $this->parameters = array('allowedFileExtensions' => $allowed, 'disallowedFileExtensions' => $disallowed, 'values' => $values);
     $this->tceMainMock->expects($this->never())->method('deleteAction');
     $this->fileFactoryMock->expects($this->never())->method('getFileReferenceObject');
     $this->filter->filterInlineChildren($this->parameters, $this->tceMainMock);
 }
	/**
	 * Create an (cached) instance of t3lib_TCEmain
	 *
	 * @return t3lib_TCEmain
	 */
	protected function _tce() {
		if( $this->_tce === null ) {
			$this->_tce = t3lib_div::makeInstance ('t3lib_TCEmain');
			$this->_tce->start();
		}

		return $this->_tce;
	}
    /**
     * Tests whether the 'checkModifyAccessList' hook modifies the $accessAllowed variable.
     * @test
     * @see t3lib_TCEmain::checkModifyAccessList()
     */
    public function doesCheckModifyAccessListHookModifyAccessAllowed()
    {
        $hookClass = uniqid('tx_coretest');
        eval('
			class ' . $hookClass . ' implements t3lib_TCEmain_checkModifyAccessListHook {
				public function checkModifyAccessList(&$accessAllowed, $table, t3lib_TCEmain $parent) { $accessAllowed = true; }
			}
		');
        $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['checkModifyAccessList'][] = $hookClass;
        $this->assertTrue($this->fixture->checkModifyAccessList('tt_content'));
    }
 /**
  * Creates a move placeholder for workspaces.
  * USE ONLY INTERNALLY
  * Moving placeholder: Can be done because the system sees it as a placeholder for NEW elements like t3ver_state=1
  * Moving original: Will either create the placeholder if it doesn't exist or move existing placeholder in workspace.
  *
  * @param string $table Table name to move
  * @param integer $uid Record uid to move (online record)
  * @param integer $destPid Position to move to: $destPid: >=0 then it points to a page-id on which to insert the record (as the first element). <0 then it points to a uid from its own table after which to insert it (works if
  * @param integer $wsUid UID of offline version of online record
  * @param t3lib_TCEmain $tcemainObj TCEmain object
  * @return void
  * @see moveRecord()
  */
 protected function moveRecord_wsPlaceholders($table, $uid, $destPid, $wsUid, t3lib_TCEmain $tcemainObj)
 {
     global $TCA;
     if ($plh = t3lib_BEfunc::getMovePlaceholder($table, $uid, 'uid')) {
         // If already a placeholder exists, move it:
         $tcemainObj->moveRecord_raw($table, $plh['uid'], $destPid);
     } else {
         // First, we create a placeholder record in the Live workspace that
         // represents the position to where the record is eventually moved to.
         $newVersion_placeholderFieldArray = array();
         if ($TCA[$table]['ctrl']['crdate']) {
             $newVersion_placeholderFieldArray[$TCA[$table]['ctrl']['crdate']] = $GLOBALS['EXEC_TIME'];
         }
         if ($TCA[$table]['ctrl']['cruser_id']) {
             $newVersion_placeholderFieldArray[$TCA[$table]['ctrl']['cruser_id']] = $tcemainObj->userid;
         }
         if ($TCA[$table]['ctrl']['tstamp']) {
             $newVersion_placeholderFieldArray[$TCA[$table]['ctrl']['tstamp']] = $GLOBALS['EXEC_TIME'];
         }
         if ($table == 'pages') {
             // Copy page access settings from original page to placeholder
             $perms_clause = $tcemainObj->BE_USER->getPagePermsClause(1);
             $access = t3lib_BEfunc::readPageAccess($uid, $perms_clause);
             $newVersion_placeholderFieldArray['perms_userid'] = $access['perms_userid'];
             $newVersion_placeholderFieldArray['perms_groupid'] = $access['perms_groupid'];
             $newVersion_placeholderFieldArray['perms_user'] = $access['perms_user'];
             $newVersion_placeholderFieldArray['perms_group'] = $access['perms_group'];
             $newVersion_placeholderFieldArray['perms_everybody'] = $access['perms_everybody'];
         }
         $newVersion_placeholderFieldArray['t3ver_label'] = 'MOVE-TO PLACEHOLDER for #' . $uid;
         $newVersion_placeholderFieldArray['t3ver_move_id'] = $uid;
         // Setting placeholder state value for temporary record
         $newVersion_placeholderFieldArray['t3ver_state'] = 3;
         // Setting workspace - only so display of place holders can filter out those from other workspaces.
         $newVersion_placeholderFieldArray['t3ver_wsid'] = $tcemainObj->BE_USER->workspace;
         $newVersion_placeholderFieldArray[$TCA[$table]['ctrl']['label']] = '[MOVE-TO PLACEHOLDER for #' . $uid . ', WS#' . $tcemainObj->BE_USER->workspace . ']';
         // moving localized records requires to keep localization-settings for the placeholder too
         if (array_key_exists('languageField', $GLOBALS['TCA'][$table]['ctrl']) && array_key_exists('transOrigPointerField', $GLOBALS['TCA'][$table]['ctrl'])) {
             $l10nParentRec = t3lib_BEfunc::getRecord($table, $uid);
             $newVersion_placeholderFieldArray[$GLOBALS['TCA'][$table]['ctrl']['languageField']] = $l10nParentRec[$GLOBALS['TCA'][$table]['ctrl']['languageField']];
             $newVersion_placeholderFieldArray[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] = $l10nParentRec[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']];
             unset($l10nParentRec);
         }
         // Initially, create at root level.
         $newVersion_placeholderFieldArray['pid'] = 0;
         $id = 'NEW_MOVE_PLH';
         // Saving placeholder as 'original'
         $tcemainObj->insertDB($table, $id, $newVersion_placeholderFieldArray, FALSE);
         // Move the new placeholder from temporary root-level to location:
         $tcemainObj->moveRecord_raw($table, $tcemainObj->substNEWwithIDs[$id], $destPid);
         // Move the workspace-version of the original to be the version of the move-to-placeholder:
         // Setting placeholder state value for version (so it can know it is currently a new version...)
         $updateFields = array('t3ver_state' => 4);
         $GLOBALS['TYPO3_DB']->exec_UPDATEquery($table, 'uid=' . intval($wsUid), $updateFields);
     }
     // Check for the localizations of that element and move them as well
     $tcemainObj->moveL10nOverlayRecords($table, $uid, $destPid);
 }
Beispiel #5
0
 /**
  * Redirecting the user after the processing has been done.
  * Might also display error messages directly, if any.
  *
  * @return	void
  */
 function finish()
 {
     // Prints errors, if...
     if ($this->prErr) {
         $this->tce->printLogErrorMessages($this->redirect);
     }
     if ($this->redirect && !$this->tce->debug) {
         t3lib_utility_Http::redirect($this->redirect);
     }
 }
 /**
  * Hooks into TCE Main and watches all record creations and updates. If it
  * detects that the new/updated record belongs to a table configured for
  * indexing through Solr, we add the record to the index queue.
  *
  * @param string $status Status of the current operation, 'new' or 'update'
  * @param string $table The table the record belongs to
  * @param mixed $uid The record's uid, [integer] or [string] (like 'NEW...')
  * @param array $fields The record's data
  * @param t3lib_TCEmain $tceMain TYPO3 Core Engine parent object
  * @return void
  */
 public function processDatamap_afterDatabaseOperations($status, $table, $uid, array $fields, t3lib_TCEmain $tceMain)
 {
     $recordTable = $table;
     $recordUid = $uid;
     $recordPageId = 0;
     if ($status == 'new') {
         $recordUid = $tceMain->substNEWwithIDs[$recordUid];
     }
     if (Tx_Solr_Util::isDraftRecord($table, $recordUid)) {
         // skip workspaces: index only LIVE workspace
         return;
     }
     if ($status == 'update' && !isset($fields['pid'])) {
         $recordPageId = $tceMain->getPID($recordTable, $recordUid);
     } else {
         $recordPageId = $fields['pid'];
     }
     // when a content element changes we need to updated the page instead
     if ($recordTable == 'tt_content') {
         $recordTable = 'pages';
         $recordUid = $recordPageId;
     }
     $this->solrConfiguration = Tx_Solr_Util::getSolrConfigurationFromPageId($recordPageId);
     $monitoredTables = $this->getMonitoredTables($recordPageId);
     if (in_array($recordTable, $monitoredTables, TRUE)) {
         $record = $this->getRecord($recordTable, $recordUid);
         if (!empty($record)) {
             // only update/insert the item if we actually found a record
             if ($this->isLocalizedRecord($recordTable, $record)) {
                 // if it's a localization overlay, update the original record instead
                 $recordUid = $record[$GLOBALS['TCA'][$recordTable]['ctrl']['transOrigPointerField']];
                 if ($recordTable == 'pages_language_overlay') {
                     $recordTable = 'pages';
                 }
             }
             $this->indexQueue->updateItem($recordTable, $recordUid);
             if ($recordTable == 'pages') {
                 $this->updateCanonicalPages($recordUid);
                 $this->updateMountPages($recordUid);
             }
         } else {
             // TODO move this part to the garbage collector
             // check if the item should be removed from the index because it no longer matches the conditions
             if ($this->indexQueue->containsItem($recordTable, $recordUid)) {
                 $this->removeFromIndexAndQueue($recordTable, $recordUid);
             }
         }
     }
 }
 /**
  * This method is used to extend the tce_main process_cmdmap function. It provides the functionallity to
  * disallow users to move, cut or copy any element which has an overlay. Moving and Cutting of elements
  * with overlays is dangerous because the extisting overlays may also need to be moved.
  *
  *
  */
 function process_cmdmap()
 {
     if (t3lib_extMgm::isLoaded('languagevisibility') && $this->isCutCopyAndMoveObservationEnabled()) {
         require_once t3lib_extMgm::extPath("languagevisibility") . 'patch/lib/class.tx_languagevisibility_commandMap.php';
         //user has no rights to cut move copy or delete, therefore the commands need to be filtered
         $command_map = t3lib_div::makeInstance('tx_languagevisibility_commandMap');
         $command_map->setMap($this->cmdmap);
         $command_elements = $command_map->getElementsByCommands(array('cut', 'move', 'copy', 'delete'));
         if (is_array($command_elements)) {
             foreach ($command_elements as $command_element) {
                 try {
                     //get row
                     $table = $command_element['table'];
                     $uid = $command_element['uid'];
                     $row = tx_languagevisibility_daocommon::getRecord($uid, $table);
                     $command = $command_element['cmd'];
                     if (tx_languagevisibility_beservices::isOverlayRecord($row, $table)) {
                         //current element is an overlay -> restrict cut copy and move in general -> filter the command map
                         if (($command == 'move' || $command == 'cut' || $command == 'copy') && $this->isCutCopyAndMoveRestrictedForOverlays()) {
                             $this->newlog('The command ' . $command . ' can not be applied on overlays', 1);
                             //overlay records should no be move,copy or cutable but it should be possible to delete them
                             //therefore we remove all elements which have the comment cut, copy or move
                             $command_map->removeElement($command_element);
                         }
                     } else {
                         //current element is no overlay
                         if (!tx_languagevisibility_beservices::canCurrrentUserCutCopyMoveDelete()) {
                             //if the record has any translation disallow move, cut, copy and delete
                             $elementObj = tx_languagevisibility_beservices::getElement($uid, $table);
                             if ($elementObj->hasAnyTranslationInAnyWorkspace()) {
                                 $command_map->removeElement($command_element);
                                 $this->newlog('You have no rights to apply the command ' . $command . ' on elements with overlays', 1);
                             }
                         }
                     }
                 } catch (Exception $e) {
                     //element not supported by language visibility
                 }
             }
         }
         //overwrite the internal map an process the base tce_main method
         $this->cmdmap = $command_map->getMap();
     }
     //process parent method to use basic functionallity
     parent::process_cmdmap();
 }