‪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;
60 
76 {
81 
89  public ‪$actionPerms = [
90  // File permissions
91  'addFile' => false,
92  'readFile' => false,
93  'writeFile' => false,
94  'copyFile' => false,
95  'moveFile' => false,
96  'renameFile' => false,
97  'deleteFile' => false,
98  // Folder permissions
99  'addFolder' => false,
100  'readFolder' => false,
101  'writeFolder' => false,
102  'copyFolder' => false,
103  'moveFolder' => false,
104  'renameFolder' => false,
105  'deleteFolder' => false,
106  'recursivedeleteFolder' => false,
107  ];
108 
114  public ‪$internalUploadMap = [];
115 
121  protected ‪$flashMessages = [];
122 
126  protected ‪$fileCmdMap;
127 
133  protected ‪$fileFactory;
134 
138  public function ‪getExistingFilesConflictMode(): string
139  {
140  return $this->existingFilesConflictMode->value;
141  }
142 
147  {
148  $this->existingFilesConflictMode = ‪$existingFilesConflictMode;
149  }
150 
156  public function ‪start($fileCmds)
157  {
158  // Initialize Object Factory
159  $this->fileFactory = GeneralUtility::makeInstance(ResourceFactory::class);
160  // Initializing file processing commands:
161  $this->fileCmdMap = $fileCmds;
162  }
163 
170  public function ‪setActionPermissions(array $permissions = [])
171  {
172  if (empty($permissions)) {
173  $permissions = $this->‪getBackendUser()->getFilePermissions();
174  }
175  $this->actionPerms = $permissions;
176  }
177 
184  public function ‪processData()
185  {
186  $result = [];
187  if (is_array($this->fileCmdMap)) {
188  // Check if there were uploads expected, but no one made
189  if ($this->fileCmdMap['upload'] ?? false) {
190  $uploads = $this->fileCmdMap['upload'];
191  foreach ($uploads as $upload) {
192  if (empty($_FILES['upload_' . $upload['data']]['name'])
193  || (
194  is_array($_FILES['upload_' . $upload['data']]['name'])
195  && empty($_FILES['upload_' . $upload['data']]['name'][0])
196  )
197  ) {
198  unset($this->fileCmdMap['upload'][$upload['data']]);
199  }
200  }
201  if (empty($this->fileCmdMap['upload'])) {
202  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::USER_ERROR, 'No file was uploaded');
203  $this->‪addMessageToFlashMessageQueue('FileUtility.NoFileWasUploaded');
204  }
205  }
206 
207  // Check if there were new folder names expected, but non given
208  if ($this->fileCmdMap['newfolder'] ?? false) {
209  foreach ($this->fileCmdMap['newfolder'] as $key => $cmdArr) {
210  if ((string)($cmdArr['data'] ?? '') === '') {
211  unset($this->fileCmdMap['newfolder'][$key]);
212  }
213  }
214  if (empty($this->fileCmdMap['newfolder'])) {
215  $this->‪writeLog(SystemLogFileAction::NEW_FOLDER, SystemLogErrorClassification::USER_ERROR, 'No name for new folder given');
216  $this->‪addMessageToFlashMessageQueue('FileUtility.NoNameForNewFolderGiven');
217  }
218  }
219 
220  // Traverse each set of actions
221  foreach ($this->fileCmdMap as $action => $actionData) {
222  // Traverse all action data. More than one file might be affected at the same time.
223  if (is_array($actionData)) {
224  $result[$action] = [];
225  // We reset the array keys of $actionData to keep track of the corresponding
226  // result, while not changing the previous behaviour of $result[$action][].
227  foreach (array_values($actionData) as $key => $cmdArr) {
228  // Clear file stats
229  clearstatcache();
230  // Branch out based on command:
231  switch ($action) {
232  case 'delete':
233  $result[$action][$key] = $this->‪func_delete($cmdArr);
234  break;
235  case 'copy':
236  $result[$action][$key] = $this->‪func_copy($cmdArr);
237  break;
238  case 'move':
239  $result[$action][$key] = $this->‪func_move($cmdArr);
240  break;
241  case 'rename':
242  $result[$action][$key] = $this->‪func_rename($cmdArr);
243  break;
244  case 'newfolder':
245  $result[$action][$key] = $this->‪func_newfolder($cmdArr);
246  break;
247  case 'newfile':
248  $result[$action][$key] = $this->‪func_newfile($cmdArr);
249  break;
250  case 'editfile':
251  $result[$action][$key] = $this->‪func_edit($cmdArr);
252  break;
253  case 'upload':
254  $result[$action][$key] = $this->‪func_upload($cmdArr);
255  break;
256  case 'replace':
257  $result[$action][$key] = $this->‪replaceFile($cmdArr);
258  break;
259  }
260 
261  GeneralUtility::makeInstance(EventDispatcherInterface::class)->dispatch(
262  new AfterFileCommandProcessedEvent([$action => $cmdArr], $result[$action][$key], $this->existingFilesConflictMode->value)
263  );
264  }
265  }
266  }
267  }
268  return $result;
269  }
270 
277  protected function ‪writeLog(int $action, int $severity, string $message, array $context = []): void
278  {
279  if (!is_object($this->‪getBackendUser())) {
280  return;
281  }
282  $this->‪getBackendUser()->writelog(SystemLogType::FILE, $action, $severity, 0, $message, $context);
283  }
284 
292  protected function ‪addMessageToFlashMessageQueue($localizationKey, array $replaceMarkers = [], ‪ContextualFeedbackSeverity $severity = ContextualFeedbackSeverity::ERROR)
293  {
294  if ((‪$GLOBALS['TYPO3_REQUEST'] ?? null) instanceof ServerRequestInterface
295  && ‪ApplicationType::fromRequest(‪$GLOBALS['TYPO3_REQUEST'])->isBackend()
296  ) {
297  $label = $this->‪getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/fileMessages.xlf:' . $localizationKey);
298  $message = vsprintf($label, $replaceMarkers);
299  $flashMessage = GeneralUtility::makeInstance(
300  FlashMessage::class,
301  $message,
302  '',
303  $severity,
304  true
305  );
306  $this->‪addFlashMessage($flashMessage);
307  }
308  }
309 
310  /*************************************
311  *
312  * File operation functions
313  *
314  **************************************/
321  public function ‪func_delete(array $cmds)
322  {
323  $result = false;
324  // Example identifier for $cmds['data'] => "4:mypath/tomyfolder/myfile.jpg"
325  // for backwards compatibility: the combined file identifier was the path+filename
326  try {
327  $fileObject = $this->‪getFileObject($cmds['data']);
328  } catch (ResourceDoesNotExistException $e) {
329  $flashMessage = GeneralUtility::makeInstance(
330  FlashMessage::class,
331  sprintf(
332  $this->‪getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:message.description.fileNotFound'),
333  $cmds['data']
334  ),
335  $this->‪getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:message.header.fileNotFound'),
336  ContextualFeedbackSeverity::ERROR,
337  true
338  );
339  $this->‪addFlashMessage($flashMessage);
340 
341  return false;
342  }
343  // checks to delete the file
344  if ($fileObject instanceof File) {
345  // check if the file still has references
346  // Exclude sys_file_metadata records as these are no use references
347  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('sys_refindex');
348  $refIndexRecords = $queryBuilder
349  ->select('tablename', 'recuid', 'ref_uid')
350  ->from('sys_refindex')
351  ->where(
352  $queryBuilder->expr()->eq(
353  'ref_table',
354  $queryBuilder->createNamedParameter('sys_file')
355  ),
356  $queryBuilder->expr()->eq(
357  'ref_uid',
358  $queryBuilder->createNamedParameter($fileObject->getUid(), ‪Connection::PARAM_INT)
359  ),
360  $queryBuilder->expr()->neq(
361  'tablename',
362  $queryBuilder->createNamedParameter('sys_file_metadata')
363  )
364  )
365  ->executeQuery()
366  ->fetchAllAssociative();
367  $deleteFile = true;
368  if (!empty($refIndexRecords)) {
369  $shortcutContent = [];
370  $brokenReferences = [];
371 
372  foreach ($refIndexRecords as $fileReferenceRow) {
373  if ($fileReferenceRow['tablename'] === 'sys_file_reference') {
374  $row = $this->‪transformFileReferenceToRecordReference($fileReferenceRow);
375  $shortcutRecord = BackendUtility::getRecord($row['tablename'], $row['recuid']);
376 
377  if ($shortcutRecord) {
378  $shortcutContent[] = '[record:' . $row['tablename'] . ':' . $row['recuid'] . ']';
379  } else {
380  $brokenReferences[] = $fileReferenceRow['ref_uid'];
381  }
382  } else {
383  $shortcutContent[] = '[record:' . $fileReferenceRow['tablename'] . ':' . $fileReferenceRow['recuid'] . ']';
384  }
385  }
386  if (!empty($brokenReferences)) {
387  // render a message that the file has broken references
388  $flashMessage = GeneralUtility::makeInstance(
389  FlashMessage::class,
390  sprintf($this->‪getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:message.description.fileHasBrokenReferences'), count($brokenReferences)),
391  $this->‪getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:message.header.fileHasBrokenReferences'),
392  ContextualFeedbackSeverity::INFO,
393  true
394  );
395  $this->‪addFlashMessage($flashMessage);
396  }
397  if (!empty($shortcutContent)) {
398  // render a message that the file could not be deleted
399  $flashMessage = GeneralUtility::makeInstance(
400  FlashMessage::class,
401  sprintf($this->‪getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:message.description.fileNotDeletedHasReferences'), $fileObject->getName()) . ' ' . implode(', ', $shortcutContent),
402  $this->‪getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:message.header.fileNotDeletedHasReferences'),
403  ContextualFeedbackSeverity::WARNING,
404  true
405  );
406  $this->‪addFlashMessage($flashMessage);
407  $deleteFile = false;
408  }
409  }
410 
411  if ($deleteFile) {
412  try {
413  $result = $fileObject->delete();
414 
415  // show the user that the file was deleted
416  $flashMessage = GeneralUtility::makeInstance(
417  FlashMessage::class,
418  sprintf($this->‪getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:message.description.fileDeleted'), $fileObject->getName()),
419  $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:message.header.fileDeleted'),
420  ContextualFeedbackSeverity::OK,
421  true
422  );
423  $this->‪addFlashMessage($flashMessage);
424  // Log success
425  $this->‪writeLog(SystemLogFileAction::DELETE, SystemLogErrorClassification::MESSAGE, 'File "{identifier}" deleted', ['identifier' => $fileObject->getIdentifier()]);
426  } catch (InsufficientFileAccessPermissionsException $e) {
427  $this->‪writeLog(SystemLogFileAction::DELETE, SystemLogErrorClassification::USER_ERROR, 'You are not allowed to access the file "{identifier}"', ['identifier' => $fileObject->getIdentifier()]);
428  $this->‪addMessageToFlashMessageQueue('FileUtility.YouAreNotAllowedToAccessTheFile', [$fileObject->getIdentifier()]);
429  } catch (NotInMountPointException $e) {
430  $this->‪writeLog(SystemLogFileAction::DELETE, SystemLogErrorClassification::USER_ERROR, 'Target "{identifier}" was not within your mountpoints"', ['identifier' => $fileObject->getIdentifier()]);
431  $this->‪addMessageToFlashMessageQueue('FileUtility.TargetWasNotWithinYourMountpoints', [$fileObject->getIdentifier()]);
432  } catch (\RuntimeException $e) {
433  $this->‪writeLog(SystemLogFileAction::DELETE, SystemLogErrorClassification::USER_ERROR, 'Could not delete file "{identifier}". Write-permission problem?', ['identifier' => $fileObject->getIdentifier()]);
434  $this->‪addMessageToFlashMessageQueue('FileUtility.CouldNotDeleteFile', [$fileObject->getIdentifier()]);
435  }
436  }
437  } else {
439  if (!$this->‪folderHasFilesInUse($fileObject)) {
440  try {
441  $result = $fileObject->delete(true);
442  if ($result) {
443  // notify the user that the folder was deleted
444  $flashMessage = GeneralUtility::makeInstance(
445  FlashMessage::class,
446  sprintf($this->‪getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:message.description.folderDeleted'), $fileObject->getName()),
447  $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:message.header.folderDeleted'),
448  ContextualFeedbackSeverity::OK,
449  true
450  );
451  $this->‪addFlashMessage($flashMessage);
452  // Log success
453  $this->‪writeLog(SystemLogFileAction::DELETE, SystemLogErrorClassification::MESSAGE, 'Directory "{identifier}" deleted', ['identifier' => $fileObject->getIdentifier()]);
454  }
455  } catch (InsufficientUserPermissionsException $e) {
456  $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()]);
457  $this->‪addMessageToFlashMessageQueue('FileUtility.CouldNotDeleteDirectory', [$fileObject->getIdentifier()]);
458  } catch (InsufficientFolderAccessPermissionsException $e) {
459  $this->‪writeLog(SystemLogFileAction::DELETE, SystemLogErrorClassification::USER_ERROR, 'You are not allowed to access the directory "{identifier}"', ['identifier' => $fileObject->getIdentifier()]);
460  $this->‪addMessageToFlashMessageQueue('FileUtility.YouAreNotAllowedToAccessTheDirectory', [$fileObject->getIdentifier()]);
461  } catch (NotInMountPointException $e) {
462  $this->‪writeLog(SystemLogFileAction::DELETE, SystemLogErrorClassification::USER_ERROR, 'Target "{identifier}" was not within your mountpoints', ['identifier' => $fileObject->getIdentifier()]);
463  $this->‪addMessageToFlashMessageQueue('FileUtility.TargetWasNotWithinYourMountpoints', [$fileObject->getIdentifier()]);
464  } catch (FileOperationErrorException $e) {
465  $this->‪writeLog(SystemLogFileAction::DELETE, SystemLogErrorClassification::USER_ERROR, 'Could not delete directory "{identifier}". Write-permission problem?', ['identifier' => $fileObject->getIdentifier()]);
466  $this->‪addMessageToFlashMessageQueue('FileUtility.CouldNotDeleteDirectory', [$fileObject->getIdentifier()]);
467  }
468  }
469  }
470 
471  return $result;
472  }
473 
482  public function ‪folderHasFilesInUse(Folder $folder)
483  {
484  $files = $folder->getFiles(0, 0, ‪Folder::FILTER_MODE_USE_OWN_AND_STORAGE_FILTERS, true);
485  if (empty($files)) {
486  return false;
487  }
488 
490  $fileUids = [];
491  foreach ($files as $file) {
492  $fileUids[] = $file->getUid();
493  }
494 
495  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('sys_refindex');
496  $numberOfReferences = $queryBuilder
497  ->count('hash')
498  ->from('sys_refindex')
499  ->where(
500  $queryBuilder->expr()->eq(
501  'ref_table',
502  $queryBuilder->createNamedParameter('sys_file')
503  ),
504  $queryBuilder->expr()->in(
505  'ref_uid',
506  $queryBuilder->createNamedParameter($fileUids, ‪Connection::PARAM_INT_ARRAY)
507  ),
508  $queryBuilder->expr()->neq(
509  'tablename',
510  $queryBuilder->createNamedParameter('sys_file_metadata')
511  )
512  )->executeQuery()->fetchOne();
513 
514  $hasReferences = $numberOfReferences > 0;
515  if ($hasReferences) {
516  $flashMessage = GeneralUtility::makeInstance(
517  FlashMessage::class,
518  $this->‪getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:message.description.folderNotDeletedHasFilesWithReferences'),
519  $this->‪getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:message.header.folderNotDeletedHasFilesWithReferences'),
520  ContextualFeedbackSeverity::WARNING,
521  true
522  );
523  $this->‪addFlashMessage($flashMessage);
524  }
525 
526  return $hasReferences;
527  }
528 
535  protected function ‪transformFileReferenceToRecordReference(array $referenceRecord)
536  {
537  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('sys_refindex');
538  $queryBuilder->getRestrictions()->removeAll();
539  $fileReference = $queryBuilder
540  ->select('uid_foreign', 'tablenames', 'fieldname', 'sorting_foreign')
541  ->from('sys_file_reference')
542  ->where(
543  $queryBuilder->expr()->eq(
544  'uid',
545  $queryBuilder->createNamedParameter($referenceRecord['recuid'], ‪Connection::PARAM_INT)
546  )
547  )
548  ->executeQuery()
549  ->fetchAssociative();
550 
551  return [
552  'recuid' => $fileReference['uid_foreign'],
553  'tablename' => $fileReference['tablenames'],
554  'field' => $fileReference['fieldname'],
555  'flexpointer' => '',
556  'softref_key' => '',
557  'sorting' => $fileReference['sorting_foreign'],
558  ];
559  }
560 
564  protected function ‪getFileObject(string ‪$identifier)
565  {
566  $object = $this->fileFactory->retrieveFileOrFolderObject(‪$identifier);
567  if ($object === null) {
568  throw new ‪InvalidFileException('The item ' . ‪$identifier . ' was not a file or directory', 1320122453);
569  }
570  if ($object->getStorage()->isFallbackStorage()) {
571  throw new InsufficientFileAccessPermissionsException('You are not allowed to access files outside your storages', 1375889830);
572  }
573  return $object;
574  }
575 
589  protected function ‪func_copy($cmds)
590  {
591  $sourceFileObject = $this->‪getFileObject($cmds['data']);
593  $targetFolderObject = $this->‪getFileObject($cmds['target']);
594  // Basic check
595  if (!$targetFolderObject instanceof Folder) {
596  $this->‪writeLog(SystemLogFileAction::COPY, SystemLogErrorClassification::SYSTEM_ERROR, 'Destination "{identifier}" was not a directory', ['identifier' => $cmds['target']]);
597  $this->‪addMessageToFlashMessageQueue('FileUtility.DestinationWasNotADirectory', [$cmds['target']]);
598  return false;
599  }
600  // If this is TRUE, we append _XX to the file name if
601  $appendSuffixOnConflict = (string)($cmds['altName'] ?? '');
602  $resultObject = null;
603  $conflictMode = $appendSuffixOnConflict !== '' ? DuplicationBehavior::RENAME : DuplicationBehavior::CANCEL;
604  // Copying the file
605  if ($sourceFileObject instanceof File) {
606  try {
607  $resultObject = $sourceFileObject->copyTo($targetFolderObject, null, $conflictMode);
608  } catch (InsufficientUserPermissionsException $e) {
609  $this->‪writeLog(SystemLogFileAction::COPY, SystemLogErrorClassification::USER_ERROR, 'You are not allowed to copy files');
610  $this->‪addMessageToFlashMessageQueue('FileUtility.YouAreNotAllowedToCopyFiles');
611  } catch (InsufficientFileAccessPermissionsException $e) {
612  $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()]);
613  $this->‪addMessageToFlashMessageQueue('FileUtility.CouldNotAccessAllNecessaryResources', [$sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
614  } catch (IllegalFileExtensionException $e) {
615  $this->‪writeLog(SystemLogFileAction::COPY, SystemLogErrorClassification::USER_ERROR, 'Extension of file name "{identifier}" is not allowed in "{destination}"', ['identifier' => $sourceFileObject->getIdentifier(), 'destination' => $targetFolderObject->getIdentifier()]);
616  $this->‪addMessageToFlashMessageQueue('FileUtility.ExtensionOfFileNameIsNotAllowedIn', [$sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
617  } catch (ExistingTargetFileNameException $e) {
618  $this->‪writeLog(SystemLogFileAction::COPY, SystemLogErrorClassification::USER_ERROR, 'File "{identifier}" already exists in folder "{destination}"', ['identifier' => $sourceFileObject->getIdentifier(), 'destination' => $targetFolderObject->getIdentifier()]);
619  $this->‪addMessageToFlashMessageQueue('FileUtility.FileAlreadyExistsInFolder', [$sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
620  } catch (NotImplementedMethodException $e) {
621  $this->‪writeLog(SystemLogFileAction::MOVE, SystemLogErrorClassification::USER_ERROR, 'The function to copy a file between storages is not yet implemented');
622  $this->‪addMessageToFlashMessageQueue('FileUtility.TheFunctionToCopyAFileBetweenStoragesIsNotYetImplemented');
623  } catch (\RuntimeException $e) {
624  $this->‪writeLog(SystemLogFileAction::COPY, SystemLogErrorClassification::SYSTEM_ERROR, 'File "{identifier}" was not copied to "{destination}" - Write-permission problem?', ['identifier' => $sourceFileObject->getIdentifier(), 'destination' => $targetFolderObject->getIdentifier()]);
625  $this->‪addMessageToFlashMessageQueue('FileUtility.FileWasNotCopiedTo', [$sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
626  }
627  if ($resultObject) {
628  $this->‪writeLog(SystemLogFileAction::COPY, SystemLogErrorClassification::MESSAGE, 'File "{identifier}" copied to "{destination}"', ['identifier' => $sourceFileObject->getIdentifier(), 'destination' => $resultObject->getIdentifier()]);
629  $this->‪addMessageToFlashMessageQueue('FileUtility.FileCopiedTo', [$sourceFileObject->getIdentifier(), $resultObject->getIdentifier()], ContextualFeedbackSeverity::OK);
630  }
631  } else {
632  // Else means this is a Folder
633  $sourceFolderObject = $sourceFileObject;
634  try {
635  $resultObject = $sourceFolderObject->copyTo($targetFolderObject, null, $conflictMode);
636  } catch (InsufficientUserPermissionsException $e) {
637  $this->‪writeLog(SystemLogFileAction::COPY, SystemLogErrorClassification::USER_ERROR, 'You are not allowed to copy directories');
638  $this->‪addMessageToFlashMessageQueue('FileUtility.YouAreNotAllowedToCopyDirectories');
639  } catch (InsufficientFileAccessPermissionsException $e) {
640  $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()]);
641  $this->‪addMessageToFlashMessageQueue('FileUtility.CouldNotAccessAllNecessaryResources', [$sourceFolderObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
642  } catch (InsufficientFolderAccessPermissionsException $e) {
643  $this->‪writeLog(SystemLogFileAction::COPY, SystemLogErrorClassification::USER_ERROR, 'You don\'t have full access to the destination directory "{destination}"', ['destination' => $targetFolderObject->getIdentifier()]);
644  $this->‪addMessageToFlashMessageQueue('FileUtility.YouDontHaveFullAccessToTheDestinationDirectory', [$targetFolderObject->getIdentifier()]);
645  } catch (InvalidTargetFolderException $e) {
646  $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()]);
647  $this->‪addMessageToFlashMessageQueue('FileUtility.CannotCopyFolderIntoTargetFolderBecauseTheTargetFolderIsAlreadyWithinTheFolderToBeCopied', [$sourceFolderObject->getName(), $targetFolderObject->getIdentifier()]);
648  } catch (ExistingTargetFolderException $e) {
649  $this->‪writeLog(SystemLogFileAction::COPY, SystemLogErrorClassification::USER_ERROR, 'Target "{destination}" already exists', ['destination' => $targetFolderObject->getIdentifier()]);
650  $this->‪addMessageToFlashMessageQueue('FileUtility.TargetAlreadyExists', [$targetFolderObject->getIdentifier()]);
651  } catch (NotImplementedMethodException $e) {
652  $this->‪writeLog(SystemLogFileAction::MOVE, SystemLogErrorClassification::USER_ERROR, 'The function to copy a folder between storages is not yet implemented');
653  $this->‪addMessageToFlashMessageQueue('FileUtility.TheFunctionToCopyAFolderBetweenStoragesIsNotYetImplemented');
654  } catch (\RuntimeException $e) {
655  $this->‪writeLog(SystemLogFileAction::COPY, SystemLogErrorClassification::SYSTEM_ERROR, 'Directory "{identifier}" was not copied to "{destination}". Write-permission problem?', ['identifier' => $sourceFolderObject->getIdentifier(), 'destination' => $targetFolderObject->getIdentifier()]);
656  $this->‪addMessageToFlashMessageQueue('FileUtility.DirectoryWasNotCopiedTo', [$sourceFolderObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
657  }
658  if ($resultObject) {
659  $this->‪writeLog(SystemLogFileAction::COPY, SystemLogErrorClassification::MESSAGE, 'Directory "{identifier}" copied to "{destination}"', ['identifier' => $sourceFolderObject->getIdentifier(), 'destination' => $targetFolderObject->getIdentifier()]);
660  $this->‪addMessageToFlashMessageQueue('FileUtility.DirectoryCopiedTo', [$sourceFolderObject->getIdentifier(), $targetFolderObject->getIdentifier()], ContextualFeedbackSeverity::OK);
661  }
662  }
663  return $resultObject;
664  }
665 
679  protected function ‪func_move($cmds)
680  {
681  $sourceFileObject = $this->‪getFileObject($cmds['data']);
682  $targetFolderObject = $this->‪getFileObject($cmds['target']);
683  // Basic check
684  if (!$targetFolderObject instanceof Folder) {
685  $this->‪writeLog(SystemLogFileAction::MOVE, SystemLogErrorClassification::SYSTEM_ERROR, 'Destination "{destination}" was not a directory', ['destination' => $cmds['target']]);
686  $this->‪addMessageToFlashMessageQueue('FileUtility.DestinationWasNotADirectory', [$cmds['target']]);
687  return false;
688  }
689  $alternativeName = (string)($cmds['altName'] ?? '');
690  $resultObject = null;
691  // Moving the file
692  if ($sourceFileObject instanceof File) {
693  try {
694  $sourcePath = $sourceFileObject->getIdentifier();
695  if ($alternativeName !== '') {
696  // Don't allow overwriting existing files, but find a new name
697  $resultObject = $sourceFileObject->moveTo($targetFolderObject, $alternativeName, DuplicationBehavior::RENAME);
698  } else {
699  // Don't allow overwriting existing files
700  $resultObject = $sourceFileObject->moveTo($targetFolderObject, null, DuplicationBehavior::CANCEL);
701  }
702  $this->‪writeLog(SystemLogFileAction::MOVE, SystemLogErrorClassification::MESSAGE, 'File "{identifier}" moved to "{destination}"', ['identifier' => $sourcePath, 'destination' => $resultObject->getIdentifier()]);
703  $this->‪addMessageToFlashMessageQueue('FileUtility.FileMovedTo', [$sourcePath, $resultObject->getIdentifier()], ContextualFeedbackSeverity::OK);
704  } catch (InsufficientUserPermissionsException $e) {
705  $this->‪writeLog(SystemLogFileAction::MOVE, SystemLogErrorClassification::USER_ERROR, 'You are not allowed to move files');
706  $this->‪addMessageToFlashMessageQueue('FileUtility.YouAreNotAllowedToMoveFiles');
707  } catch (InsufficientFileAccessPermissionsException $e) {
708  $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()]);
709  $this->‪addMessageToFlashMessageQueue('FileUtility.CouldNotAccessAllNecessaryResources', [$sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
710  } catch (IllegalFileExtensionException $e) {
711  $this->‪writeLog(SystemLogFileAction::MOVE, SystemLogErrorClassification::USER_ERROR, 'Extension of file name "{identifier}" is not allowed in "{destination}"', ['identifier' => $sourceFileObject->getIdentifier(), 'destination' => $targetFolderObject->getIdentifier()]);
712  $this->‪addMessageToFlashMessageQueue('FileUtility.ExtensionOfFileNameIsNotAllowedIn', [$sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
713  } catch (ExistingTargetFileNameException $e) {
714  $this->‪writeLog(SystemLogFileAction::MOVE, SystemLogErrorClassification::USER_ERROR, 'File "{identifier}" already exists in folder "{destination}"', ['identifier' => $sourceFileObject->getIdentifier(), 'destination' => $targetFolderObject->getIdentifier()]);
715  $this->‪addMessageToFlashMessageQueue('FileUtility.FileAlreadyExistsInFolder', [$sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
716  } catch (NotImplementedMethodException $e) {
717  $this->‪writeLog(SystemLogFileAction::MOVE, SystemLogErrorClassification::USER_ERROR, 'The function to move a file between storages is not yet implemented');
718  $this->‪addMessageToFlashMessageQueue('FileUtility.TheFunctionToMoveAFileBetweenStoragesIsNotYetImplemented');
719  } catch (\RuntimeException $e) {
720  $this->‪writeLog(SystemLogFileAction::MOVE, SystemLogErrorClassification::SYSTEM_ERROR, 'File "{identifier}" was not copied to "{destination}". Write-permission problem?', ['identifier' => $sourceFileObject->getIdentifier(), 'destination' => $targetFolderObject->getIdentifier()]);
721  $this->‪addMessageToFlashMessageQueue('FileUtility.FileWasNotCopiedTo', [$sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
722  }
723  } else {
724  // Else means this is a Folder
725  $sourceFolderObject = $sourceFileObject;
726  try {
727  if ($alternativeName !== '') {
728  // Don't allow overwriting existing files, but find a new name
729  $resultObject = $sourceFolderObject->moveTo($targetFolderObject, $alternativeName, DuplicationBehavior::RENAME);
730  } else {
731  // Don't allow overwriting existing files
732  $resultObject = $sourceFolderObject->moveTo($targetFolderObject, null, DuplicationBehavior::RENAME);
733  }
734  $this->‪writeLog(SystemLogFileAction::MOVE, SystemLogErrorClassification::MESSAGE, 'Directory "{identifier}" moved to "{destination}"', ['identifier' => $sourceFolderObject->getIdentifier(), 'destination' => $targetFolderObject->getIdentifier()]);
735  $this->‪addMessageToFlashMessageQueue('FileUtility.DirectoryMovedTo', [$sourceFolderObject->getIdentifier(), $targetFolderObject->getIdentifier()], ContextualFeedbackSeverity::OK);
736  } catch (InsufficientUserPermissionsException $e) {
737  $this->‪writeLog(SystemLogFileAction::MOVE, SystemLogErrorClassification::USER_ERROR, 'You are not allowed to move directories');
738  $this->‪addMessageToFlashMessageQueue('FileUtility.YouAreNotAllowedToMoveDirectories');
739  } catch (InsufficientFileAccessPermissionsException $e) {
740  $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()]);
741  $this->‪addMessageToFlashMessageQueue('FileUtility.CouldNotAccessAllNecessaryResources', [$sourceFolderObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
742  } catch (InsufficientFolderAccessPermissionsException $e) {
743  $this->‪writeLog(SystemLogFileAction::MOVE, SystemLogErrorClassification::USER_ERROR, 'You don\'t have full access to the destination directory "{destination}"', ['destination' => $targetFolderObject->getIdentifier()]);
744  $this->‪addMessageToFlashMessageQueue('FileUtility.YouDontHaveFullAccessToTheDestinationDirectory', [$targetFolderObject->getIdentifier()]);
745  } catch (InvalidTargetFolderException $e) {
746  $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()]);
747  $this->‪addMessageToFlashMessageQueue('FileUtility.CannotMoveFolderIntoTargetFolderBecauseTheTargetFolderIsAlreadyWithinTheFolderToBeMoved', [$sourceFolderObject->getName(), $targetFolderObject->getName()]);
748  } catch (ExistingTargetFolderException $e) {
749  $this->‪writeLog(SystemLogFileAction::MOVE, SystemLogErrorClassification::USER_ERROR, 'Target "{destination}" already exists', ['destination' => $targetFolderObject->getIdentifier()]);
750  $this->‪addMessageToFlashMessageQueue('FileUtility.TargetAlreadyExists', [$targetFolderObject->getIdentifier()]);
751  } catch (NotImplementedMethodException $e) {
752  $this->‪writeLog(SystemLogFileAction::MOVE, SystemLogErrorClassification::USER_ERROR, 'The function to move a folder between storages is not yet implemented');
753  $this->‪addMessageToFlashMessageQueue('FileUtility.TheFunctionToMoveAFolderBetweenStoragesIsNotYetImplemented');
754  } catch (\RuntimeException $e) {
755  $this->‪writeLog(SystemLogFileAction::MOVE, SystemLogErrorClassification::SYSTEM_ERROR, 'Directory "{identifier}" was not moved to "{destination}". Write-permission problem?', ['identifier' => $sourceFolderObject->getIdentifier(), 'destination' => $targetFolderObject->getIdentifier()]);
756  $this->‪addMessageToFlashMessageQueue('FileUtility.DirectoryWasNotMovedTo', [$sourceFolderObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
757  }
758  }
759  return $resultObject;
760  }
761 
773  public function ‪func_rename($cmds)
774  {
775  $sourceFileObject = $this->‪getFileObject($cmds['data']);
776  $sourceFile = $sourceFileObject->getName();
777  $targetFile = $cmds['target'];
778  $resultObject = null;
779  if ($sourceFileObject instanceof File) {
780  try {
781  // Try to rename the File
782  $resultObject = $sourceFileObject->rename($targetFile, $this->existingFilesConflictMode);
783  if ($resultObject->getName() !== $targetFile) {
784  $this->‪writeLog(SystemLogFileAction::RENAME, SystemLogErrorClassification::USER_ERROR, 'File renamed from "{identifier}" to "{destination}". Filename had to be sanitized', ['identifier' => $sourceFile, 'destination' => $targetFile]);
785  $this->‪addMessageToFlashMessageQueue('FileUtility.FileNameSanitized', [$targetFile, $resultObject->getName()], ContextualFeedbackSeverity::WARNING);
786  } else {
787  $this->‪writeLog(SystemLogFileAction::RENAME, SystemLogErrorClassification::MESSAGE, 'File renamed from "{identifier}" to "{destination}"', ['identifier' => $sourceFile, 'destination' => $targetFile]);
788  }
789  if ($sourceFile === $resultObject->getName()) {
790  $this->‪addMessageToFlashMessageQueue('FileUtility.FileRenamedSameName', [$sourceFile], ContextualFeedbackSeverity::INFO);
791  } else {
792  $this->‪addMessageToFlashMessageQueue('FileUtility.FileRenamedFromTo', [$sourceFile, $resultObject->getName()], ContextualFeedbackSeverity::OK);
793  }
794  } catch (InsufficientUserPermissionsException $e) {
795  $this->‪writeLog(SystemLogFileAction::RENAME, SystemLogErrorClassification::USER_ERROR, 'You are not allowed to rename files');
796  $this->‪addMessageToFlashMessageQueue('FileUtility.YouAreNotAllowedToRenameFiles');
797  } catch (IllegalFileExtensionException $e) {
798  $this->‪writeLog(SystemLogFileAction::RENAME, SystemLogErrorClassification::USER_ERROR, 'Extension of file name "{identifier}" or "{destination}" was not allowed', ['identifier' => $sourceFileObject->getName(), 'destination' => $targetFile]);
799  $this->‪addMessageToFlashMessageQueue('FileUtility.ExtensionOfFileNameOrWasNotAllowed', [$sourceFileObject->getName(), $targetFile]);
800  } catch (ExistingTargetFileNameException $e) {
801  $this->‪writeLog(SystemLogFileAction::RENAME, SystemLogErrorClassification::USER_ERROR, 'Destination "{destination}" existed already', ['destination' => $targetFile]);
802  $this->‪addMessageToFlashMessageQueue('FileUtility.DestinationExistedAlready', [$targetFile]);
803  } catch (NotInMountPointException $e) {
804  $this->‪writeLog(SystemLogFileAction::RENAME, SystemLogErrorClassification::USER_ERROR, 'Destination path "{destination}" was not within your mountpoints', ['destination' => $targetFile]);
805  $this->‪addMessageToFlashMessageQueue('FileUtility.DestinationPathWasNotWithinYourMountpoints', [$targetFile]);
806  } catch (\RuntimeException $e) {
807  $this->‪writeLog(SystemLogFileAction::RENAME, SystemLogErrorClassification::USER_ERROR, 'File "{identifier}" was not renamed. Write-permission problem in "{destination}"?', ['identifier' => $sourceFileObject->getName(), 'destination' => $targetFile]);
808  $this->‪addMessageToFlashMessageQueue('FileUtility.FileWasNotRenamed', [$sourceFileObject->getName(), $targetFile]);
809  }
810  } else {
811  // Else means this is a Folder
812  try {
813  // Try to rename the Folder
814  $resultObject = $sourceFileObject->rename($targetFile);
815  $newFolderName = $resultObject->getName();
816  $this->‪writeLog(SystemLogFileAction::RENAME, SystemLogErrorClassification::MESSAGE, 'Directory renamed from "{identifier}" to "{destination}"', ['identifier' => $sourceFile, 'destination' => $targetFile]);
817  if ($sourceFile === $newFolderName) {
818  $this->‪addMessageToFlashMessageQueue('FileUtility.DirectoryRenamedSameName', [$sourceFile], ContextualFeedbackSeverity::INFO);
819  } else {
820  if ($newFolderName === $targetFile) {
821  $this->‪addMessageToFlashMessageQueue('FileUtility.DirectoryRenamedFromTo', [$sourceFile, $newFolderName], ContextualFeedbackSeverity::OK);
822  } else {
823  $this->‪addMessageToFlashMessageQueue('FileUtility.DirectoryRenamedFromToCharReplaced', [$sourceFile, $newFolderName], ContextualFeedbackSeverity::WARNING);
824  }
825  }
826  } catch (InsufficientUserPermissionsException $e) {
827  $this->‪writeLog(SystemLogFileAction::RENAME, SystemLogErrorClassification::USER_ERROR, 'You are not allowed to rename directories');
828  $this->‪addMessageToFlashMessageQueue('FileUtility.YouAreNotAllowedToRenameDirectories');
829  } catch (ExistingTargetFileNameException $e) {
830  $this->‪writeLog(SystemLogFileAction::RENAME, SystemLogErrorClassification::USER_ERROR, 'Destination "{destination}" existed already', ['destination' => $targetFile]);
831  $this->‪addMessageToFlashMessageQueue('FileUtility.DestinationExistedAlready', [$targetFile]);
832  } catch (NotInMountPointException $e) {
833  $this->‪writeLog(SystemLogFileAction::RENAME, SystemLogErrorClassification::USER_ERROR, 'Destination path "{destination}" was not within your mountpoints', ['destination' => $targetFile]);
834  $this->‪addMessageToFlashMessageQueue('FileUtility.DestinationPathWasNotWithinYourMountpoints', [$targetFile]);
835  } catch (\RuntimeException $e) {
836  $this->‪writeLog(SystemLogFileAction::RENAME, SystemLogErrorClassification::USER_ERROR, 'Directory "{identifier}" was not renamed. Write-permission problem in "{destination}"?', ['identifier' => $sourceFileObject->getName(), 'destination' => $targetFile]);
837  $this->‪addMessageToFlashMessageQueue('FileUtility.DirectoryWasNotRenamed', [$sourceFileObject->getName(), $targetFile]);
838  }
839  }
840  return $resultObject;
841  }
842 
853  public function ‪func_newfolder($cmds)
854  {
855  $resultObject = false;
856  $targetFolderObject = $this->‪getFileObject($cmds['target']);
857  if (!$targetFolderObject instanceof Folder) {
858  $this->‪writeLog(SystemLogFileAction::NEW_FOLDER, SystemLogErrorClassification::SYSTEM_ERROR, 'Destination "{destination}" was not a directory', ['destination' => $cmds['target']]);
859  $this->‪addMessageToFlashMessageQueue('FileUtility.DestinationWasNotADirectory', [$cmds['target']]);
860  return false;
861  }
862  $folderName = $cmds['data'];
863  try {
864  $resultObject = $targetFolderObject->createFolder($folderName);
865  $this->‪writeLog(SystemLogFileAction::NEW_FOLDER, SystemLogErrorClassification::MESSAGE, 'Directory "{identifier}" created in "{destination}"', ['identifier' => $folderName, 'destination' => $targetFolderObject->getIdentifier()]);
866  $this->‪addMessageToFlashMessageQueue('FileUtility.DirectoryCreatedIn', [$folderName, $targetFolderObject->getIdentifier()], ContextualFeedbackSeverity::OK);
867  } catch (InvalidFileNameException $e) {
868  $this->‪writeLog(SystemLogFileAction::NEW_FOLDER, SystemLogErrorClassification::USER_ERROR, 'Invalid folder name "{identifier}"', ['identifier' => $folderName]);
869  $this->‪addMessageToFlashMessageQueue('FileUtility.YouAreNotAllowedToCreateDirectories', [$folderName]);
870  } catch (InsufficientFolderWritePermissionsException $e) {
871  $this->‪writeLog(SystemLogFileAction::NEW_FOLDER, SystemLogErrorClassification::USER_ERROR, 'You are not allowed to create directories');
872  $this->‪addMessageToFlashMessageQueue('FileUtility.YouAreNotAllowedToCreateDirectories');
873  } catch (NotInMountPointException $e) {
874  $this->‪writeLog(SystemLogFileAction::NEW_FOLDER, SystemLogErrorClassification::USER_ERROR, 'Destination path "{destination}" was not within your mountpoints', ['destination' => $targetFolderObject->getIdentifier()]);
875  $this->‪addMessageToFlashMessageQueue('FileUtility.DestinationPathWasNotWithinYourMountpoints', [$targetFolderObject->getIdentifier()]);
876  } catch (ExistingTargetFolderException $e) {
877  $this->‪writeLog(SystemLogFileAction::NEW_FOLDER, SystemLogErrorClassification::USER_ERROR, 'File or directory "{identifier}" existed already', ['identifier' => $folderName]);
878  $this->‪addMessageToFlashMessageQueue('FileUtility.FileOrDirectoryExistedAlready', [$folderName]);
879  } catch (\RuntimeException $e) {
880  $this->‪writeLog(SystemLogFileAction::NEW_FOLDER, SystemLogErrorClassification::USER_ERROR, 'Directory "{identifier}" not created. Write-permission problem in "{destination}"?', ['identifier' => $folderName, 'destination' => $targetFolderObject->getIdentifier()]);
881  $this->‪addMessageToFlashMessageQueue('FileUtility.DirectoryNotCreated', [$folderName, $targetFolderObject->getIdentifier()]);
882  }
883  return $resultObject;
884  }
885 
894  public function ‪func_newfile($cmds): File|false|null
895  {
896  $targetFolderObject = $this->‪getFileObject($cmds['target']);
897  if (!$targetFolderObject instanceof Folder) {
898  $this->‪writeLog(SystemLogFileAction::NEW_FILE, SystemLogErrorClassification::SYSTEM_ERROR, 'Destination "{destination}" was not a directory', ['destination' => $cmds['target']]);
899  $this->‪addMessageToFlashMessageQueue('FileUtility.DestinationWasNotADirectory', [$cmds['target']]);
900  return false;
901  }
902  $resultObject = null;
903  $fileName = $cmds['data'];
904  try {
905  $resultObject = $targetFolderObject->createFile($fileName);
906  $this->‪writeLog(SystemLogFileAction::NEW_FILE, SystemLogErrorClassification::MESSAGE, 'File "{identifier}" created', ['identifier' => $fileName]);
907  if ($resultObject->getName() !== $fileName) {
908  $this->‪addMessageToFlashMessageQueue('FileUtility.FileNameSanitized', [$fileName, $resultObject->getName()], ContextualFeedbackSeverity::WARNING);
909  }
910  $this->‪addMessageToFlashMessageQueue('FileUtility.FileCreated', [$resultObject->getName()], ContextualFeedbackSeverity::OK);
911  } catch (IllegalFileExtensionException $e) {
912  $this->‪writeLog(SystemLogFileAction::NEW_FILE, SystemLogErrorClassification::USER_ERROR, 'Extension of file "{identifier}" was not allowed', ['identifier' => $fileName]);
913  $this->‪addMessageToFlashMessageQueue('FileUtility.ExtensionOfFileWasNotAllowed', [$fileName]);
914  } catch (InsufficientFolderWritePermissionsException $e) {
915  $this->‪writeLog(SystemLogFileAction::NEW_FILE, SystemLogErrorClassification::USER_ERROR, 'You are not allowed to create files');
916  $this->‪addMessageToFlashMessageQueue('FileUtility.YouAreNotAllowedToCreateFiles');
917  } catch (NotInMountPointException $e) {
918  $this->‪writeLog(SystemLogFileAction::NEW_FILE, SystemLogErrorClassification::USER_ERROR, 'Destination path "{destination}" was not within your mountpoints', ['destination' => $targetFolderObject->getIdentifier()]);
919  $this->‪addMessageToFlashMessageQueue('FileUtility.DestinationPathWasNotWithinYourMountpoints', [$targetFolderObject->getIdentifier()]);
920  } catch (ExistingTargetFileNameException $e) {
921  $this->‪writeLog(SystemLogFileAction::NEW_FILE, SystemLogErrorClassification::USER_ERROR, 'File existed already in "{destination}"', ['destination' => $targetFolderObject->getIdentifier()]);
922  $this->‪addMessageToFlashMessageQueue('FileUtility.FileExistedAlreadyIn', [$targetFolderObject->getIdentifier()]);
923  } catch (InvalidFileNameException $e) {
924  $this->‪writeLog(SystemLogFileAction::NEW_FILE, SystemLogErrorClassification::USER_ERROR, 'File name "{identifier}" was not allowed', ['identifier' => $fileName]);
925  $this->‪addMessageToFlashMessageQueue('FileUtility.FileNameWasNotAllowed', [$fileName]);
926  } catch (\RuntimeException $e) {
927  $this->‪writeLog(SystemLogFileAction::NEW_FILE, SystemLogErrorClassification::USER_ERROR, 'File "{identifier}" was not created. Write-permission problem in "{destination}"?', ['identifier' => $fileName, 'destination' => $targetFolderObject->getIdentifier()]);
928  $this->‪addMessageToFlashMessageQueue('FileUtility.FileWasNotCreated', [$fileName, $targetFolderObject->getIdentifier()]);
929  }
930  return $resultObject;
931  }
932 
939  public function ‪func_edit($cmds)
940  {
941  // Example identifier for $cmds['target'] => "4:mypath/tomyfolder/myfile.jpg"
942  // for backwards compatibility: the combined file identifier was the path+filename
943  $fileIdentifier = $cmds['target'];
944  $fileObject = $this->‪getFileObject($fileIdentifier);
945  if (!$fileObject instanceof File) {
946  $this->‪writeLog(SystemLogFileAction::EDIT, SystemLogErrorClassification::SYSTEM_ERROR, 'Target "{destination}" was not a file', ['destination' => $fileIdentifier]);
947  $this->‪addMessageToFlashMessageQueue('FileUtility.TargetWasNotAFile', [$fileIdentifier]);
948  return false;
949  }
950  if (!$fileObject->isTextFile()) {
951  $extList = ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['textfile_ext'];
952  $this->‪writeLog(SystemLogFileAction::EDIT, SystemLogErrorClassification::USER_ERROR, 'File extension "{extension}" is not a textfile format ({allowedExtensions})', ['extension' => $fileObject->getExtension(), 'allowedExtensions' => $extList]);
953  $this->‪addMessageToFlashMessageQueue('FileUtility.FileExtensionIsNotATextfileFormat', [$fileObject->getExtension(), $extList]);
954  return false;
955  }
956  try {
957  // Example identifier for $cmds['target'] => "2:targetpath/targetfolder/"
958  $content = $cmds['data'];
959  $fileObject->setContents($content);
960  clearstatcache();
961  $this->‪writeLog(SystemLogFileAction::EDIT, SystemLogErrorClassification::MESSAGE, 'File saved to "{identifier}", bytes: {size}', ['identifier' => $fileObject->getIdentifier(), 'size' => $fileObject->getSize()]);
962  $this->‪addMessageToFlashMessageQueue('FileUtility.FileSavedTo', [$fileObject->getIdentifier()], ContextualFeedbackSeverity::OK);
963  return true;
964  } catch (InsufficientUserPermissionsException $e) {
965  $this->‪writeLog(SystemLogFileAction::EDIT, SystemLogErrorClassification::USER_ERROR, 'You are not allowed to edit files');
966  $this->‪addMessageToFlashMessageQueue('FileUtility.YouAreNotAllowedToEditFiles');
967  return false;
968  } catch (InsufficientFileWritePermissionsException $e) {
969  $this->‪writeLog(SystemLogFileAction::EDIT, SystemLogErrorClassification::USER_ERROR, 'File "{identifier}" was not saved. Write-permission problem?', ['identifier' => $fileObject->getIdentifier()]);
970  $this->‪addMessageToFlashMessageQueue('FileUtility.FileWasNotSaved', [$fileObject->getIdentifier()]);
971  return false;
972  } catch (IllegalFileExtensionException|\RuntimeException $e) {
973  $this->‪writeLog(SystemLogFileAction::EDIT, SystemLogErrorClassification::USER_ERROR, 'File "{identifier}" was not saved. File extension rejected', ['identifier' => $fileObject->getIdentifier()]);
974  $this->‪addMessageToFlashMessageQueue('FileUtility.FileWasNotSaved', [$fileObject->getIdentifier()]);
975  return false;
976  }
977  }
978 
1009  public function ‪func_upload($cmds)
1010  {
1011  $uploadPosition = $cmds['data'];
1012  $uploadedFileData = $_FILES['upload_' . $uploadPosition];
1013  if (empty($uploadedFileData['name']) || is_array($uploadedFileData['name']) && empty($uploadedFileData['name'][0])) {
1014  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::SYSTEM_ERROR, 'No file was uploaded');
1015  $this->‪addMessageToFlashMessageQueue('FileUtility.NoFileWasUploaded');
1016  return false;
1017  }
1018  // Example identifier for $cmds['target'] => "2:targetpath/targetfolder/"
1019  $targetFolderObject = $this->‪getFileObject($cmds['target']);
1020  // Uploading with non HTML-5-style, thus, make an array out of it, so we can loop over it
1021  if (!is_array($uploadedFileData['name'])) {
1022  $uploadedFileData = [
1023  'name' => [$uploadedFileData['name']],
1024  'type' => [$uploadedFileData['type']],
1025  'tmp_name' => [$uploadedFileData['tmp_name']],
1026  'size' => [$uploadedFileData['size']],
1027  ];
1028  }
1029  $uploadedFileData['name'] = array_map(\Normalizer::normalize(...), $uploadedFileData['name']);
1030  $resultObjects = [];
1031  $numberOfUploadedFilesForPosition = count($uploadedFileData['name']);
1032  // Loop through all uploaded files
1033  for ($i = 0; $i < $numberOfUploadedFilesForPosition; $i++) {
1034  $fileInfo = [
1035  'name' => $uploadedFileData['name'][$i],
1036  'type' => $uploadedFileData['type'][$i],
1037  'tmp_name' => $uploadedFileData['tmp_name'][$i],
1038  'size' => $uploadedFileData['size'][$i],
1039  ];
1040  try {
1041  $fileObject = $targetFolderObject->addUploadedFile($fileInfo, $this->existingFilesConflictMode);
1042  if ($this->existingFilesConflictMode === DuplicationBehavior::REPLACE) {
1043  $this->‪getIndexer($fileObject->getStorage())->‪updateIndexEntry($fileObject);
1044  }
1045  $resultObjects[] = $fileObject;
1046  $this->internalUploadMap[$uploadPosition] = $fileObject->getCombinedIdentifier();
1047  if ($fileObject->getName() !== $fileInfo['name']) {
1048  $this->‪addMessageToFlashMessageQueue('FileUtility.FileNameSanitized', [$fileInfo['name'], $fileObject->getName()], ContextualFeedbackSeverity::WARNING);
1049  }
1050  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::MESSAGE, 'Uploading file "{identifier}" to "{destination}"', ['identifier' => $fileInfo['name'], 'destination' => $targetFolderObject->getIdentifier()]);
1051  $this->‪addMessageToFlashMessageQueue('FileUtility.UploadingFileTo', [$fileInfo['name'], $targetFolderObject->getIdentifier()], ContextualFeedbackSeverity::OK);
1052  } catch (InsufficientFileWritePermissionsException $e) {
1053  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::USER_ERROR, 'You are not allowed to override {identifier}', ['identifier' => $fileInfo['name']]);
1054  $this->‪addMessageToFlashMessageQueue('FileUtility.YouAreNotAllowedToOverride', [$fileInfo['name']]);
1055  } catch (UploadException $e) {
1056  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::SYSTEM_ERROR, 'The upload has failed, no uploaded file found');
1057  $this->‪addMessageToFlashMessageQueue('FileUtility.TheUploadHasFailedNoUploadedFileFound');
1058  } catch (InsufficientUserPermissionsException $e) {
1059  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::USER_ERROR, 'You are not allowed to upload files');
1060  $this->‪addMessageToFlashMessageQueue('FileUtility.YouAreNotAllowedToUploadFiles');
1061  } catch (UploadSizeException $e) {
1062  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::USER_ERROR, 'The uploaded file "{identifier}" exceeds the size-limit', ['identifier' => $fileInfo['name']]);
1063  $this->‪addMessageToFlashMessageQueue('FileUtility.TheUploadedFileExceedsTheSize-limit', [$fileInfo['name']]);
1064  } catch (InsufficientFolderWritePermissionsException $e) {
1065  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::USER_ERROR, 'Destination path "{destination}" was not within your mountpoints', ['destination' => $targetFolderObject->getIdentifier()]);
1066  $this->‪addMessageToFlashMessageQueue('FileUtility.DestinationPathWasNotWithinYourMountpoints', [$targetFolderObject->getIdentifier()]);
1067  } catch (IllegalFileExtensionException $e) {
1068  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::USER_ERROR, 'Extension of file name "{identifier}" is not allowed in "{destination}"', ['identifier' => $fileInfo['name'], 'destination' => $targetFolderObject->getIdentifier()]);
1069  $this->‪addMessageToFlashMessageQueue('FileUtility.ExtensionOfFileNameIsNotAllowedIn', [$fileInfo['name'], $targetFolderObject->getIdentifier()]);
1070  } catch (ExistingTargetFileNameException $e) {
1071  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::USER_ERROR, 'No unique filename available in "{destination}"', ['destination' => $targetFolderObject->getIdentifier()]);
1072  $this->‪addMessageToFlashMessageQueue('FileUtility.NoUniqueFilenameAvailableIn', [$targetFolderObject->getIdentifier()]);
1073  } catch (\RuntimeException $e) {
1074  $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()]);
1075  $this->‪addMessageToFlashMessageQueue('FileUtility.UploadedFileCouldNotBeMoved', [$targetFolderObject->getIdentifier()]);
1076  }
1077  }
1078 
1079  return $resultObjects;
1080  }
1081 
1091  protected function ‪replaceFile(array $cmdArr)
1092  {
1093  $fileObjectToReplace = null;
1094  $uploadPosition = $cmdArr['data'];
1095  $fileInfo = $_FILES['replace_' . $uploadPosition];
1096  if (empty($fileInfo['name'])) {
1097  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::SYSTEM_ERROR, 'No file was uploaded for replacing');
1098  $this->‪addMessageToFlashMessageQueue('FileUtility.NoFileWasUploadedForReplacing');
1099  return false;
1100  }
1101 
1102  $keepFileName = (bool)($cmdArr['keepFilename'] ?? false);
1103  $resultObjects = [];
1104 
1105  try {
1106  $fileObjectToReplace = $this->‪getFileObject($cmdArr['uid']);
1107  $folder = $fileObjectToReplace->getParentFolder();
1108  $resourceStorage = $fileObjectToReplace->getStorage();
1109 
1110  $fileObject = $resourceStorage->addUploadedFile($fileInfo, $folder, $fileObjectToReplace->getName(), DuplicationBehavior::REPLACE);
1111 
1112  // Check if there is a file that is going to be uploaded that has a different name as the replacing one
1113  // but exists in that folder as well.
1114  // rename to another name, but check if the name is already given
1115  if ($keepFileName === false) {
1116  // if a file with the same name already exists, we need to change it to _01 etc.
1117  // if the file does not exist, we can do a simple rename
1118  $resourceStorage->moveFile($fileObject, $folder, $fileInfo['name'], DuplicationBehavior::RENAME);
1119  }
1120 
1121  $resultObjects[] = $fileObject;
1122  $this->internalUploadMap[$uploadPosition] = $fileObject->getCombinedIdentifier();
1123 
1124  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::MESSAGE, 'Replacing file "{identifier}" to "{destination}"', ['identifier' => $fileInfo['name'], 'destination' => $fileObjectToReplace->getIdentifier()]);
1125  $this->‪addMessageToFlashMessageQueue('FileUtility.ReplacingFileTo', [$fileInfo['name'], $fileObjectToReplace->getIdentifier()], ContextualFeedbackSeverity::OK);
1126  } catch (InsufficientFileWritePermissionsException $e) {
1127  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::USER_ERROR, 'You are not allowed to override "{destination}"', ['destination' => $fileInfo['name']]);
1128  $this->‪addMessageToFlashMessageQueue('FileUtility.YouAreNotAllowedToOverride', [$fileInfo['name']]);
1129  } catch (UploadException $e) {
1130  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::SYSTEM_ERROR, 'The upload has failed, no uploaded file found');
1131  $this->‪addMessageToFlashMessageQueue('FileUtility.TheUploadHasFailedNoUploadedFileFound');
1132  } catch (InsufficientUserPermissionsException $e) {
1133  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::USER_ERROR, 'You are not allowed to upload files');
1134  $this->‪addMessageToFlashMessageQueue('FileUtility.YouAreNotAllowedToUploadFiles');
1135  } catch (UploadSizeException $e) {
1136  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::USER_ERROR, 'The uploaded file "{identifier}" exceeds the size-limit', ['identifier' => $fileInfo['name']]);
1137  $this->‪addMessageToFlashMessageQueue('FileUtility.TheUploadedFileExceedsTheSize-limit', [$fileInfo['name']]);
1138  } catch (InsufficientFolderWritePermissionsException $e) {
1139  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::USER_ERROR, 'Destination path "{destination}" was not within your mountpoints', ['destination' => $fileObjectToReplace->getIdentifier()]);
1140  $this->‪addMessageToFlashMessageQueue('FileUtility.DestinationPathWasNotWithinYourMountpoints', [$fileObjectToReplace->getIdentifier()]);
1141  } catch (IllegalFileExtensionException $e) {
1142  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::USER_ERROR, 'Extension of file name "{identifier}" is not allowed in "{destination}"', ['identifier' => $fileInfo['name'], 'destination' => $fileObjectToReplace->getIdentifier()]);
1143  $this->‪addMessageToFlashMessageQueue('FileUtility.ExtensionOfFileNameIsNotAllowedIn', [$fileInfo['name'], $fileObjectToReplace->getIdentifier()]);
1144  } catch (ExistingTargetFileNameException $e) {
1145  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::USER_ERROR, 'No unique filename available in "{destination}"', ['destination' => $fileObjectToReplace->getIdentifier()]);
1146  $this->‪addMessageToFlashMessageQueue('FileUtility.NoUniqueFilenameAvailableIn', [$fileObjectToReplace->getIdentifier()]);
1147  } catch (\RuntimeException $e) {
1148  throw $e;
1149  }
1150  return $resultObjects;
1151  }
1152 
1156  protected function ‪addFlashMessage(‪FlashMessage $flashMessage)
1157  {
1158  $flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class);
1159 
1160  $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
1161  $defaultFlashMessageQueue->enqueue($flashMessage);
1162  }
1163 
1169  protected function ‪getIndexer(‪ResourceStorage $storage)
1170  {
1171  return GeneralUtility::makeInstance(Indexer::class, $storage);
1172  }
1173 
1175  {
1176  return ‪$GLOBALS['BE_USER'];
1177  }
1178 
1179  protected function ‪getLanguageService(): ‪LanguageService
1180  {
1181  return ‪$GLOBALS['LANG'];
1182  }
1183 }
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\folderHasFilesInUse
‪bool folderHasFilesInUse(Folder $folder)
Definition: ExtendedFileUtility.php:477
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\func_delete
‪bool func_delete(array $cmds)
Definition: ExtendedFileUtility.php:316
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\addFlashMessage
‪addFlashMessage(FlashMessage $flashMessage)
Definition: ExtendedFileUtility.php:1151
‪TYPO3\CMS\Core\Resource\Exception\InsufficientFileWritePermissionsException
Definition: InsufficientFileWritePermissionsException.php:21
‪TYPO3\CMS\Core\Resource\Exception\InsufficientUserPermissionsException
Definition: InsufficientUserPermissionsException.php:23
‪TYPO3\CMS\Core\Database\Connection\PARAM_INT
‪const PARAM_INT
Definition: Connection.php:52
‪TYPO3\CMS\Core\Resource\Exception\ExistingTargetFolderException
Definition: ExistingTargetFolderException.php:23
‪TYPO3\CMS\Core\Resource\Exception\InsufficientFolderAccessPermissionsException
Definition: InsufficientFolderAccessPermissionsException.php:23
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\getLanguageService
‪getLanguageService()
Definition: ExtendedFileUtility.php:1174
‪TYPO3\CMS\Core\Utility\File\BasicFileUtility
Definition: BasicFileUtility.php:37
‪TYPO3\CMS\Core\Resource\Index\Indexer
Definition: Indexer.php:35
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\processData
‪mixed processData()
Definition: ExtendedFileUtility.php:179
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\getExistingFilesConflictMode
‪getExistingFilesConflictMode()
Definition: ExtendedFileUtility.php:133
‪TYPO3\CMS\Core\Resource\Folder\FILTER_MODE_USE_OWN_AND_STORAGE_FILTERS
‪const FILTER_MODE_USE_OWN_AND_STORAGE_FILTERS
Definition: Folder.php:70
‪TYPO3\CMS\Core\Resource\Exception\ExistingTargetFileNameException
Definition: ExistingTargetFileNameException.php:23
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\func_edit
‪bool func_edit($cmds)
Definition: ExtendedFileUtility.php:934
‪TYPO3\CMS\Core\Resource\Index\Indexer\updateIndexEntry
‪updateIndexEntry(File $fileObject)
Definition: Indexer.php:93
‪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:287
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\getBackendUser
‪getBackendUser()
Definition: ExtendedFileUtility.php:1169
‪TYPO3\CMS\Core\Resource\Exception\IllegalFileExtensionException
Definition: IllegalFileExtensionException.php:23
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\func_newfile
‪func_newfile($cmds)
Definition: ExtendedFileUtility.php:889
‪TYPO3\CMS\Core\Resource\Exception\InsufficientFileAccessPermissionsException
Definition: InsufficientFileAccessPermissionsException.php:23
‪TYPO3\CMS\Core\Resource\Exception\InvalidTargetFolderException
Definition: InvalidTargetFolderException.php:23
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\replaceFile
‪array bool replaceFile(array $cmdArr)
Definition: ExtendedFileUtility.php:1086
‪TYPO3\CMS\Core\Resource\Exception\UploadException
Definition: UploadException.php:21
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\setExistingFilesConflictMode
‪setExistingFilesConflictMode(DuplicationBehavior $existingFilesConflictMode)
Definition: ExtendedFileUtility.php:141
‪TYPO3\CMS\Core\Type\ContextualFeedbackSeverity
‪ContextualFeedbackSeverity
Definition: ContextualFeedbackSeverity.php:25
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility
Definition: ExtendedFileUtility.php:76
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\func_upload
‪File[] bool func_upload($cmds)
Definition: ExtendedFileUtility.php:1004
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\$fileFactory
‪TYPO3 CMS Core Resource ResourceFactory $fileFactory
Definition: ExtendedFileUtility.php:128
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\setActionPermissions
‪setActionPermissions(array $permissions=[])
Definition: ExtendedFileUtility.php:165
‪TYPO3\CMS\Core\Resource\Exception\UploadSizeException
Definition: UploadSizeException.php:21
‪TYPO3\CMS\Core\Resource\Folder
Definition: Folder.php:38
‪TYPO3\CMS\Core\Resource\ResourceFactory
Definition: ResourceFactory.php:42
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\$existingFilesConflictMode
‪DuplicationBehavior $existingFilesConflictMode
Definition: ExtendedFileUtility.php:80
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\func_move
‪TYPO3 CMS Core Resource File false func_move($cmds)
Definition: ExtendedFileUtility.php:674
‪TYPO3\CMS\Core\Resource\Exception\ResourceDoesNotExistException
Definition: ResourceDoesNotExistException.php:23
‪TYPO3\CMS\Core\Resource\File
Definition: File.php:26
‪TYPO3\CMS\Core\SysLog\Error
Definition: Error.php:24
‪TYPO3\CMS\Core\Resource\Exception\InvalidFileException
Definition: InvalidFileException.php:23
‪TYPO3\CMS\Core\Resource\Enum\DuplicationBehavior
‪DuplicationBehavior
Definition: DuplicationBehavior.php:28
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:62
‪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:202
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\getIndexer
‪TYPO3 CMS Core Resource Index Indexer getIndexer(ResourceStorage $storage)
Definition: ExtendedFileUtility.php:1164
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\$flashMessages
‪array $flashMessages
Definition: ExtendedFileUtility.php:118
‪TYPO3\CMS\Core\Resource\AbstractFile\getUid
‪return MathUtility::canBeInterpretedAsInteger($size) ?(int) $size int getUid()
Definition: AbstractFile.php:195
‪TYPO3\CMS\Core\Database\Connection
Definition: Connection.php:41
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\func_copy
‪TYPO3 CMS Core Resource File false func_copy($cmds)
Definition: ExtendedFileUtility.php:584
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\func_newfolder
‪Folder false func_newfolder($cmds)
Definition: ExtendedFileUtility.php:848
‪TYPO3\CMS\Core\Resource\ResourceStorage
Definition: ResourceStorage.php:129
‪TYPO3\CMS\Core\Messaging\FlashMessage
Definition: FlashMessage.php:27
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\start
‪start($fileCmds)
Definition: ExtendedFileUtility.php:151
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\$fileCmdMap
‪array $fileCmdMap
Definition: ExtendedFileUtility.php:122
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\$internalUploadMap
‪array $internalUploadMap
Definition: ExtendedFileUtility.php:112
‪TYPO3\CMS\Core\Resource\Exception\InsufficientFolderWritePermissionsException
Definition: InsufficientFolderWritePermissionsException.php:21
‪TYPO3\CMS\Core\Utility\Exception\NotImplementedMethodException
Definition: NotImplementedMethodException.php:26
‪TYPO3\CMS\Core\Http\fromRequest
‪@ fromRequest
Definition: ApplicationType.php:66
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:46
‪TYPO3\CMS\Core\Database\ConnectionPool
Definition: ConnectionPool.php:46
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\writeLog
‪writeLog(int $action, int $severity, string $message, array $context=[])
Definition: ExtendedFileUtility.php:272
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52
‪TYPO3\CMS\Core\Resource\Exception\FileOperationErrorException
Definition: FileOperationErrorException.php:21
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\func_rename
‪TYPO3 CMS Core Resource File func_rename($cmds)
Definition: ExtendedFileUtility.php:768
‪TYPO3\CMS\Core\Resource\Exception\NotInMountPointException
Definition: NotInMountPointException.php:23
‪TYPO3\CMS\Core\Database\Connection\PARAM_INT_ARRAY
‪const PARAM_INT_ARRAY
Definition: Connection.php:72
‪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:23
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\transformFileReferenceToRecordReference
‪array transformFileReferenceToRecordReference(array $referenceRecord)
Definition: ExtendedFileUtility.php:530
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\getFileObject
‪getFileObject(string $identifier)
Definition: ExtendedFileUtility.php:559
‪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:88
‪TYPO3\CMS\Core\Http\ApplicationType
‪ApplicationType
Definition: ApplicationType.php:55