‪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  if ($alternativeName !== '') {
695  // Don't allow overwriting existing files, but find a new name
696  $resultObject = $sourceFileObject->moveTo($targetFolderObject, $alternativeName, DuplicationBehavior::RENAME);
697  } else {
698  // Don't allow overwriting existing files
699  $resultObject = $sourceFileObject->moveTo($targetFolderObject, null, DuplicationBehavior::CANCEL);
700  }
701  $this->‪writeLog(SystemLogFileAction::MOVE, SystemLogErrorClassification::MESSAGE, 'File "{identifier}" moved to "{destination}"', ['identifier' => $sourceFileObject->getIdentifier(), 'destination' => $resultObject->getIdentifier()]);
702  $this->‪addMessageToFlashMessageQueue('FileUtility.FileMovedTo', [$sourceFileObject->getIdentifier(), $resultObject->getIdentifier()], ContextualFeedbackSeverity::OK);
703  } catch (InsufficientUserPermissionsException $e) {
704  $this->‪writeLog(SystemLogFileAction::MOVE, SystemLogErrorClassification::USER_ERROR, 'You are not allowed to move files');
705  $this->‪addMessageToFlashMessageQueue('FileUtility.YouAreNotAllowedToMoveFiles');
706  } catch (InsufficientFileAccessPermissionsException $e) {
707  $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()]);
708  $this->‪addMessageToFlashMessageQueue('FileUtility.CouldNotAccessAllNecessaryResources', [$sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
709  } catch (IllegalFileExtensionException $e) {
710  $this->‪writeLog(SystemLogFileAction::MOVE, SystemLogErrorClassification::USER_ERROR, 'Extension of file name "{identifier}" is not allowed in "{destination}"', ['identifier' => $sourceFileObject->getIdentifier(), 'destination' => $targetFolderObject->getIdentifier()]);
711  $this->‪addMessageToFlashMessageQueue('FileUtility.ExtensionOfFileNameIsNotAllowedIn', [$sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
712  } catch (ExistingTargetFileNameException $e) {
713  $this->‪writeLog(SystemLogFileAction::MOVE, SystemLogErrorClassification::USER_ERROR, 'File "{identifier}" already exists in folder "{destination}"', ['identifier' => $sourceFileObject->getIdentifier(), 'destination' => $targetFolderObject->getIdentifier()]);
714  $this->‪addMessageToFlashMessageQueue('FileUtility.FileAlreadyExistsInFolder', [$sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
715  } catch (NotImplementedMethodException $e) {
716  $this->‪writeLog(SystemLogFileAction::MOVE, SystemLogErrorClassification::USER_ERROR, 'The function to move a file between storages is not yet implemented');
717  $this->‪addMessageToFlashMessageQueue('FileUtility.TheFunctionToMoveAFileBetweenStoragesIsNotYetImplemented');
718  } catch (\RuntimeException $e) {
719  $this->‪writeLog(SystemLogFileAction::MOVE, SystemLogErrorClassification::SYSTEM_ERROR, 'File "{identifier}" was not copied to "{destination}". Write-permission problem?', ['identifier' => $sourceFileObject->getIdentifier(), 'destination' => $targetFolderObject->getIdentifier()]);
720  $this->‪addMessageToFlashMessageQueue('FileUtility.FileWasNotCopiedTo', [$sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
721  }
722  } else {
723  // Else means this is a Folder
724  $sourceFolderObject = $sourceFileObject;
725  try {
726  if ($alternativeName !== '') {
727  // Don't allow overwriting existing files, but find a new name
728  $resultObject = $sourceFolderObject->moveTo($targetFolderObject, $alternativeName, DuplicationBehavior::RENAME);
729  } else {
730  // Don't allow overwriting existing files
731  $resultObject = $sourceFolderObject->moveTo($targetFolderObject, null, DuplicationBehavior::RENAME);
732  }
733  $this->‪writeLog(SystemLogFileAction::MOVE, SystemLogErrorClassification::MESSAGE, 'Directory "{identifier}" moved to "{destination}"', ['identifier' => $sourceFolderObject->getIdentifier(), 'destination' => $targetFolderObject->getIdentifier()]);
734  $this->‪addMessageToFlashMessageQueue('FileUtility.DirectoryMovedTo', [$sourceFolderObject->getIdentifier(), $targetFolderObject->getIdentifier()], ContextualFeedbackSeverity::OK);
735  } catch (InsufficientUserPermissionsException $e) {
736  $this->‪writeLog(SystemLogFileAction::MOVE, SystemLogErrorClassification::USER_ERROR, 'You are not allowed to move directories');
737  $this->‪addMessageToFlashMessageQueue('FileUtility.YouAreNotAllowedToMoveDirectories');
738  } catch (InsufficientFileAccessPermissionsException $e) {
739  $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()]);
740  $this->‪addMessageToFlashMessageQueue('FileUtility.CouldNotAccessAllNecessaryResources', [$sourceFolderObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
741  } catch (InsufficientFolderAccessPermissionsException $e) {
742  $this->‪writeLog(SystemLogFileAction::MOVE, SystemLogErrorClassification::USER_ERROR, 'You don\'t have full access to the destination directory "{destination}"', ['destination' => $targetFolderObject->getIdentifier()]);
743  $this->‪addMessageToFlashMessageQueue('FileUtility.YouDontHaveFullAccessToTheDestinationDirectory', [$targetFolderObject->getIdentifier()]);
744  } catch (InvalidTargetFolderException $e) {
745  $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()]);
746  $this->‪addMessageToFlashMessageQueue('FileUtility.CannotMoveFolderIntoTargetFolderBecauseTheTargetFolderIsAlreadyWithinTheFolderToBeMoved', [$sourceFolderObject->getName(), $targetFolderObject->getName()]);
747  } catch (ExistingTargetFolderException $e) {
748  $this->‪writeLog(SystemLogFileAction::MOVE, SystemLogErrorClassification::USER_ERROR, 'Target "{destination}" already exists', ['destination' => $targetFolderObject->getIdentifier()]);
749  $this->‪addMessageToFlashMessageQueue('FileUtility.TargetAlreadyExists', [$targetFolderObject->getIdentifier()]);
750  } catch (NotImplementedMethodException $e) {
751  $this->‪writeLog(SystemLogFileAction::MOVE, SystemLogErrorClassification::USER_ERROR, 'The function to move a folder between storages is not yet implemented');
752  $this->‪addMessageToFlashMessageQueue('FileUtility.TheFunctionToMoveAFolderBetweenStoragesIsNotYetImplemented');
753  } catch (\RuntimeException $e) {
754  $this->‪writeLog(SystemLogFileAction::MOVE, SystemLogErrorClassification::SYSTEM_ERROR, 'Directory "{identifier}" was not moved to "{destination}". Write-permission problem?', ['identifier' => $sourceFolderObject->getIdentifier(), 'destination' => $targetFolderObject->getIdentifier()]);
755  $this->‪addMessageToFlashMessageQueue('FileUtility.DirectoryWasNotMovedTo', [$sourceFolderObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
756  }
757  }
758  return $resultObject;
759  }
760 
772  public function ‪func_rename($cmds)
773  {
774  $sourceFileObject = $this->‪getFileObject($cmds['data']);
775  $sourceFile = $sourceFileObject->getName();
776  $targetFile = $cmds['target'];
777  $resultObject = null;
778  if ($sourceFileObject instanceof File) {
779  try {
780  // Try to rename the File
781  $resultObject = $sourceFileObject->rename($targetFile, $this->existingFilesConflictMode);
782  if ($resultObject->getName() !== $targetFile) {
783  $this->‪writeLog(SystemLogFileAction::RENAME, SystemLogErrorClassification::USER_ERROR, 'File renamed from "{identifier}" to "{destination}". Filename had to be sanitized', ['identifier' => $sourceFile, 'destination' => $targetFile]);
784  $this->‪addMessageToFlashMessageQueue('FileUtility.FileNameSanitized', [$targetFile, $resultObject->getName()], ContextualFeedbackSeverity::WARNING);
785  } else {
786  $this->‪writeLog(SystemLogFileAction::RENAME, SystemLogErrorClassification::MESSAGE, 'File renamed from "{identifier}" to "{destination}"', ['identifier' => $sourceFile, 'destination' => $targetFile]);
787  }
788  if ($sourceFile === $resultObject->getName()) {
789  $this->‪addMessageToFlashMessageQueue('FileUtility.FileRenamedSameName', [$sourceFile], ContextualFeedbackSeverity::INFO);
790  } else {
791  $this->‪addMessageToFlashMessageQueue('FileUtility.FileRenamedFromTo', [$sourceFile, $resultObject->getName()], ContextualFeedbackSeverity::OK);
792  }
793  } catch (InsufficientUserPermissionsException $e) {
794  $this->‪writeLog(SystemLogFileAction::RENAME, SystemLogErrorClassification::USER_ERROR, 'You are not allowed to rename files');
795  $this->‪addMessageToFlashMessageQueue('FileUtility.YouAreNotAllowedToRenameFiles');
796  } catch (IllegalFileExtensionException $e) {
797  $this->‪writeLog(SystemLogFileAction::RENAME, SystemLogErrorClassification::USER_ERROR, 'Extension of file name "{identifier}" or "{destination}" was not allowed', ['identifier' => $sourceFileObject->getName(), 'destination' => $targetFile]);
798  $this->‪addMessageToFlashMessageQueue('FileUtility.ExtensionOfFileNameOrWasNotAllowed', [$sourceFileObject->getName(), $targetFile]);
799  } catch (ExistingTargetFileNameException $e) {
800  $this->‪writeLog(SystemLogFileAction::RENAME, SystemLogErrorClassification::USER_ERROR, 'Destination "{destination}" existed already', ['destination' => $targetFile]);
801  $this->‪addMessageToFlashMessageQueue('FileUtility.DestinationExistedAlready', [$targetFile]);
802  } catch (NotInMountPointException $e) {
803  $this->‪writeLog(SystemLogFileAction::RENAME, SystemLogErrorClassification::USER_ERROR, 'Destination path "{destination}" was not within your mountpoints', ['destination' => $targetFile]);
804  $this->‪addMessageToFlashMessageQueue('FileUtility.DestinationPathWasNotWithinYourMountpoints', [$targetFile]);
805  } catch (\RuntimeException $e) {
806  $this->‪writeLog(SystemLogFileAction::RENAME, SystemLogErrorClassification::USER_ERROR, 'File "{identifier}" was not renamed. Write-permission problem in "{destination}"?', ['identifier' => $sourceFileObject->getName(), 'destination' => $targetFile]);
807  $this->‪addMessageToFlashMessageQueue('FileUtility.FileWasNotRenamed', [$sourceFileObject->getName(), $targetFile]);
808  }
809  } else {
810  // Else means this is a Folder
811  try {
812  // Try to rename the Folder
813  $resultObject = $sourceFileObject->rename($targetFile);
814  $newFolderName = $resultObject->getName();
815  $this->‪writeLog(SystemLogFileAction::RENAME, SystemLogErrorClassification::MESSAGE, 'Directory renamed from "{identifier}" to "{destination}"', ['identifier' => $sourceFile, 'destination' => $targetFile]);
816  if ($sourceFile === $newFolderName) {
817  $this->‪addMessageToFlashMessageQueue('FileUtility.DirectoryRenamedSameName', [$sourceFile], ContextualFeedbackSeverity::INFO);
818  } else {
819  if ($newFolderName === $targetFile) {
820  $this->‪addMessageToFlashMessageQueue('FileUtility.DirectoryRenamedFromTo', [$sourceFile, $newFolderName], ContextualFeedbackSeverity::OK);
821  } else {
822  $this->‪addMessageToFlashMessageQueue('FileUtility.DirectoryRenamedFromToCharReplaced', [$sourceFile, $newFolderName], ContextualFeedbackSeverity::WARNING);
823  }
824  }
825  } catch (InsufficientUserPermissionsException $e) {
826  $this->‪writeLog(SystemLogFileAction::RENAME, SystemLogErrorClassification::USER_ERROR, 'You are not allowed to rename directories');
827  $this->‪addMessageToFlashMessageQueue('FileUtility.YouAreNotAllowedToRenameDirectories');
828  } catch (ExistingTargetFileNameException $e) {
829  $this->‪writeLog(SystemLogFileAction::RENAME, SystemLogErrorClassification::USER_ERROR, 'Destination "{destination}" existed already', ['destination' => $targetFile]);
830  $this->‪addMessageToFlashMessageQueue('FileUtility.DestinationExistedAlready', [$targetFile]);
831  } catch (NotInMountPointException $e) {
832  $this->‪writeLog(SystemLogFileAction::RENAME, SystemLogErrorClassification::USER_ERROR, 'Destination path "{destination}" was not within your mountpoints', ['destination' => $targetFile]);
833  $this->‪addMessageToFlashMessageQueue('FileUtility.DestinationPathWasNotWithinYourMountpoints', [$targetFile]);
834  } catch (\RuntimeException $e) {
835  $this->‪writeLog(SystemLogFileAction::RENAME, SystemLogErrorClassification::USER_ERROR, 'Directory "{identifier}" was not renamed. Write-permission problem in "{destination}"?', ['identifier' => $sourceFileObject->getName(), 'destination' => $targetFile]);
836  $this->‪addMessageToFlashMessageQueue('FileUtility.DirectoryWasNotRenamed', [$sourceFileObject->getName(), $targetFile]);
837  }
838  }
839  return $resultObject;
840  }
841 
852  public function ‪func_newfolder($cmds)
853  {
854  $resultObject = false;
855  $targetFolderObject = $this->‪getFileObject($cmds['target']);
856  if (!$targetFolderObject instanceof Folder) {
857  $this->‪writeLog(SystemLogFileAction::NEW_FOLDER, SystemLogErrorClassification::SYSTEM_ERROR, 'Destination "{destination}" was not a directory', ['destination' => $cmds['target']]);
858  $this->‪addMessageToFlashMessageQueue('FileUtility.DestinationWasNotADirectory', [$cmds['target']]);
859  return false;
860  }
861  $folderName = $cmds['data'];
862  try {
863  $resultObject = $targetFolderObject->createFolder($folderName);
864  $this->‪writeLog(SystemLogFileAction::NEW_FOLDER, SystemLogErrorClassification::MESSAGE, 'Directory "{identifier}" created in "{destination}"', ['identifier' => $folderName, 'destination' => $targetFolderObject->getIdentifier()]);
865  $this->‪addMessageToFlashMessageQueue('FileUtility.DirectoryCreatedIn', [$folderName, $targetFolderObject->getIdentifier()], ContextualFeedbackSeverity::OK);
866  } catch (InvalidFileNameException $e) {
867  $this->‪writeLog(SystemLogFileAction::NEW_FOLDER, SystemLogErrorClassification::USER_ERROR, 'Invalid folder name "{identifier}"', ['identifier' => $folderName]);
868  $this->‪addMessageToFlashMessageQueue('FileUtility.YouAreNotAllowedToCreateDirectories', [$folderName]);
869  } catch (InsufficientFolderWritePermissionsException $e) {
870  $this->‪writeLog(SystemLogFileAction::NEW_FOLDER, SystemLogErrorClassification::USER_ERROR, 'You are not allowed to create directories');
871  $this->‪addMessageToFlashMessageQueue('FileUtility.YouAreNotAllowedToCreateDirectories');
872  } catch (NotInMountPointException $e) {
873  $this->‪writeLog(SystemLogFileAction::NEW_FOLDER, SystemLogErrorClassification::USER_ERROR, 'Destination path "{destination}" was not within your mountpoints', ['destination' => $targetFolderObject->getIdentifier()]);
874  $this->‪addMessageToFlashMessageQueue('FileUtility.DestinationPathWasNotWithinYourMountpoints', [$targetFolderObject->getIdentifier()]);
875  } catch (ExistingTargetFolderException $e) {
876  $this->‪writeLog(SystemLogFileAction::NEW_FOLDER, SystemLogErrorClassification::USER_ERROR, 'File or directory "{identifier}" existed already', ['identifier' => $folderName]);
877  $this->‪addMessageToFlashMessageQueue('FileUtility.FileOrDirectoryExistedAlready', [$folderName]);
878  } catch (\RuntimeException $e) {
879  $this->‪writeLog(SystemLogFileAction::NEW_FOLDER, SystemLogErrorClassification::USER_ERROR, 'Directory "{identifier}" not created. Write-permission problem in "{destination}"?', ['identifier' => $folderName, 'destination' => $targetFolderObject->getIdentifier()]);
880  $this->‪addMessageToFlashMessageQueue('FileUtility.DirectoryNotCreated', [$folderName, $targetFolderObject->getIdentifier()]);
881  }
882  return $resultObject;
883  }
884 
893  public function ‪func_newfile($cmds): File|false|null
894  {
895  $targetFolderObject = $this->‪getFileObject($cmds['target']);
896  if (!$targetFolderObject instanceof Folder) {
897  $this->‪writeLog(SystemLogFileAction::NEW_FILE, SystemLogErrorClassification::SYSTEM_ERROR, 'Destination "{destination}" was not a directory', ['destination' => $cmds['target']]);
898  $this->‪addMessageToFlashMessageQueue('FileUtility.DestinationWasNotADirectory', [$cmds['target']]);
899  return false;
900  }
901  $resultObject = null;
902  $fileName = $cmds['data'];
903  try {
904  $resultObject = $targetFolderObject->createFile($fileName);
905  $this->‪writeLog(SystemLogFileAction::NEW_FILE, SystemLogErrorClassification::MESSAGE, 'File "{identifier}" created', ['identifier' => $fileName]);
906  if ($resultObject->getName() !== $fileName) {
907  $this->‪addMessageToFlashMessageQueue('FileUtility.FileNameSanitized', [$fileName, $resultObject->getName()], ContextualFeedbackSeverity::WARNING);
908  }
909  $this->‪addMessageToFlashMessageQueue('FileUtility.FileCreated', [$resultObject->getName()], ContextualFeedbackSeverity::OK);
910  } catch (IllegalFileExtensionException $e) {
911  $this->‪writeLog(SystemLogFileAction::NEW_FILE, SystemLogErrorClassification::USER_ERROR, 'Extension of file "{identifier}" was not allowed', ['identifier' => $fileName]);
912  $this->‪addMessageToFlashMessageQueue('FileUtility.ExtensionOfFileWasNotAllowed', [$fileName]);
913  } catch (InsufficientFolderWritePermissionsException $e) {
914  $this->‪writeLog(SystemLogFileAction::NEW_FILE, SystemLogErrorClassification::USER_ERROR, 'You are not allowed to create files');
915  $this->‪addMessageToFlashMessageQueue('FileUtility.YouAreNotAllowedToCreateFiles');
916  } catch (NotInMountPointException $e) {
917  $this->‪writeLog(SystemLogFileAction::NEW_FILE, SystemLogErrorClassification::USER_ERROR, 'Destination path "{destination}" was not within your mountpoints', ['destination' => $targetFolderObject->getIdentifier()]);
918  $this->‪addMessageToFlashMessageQueue('FileUtility.DestinationPathWasNotWithinYourMountpoints', [$targetFolderObject->getIdentifier()]);
919  } catch (ExistingTargetFileNameException $e) {
920  $this->‪writeLog(SystemLogFileAction::NEW_FILE, SystemLogErrorClassification::USER_ERROR, 'File existed already in "{destination}"', ['destination' => $targetFolderObject->getIdentifier()]);
921  $this->‪addMessageToFlashMessageQueue('FileUtility.FileExistedAlreadyIn', [$targetFolderObject->getIdentifier()]);
922  } catch (InvalidFileNameException $e) {
923  $this->‪writeLog(SystemLogFileAction::NEW_FILE, SystemLogErrorClassification::USER_ERROR, 'File name "{identifier}" was not allowed', ['identifier' => $fileName]);
924  $this->‪addMessageToFlashMessageQueue('FileUtility.FileNameWasNotAllowed', [$fileName]);
925  } catch (\RuntimeException $e) {
926  $this->‪writeLog(SystemLogFileAction::NEW_FILE, SystemLogErrorClassification::USER_ERROR, 'File "{identifier}" was not created. Write-permission problem in "{destination}"?', ['identifier' => $fileName, 'destination' => $targetFolderObject->getIdentifier()]);
927  $this->‪addMessageToFlashMessageQueue('FileUtility.FileWasNotCreated', [$fileName, $targetFolderObject->getIdentifier()]);
928  }
929  return $resultObject;
930  }
931 
938  public function ‪func_edit($cmds)
939  {
940  // Example identifier for $cmds['target'] => "4:mypath/tomyfolder/myfile.jpg"
941  // for backwards compatibility: the combined file identifier was the path+filename
942  $fileIdentifier = $cmds['target'];
943  $fileObject = $this->‪getFileObject($fileIdentifier);
944  if (!$fileObject instanceof File) {
945  $this->‪writeLog(SystemLogFileAction::EDIT, SystemLogErrorClassification::SYSTEM_ERROR, 'Target "{destination}" was not a file', ['destination' => $fileIdentifier]);
946  $this->‪addMessageToFlashMessageQueue('FileUtility.TargetWasNotAFile', [$fileIdentifier]);
947  return false;
948  }
949  if (!$fileObject->isTextFile()) {
950  $extList = ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['textfile_ext'];
951  $this->‪writeLog(SystemLogFileAction::EDIT, SystemLogErrorClassification::USER_ERROR, 'File extension "{extension}" is not a textfile format ({allowedExtensions})', ['extension' => $fileObject->getExtension(), 'allowedExtensions' => $extList]);
952  $this->‪addMessageToFlashMessageQueue('FileUtility.FileExtensionIsNotATextfileFormat', [$fileObject->getExtension(), $extList]);
953  return false;
954  }
955  try {
956  // Example identifier for $cmds['target'] => "2:targetpath/targetfolder/"
957  $content = $cmds['data'];
958  $fileObject->setContents($content);
959  clearstatcache();
960  $this->‪writeLog(SystemLogFileAction::EDIT, SystemLogErrorClassification::MESSAGE, 'File saved to "{identifier}", bytes: {size}', ['identifier' => $fileObject->getIdentifier(), 'size' => $fileObject->getSize()]);
961  $this->‪addMessageToFlashMessageQueue('FileUtility.FileSavedTo', [$fileObject->getIdentifier()], ContextualFeedbackSeverity::OK);
962  return true;
963  } catch (InsufficientUserPermissionsException $e) {
964  $this->‪writeLog(SystemLogFileAction::EDIT, SystemLogErrorClassification::USER_ERROR, 'You are not allowed to edit files');
965  $this->‪addMessageToFlashMessageQueue('FileUtility.YouAreNotAllowedToEditFiles');
966  return false;
967  } catch (InsufficientFileWritePermissionsException $e) {
968  $this->‪writeLog(SystemLogFileAction::EDIT, SystemLogErrorClassification::USER_ERROR, 'File "{identifier}" was not saved. Write-permission problem?', ['identifier' => $fileObject->getIdentifier()]);
969  $this->‪addMessageToFlashMessageQueue('FileUtility.FileWasNotSaved', [$fileObject->getIdentifier()]);
970  return false;
971  } catch (IllegalFileExtensionException|\RuntimeException $e) {
972  $this->‪writeLog(SystemLogFileAction::EDIT, SystemLogErrorClassification::USER_ERROR, 'File "{identifier}" was not saved. File extension rejected', ['identifier' => $fileObject->getIdentifier()]);
973  $this->‪addMessageToFlashMessageQueue('FileUtility.FileWasNotSaved', [$fileObject->getIdentifier()]);
974  return false;
975  }
976  }
977 
1008  public function ‪func_upload($cmds)
1009  {
1010  $uploadPosition = $cmds['data'];
1011  $uploadedFileData = $_FILES['upload_' . $uploadPosition];
1012  if (empty($uploadedFileData['name']) || is_array($uploadedFileData['name']) && empty($uploadedFileData['name'][0])) {
1013  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::SYSTEM_ERROR, 'No file was uploaded');
1014  $this->‪addMessageToFlashMessageQueue('FileUtility.NoFileWasUploaded');
1015  return false;
1016  }
1017  // Example identifier for $cmds['target'] => "2:targetpath/targetfolder/"
1018  $targetFolderObject = $this->‪getFileObject($cmds['target']);
1019  // Uploading with non HTML-5-style, thus, make an array out of it, so we can loop over it
1020  if (!is_array($uploadedFileData['name'])) {
1021  $uploadedFileData = [
1022  'name' => [$uploadedFileData['name']],
1023  'type' => [$uploadedFileData['type']],
1024  'tmp_name' => [$uploadedFileData['tmp_name']],
1025  'size' => [$uploadedFileData['size']],
1026  ];
1027  }
1028  $uploadedFileData['name'] = array_map(\Normalizer::normalize(...), $uploadedFileData['name']);
1029  $resultObjects = [];
1030  $numberOfUploadedFilesForPosition = count($uploadedFileData['name']);
1031  // Loop through all uploaded files
1032  for ($i = 0; $i < $numberOfUploadedFilesForPosition; $i++) {
1033  $fileInfo = [
1034  'name' => $uploadedFileData['name'][$i],
1035  'type' => $uploadedFileData['type'][$i],
1036  'tmp_name' => $uploadedFileData['tmp_name'][$i],
1037  'size' => $uploadedFileData['size'][$i],
1038  ];
1039  try {
1040  $fileObject = $targetFolderObject->addUploadedFile($fileInfo, $this->existingFilesConflictMode);
1041  if ($this->existingFilesConflictMode === DuplicationBehavior::REPLACE) {
1042  $this->‪getIndexer($fileObject->getStorage())->‪updateIndexEntry($fileObject);
1043  }
1044  $resultObjects[] = $fileObject;
1045  $this->internalUploadMap[$uploadPosition] = $fileObject->getCombinedIdentifier();
1046  if ($fileObject->getName() !== $fileInfo['name']) {
1047  $this->‪addMessageToFlashMessageQueue('FileUtility.FileNameSanitized', [$fileInfo['name'], $fileObject->getName()], ContextualFeedbackSeverity::WARNING);
1048  }
1049  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::MESSAGE, 'Uploading file "{identifier}" to "{destination}"', ['identifier' => $fileInfo['name'], 'destination' => $targetFolderObject->getIdentifier()]);
1050  $this->‪addMessageToFlashMessageQueue('FileUtility.UploadingFileTo', [$fileInfo['name'], $targetFolderObject->getIdentifier()], ContextualFeedbackSeverity::OK);
1051  } catch (InsufficientFileWritePermissionsException $e) {
1052  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::USER_ERROR, 'You are not allowed to override {identifier}', ['identifier' => $fileInfo['name']]);
1053  $this->‪addMessageToFlashMessageQueue('FileUtility.YouAreNotAllowedToOverride', [$fileInfo['name']]);
1054  } catch (UploadException $e) {
1055  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::SYSTEM_ERROR, 'The upload has failed, no uploaded file found');
1056  $this->‪addMessageToFlashMessageQueue('FileUtility.TheUploadHasFailedNoUploadedFileFound');
1057  } catch (InsufficientUserPermissionsException $e) {
1058  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::USER_ERROR, 'You are not allowed to upload files');
1059  $this->‪addMessageToFlashMessageQueue('FileUtility.YouAreNotAllowedToUploadFiles');
1060  } catch (UploadSizeException $e) {
1061  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::USER_ERROR, 'The uploaded file "{identifier}" exceeds the size-limit', ['identifier' => $fileInfo['name']]);
1062  $this->‪addMessageToFlashMessageQueue('FileUtility.TheUploadedFileExceedsTheSize-limit', [$fileInfo['name']]);
1063  } catch (InsufficientFolderWritePermissionsException $e) {
1064  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::USER_ERROR, 'Destination path "{destination}" was not within your mountpoints', ['destination' => $targetFolderObject->getIdentifier()]);
1065  $this->‪addMessageToFlashMessageQueue('FileUtility.DestinationPathWasNotWithinYourMountpoints', [$targetFolderObject->getIdentifier()]);
1066  } catch (IllegalFileExtensionException $e) {
1067  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::USER_ERROR, 'Extension of file name "{identifier}" is not allowed in "{destination}"', ['identifier' => $fileInfo['name'], 'destination' => $targetFolderObject->getIdentifier()]);
1068  $this->‪addMessageToFlashMessageQueue('FileUtility.ExtensionOfFileNameIsNotAllowedIn', [$fileInfo['name'], $targetFolderObject->getIdentifier()]);
1069  } catch (ExistingTargetFileNameException $e) {
1070  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::USER_ERROR, 'No unique filename available in "{destination}"', ['destination' => $targetFolderObject->getIdentifier()]);
1071  $this->‪addMessageToFlashMessageQueue('FileUtility.NoUniqueFilenameAvailableIn', [$targetFolderObject->getIdentifier()]);
1072  } catch (\RuntimeException $e) {
1073  $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()]);
1074  $this->‪addMessageToFlashMessageQueue('FileUtility.UploadedFileCouldNotBeMoved', [$targetFolderObject->getIdentifier()]);
1075  }
1076  }
1077 
1078  return $resultObjects;
1079  }
1080 
1090  protected function ‪replaceFile(array $cmdArr)
1091  {
1092  $fileObjectToReplace = null;
1093  $uploadPosition = $cmdArr['data'];
1094  $fileInfo = $_FILES['replace_' . $uploadPosition];
1095  if (empty($fileInfo['name'])) {
1096  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::SYSTEM_ERROR, 'No file was uploaded for replacing');
1097  $this->‪addMessageToFlashMessageQueue('FileUtility.NoFileWasUploadedForReplacing');
1098  return false;
1099  }
1100 
1101  $keepFileName = (bool)($cmdArr['keepFilename'] ?? false);
1102  $resultObjects = [];
1103 
1104  try {
1105  $fileObjectToReplace = $this->‪getFileObject($cmdArr['uid']);
1106  $folder = $fileObjectToReplace->getParentFolder();
1107  $resourceStorage = $fileObjectToReplace->getStorage();
1108 
1109  $fileObject = $resourceStorage->addUploadedFile($fileInfo, $folder, $fileObjectToReplace->getName(), DuplicationBehavior::REPLACE);
1110 
1111  // Check if there is a file that is going to be uploaded that has a different name as the replacing one
1112  // but exists in that folder as well.
1113  // rename to another name, but check if the name is already given
1114  if ($keepFileName === false) {
1115  // if a file with the same name already exists, we need to change it to _01 etc.
1116  // if the file does not exist, we can do a simple rename
1117  $resourceStorage->moveFile($fileObject, $folder, $fileInfo['name'], DuplicationBehavior::RENAME);
1118  }
1119 
1120  $resultObjects[] = $fileObject;
1121  $this->internalUploadMap[$uploadPosition] = $fileObject->getCombinedIdentifier();
1122 
1123  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::MESSAGE, 'Replacing file "{identifier}" to "{destination}"', ['identifier' => $fileInfo['name'], 'destination' => $fileObjectToReplace->getIdentifier()]);
1124  $this->‪addMessageToFlashMessageQueue('FileUtility.ReplacingFileTo', [$fileInfo['name'], $fileObjectToReplace->getIdentifier()], ContextualFeedbackSeverity::OK);
1125  } catch (InsufficientFileWritePermissionsException $e) {
1126  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::USER_ERROR, 'You are not allowed to override "{destination}"', ['destination' => $fileInfo['name']]);
1127  $this->‪addMessageToFlashMessageQueue('FileUtility.YouAreNotAllowedToOverride', [$fileInfo['name']]);
1128  } catch (UploadException $e) {
1129  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::SYSTEM_ERROR, 'The upload has failed, no uploaded file found');
1130  $this->‪addMessageToFlashMessageQueue('FileUtility.TheUploadHasFailedNoUploadedFileFound');
1131  } catch (InsufficientUserPermissionsException $e) {
1132  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::USER_ERROR, 'You are not allowed to upload files');
1133  $this->‪addMessageToFlashMessageQueue('FileUtility.YouAreNotAllowedToUploadFiles');
1134  } catch (UploadSizeException $e) {
1135  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::USER_ERROR, 'The uploaded file "{identifier}" exceeds the size-limit', ['identifier' => $fileInfo['name']]);
1136  $this->‪addMessageToFlashMessageQueue('FileUtility.TheUploadedFileExceedsTheSize-limit', [$fileInfo['name']]);
1137  } catch (InsufficientFolderWritePermissionsException $e) {
1138  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::USER_ERROR, 'Destination path "{destination}" was not within your mountpoints', ['destination' => $fileObjectToReplace->getIdentifier()]);
1139  $this->‪addMessageToFlashMessageQueue('FileUtility.DestinationPathWasNotWithinYourMountpoints', [$fileObjectToReplace->getIdentifier()]);
1140  } catch (IllegalFileExtensionException $e) {
1141  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::USER_ERROR, 'Extension of file name "{identifier}" is not allowed in "{destination}"', ['identifier' => $fileInfo['name'], 'destination' => $fileObjectToReplace->getIdentifier()]);
1142  $this->‪addMessageToFlashMessageQueue('FileUtility.ExtensionOfFileNameIsNotAllowedIn', [$fileInfo['name'], $fileObjectToReplace->getIdentifier()]);
1143  } catch (ExistingTargetFileNameException $e) {
1144  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::USER_ERROR, 'No unique filename available in "{destination}"', ['destination' => $fileObjectToReplace->getIdentifier()]);
1145  $this->‪addMessageToFlashMessageQueue('FileUtility.NoUniqueFilenameAvailableIn', [$fileObjectToReplace->getIdentifier()]);
1146  } catch (\RuntimeException $e) {
1147  throw $e;
1148  }
1149  return $resultObjects;
1150  }
1151 
1155  protected function ‪addFlashMessage(‪FlashMessage $flashMessage)
1156  {
1157  $flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class);
1158 
1159  $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
1160  $defaultFlashMessageQueue->enqueue($flashMessage);
1161  }
1162 
1168  protected function ‪getIndexer(‪ResourceStorage $storage)
1169  {
1170  return GeneralUtility::makeInstance(Indexer::class, $storage);
1171  }
1172 
1174  {
1175  return ‪$GLOBALS['BE_USER'];
1176  }
1177 
1178  protected function ‪getLanguageService(): ‪LanguageService
1179  {
1180  return ‪$GLOBALS['LANG'];
1181  }
1182 }
‪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:1150
‪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:1173
‪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:933
‪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:1168
‪TYPO3\CMS\Core\Resource\Exception\IllegalFileExtensionException
Definition: IllegalFileExtensionException.php:23
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\func_newfile
‪func_newfile($cmds)
Definition: ExtendedFileUtility.php:888
‪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:1085
‪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:1003
‪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:1163
‪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:847
‪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:767
‪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