/** * Post-process the matcher object to respect the file storages. * * @param Matcher $matcher * @param string $dataType * @return void */ public function addFilePermissionsForFileStorages(Matcher $matcher, $dataType) { if ($dataType === 'sys_file' && $this->isPermissionNecessary()) { if ($this->isFolderConsidered()) { $folder = $this->getMediaModule()->getCurrentFolder(); if ($this->getMediaModule()->hasRecursiveSelection()) { // Only add like condition if needed. if ($folder->getStorage()->getRootLevelFolder() !== $folder) { $matcher->like('identifier', $folder->getIdentifier() . '%', $automaticallyAddWildCard = FALSE); } } else { // Browse only currently $files = $this->getFileUids($folder); $matcher->in('uid', $files); } $matcher->equals('storage', $folder->getStorage()->getUid()); } else { $storage = $this->getMediaModule()->getCurrentStorage(); // Set the storage identifier only if the storage is on-line. $identifier = -1; if ($storage->isOnline()) { $identifier = $storage->getUid(); } if ($this->getModuleLoader()->hasPlugin() && !$this->getCurrentBackendUser()->isAdmin()) { $fileMounts = $this->getCurrentBackendUser()->getFileMountRecords(); $collectedFiles = array(); foreach ($fileMounts as $fileMount) { $combinedIdentifier = $fileMount['base'] . ':' . $fileMount['path']; $folder = ResourceFactory::getInstance()->getFolderObjectFromCombinedIdentifier($combinedIdentifier); $files = $this->getFileUids($folder); $collectedFiles = array_merge($collectedFiles, $files); } $matcher->in('uid', $collectedFiles); } $matcher->equals('storage', $identifier); } } }
/** * Apply criteria from categories. * * @param Matcher $matcher * @return Matcher $matcher */ protected function applyCriteriaFromAdditionalConstraints(Matcher $matcher) { if (!empty($this->settings['additionalEquals'])) { $constraints = GeneralUtility::trimExplode(',', $this->settings['additionalEquals'], TRUE); foreach ($constraints as $constraint) { if (preg_match('/.+=.+/isU', $constraint, $matches)) { $constraintParts = GeneralUtility::trimExplode('=', $constraint, TRUE); if (count($constraintParts) === 2) { $matcher->equals(trim($constraintParts[0]), trim($constraintParts[1])); } } elseif (preg_match('/.+like.+/isU', $constraint, $matches)) { $constraintParts = GeneralUtility::trimExplode('like', $constraint, TRUE); if (count($constraintParts) === 2) { $matcher->like(trim($constraintParts[0]), trim($constraintParts[1])); } } } } return $matcher; }
/** * Apply criteria specific to jQuery plugin Datatable. * * @param Matcher $matcher * @param array $matches * @return Matcher $matcher */ protected function applyCriteriaFromMatchesArgument(Matcher $matcher, $matches) { foreach ($matches as $fieldNameAndPath => $value) { // CSV values should be considered as "in" operator in Query, otherwise "equals". $explodedValues = GeneralUtility::trimExplode(',', $value, TRUE); if (count($explodedValues) > 1) { $matcher->in($fieldNameAndPath, $explodedValues); } else { $matcher->equals($fieldNameAndPath, $explodedValues[0]); } } return $matcher; }