‪TYPO3CMS  ‪main
ExtendedFileUtility.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use Psr\EventDispatcher\EventDispatcherInterface;
21 use Psr\Http\Message\ServerRequestInterface;
22 use TYPO3\CMS\Backend\Utility\BackendUtility;
54 use ‪TYPO3\CMS\Core\SysLog\Action\File as SystemLogFileAction;
55 use ‪TYPO3\CMS\Core\SysLog\Error as SystemLogErrorClassification;
56 use ‪TYPO3\CMS\Core\SysLog\Type as SystemLogType;
61 
77 {
85 
93  public ‪$actionPerms = [
94  // File permissions
95  'addFile' => false,
96  'readFile' => false,
97  'writeFile' => false,
98  'copyFile' => false,
99  'moveFile' => false,
100  'renameFile' => false,
101  'deleteFile' => false,
102  // Folder permissions
103  'addFolder' => false,
104  'readFolder' => false,
105  'writeFolder' => false,
106  'copyFolder' => false,
107  'moveFolder' => false,
108  'renameFolder' => false,
109  'deleteFolder' => false,
110  'recursivedeleteFolder' => false,
111  ];
112 
118  public ‪$internalUploadMap = [];
119 
125  protected ‪$flashMessages = [];
126 
130  protected ‪$fileCmdMap;
131 
137  protected ‪$fileFactory;
138 
144  public function ‪getExistingFilesConflictMode()
145  {
147  }
148 
156  {
157  try {
158  $this->existingFilesConflictMode = ‪DuplicationBehavior::cast(‪$existingFilesConflictMode);
159  } catch (InvalidEnumerationValueException $e) {
160  throw new ‪Exception(
161  sprintf(
162  'Invalid argument, received: "%s", expected a value from enumeration \TYPO3\CMS\Core\Resource\DuplicationBehavior (%s)',
164  implode(', ', ‪DuplicationBehavior::getConstants())
165  ),
166  1476046229
167  );
168  }
169  }
170 
176  public function ‪start($fileCmds)
177  {
178  // Initialize Object Factory
179  $this->fileFactory = GeneralUtility::makeInstance(ResourceFactory::class);
180  // Initializing file processing commands:
181  $this->fileCmdMap = $fileCmds;
182  }
183 
190  public function ‪setActionPermissions(array $permissions = [])
191  {
192  if (empty($permissions)) {
193  $permissions = $this->‪getBackendUser()->getFilePermissions();
194  }
195  $this->actionPerms = $permissions;
196  }
197 
204  public function ‪processData()
205  {
206  $result = [];
207  if (is_array($this->fileCmdMap)) {
208  // Check if there were uploads expected, but no one made
209  if ($this->fileCmdMap['upload'] ?? false) {
210  $uploads = $this->fileCmdMap['upload'];
211  foreach ($uploads as $upload) {
212  if (empty($_FILES['upload_' . $upload['data']]['name'])
213  || (
214  is_array($_FILES['upload_' . $upload['data']]['name'])
215  && empty($_FILES['upload_' . $upload['data']]['name'][0])
216  )
217  ) {
218  unset($this->fileCmdMap['upload'][$upload['data']]);
219  }
220  }
221  if (empty($this->fileCmdMap['upload'])) {
222  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::USER_ERROR, 'No file was uploaded');
223  $this->‪addMessageToFlashMessageQueue('FileUtility.NoFileWasUploaded');
224  }
225  }
226 
227  // Check if there were new folder names expected, but non given
228  if ($this->fileCmdMap['newfolder'] ?? false) {
229  foreach ($this->fileCmdMap['newfolder'] as $key => $cmdArr) {
230  if (empty($cmdArr['data'])) {
231  unset($this->fileCmdMap['newfolder'][$key]);
232  }
233  }
234  if (empty($this->fileCmdMap['newfolder'])) {
235  $this->‪writeLog(SystemLogFileAction::NEW_FOLDER, SystemLogErrorClassification::USER_ERROR, 'No name for new folder given');
236  $this->‪addMessageToFlashMessageQueue('FileUtility.NoNameForNewFolderGiven');
237  }
238  }
239 
240  // Traverse each set of actions
241  foreach ($this->fileCmdMap as $action => $actionData) {
242  // Traverse all action data. More than one file might be affected at the same time.
243  if (is_array($actionData)) {
244  $result[$action] = [];
245  // We reset the array keys of $actionData to keep track of the corresponding
246  // result, while not changing the previous behaviour of $result[$action][].
247  foreach (array_values($actionData) as $key => $cmdArr) {
248  // Clear file stats
249  clearstatcache();
250  // Branch out based on command:
251  switch ($action) {
252  case 'delete':
253  $result[$action][$key] = $this->‪func_delete($cmdArr);
254  break;
255  case 'copy':
256  $result[$action][$key] = $this->‪func_copy($cmdArr);
257  break;
258  case 'move':
259  $result[$action][$key] = $this->‪func_move($cmdArr);
260  break;
261  case 'rename':
262  $result[$action][$key] = $this->‪func_rename($cmdArr);
263  break;
264  case 'newfolder':
265  $result[$action][$key] = $this->‪func_newfolder($cmdArr);
266  break;
267  case 'newfile':
268  $result[$action][$key] = $this->‪func_newfile($cmdArr);
269  break;
270  case 'editfile':
271  $result[$action][$key] = $this->‪func_edit($cmdArr);
272  break;
273  case 'upload':
274  $result[$action][$key] = $this->‪func_upload($cmdArr);
275  break;
276  case 'replace':
277  $result[$action][$key] = $this->‪replaceFile($cmdArr);
278  break;
279  }
280 
281  GeneralUtility::makeInstance(EventDispatcherInterface::class)->dispatch(
282  new AfterFileCommandProcessedEvent([$action => $cmdArr], $result[$action][$key], (string)$this->existingFilesConflictMode)
283  );
284  }
285  }
286  }
287  }
288  return $result;
289  }
290 
297  protected function ‪writeLog(int $action, int $severity, string $message, array $context = []): void
298  {
299  if (!is_object($this->‪getBackendUser())) {
300  return;
301  }
302  $this->‪getBackendUser()->writelog(SystemLogType::FILE, $action, $severity, 0, $message, $context);
303  }
304 
312  protected function ‪addMessageToFlashMessageQueue($localizationKey, array $replaceMarkers = [], ‪ContextualFeedbackSeverity $severity = ContextualFeedbackSeverity::ERROR)
313  {
314  if ((‪$GLOBALS['TYPO3_REQUEST'] ?? null) instanceof ServerRequestInterface
315  && ‪ApplicationType::fromRequest(‪$GLOBALS['TYPO3_REQUEST'])->isBackend()
316  ) {
317  $label = $this->‪getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/fileMessages.xlf:' . $localizationKey);
318  $message = vsprintf($label, $replaceMarkers);
319  $flashMessage = GeneralUtility::makeInstance(
320  FlashMessage::class,
321  $message,
322  '',
323  $severity,
324  true
325  );
326  $this->‪addFlashMessage($flashMessage);
327  }
328  }
329 
330  /*************************************
331  *
332  * File operation functions
333  *
334  **************************************/
341  public function ‪func_delete(array $cmds)
342  {
343  $result = false;
344  // Example identifier for $cmds['data'] => "4:mypath/tomyfolder/myfile.jpg"
345  // for backwards compatibility: the combined file identifier was the path+filename
346  try {
347  $fileObject = $this->‪getFileObject($cmds['data']);
348  } catch (ResourceDoesNotExistException $e) {
349  $flashMessage = GeneralUtility::makeInstance(
350  FlashMessage::class,
351  sprintf(
352  $this->‪getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:message.description.fileNotFound'),
353  $cmds['data']
354  ),
355  $this->‪getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:message.header.fileNotFound'),
356  ContextualFeedbackSeverity::ERROR,
357  true
358  );
359  $this->‪addFlashMessage($flashMessage);
360 
361  return false;
362  }
363  // checks to delete the file
364  if ($fileObject instanceof File) {
365  // check if the file still has references
366  // Exclude sys_file_metadata records as these are no use references
367  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('sys_refindex');
368  $refIndexRecords = $queryBuilder
369  ->select('tablename', 'recuid', 'ref_uid')
370  ->from('sys_refindex')
371  ->where(
372  $queryBuilder->expr()->eq(
373  'ref_table',
374  $queryBuilder->createNamedParameter('sys_file')
375  ),
376  $queryBuilder->expr()->eq(
377  'ref_uid',
378  $queryBuilder->createNamedParameter($fileObject->getUid(), ‪Connection::PARAM_INT)
379  ),
380  $queryBuilder->expr()->neq(
381  'tablename',
382  $queryBuilder->createNamedParameter('sys_file_metadata')
383  )
384  )
385  ->executeQuery()
386  ->fetchAllAssociative();
387  $deleteFile = true;
388  if (!empty($refIndexRecords)) {
389  $shortcutContent = [];
390  $brokenReferences = [];
391 
392  foreach ($refIndexRecords as $fileReferenceRow) {
393  if ($fileReferenceRow['tablename'] === 'sys_file_reference') {
394  $row = $this->‪transformFileReferenceToRecordReference($fileReferenceRow);
395  $shortcutRecord = BackendUtility::getRecord($row['tablename'], $row['recuid']);
396 
397  if ($shortcutRecord) {
398  $shortcutContent[] = '[record:' . $row['tablename'] . ':' . $row['recuid'] . ']';
399  } else {
400  $brokenReferences[] = $fileReferenceRow['ref_uid'];
401  }
402  } else {
403  $shortcutContent[] = '[record:' . $fileReferenceRow['tablename'] . ':' . $fileReferenceRow['recuid'] . ']';
404  }
405  }
406  if (!empty($brokenReferences)) {
407  // render a message that the file has broken references
408  $flashMessage = GeneralUtility::makeInstance(
409  FlashMessage::class,
410  sprintf($this->‪getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:message.description.fileHasBrokenReferences'), count($brokenReferences)),
411  $this->‪getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:message.header.fileHasBrokenReferences'),
412  ContextualFeedbackSeverity::INFO,
413  true
414  );
415  $this->‪addFlashMessage($flashMessage);
416  }
417  if (!empty($shortcutContent)) {
418  // render a message that the file could not be deleted
419  $flashMessage = GeneralUtility::makeInstance(
420  FlashMessage::class,
421  sprintf($this->‪getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:message.description.fileNotDeletedHasReferences'), $fileObject->getName()) . ' ' . implode(', ', $shortcutContent),
422  $this->‪getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:message.header.fileNotDeletedHasReferences'),
423  ContextualFeedbackSeverity::WARNING,
424  true
425  );
426  $this->‪addFlashMessage($flashMessage);
427  $deleteFile = false;
428  }
429  }
430 
431  if ($deleteFile) {
432  try {
433  $result = $fileObject->delete();
434 
435  // show the user that the file was deleted
436  $flashMessage = GeneralUtility::makeInstance(
437  FlashMessage::class,
438  sprintf($this->‪getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:message.description.fileDeleted'), $fileObject->getName()),
439  $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:message.header.fileDeleted'),
440  ContextualFeedbackSeverity::OK,
441  true
442  );
443  $this->‪addFlashMessage($flashMessage);
444  // Log success
445  $this->‪writeLog(SystemLogFileAction::DELETE, SystemLogErrorClassification::MESSAGE, 'File "{identifier}" deleted', ['identifier' => $fileObject->getIdentifier()]);
446  } catch (InsufficientFileAccessPermissionsException $e) {
447  $this->‪writeLog(SystemLogFileAction::DELETE, SystemLogErrorClassification::USER_ERROR, 'You are not allowed to access the file "{identifier}"', ['identifier' => $fileObject->getIdentifier()]);
448  $this->‪addMessageToFlashMessageQueue('FileUtility.YouAreNotAllowedToAccessTheFile', [$fileObject->getIdentifier()]);
449  } catch (NotInMountPointException $e) {
450  $this->‪writeLog(SystemLogFileAction::DELETE, SystemLogErrorClassification::USER_ERROR, 'Target "{identifier}" was not within your mountpoints"', ['identifier' => $fileObject->getIdentifier()]);
451  $this->‪addMessageToFlashMessageQueue('FileUtility.TargetWasNotWithinYourMountpoints', [$fileObject->getIdentifier()]);
452  } catch (\RuntimeException $e) {
453  $this->‪writeLog(SystemLogFileAction::DELETE, SystemLogErrorClassification::USER_ERROR, 'Could not delete file "{identifier}". Write-permission problem?', ['identifier' => $fileObject->getIdentifier()]);
454  $this->‪addMessageToFlashMessageQueue('FileUtility.CouldNotDeleteFile', [$fileObject->getIdentifier()]);
455  }
456  }
457  } else {
459  if (!$this->‪folderHasFilesInUse($fileObject)) {
460  try {
461  $result = $fileObject->delete(true);
462  if ($result) {
463  // notify the user that the folder was deleted
464  $flashMessage = GeneralUtility::makeInstance(
465  FlashMessage::class,
466  sprintf($this->‪getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:message.description.folderDeleted'), $fileObject->getName()),
467  $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:message.header.folderDeleted'),
468  ContextualFeedbackSeverity::OK,
469  true
470  );
471  $this->‪addFlashMessage($flashMessage);
472  // Log success
473  $this->‪writeLog(SystemLogFileAction::DELETE, SystemLogErrorClassification::MESSAGE, 'Directory "{identifier}" deleted', ['identifier' => $fileObject->getIdentifier()]);
474  }
475  } catch (InsufficientUserPermissionsException $e) {
476  $this->‪writeLog(SystemLogFileAction::DELETE, SystemLogErrorClassification::USER_ERROR, 'Could not delete directory. Is directory "{identifier}" empty? (You are not allowed to delete directories recursively)', ['identifier' => $fileObject->getIdentifier()]);
477  $this->‪addMessageToFlashMessageQueue('FileUtility.CouldNotDeleteDirectory', [$fileObject->getIdentifier()]);
478  } catch (InsufficientFolderAccessPermissionsException $e) {
479  $this->‪writeLog(SystemLogFileAction::DELETE, SystemLogErrorClassification::USER_ERROR, 'You are not allowed to access the directory "{identifier}"', ['identifier' => $fileObject->getIdentifier()]);
480  $this->‪addMessageToFlashMessageQueue('FileUtility.YouAreNotAllowedToAccessTheDirectory', [$fileObject->getIdentifier()]);
481  } catch (NotInMountPointException $e) {
482  $this->‪writeLog(SystemLogFileAction::DELETE, SystemLogErrorClassification::USER_ERROR, 'Target "{identifier}" was not within your mountpoints', ['identifier' => $fileObject->getIdentifier()]);
483  $this->‪addMessageToFlashMessageQueue('FileUtility.TargetWasNotWithinYourMountpoints', [$fileObject->getIdentifier()]);
484  } catch (FileOperationErrorException $e) {
485  $this->‪writeLog(SystemLogFileAction::DELETE, SystemLogErrorClassification::USER_ERROR, 'Could not delete directory "{identifier}". Write-permission problem?', ['identifier' => $fileObject->getIdentifier()]);
486  $this->‪addMessageToFlashMessageQueue('FileUtility.CouldNotDeleteDirectory', [$fileObject->getIdentifier()]);
487  }
488  }
489  }
490 
491  return $result;
492  }
493 
502  public function ‪folderHasFilesInUse(Folder $folder)
503  {
504  $files = $folder->getFiles(0, 0, ‪Folder::FILTER_MODE_USE_OWN_AND_STORAGE_FILTERS, true);
505  if (empty($files)) {
506  return false;
507  }
508 
510  $fileUids = [];
511  foreach ($files as $file) {
512  $fileUids[] = $file->getUid();
513  }
514 
515  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('sys_refindex');
516  $numberOfReferences = $queryBuilder
517  ->count('hash')
518  ->from('sys_refindex')
519  ->where(
520  $queryBuilder->expr()->eq(
521  'ref_table',
522  $queryBuilder->createNamedParameter('sys_file')
523  ),
524  $queryBuilder->expr()->in(
525  'ref_uid',
526  $queryBuilder->createNamedParameter($fileUids, Connection::PARAM_INT_ARRAY)
527  ),
528  $queryBuilder->expr()->neq(
529  'tablename',
530  $queryBuilder->createNamedParameter('sys_file_metadata')
531  )
532  )->executeQuery()->fetchOne();
533 
534  $hasReferences = $numberOfReferences > 0;
535  if ($hasReferences) {
536  $flashMessage = GeneralUtility::makeInstance(
537  FlashMessage::class,
538  $this->‪getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:message.description.folderNotDeletedHasFilesWithReferences'),
539  $this->‪getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:message.header.folderNotDeletedHasFilesWithReferences'),
540  ContextualFeedbackSeverity::WARNING,
541  true
542  );
543  $this->‪addFlashMessage($flashMessage);
544  }
545 
546  return $hasReferences;
547  }
548 
555  protected function ‪transformFileReferenceToRecordReference(array $referenceRecord)
556  {
557  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('sys_refindex');
558  $queryBuilder->getRestrictions()->removeAll();
559  $fileReference = $queryBuilder
560  ->select('uid_foreign', 'tablenames', 'fieldname', 'sorting_foreign')
561  ->from('sys_file_reference')
562  ->where(
563  $queryBuilder->expr()->eq(
564  'uid',
565  $queryBuilder->createNamedParameter($referenceRecord['recuid'], ‪Connection::PARAM_INT)
566  )
567  )
568  ->executeQuery()
569  ->fetchAssociative();
570 
571  return [
572  'recuid' => $fileReference['uid_foreign'],
573  'tablename' => $fileReference['tablenames'],
574  'field' => $fileReference['fieldname'],
575  'flexpointer' => '',
576  'softref_key' => '',
577  'sorting' => $fileReference['sorting_foreign'],
578  ];
579  }
580 
589  protected function ‪getFileObject(‪$identifier)
590  {
591  $object = $this->fileFactory->retrieveFileOrFolderObject(‪$identifier);
592  if ($object === null) {
593  throw new InvalidFileException('The item ' . ‪$identifier . ' was not a file or directory', 1320122453);
594  }
595  if ($object->getStorage()->getUid() === 0) {
596  throw new InsufficientFileAccessPermissionsException('You are not allowed to access files outside your storages', 1375889830);
597  }
598  return $object;
599  }
600 
614  protected function ‪func_copy($cmds)
615  {
616  $sourceFileObject = $this->‪getFileObject($cmds['data']);
618  $targetFolderObject = $this->‪getFileObject($cmds['target']);
619  // Basic check
620  if (!$targetFolderObject instanceof Folder) {
621  $this->‪writeLog(SystemLogFileAction::COPY, SystemLogErrorClassification::SYSTEM_ERROR, 'Destination "{identifier}" was not a directory', ['identifier' => $cmds['target']]);
622  $this->‪addMessageToFlashMessageQueue('FileUtility.DestinationWasNotADirectory', [$cmds['target']]);
623  return false;
624  }
625  // If this is TRUE, we append _XX to the file name if
626  $appendSuffixOnConflict = (string)($cmds['altName'] ?? '');
627  $resultObject = null;
628  $conflictMode = $appendSuffixOnConflict !== '' ? ‪DuplicationBehavior::RENAME : ‪DuplicationBehavior::CANCEL;
629  // Copying the file
630  if ($sourceFileObject instanceof File) {
631  try {
632  $resultObject = $sourceFileObject->copyTo($targetFolderObject, null, $conflictMode);
633  } catch (InsufficientUserPermissionsException $e) {
634  $this->‪writeLog(SystemLogFileAction::COPY, SystemLogErrorClassification::USER_ERROR, 'You are not allowed to copy files');
635  $this->‪addMessageToFlashMessageQueue('FileUtility.YouAreNotAllowedToCopyFiles');
636  } catch (InsufficientFileAccessPermissionsException $e) {
637  $this->‪writeLog(SystemLogFileAction::COPY, SystemLogErrorClassification::USER_ERROR, 'Could not access all necessary resources. Source file "{identifier}" or destination "{destination}" was not within your mountpoints maybe', ['identifier' => $sourceFileObject->getIdentifier(), 'destination' => $targetFolderObject->getIdentifier()]);
638  $this->‪addMessageToFlashMessageQueue('FileUtility.CouldNotAccessAllNecessaryResources', [$sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
639  } catch (IllegalFileExtensionException $e) {
640  $this->‪writeLog(SystemLogFileAction::COPY, SystemLogErrorClassification::USER_ERROR, 'Extension of file name "{identifier}" is not allowed in "{destination}"', ['identifier' => $sourceFileObject->getIdentifier(), 'destination' => $targetFolderObject->getIdentifier()]);
641  $this->‪addMessageToFlashMessageQueue('FileUtility.ExtensionOfFileNameIsNotAllowedIn', [$sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
642  } catch (ExistingTargetFileNameException $e) {
643  $this->‪writeLog(SystemLogFileAction::COPY, SystemLogErrorClassification::USER_ERROR, 'File "{identifier}" already exists in folder "{destination}"', ['identifier' => $sourceFileObject->getIdentifier(), 'destination' => $targetFolderObject->getIdentifier()]);
644  $this->‪addMessageToFlashMessageQueue('FileUtility.FileAlreadyExistsInFolder', [$sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
645  } catch (NotImplementedMethodException $e) {
646  $this->‪writeLog(SystemLogFileAction::MOVE, SystemLogErrorClassification::USER_ERROR, 'The function to copy a file between storages is not yet implemented');
647  $this->‪addMessageToFlashMessageQueue('FileUtility.TheFunctionToCopyAFileBetweenStoragesIsNotYetImplemented');
648  } catch (\RuntimeException $e) {
649  $this->‪writeLog(SystemLogFileAction::COPY, SystemLogErrorClassification::SYSTEM_ERROR, 'File "{identifier}" was not copied to "{destination}" - Write-permission problem?', ['identifier' => $sourceFileObject->getIdentifier(), 'destination' => $targetFolderObject->getIdentifier()]);
650  $this->‪addMessageToFlashMessageQueue('FileUtility.FileWasNotCopiedTo', [$sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
651  }
652  if ($resultObject) {
653  $this->‪writeLog(SystemLogFileAction::COPY, SystemLogErrorClassification::MESSAGE, 'File "{identifier}" copied to "{destination}"', ['identifier' => $sourceFileObject->getIdentifier(), 'destination' => $resultObject->getIdentifier()]);
654  $this->‪addMessageToFlashMessageQueue('FileUtility.FileCopiedTo', [$sourceFileObject->getIdentifier(), $resultObject->getIdentifier()], ContextualFeedbackSeverity::OK);
655  }
656  } else {
657  // Else means this is a Folder
658  $sourceFolderObject = $sourceFileObject;
659  try {
660  $resultObject = $sourceFolderObject->copyTo($targetFolderObject, null, $conflictMode);
661  } catch (InsufficientUserPermissionsException $e) {
662  $this->‪writeLog(SystemLogFileAction::COPY, SystemLogErrorClassification::USER_ERROR, 'You are not allowed to copy directories');
663  $this->‪addMessageToFlashMessageQueue('FileUtility.YouAreNotAllowedToCopyDirectories');
664  } catch (InsufficientFileAccessPermissionsException $e) {
665  $this->‪writeLog(SystemLogFileAction::COPY, SystemLogErrorClassification::USER_ERROR, 'Could not access all necessary resources. Maybe source file "{identifier}" or destination "{destination}" was not within your mountpoints', ['identifier' => $sourceFolderObject->getIdentifier(), 'destination' => $targetFolderObject->getIdentifier()]);
666  $this->‪addMessageToFlashMessageQueue('FileUtility.CouldNotAccessAllNecessaryResources', [$sourceFolderObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
667  } catch (InsufficientFolderAccessPermissionsException $e) {
668  $this->‪writeLog(SystemLogFileAction::COPY, SystemLogErrorClassification::USER_ERROR, 'You don\'t have full access to the destination directory "{destination}"', ['destination' => $targetFolderObject->getIdentifier()]);
669  $this->‪addMessageToFlashMessageQueue('FileUtility.YouDontHaveFullAccessToTheDestinationDirectory', [$targetFolderObject->getIdentifier()]);
670  } catch (InvalidTargetFolderException $e) {
671  $this->‪writeLog(SystemLogFileAction::COPY, SystemLogErrorClassification::USER_ERROR, 'Cannot copy folder "{name}" into target folder "{destination}", because there is already a folder or file with that name in the target folder', ['name' => $sourceFolderObject->getName(), 'destination' => $targetFolderObject->getIdentifier()]);
672  $this->‪addMessageToFlashMessageQueue('FileUtility.CannotCopyFolderIntoTargetFolderBecauseTheTargetFolderIsAlreadyWithinTheFolderToBeCopied', [$sourceFolderObject->getName(), $targetFolderObject->getIdentifier()]);
673  } catch (ExistingTargetFolderException $e) {
674  $this->‪writeLog(SystemLogFileAction::COPY, SystemLogErrorClassification::USER_ERROR, 'Target "{destination}" already exists', ['destination' => $targetFolderObject->getIdentifier()]);
675  $this->‪addMessageToFlashMessageQueue('FileUtility.TargetAlreadyExists', [$targetFolderObject->getIdentifier()]);
676  } catch (NotImplementedMethodException $e) {
677  $this->‪writeLog(SystemLogFileAction::MOVE, SystemLogErrorClassification::USER_ERROR, 'The function to copy a folder between storages is not yet implemented');
678  $this->‪addMessageToFlashMessageQueue('FileUtility.TheFunctionToCopyAFolderBetweenStoragesIsNotYetImplemented');
679  } catch (\RuntimeException $e) {
680  $this->‪writeLog(SystemLogFileAction::COPY, SystemLogErrorClassification::SYSTEM_ERROR, 'Directory "{identifier}" was not copied to "{destination}". Write-permission problem?', ['identifier' => $sourceFolderObject->getIdentifier(), 'destination' => $targetFolderObject->getIdentifier()]);
681  $this->‪addMessageToFlashMessageQueue('FileUtility.DirectoryWasNotCopiedTo', [$sourceFolderObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
682  }
683  if ($resultObject) {
684  $this->‪writeLog(SystemLogFileAction::COPY, SystemLogErrorClassification::MESSAGE, 'Directory "{identifier}" copied to "{destination}"', ['identifier' => $sourceFolderObject->getIdentifier(), 'destination' => $targetFolderObject->getIdentifier()]);
685  $this->‪addMessageToFlashMessageQueue('FileUtility.DirectoryCopiedTo', [$sourceFolderObject->getIdentifier(), $targetFolderObject->getIdentifier()], ContextualFeedbackSeverity::OK);
686  }
687  }
688  return $resultObject;
689  }
690 
704  protected function ‪func_move($cmds)
705  {
706  $sourceFileObject = $this->‪getFileObject($cmds['data']);
707  $targetFolderObject = $this->‪getFileObject($cmds['target']);
708  // Basic check
709  if (!$targetFolderObject instanceof Folder) {
710  $this->‪writeLog(SystemLogFileAction::MOVE, SystemLogErrorClassification::SYSTEM_ERROR, 'Destination "{destination}" was not a directory', ['destination' => $cmds['target']]);
711  $this->‪addMessageToFlashMessageQueue('FileUtility.DestinationWasNotADirectory', [$cmds['target']]);
712  return false;
713  }
714  $alternativeName = (string)($cmds['altName'] ?? '');
715  $resultObject = null;
716  // Moving the file
717  if ($sourceFileObject instanceof File) {
718  try {
719  if ($alternativeName !== '') {
720  // Don't allow overwriting existing files, but find a new name
721  $resultObject = $sourceFileObject->moveTo($targetFolderObject, $alternativeName, ‪DuplicationBehavior::RENAME);
722  } else {
723  // Don't allow overwriting existing files
724  $resultObject = $sourceFileObject->moveTo($targetFolderObject, null, ‪DuplicationBehavior::CANCEL);
725  }
726  $this->‪writeLog(SystemLogFileAction::MOVE, SystemLogErrorClassification::MESSAGE, 'File "{identifier}" moved to "{destination}"', ['identifier' => $sourceFileObject->getIdentifier(), 'destination' => $resultObject->getIdentifier()]);
727  $this->‪addMessageToFlashMessageQueue('FileUtility.FileMovedTo', [$sourceFileObject->getIdentifier(), $resultObject->getIdentifier()], ContextualFeedbackSeverity::OK);
728  } catch (InsufficientUserPermissionsException $e) {
729  $this->‪writeLog(SystemLogFileAction::MOVE, SystemLogErrorClassification::USER_ERROR, 'You are not allowed to move files');
730  $this->‪addMessageToFlashMessageQueue('FileUtility.YouAreNotAllowedToMoveFiles');
731  } catch (InsufficientFileAccessPermissionsException $e) {
732  $this->‪writeLog(SystemLogFileAction::MOVE, SystemLogErrorClassification::USER_ERROR, 'Could not access all necessary resources. Maybe source file "{identifier}" or destination "{destination}" was not within your mountpoints', ['identifier' => $sourceFileObject->getIdentifier(), 'destination' => $targetFolderObject->getIdentifier()]);
733  $this->‪addMessageToFlashMessageQueue('FileUtility.CouldNotAccessAllNecessaryResources', [$sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
734  } catch (IllegalFileExtensionException $e) {
735  $this->‪writeLog(SystemLogFileAction::MOVE, SystemLogErrorClassification::USER_ERROR, 'Extension of file name "{identifier}" is not allowed in "{destination}"', ['identifier' => $sourceFileObject->getIdentifier(), 'destination' => $targetFolderObject->getIdentifier()]);
736  $this->‪addMessageToFlashMessageQueue('FileUtility.ExtensionOfFileNameIsNotAllowedIn', [$sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
737  } catch (ExistingTargetFileNameException $e) {
738  $this->‪writeLog(SystemLogFileAction::MOVE, SystemLogErrorClassification::USER_ERROR, 'File "{identifier}" already exists in folder "{destination}"', ['identifier' => $sourceFileObject->getIdentifier(), 'destination' => $targetFolderObject->getIdentifier()]);
739  $this->‪addMessageToFlashMessageQueue('FileUtility.FileAlreadyExistsInFolder', [$sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
740  } catch (NotImplementedMethodException $e) {
741  $this->‪writeLog(SystemLogFileAction::MOVE, SystemLogErrorClassification::USER_ERROR, 'The function to move a file between storages is not yet implemented');
742  $this->‪addMessageToFlashMessageQueue('FileUtility.TheFunctionToMoveAFileBetweenStoragesIsNotYetImplemented');
743  } catch (\RuntimeException $e) {
744  $this->‪writeLog(SystemLogFileAction::MOVE, SystemLogErrorClassification::SYSTEM_ERROR, 'File "{identifier}" was not copied to "{destination}". Write-permission problem?', ['identifier' => $sourceFileObject->getIdentifier(), 'destination' => $targetFolderObject->getIdentifier()]);
745  $this->‪addMessageToFlashMessageQueue('FileUtility.FileWasNotCopiedTo', [$sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
746  }
747  } else {
748  // Else means this is a Folder
749  $sourceFolderObject = $sourceFileObject;
750  try {
751  if ($alternativeName !== '') {
752  // Don't allow overwriting existing files, but find a new name
753  $resultObject = $sourceFolderObject->moveTo($targetFolderObject, $alternativeName, ‪DuplicationBehavior::RENAME);
754  } else {
755  // Don't allow overwriting existing files
756  $resultObject = $sourceFolderObject->moveTo($targetFolderObject, null, ‪DuplicationBehavior::RENAME);
757  }
758  $this->‪writeLog(SystemLogFileAction::MOVE, SystemLogErrorClassification::MESSAGE, 'Directory "{identifier}" moved to "{destination}"', ['identifier' => $sourceFolderObject->getIdentifier(), 'destination' => $targetFolderObject->getIdentifier()]);
759  $this->‪addMessageToFlashMessageQueue('FileUtility.DirectoryMovedTo', [$sourceFolderObject->getIdentifier(), $targetFolderObject->getIdentifier()], ContextualFeedbackSeverity::OK);
760  } catch (InsufficientUserPermissionsException $e) {
761  $this->‪writeLog(SystemLogFileAction::MOVE, SystemLogErrorClassification::USER_ERROR, 'You are not allowed to move directories');
762  $this->‪addMessageToFlashMessageQueue('FileUtility.YouAreNotAllowedToMoveDirectories');
763  } catch (InsufficientFileAccessPermissionsException $e) {
764  $this->‪writeLog(SystemLogFileAction::MOVE, SystemLogErrorClassification::USER_ERROR, 'Could not access all necessary resources. Maybe source folder "{identifier}" or destination "{destination}" was not within your mountpoints', ['identifier' => $sourceFolderObject->getIdentifier(), 'destination' => $targetFolderObject->getIdentifier()]);
765  $this->‪addMessageToFlashMessageQueue('FileUtility.CouldNotAccessAllNecessaryResources', [$sourceFolderObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
766  } catch (InsufficientFolderAccessPermissionsException $e) {
767  $this->‪writeLog(SystemLogFileAction::MOVE, SystemLogErrorClassification::USER_ERROR, 'You don\'t have full access to the destination directory "{destination}"', ['destination' => $targetFolderObject->getIdentifier()]);
768  $this->‪addMessageToFlashMessageQueue('FileUtility.YouDontHaveFullAccessToTheDestinationDirectory', [$targetFolderObject->getIdentifier()]);
769  } catch (InvalidTargetFolderException $e) {
770  $this->‪writeLog(SystemLogFileAction::MOVE, SystemLogErrorClassification::USER_ERROR, 'Cannot move folder "{identifier}" into target folder "{destination}", because the target folder is already within the folder to be moved', ['identifier' => $sourceFolderObject->getName(), 'destination' => $targetFolderObject->getName()]);
771  $this->‪addMessageToFlashMessageQueue('FileUtility.CannotMoveFolderIntoTargetFolderBecauseTheTargetFolderIsAlreadyWithinTheFolderToBeMoved', [$sourceFolderObject->getName(), $targetFolderObject->getName()]);
772  } catch (ExistingTargetFolderException $e) {
773  $this->‪writeLog(SystemLogFileAction::MOVE, SystemLogErrorClassification::USER_ERROR, 'Target "{destination}" already exists', ['destination' => $targetFolderObject->getIdentifier()]);
774  $this->‪addMessageToFlashMessageQueue('FileUtility.TargetAlreadyExists', [$targetFolderObject->getIdentifier()]);
775  } catch (NotImplementedMethodException $e) {
776  $this->‪writeLog(SystemLogFileAction::MOVE, SystemLogErrorClassification::USER_ERROR, 'The function to move a folder between storages is not yet implemented');
777  $this->‪addMessageToFlashMessageQueue('FileUtility.TheFunctionToMoveAFolderBetweenStoragesIsNotYetImplemented');
778  } catch (\RuntimeException $e) {
779  $this->‪writeLog(SystemLogFileAction::MOVE, SystemLogErrorClassification::SYSTEM_ERROR, 'Directory "{identifier}" was not moved to "{destination}". Write-permission problem?', ['identifier' => $sourceFolderObject->getIdentifier(), 'destination' => $targetFolderObject->getIdentifier()]);
780  $this->‪addMessageToFlashMessageQueue('FileUtility.DirectoryWasNotMovedTo', [$sourceFolderObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
781  }
782  }
783  return $resultObject;
784  }
785 
797  public function ‪func_rename($cmds)
798  {
799  $sourceFileObject = $this->‪getFileObject($cmds['data']);
800  $sourceFile = $sourceFileObject->getName();
801  $targetFile = $cmds['target'];
802  $resultObject = null;
803  if ($sourceFileObject instanceof File) {
804  try {
805  // Try to rename the File
806  $resultObject = $sourceFileObject->rename($targetFile, (string)$this->existingFilesConflictMode);
807  if ($resultObject->getName() !== $targetFile) {
808  $this->‪writeLog(SystemLogFileAction::RENAME, SystemLogErrorClassification::USER_ERROR, 'File renamed from "{identifier}" to "{destination}". Filename had to be sanitized', ['identifier' => $sourceFile, 'destination' => $targetFile]);
809  $this->‪addMessageToFlashMessageQueue('FileUtility.FileNameSanitized', [$targetFile, $resultObject->getName()], ContextualFeedbackSeverity::WARNING);
810  } else {
811  $this->‪writeLog(SystemLogFileAction::RENAME, SystemLogErrorClassification::MESSAGE, 'File renamed from "{identifier}" to "{destination}"', ['identifier' => $sourceFile, 'destination' => $targetFile]);
812  }
813  if ($sourceFile === $resultObject->getName()) {
814  $this->‪addMessageToFlashMessageQueue('FileUtility.FileRenamedSameName', [$sourceFile], ContextualFeedbackSeverity::INFO);
815  } else {
816  $this->‪addMessageToFlashMessageQueue('FileUtility.FileRenamedFromTo', [$sourceFile, $resultObject->getName()], ContextualFeedbackSeverity::OK);
817  }
818  } catch (InsufficientUserPermissionsException $e) {
819  $this->‪writeLog(SystemLogFileAction::RENAME, SystemLogErrorClassification::USER_ERROR, 'You are not allowed to rename files');
820  $this->‪addMessageToFlashMessageQueue('FileUtility.YouAreNotAllowedToRenameFiles');
821  } catch (IllegalFileExtensionException $e) {
822  $this->‪writeLog(SystemLogFileAction::RENAME, SystemLogErrorClassification::USER_ERROR, 'Extension of file name "{identifier}" or "{destination}" was not allowed', ['identifier' => $sourceFileObject->getName(), 'destination' => $targetFile]);
823  $this->‪addMessageToFlashMessageQueue('FileUtility.ExtensionOfFileNameOrWasNotAllowed', [$sourceFileObject->getName(), $targetFile]);
824  } catch (ExistingTargetFileNameException $e) {
825  $this->‪writeLog(SystemLogFileAction::RENAME, SystemLogErrorClassification::USER_ERROR, 'Destination "{destination}" existed already', ['destination' => $targetFile]);
826  $this->‪addMessageToFlashMessageQueue('FileUtility.DestinationExistedAlready', [$targetFile]);
827  } catch (NotInMountPointException $e) {
828  $this->‪writeLog(SystemLogFileAction::RENAME, SystemLogErrorClassification::USER_ERROR, 'Destination path "{destination}" was not within your mountpoints', ['destination' => $targetFile]);
829  $this->‪addMessageToFlashMessageQueue('FileUtility.DestinationPathWasNotWithinYourMountpoints', [$targetFile]);
830  } catch (\RuntimeException $e) {
831  $this->‪writeLog(SystemLogFileAction::RENAME, SystemLogErrorClassification::USER_ERROR, 'File "{identifier}" was not renamed. Write-permission problem in "{destination}"?', ['identifier' => $sourceFileObject->getName(), 'destination' => $targetFile]);
832  $this->‪addMessageToFlashMessageQueue('FileUtility.FileWasNotRenamed', [$sourceFileObject->getName(), $targetFile]);
833  }
834  } else {
835  // Else means this is a Folder
836  try {
837  // Try to rename the Folder
838  $resultObject = $sourceFileObject->rename($targetFile);
839  $newFolderName = $resultObject->getName();
840  $this->‪writeLog(SystemLogFileAction::RENAME, SystemLogErrorClassification::MESSAGE, 'Directory renamed from "{identifier}" to "{destination}"', ['identifier' => $sourceFile, 'destination' => $targetFile]);
841  if ($sourceFile === $newFolderName) {
842  $this->‪addMessageToFlashMessageQueue('FileUtility.DirectoryRenamedSameName', [$sourceFile], ContextualFeedbackSeverity::INFO);
843  } else {
844  if ($newFolderName === $targetFile) {
845  $this->‪addMessageToFlashMessageQueue('FileUtility.DirectoryRenamedFromTo', [$sourceFile, $newFolderName], ContextualFeedbackSeverity::OK);
846  } else {
847  $this->‪addMessageToFlashMessageQueue('FileUtility.DirectoryRenamedFromToCharReplaced', [$sourceFile, $newFolderName], ContextualFeedbackSeverity::WARNING);
848  }
849  }
850  } catch (InsufficientUserPermissionsException $e) {
851  $this->‪writeLog(SystemLogFileAction::RENAME, SystemLogErrorClassification::USER_ERROR, 'You are not allowed to rename directories');
852  $this->‪addMessageToFlashMessageQueue('FileUtility.YouAreNotAllowedToRenameDirectories');
853  } catch (ExistingTargetFileNameException $e) {
854  $this->‪writeLog(SystemLogFileAction::RENAME, SystemLogErrorClassification::USER_ERROR, 'Destination "{destination}" existed already', ['destination' => $targetFile]);
855  $this->‪addMessageToFlashMessageQueue('FileUtility.DestinationExistedAlready', [$targetFile]);
856  } catch (NotInMountPointException $e) {
857  $this->‪writeLog(SystemLogFileAction::RENAME, SystemLogErrorClassification::USER_ERROR, 'Destination path "{destination}" was not within your mountpoints', ['destination' => $targetFile]);
858  $this->‪addMessageToFlashMessageQueue('FileUtility.DestinationPathWasNotWithinYourMountpoints', [$targetFile]);
859  } catch (\RuntimeException $e) {
860  $this->‪writeLog(SystemLogFileAction::RENAME, SystemLogErrorClassification::USER_ERROR, 'Directory "{identifier}" was not renamed. Write-permission problem in "{destination}"?', ['identifier' => $sourceFileObject->getName(), 'destination' => $targetFile]);
861  $this->‪addMessageToFlashMessageQueue('FileUtility.DirectoryWasNotRenamed', [$sourceFileObject->getName(), $targetFile]);
862  }
863  }
864  return $resultObject;
865  }
866 
877  public function ‪func_newfolder($cmds)
878  {
879  $resultObject = false;
880  $targetFolderObject = $this->‪getFileObject($cmds['target']);
881  if (!$targetFolderObject instanceof Folder) {
882  $this->‪writeLog(SystemLogFileAction::NEW_FOLDER, SystemLogErrorClassification::SYSTEM_ERROR, 'Destination "{destination}" was not a directory', ['destination' => $cmds['target']]);
883  $this->‪addMessageToFlashMessageQueue('FileUtility.DestinationWasNotADirectory', [$cmds['target']]);
884  return false;
885  }
886  $folderName = $cmds['data'];
887  try {
888  $resultObject = $targetFolderObject->createFolder($folderName);
889  $this->‪writeLog(SystemLogFileAction::NEW_FOLDER, SystemLogErrorClassification::MESSAGE, 'Directory "{identifier}" created in "{destination}"', ['identifier' => $folderName, 'destination' => $targetFolderObject->getIdentifier()]);
890  $this->‪addMessageToFlashMessageQueue('FileUtility.DirectoryCreatedIn', [$folderName, $targetFolderObject->getIdentifier()], ContextualFeedbackSeverity::OK);
891  } catch (InvalidFileNameException $e) {
892  $this->‪writeLog(SystemLogFileAction::NEW_FOLDER, SystemLogErrorClassification::USER_ERROR, 'Invalid folder name "{identifier}"', ['identifier' => $folderName]);
893  $this->‪addMessageToFlashMessageQueue('FileUtility.YouAreNotAllowedToCreateDirectories', [$folderName]);
894  } catch (InsufficientFolderWritePermissionsException $e) {
895  $this->‪writeLog(SystemLogFileAction::NEW_FOLDER, SystemLogErrorClassification::USER_ERROR, 'You are not allowed to create directories');
896  $this->‪addMessageToFlashMessageQueue('FileUtility.YouAreNotAllowedToCreateDirectories');
897  } catch (NotInMountPointException $e) {
898  $this->‪writeLog(SystemLogFileAction::NEW_FOLDER, SystemLogErrorClassification::USER_ERROR, 'Destination path "{destination}" was not within your mountpoints', ['destination' => $targetFolderObject->getIdentifier()]);
899  $this->‪addMessageToFlashMessageQueue('FileUtility.DestinationPathWasNotWithinYourMountpoints', [$targetFolderObject->getIdentifier()]);
900  } catch (ExistingTargetFolderException $e) {
901  $this->‪writeLog(SystemLogFileAction::NEW_FOLDER, SystemLogErrorClassification::USER_ERROR, 'File or directory "{identifier}" existed already', ['identifier' => $folderName]);
902  $this->‪addMessageToFlashMessageQueue('FileUtility.FileOrDirectoryExistedAlready', [$folderName]);
903  } catch (\RuntimeException $e) {
904  $this->‪writeLog(SystemLogFileAction::NEW_FOLDER, SystemLogErrorClassification::USER_ERROR, 'Directory "{identifier}" not created. Write-permission problem in "{destination}"?', ['identifier' => $folderName, 'destination' => $targetFolderObject->getIdentifier()]);
905  $this->‪addMessageToFlashMessageQueue('FileUtility.DirectoryNotCreated', [$folderName, $targetFolderObject->getIdentifier()]);
906  }
907  return $resultObject;
908  }
909 
919  public function ‪func_newfile($cmds)
920  {
921  $targetFolderObject = $this->‪getFileObject($cmds['target']);
922  if (!$targetFolderObject instanceof Folder) {
923  $this->‪writeLog(SystemLogFileAction::NEW_FILE, SystemLogErrorClassification::SYSTEM_ERROR, 'Destination "{destination}" was not a directory', ['destination' => $cmds['target']]);
924  $this->‪addMessageToFlashMessageQueue('FileUtility.DestinationWasNotADirectory', [$cmds['target']]);
925  return false;
926  }
927  $resultObject = null;
928  $fileName = $cmds['data'];
929  try {
930  $resultObject = $targetFolderObject->createFile($fileName);
931  $this->‪writeLog(SystemLogFileAction::NEW_FILE, SystemLogErrorClassification::MESSAGE, 'File "{identifier}" created', ['identifier' => $fileName]);
932  if ($resultObject->getName() !== $fileName) {
933  $this->‪addMessageToFlashMessageQueue('FileUtility.FileNameSanitized', [$fileName, $resultObject->getName()], ContextualFeedbackSeverity::WARNING);
934  }
935  $this->‪addMessageToFlashMessageQueue('FileUtility.FileCreated', [$resultObject->getName()], ContextualFeedbackSeverity::OK);
936  } catch (IllegalFileExtensionException $e) {
937  $this->‪writeLog(SystemLogFileAction::NEW_FILE, SystemLogErrorClassification::USER_ERROR, 'Extension of file "{identifier}" was not allowed', ['identifier' => $fileName]);
938  $this->‪addMessageToFlashMessageQueue('FileUtility.ExtensionOfFileWasNotAllowed', [$fileName]);
939  } catch (InsufficientFolderWritePermissionsException $e) {
940  $this->‪writeLog(SystemLogFileAction::NEW_FILE, SystemLogErrorClassification::USER_ERROR, 'You are not allowed to create files');
941  $this->‪addMessageToFlashMessageQueue('FileUtility.YouAreNotAllowedToCreateFiles');
942  } catch (NotInMountPointException $e) {
943  $this->‪writeLog(SystemLogFileAction::NEW_FILE, SystemLogErrorClassification::USER_ERROR, 'Destination path "{destination}" was not within your mountpoints', ['destination' => $targetFolderObject->getIdentifier()]);
944  $this->‪addMessageToFlashMessageQueue('FileUtility.DestinationPathWasNotWithinYourMountpoints', [$targetFolderObject->getIdentifier()]);
945  } catch (ExistingTargetFileNameException $e) {
946  $this->‪writeLog(SystemLogFileAction::NEW_FILE, SystemLogErrorClassification::USER_ERROR, 'File existed already in "{destination}"', ['destination' => $targetFolderObject->getIdentifier()]);
947  $this->‪addMessageToFlashMessageQueue('FileUtility.FileExistedAlreadyIn', [$targetFolderObject->getIdentifier()]);
948  } catch (InvalidFileNameException $e) {
949  $this->‪writeLog(SystemLogFileAction::NEW_FILE, SystemLogErrorClassification::USER_ERROR, 'File name "{identifier}" was not allowed', ['identifier' => $fileName]);
950  $this->‪addMessageToFlashMessageQueue('FileUtility.FileNameWasNotAllowed', [$fileName]);
951  } catch (\RuntimeException $e) {
952  $this->‪writeLog(SystemLogFileAction::NEW_FILE, SystemLogErrorClassification::USER_ERROR, 'File "{identifier}" was not created. Write-permission problem in "{destination}"?', ['identifier' => $fileName, 'destination' => $targetFolderObject->getIdentifier()]);
953  $this->‪addMessageToFlashMessageQueue('FileUtility.FileWasNotCreated', [$fileName, $targetFolderObject->getIdentifier()]);
954  }
955  return $resultObject;
956  }
957 
964  public function ‪func_edit($cmds)
965  {
966  // Example identifier for $cmds['target'] => "4:mypath/tomyfolder/myfile.jpg"
967  // for backwards compatibility: the combined file identifier was the path+filename
968  $fileIdentifier = $cmds['target'];
969  $fileObject = $this->‪getFileObject($fileIdentifier);
970  if (!$fileObject instanceof File) {
971  $this->‪writeLog(SystemLogFileAction::EDIT, SystemLogErrorClassification::SYSTEM_ERROR, 'Target "{destination}" was not a file', ['destination' => $fileIdentifier]);
972  $this->‪addMessageToFlashMessageQueue('FileUtility.TargetWasNotAFile', [$fileIdentifier]);
973  return false;
974  }
975  if (!$fileObject->isTextFile()) {
976  $extList = ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['textfile_ext'];
977  $this->‪writeLog(SystemLogFileAction::EDIT, SystemLogErrorClassification::USER_ERROR, 'File extension "{extension}" is not a textfile format ({allowedExtensions})', ['extension' => $fileObject->getExtension(), 'allowedExtensions' => $extList]);
978  $this->‪addMessageToFlashMessageQueue('FileUtility.FileExtensionIsNotATextfileFormat', [$fileObject->getExtension(), $extList]);
979  return false;
980  }
981  try {
982  // Example identifier for $cmds['target'] => "2:targetpath/targetfolder/"
983  $content = $cmds['data'];
984  $fileObject->setContents($content);
985  clearstatcache();
986  $this->‪writeLog(SystemLogFileAction::EDIT, SystemLogErrorClassification::MESSAGE, 'File saved to "{identifier}", bytes: {size}', ['identifier' => $fileObject->getIdentifier(), 'size' => $fileObject->getSize()]);
987  $this->‪addMessageToFlashMessageQueue('FileUtility.FileSavedTo', [$fileObject->getIdentifier()], ContextualFeedbackSeverity::OK);
988  return true;
989  } catch (InsufficientUserPermissionsException $e) {
990  $this->‪writeLog(SystemLogFileAction::EDIT, SystemLogErrorClassification::USER_ERROR, 'You are not allowed to edit files');
991  $this->‪addMessageToFlashMessageQueue('FileUtility.YouAreNotAllowedToEditFiles');
992  return false;
993  } catch (InsufficientFileWritePermissionsException $e) {
994  $this->‪writeLog(SystemLogFileAction::EDIT, SystemLogErrorClassification::USER_ERROR, 'File "{identifier}" was not saved. Write-permission problem?', ['identifier' => $fileObject->getIdentifier()]);
995  $this->‪addMessageToFlashMessageQueue('FileUtility.FileWasNotSaved', [$fileObject->getIdentifier()]);
996  return false;
997  } catch (IllegalFileExtensionException|\RuntimeException $e) {
998  $this->‪writeLog(SystemLogFileAction::EDIT, SystemLogErrorClassification::USER_ERROR, 'File "{identifier}" was not saved. File extension rejected', ['identifier' => $fileObject->getIdentifier()]);
999  $this->‪addMessageToFlashMessageQueue('FileUtility.FileWasNotSaved', [$fileObject->getIdentifier()]);
1000  return false;
1001  }
1002  }
1003 
1034  public function ‪func_upload($cmds)
1035  {
1036  $uploadPosition = $cmds['data'];
1037  $uploadedFileData = $_FILES['upload_' . $uploadPosition];
1038  if (empty($uploadedFileData['name']) || is_array($uploadedFileData['name']) && empty($uploadedFileData['name'][0])) {
1039  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::SYSTEM_ERROR, 'No file was uploaded');
1040  $this->‪addMessageToFlashMessageQueue('FileUtility.NoFileWasUploaded');
1041  return false;
1042  }
1043  // Example identifier for $cmds['target'] => "2:targetpath/targetfolder/"
1044  $targetFolderObject = $this->‪getFileObject($cmds['target']);
1045  // Uploading with non HTML-5-style, thus, make an array out of it, so we can loop over it
1046  if (!is_array($uploadedFileData['name'])) {
1047  $uploadedFileData = [
1048  'name' => [$uploadedFileData['name']],
1049  'type' => [$uploadedFileData['type']],
1050  'tmp_name' => [$uploadedFileData['tmp_name']],
1051  'size' => [$uploadedFileData['size']],
1052  ];
1053  }
1054  $uploadedFileData['name'] = array_map(\Normalizer::normalize(...), $uploadedFileData['name']);
1055  $resultObjects = [];
1056  $numberOfUploadedFilesForPosition = count($uploadedFileData['name']);
1057  // Loop through all uploaded files
1058  for ($i = 0; $i < $numberOfUploadedFilesForPosition; $i++) {
1059  $fileInfo = [
1060  'name' => $uploadedFileData['name'][$i],
1061  'type' => $uploadedFileData['type'][$i],
1062  'tmp_name' => $uploadedFileData['tmp_name'][$i],
1063  'size' => $uploadedFileData['size'][$i],
1064  ];
1065  try {
1066  $fileObject = $targetFolderObject->addUploadedFile($fileInfo, (string)$this->existingFilesConflictMode);
1067  if ($this->existingFilesConflictMode->equals(‪DuplicationBehavior::REPLACE)) {
1068  $this->‪getIndexer($fileObject->getStorage())->‪updateIndexEntry($fileObject);
1069  }
1070  $resultObjects[] = $fileObject;
1071  $this->internalUploadMap[$uploadPosition] = $fileObject->getCombinedIdentifier();
1072  if ($fileObject->getName() !== $fileInfo['name']) {
1073  $this->‪addMessageToFlashMessageQueue('FileUtility.FileNameSanitized', [$fileInfo['name'], $fileObject->getName()], ContextualFeedbackSeverity::WARNING);
1074  }
1075  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::MESSAGE, 'Uploading file "{identifier}" to "{destination}"', ['identifier' => $fileInfo['name'], 'destination' => $targetFolderObject->getIdentifier()]);
1076  $this->‪addMessageToFlashMessageQueue('FileUtility.UploadingFileTo', [$fileInfo['name'], $targetFolderObject->getIdentifier()], ContextualFeedbackSeverity::OK);
1077  } catch (InsufficientFileWritePermissionsException $e) {
1078  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::USER_ERROR, 'You are not allowed to override {identifier}', ['identifier' => $fileInfo['name']]);
1079  $this->‪addMessageToFlashMessageQueue('FileUtility.YouAreNotAllowedToOverride', [$fileInfo['name']]);
1080  } catch (UploadException $e) {
1081  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::SYSTEM_ERROR, 'The upload has failed, no uploaded file found');
1082  $this->‪addMessageToFlashMessageQueue('FileUtility.TheUploadHasFailedNoUploadedFileFound');
1083  } catch (InsufficientUserPermissionsException $e) {
1084  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::USER_ERROR, 'You are not allowed to upload files');
1085  $this->‪addMessageToFlashMessageQueue('FileUtility.YouAreNotAllowedToUploadFiles');
1086  } catch (UploadSizeException $e) {
1087  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::USER_ERROR, 'The uploaded file "{identifier}" exceeds the size-limit', ['identifier' => $fileInfo['name']]);
1088  $this->‪addMessageToFlashMessageQueue('FileUtility.TheUploadedFileExceedsTheSize-limit', [$fileInfo['name']]);
1089  } catch (InsufficientFolderWritePermissionsException $e) {
1090  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::USER_ERROR, 'Destination path "{destination}" was not within your mountpoints', ['destination' => $targetFolderObject->getIdentifier()]);
1091  $this->‪addMessageToFlashMessageQueue('FileUtility.DestinationPathWasNotWithinYourMountpoints', [$targetFolderObject->getIdentifier()]);
1092  } catch (IllegalFileExtensionException $e) {
1093  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::USER_ERROR, 'Extension of file name "{identifier}" is not allowed in "{destination}"', ['identifier' => $fileInfo['name'], 'destination' => $targetFolderObject->getIdentifier()]);
1094  $this->‪addMessageToFlashMessageQueue('FileUtility.ExtensionOfFileNameIsNotAllowedIn', [$fileInfo['name'], $targetFolderObject->getIdentifier()]);
1095  } catch (ExistingTargetFileNameException $e) {
1096  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::USER_ERROR, 'No unique filename available in "{destination}"', ['destination' => $targetFolderObject->getIdentifier()]);
1097  $this->‪addMessageToFlashMessageQueue('FileUtility.NoUniqueFilenameAvailableIn', [$targetFolderObject->getIdentifier()]);
1098  } catch (\RuntimeException $e) {
1099  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::USER_ERROR, 'Uploaded file could not be moved. Write-permission problem in "{destination}"? Error: {error}', ['destination' => $targetFolderObject->getIdentifier(), 'error' => $e->getMessage()]);
1100  $this->‪addMessageToFlashMessageQueue('FileUtility.UploadedFileCouldNotBeMoved', [$targetFolderObject->getIdentifier()]);
1101  }
1102  }
1103 
1104  return $resultObjects;
1105  }
1106 
1116  protected function ‪replaceFile(array $cmdArr)
1117  {
1118  $fileObjectToReplace = null;
1119  $uploadPosition = $cmdArr['data'];
1120  $fileInfo = $_FILES['replace_' . $uploadPosition];
1121  if (empty($fileInfo['name'])) {
1122  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::SYSTEM_ERROR, 'No file was uploaded for replacing');
1123  $this->‪addMessageToFlashMessageQueue('FileUtility.NoFileWasUploadedForReplacing');
1124  return false;
1125  }
1126 
1127  $keepFileName = (bool)($cmdArr['keepFilename'] ?? false);
1128  $resultObjects = [];
1129 
1130  try {
1131  $fileObjectToReplace = $this->‪getFileObject($cmdArr['uid']);
1132  $folder = $fileObjectToReplace->getParentFolder();
1133  $resourceStorage = $fileObjectToReplace->getStorage();
1134 
1135  $fileObject = $resourceStorage->addUploadedFile($fileInfo, $folder, $fileObjectToReplace->getName(), ‪DuplicationBehavior::REPLACE);
1136 
1137  // Check if there is a file that is going to be uploaded that has a different name as the replacing one
1138  // but exists in that folder as well.
1139  // rename to another name, but check if the name is already given
1140  if ($keepFileName === false) {
1141  // if a file with the same name already exists, we need to change it to _01 etc.
1142  // if the file does not exist, we can do a simple rename
1143  $resourceStorage->moveFile($fileObject, $folder, $fileInfo['name'], ‪DuplicationBehavior::RENAME);
1144  }
1145 
1146  $resultObjects[] = $fileObject;
1147  $this->internalUploadMap[$uploadPosition] = $fileObject->getCombinedIdentifier();
1148 
1149  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::MESSAGE, 'Replacing file "{identifier}" to "{destination}"', ['identifier' => $fileInfo['name'], 'destination' => $fileObjectToReplace->getIdentifier()]);
1150  $this->‪addMessageToFlashMessageQueue('FileUtility.ReplacingFileTo', [$fileInfo['name'], $fileObjectToReplace->getIdentifier()], ContextualFeedbackSeverity::OK);
1151  } catch (InsufficientFileWritePermissionsException $e) {
1152  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::USER_ERROR, 'You are not allowed to override "{destination}"', ['destination' => $fileInfo['name']]);
1153  $this->‪addMessageToFlashMessageQueue('FileUtility.YouAreNotAllowedToOverride', [$fileInfo['name']]);
1154  } catch (UploadException $e) {
1155  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::SYSTEM_ERROR, 'The upload has failed, no uploaded file found');
1156  $this->‪addMessageToFlashMessageQueue('FileUtility.TheUploadHasFailedNoUploadedFileFound');
1157  } catch (InsufficientUserPermissionsException $e) {
1158  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::USER_ERROR, 'You are not allowed to upload files');
1159  $this->‪addMessageToFlashMessageQueue('FileUtility.YouAreNotAllowedToUploadFiles');
1160  } catch (UploadSizeException $e) {
1161  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::USER_ERROR, 'The uploaded file "{identifier}" exceeds the size-limit', ['identifier' => $fileInfo['name']]);
1162  $this->‪addMessageToFlashMessageQueue('FileUtility.TheUploadedFileExceedsTheSize-limit', [$fileInfo['name']]);
1163  } catch (InsufficientFolderWritePermissionsException $e) {
1164  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::USER_ERROR, 'Destination path "{destination}" was not within your mountpoints', ['destination' => $fileObjectToReplace->getIdentifier()]);
1165  $this->‪addMessageToFlashMessageQueue('FileUtility.DestinationPathWasNotWithinYourMountpoints', [$fileObjectToReplace->getIdentifier()]);
1166  } catch (IllegalFileExtensionException $e) {
1167  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::USER_ERROR, 'Extension of file name "{identifier}" is not allowed in "{destination}"', ['identifier' => $fileInfo['name'], 'destination' => $fileObjectToReplace->getIdentifier()]);
1168  $this->‪addMessageToFlashMessageQueue('FileUtility.ExtensionOfFileNameIsNotAllowedIn', [$fileInfo['name'], $fileObjectToReplace->getIdentifier()]);
1169  } catch (ExistingTargetFileNameException $e) {
1170  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::USER_ERROR, 'No unique filename available in "{destination}"', ['destination' => $fileObjectToReplace->getIdentifier()]);
1171  $this->‪addMessageToFlashMessageQueue('FileUtility.NoUniqueFilenameAvailableIn', [$fileObjectToReplace->getIdentifier()]);
1172  } catch (\RuntimeException $e) {
1173  throw $e;
1174  }
1175  return $resultObjects;
1176  }
1177 
1181  protected function ‪addFlashMessage(‪FlashMessage $flashMessage)
1182  {
1183  $flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class);
1184 
1185  $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
1186  $defaultFlashMessageQueue->enqueue($flashMessage);
1187  }
1194  protected function ‪getIndexer(‪ResourceStorage $storage)
1195  {
1196  return GeneralUtility::makeInstance(Indexer::class, $storage);
1197  }
1199  protected function ‪getBackendUser(): ‪BackendUserAuthentication
1200  {
1201  return ‪$GLOBALS['BE_USER'];
1202  }
1203 
1204  protected function ‪getLanguageService(): ‪LanguageService
1205  {
1206  return ‪$GLOBALS['LANG'];
1207  }
1208 }
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\folderHasFilesInUse
‪bool folderHasFilesInUse(Folder $folder)
Definition: ExtendedFileUtility.php:496
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\func_delete
‪bool func_delete(array $cmds)
Definition: ExtendedFileUtility.php:335
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\addFlashMessage
‪addFlashMessage(FlashMessage $flashMessage)
Definition: ExtendedFileUtility.php:1175
‪TYPO3\CMS\Core\Resource\Exception\InsufficientFileWritePermissionsException
Definition: InsufficientFileWritePermissionsException.php:22
‪TYPO3\CMS\Core\Resource\Exception\InsufficientUserPermissionsException
Definition: InsufficientUserPermissionsException.php:24
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\getExistingFilesConflictMode
‪string getExistingFilesConflictMode()
Definition: ExtendedFileUtility.php:138
‪TYPO3\CMS\Core\Database\Connection\PARAM_INT
‪const PARAM_INT
Definition: Connection.php:46
‪TYPO3\CMS\Core\Resource\Exception\ExistingTargetFolderException
Definition: ExistingTargetFolderException.php:24
‪TYPO3\CMS\Core\Resource\DuplicationBehavior
Definition: DuplicationBehavior.php:24
‪TYPO3\CMS\Core\Resource\DuplicationBehavior\CANCEL
‪const CANCEL
Definition: DuplicationBehavior.php:46
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\setExistingFilesConflictMode
‪setExistingFilesConflictMode($existingFilesConflictMode)
Definition: ExtendedFileUtility.php:149
‪TYPO3\CMS\Core\Resource\Exception\InsufficientFolderAccessPermissionsException
Definition: InsufficientFolderAccessPermissionsException.php:24
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\getLanguageService
‪getLanguageService()
Definition: ExtendedFileUtility.php:1198
‪TYPO3\CMS\Core\Utility\File\BasicFileUtility
Definition: BasicFileUtility.php:37
‪TYPO3\CMS\Core\Exception
Definition: Exception.php:22
‪TYPO3\CMS\Core\Resource\Index\Indexer
Definition: Indexer.php:34
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\getFileObject
‪File Folder getFileObject($identifier)
Definition: ExtendedFileUtility.php:583
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\processData
‪mixed processData()
Definition: ExtendedFileUtility.php:198
‪TYPO3\CMS\Core\Resource\Folder\FILTER_MODE_USE_OWN_AND_STORAGE_FILTERS
‪const FILTER_MODE_USE_OWN_AND_STORAGE_FILTERS
Definition: Folder.php:69
‪TYPO3\CMS\Core\Resource\Exception\ExistingTargetFileNameException
Definition: ExistingTargetFileNameException.php:24
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\func_edit
‪bool func_edit($cmds)
Definition: ExtendedFileUtility.php:958
‪TYPO3\CMS\Core\Resource\Index\Indexer\updateIndexEntry
‪updateIndexEntry(File $fileObject)
Definition: Indexer.php:92
‪TYPO3\CMS\Core\SysLog\Action\File
Definition: File.php:24
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\addMessageToFlashMessageQueue
‪addMessageToFlashMessageQueue($localizationKey, array $replaceMarkers=[], ContextualFeedbackSeverity $severity=ContextualFeedbackSeverity::ERROR)
Definition: ExtendedFileUtility.php:306
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\getBackendUser
‪getBackendUser()
Definition: ExtendedFileUtility.php:1193
‪TYPO3\CMS\Core\Resource\Exception\IllegalFileExtensionException
Definition: IllegalFileExtensionException.php:24
‪TYPO3\CMS\Core\Resource\Exception\InsufficientFileAccessPermissionsException
Definition: InsufficientFileAccessPermissionsException.php:24
‪TYPO3\CMS\Core\Resource\Exception\InvalidTargetFolderException
Definition: InvalidTargetFolderException.php:24
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\replaceFile
‪array bool replaceFile(array $cmdArr)
Definition: ExtendedFileUtility.php:1110
‪TYPO3\CMS\Core\Resource\Exception\UploadException
Definition: UploadException.php:22
‪TYPO3\CMS\Core\Type\ContextualFeedbackSeverity
‪ContextualFeedbackSeverity
Definition: ContextualFeedbackSeverity.php:25
‪TYPO3\CMS\Core\Type\Enumeration\cast
‪static static cast($value)
Definition: Enumeration.php:186
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility
Definition: ExtendedFileUtility.php:77
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\func_upload
‪File[] bool func_upload($cmds)
Definition: ExtendedFileUtility.php:1028
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\$fileFactory
‪TYPO3 CMS Core Resource ResourceFactory $fileFactory
Definition: ExtendedFileUtility.php:131
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\setActionPermissions
‪setActionPermissions(array $permissions=[])
Definition: ExtendedFileUtility.php:184
‪TYPO3\CMS\Core\Resource\Exception\UploadSizeException
Definition: UploadSizeException.php:22
‪TYPO3\CMS\Core\Resource\Folder
Definition: Folder.php:37
‪TYPO3\CMS\Core\Resource\ResourceFactory
Definition: ResourceFactory.php:41
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\$existingFilesConflictMode
‪DuplicationBehavior $existingFilesConflictMode
Definition: ExtendedFileUtility.php:83
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\func_move
‪TYPO3 CMS Core Resource File false func_move($cmds)
Definition: ExtendedFileUtility.php:698
‪TYPO3\CMS\Core\Resource\Exception\ResourceDoesNotExistException
Definition: ResourceDoesNotExistException.php:24
‪TYPO3\CMS\Core\Resource\File
Definition: File.php:26
‪TYPO3\CMS\Core\Resource\DuplicationBehavior\RENAME
‪const RENAME
Definition: DuplicationBehavior.php:32
‪TYPO3\CMS\Core\SysLog\Error
Definition: Error.php:24
‪TYPO3\CMS\Core\Resource\Exception\InvalidFileException
Definition: InvalidFileException.php:24
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\func_newfile
‪string func_newfile($cmds)
Definition: ExtendedFileUtility.php:913
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:64
‪TYPO3\CMS\Core\Utility\File
Definition: BasicFileUtility.php:18
‪TYPO3\CMS\Core\Resource\Event\AfterFileCommandProcessedEvent
Definition: AfterFileCommandProcessedEvent.php:26
‪TYPO3\CMS\Core\Resource\Folder\getFiles
‪TYPO3 CMS Core Resource File[] getFiles($start=0, $numberOfItems=0, $filterMode=self::FILTER_MODE_USE_OWN_AND_STORAGE_FILTERS, $recursive=false, $sort='', $sortRev=false)
Definition: Folder.php:201
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\getIndexer
‪TYPO3 CMS Core Resource Index Indexer getIndexer(ResourceStorage $storage)
Definition: ExtendedFileUtility.php:1188
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\$flashMessages
‪array $flashMessages
Definition: ExtendedFileUtility.php:121
‪TYPO3\CMS\Core\Resource\AbstractFile\getUid
‪return MathUtility::canBeInterpretedAsInteger($size) ?(int) $size int getUid()
Definition: AbstractFile.php:188
‪TYPO3\CMS\Core\Resource\Exception
Definition: Exception.php:22
‪TYPO3\CMS\Core\Database\Connection
Definition: Connection.php:35
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\func_copy
‪TYPO3 CMS Core Resource File false func_copy($cmds)
Definition: ExtendedFileUtility.php:608
‪TYPO3\CMS\Core\Type\Enumeration\getConstants
‪static array getConstants($include_default=false)
Definition: Enumeration.php:170
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\func_newfolder
‪Folder false func_newfolder($cmds)
Definition: ExtendedFileUtility.php:871
‪TYPO3\CMS\Core\Resource\ResourceStorage
Definition: ResourceStorage.php:127
‪TYPO3\CMS\Core\Messaging\FlashMessage
Definition: FlashMessage.php:27
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\start
‪start($fileCmds)
Definition: ExtendedFileUtility.php:170
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\$fileCmdMap
‪array $fileCmdMap
Definition: ExtendedFileUtility.php:125
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Core\Type\Exception\InvalidEnumerationValueException
Definition: InvalidEnumerationValueException.php:24
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\$internalUploadMap
‪array $internalUploadMap
Definition: ExtendedFileUtility.php:115
‪TYPO3\CMS\Core\Resource\Exception\InsufficientFolderWritePermissionsException
Definition: InsufficientFolderWritePermissionsException.php:22
‪TYPO3\CMS\Core\Utility\Exception\NotImplementedMethodException
Definition: NotImplementedMethodException.php:27
‪TYPO3\CMS\Core\Resource\DuplicationBehavior\REPLACE
‪const REPLACE
Definition: DuplicationBehavior.php:39
‪TYPO3\CMS\Core\Http\fromRequest
‪@ fromRequest
Definition: ApplicationType.php:67
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:46
‪TYPO3\CMS\Core\Database\ConnectionPool
Definition: ConnectionPool.php:51
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\writeLog
‪writeLog(int $action, int $severity, string $message, array $context=[])
Definition: ExtendedFileUtility.php:291
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:51
‪TYPO3\CMS\Core\Resource\Exception\FileOperationErrorException
Definition: FileOperationErrorException.php:22
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\func_rename
‪TYPO3 CMS Core Resource File func_rename($cmds)
Definition: ExtendedFileUtility.php:791
‪TYPO3\CMS\Core\Resource\Exception\NotInMountPointException
Definition: NotInMountPointException.php:24
‪TYPO3\CMS\Core\Resource\Exception
Definition: AbstractFileOperationException.php:16
‪TYPO3\CMS\Core\Messaging\FlashMessageService
Definition: FlashMessageService.php:27
‪TYPO3\CMS\Core\Resource\Exception\InvalidFileNameException
Definition: InvalidFileNameException.php:24
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\transformFileReferenceToRecordReference
‪array transformFileReferenceToRecordReference(array $referenceRecord)
Definition: ExtendedFileUtility.php:549
‪TYPO3\CMS\Webhooks\Message\$identifier
‪identifier readonly string $identifier
Definition: FileAddedMessage.php:37
‪TYPO3\CMS\Core\SysLog\Type
Definition: Type.php:28
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\$actionPerms
‪array $actionPerms
Definition: ExtendedFileUtility.php:91
‪TYPO3\CMS\Core\Http\ApplicationType
‪ApplicationType
Definition: ApplicationType.php:56