‪TYPO3CMS  10.4
ExtendedFileUtility.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
48 use ‪TYPO3\CMS\Core\SysLog\Action\File as SystemLogFileAction;
49 use ‪TYPO3\CMS\Core\SysLog\Error as SystemLogErrorClassification;
50 use ‪TYPO3\CMS\Core\SysLog\Type as SystemLogType;
54 
70 {
78 
86  public ‪$actionPerms = [
87  // File permissions
88  'addFile' => false,
89  'readFile' => false,
90  'writeFile' => false,
91  'copyFile' => false,
92  'moveFile' => false,
93  'renameFile' => false,
94  'deleteFile' => false,
95  // Folder permissions
96  'addFolder' => false,
97  'readFolder' => false,
98  'writeFolder' => false,
99  'copyFolder' => false,
100  'moveFolder' => false,
101  'renameFolder' => false,
102  'deleteFolder' => false,
103  'recursivedeleteFolder' => false
104  ];
105 
111  public ‪$internalUploadMap = [];
112 
118  protected ‪$errorMessages = [];
119 
125  protected ‪$flashMessages = [];
126 
130  protected ‪$fileCmdMap;
131 
137  protected ‪$fileFactory;
138 
144  public function ‪getExistingFilesConflictMode()
145  {
147  }
148 
156  {
157  try {
158  $this->existingFilesConflictMode = ‪DuplicationBehavior::cast(‪$existingFilesConflictMode);
160  throw new ‪Exception(
161  sprintf(
162  'Invalid argument, received: "%s", expected a value from enumeration \TYPO3\CMS\Core\Resource\DuplicationBehavior (%s)',
164  implode(', ', ‪DuplicationBehavior::getConstants())
165  ),
166  1476046229
167  );
168  }
169  }
170 
176  public function ‪start($fileCmds)
177  {
178  // Initialize Object Factory
179  $this->fileFactory = GeneralUtility::makeInstance(ResourceFactory::class);
180  // Initializing file processing commands:
181  $this->fileCmdMap = $fileCmds;
182  }
183 
190  public function ‪setActionPermissions(array $permissions = [])
191  {
192  if (empty($permissions)) {
193  $permissions = $this->‪getBackendUser()->getFilePermissions();
194  }
195  $this->actionPerms = $permissions;
196  }
197 
204  public function ‪processData()
205  {
206  $result = [];
207  if (is_array($this->fileCmdMap)) {
208  // Check if there were uploads expected, but no one made
209  if ($this->fileCmdMap['upload']) {
210  $uploads = $this->fileCmdMap['upload'];
211  foreach ($uploads as $upload) {
212  if (empty($_FILES['upload_' . $upload['data']]['name'])
213  || (
214  is_array($_FILES['upload_' . $upload['data']]['name'])
215  && empty($_FILES['upload_' . $upload['data']]['name'][0])
216  )
217  ) {
218  unset($this->fileCmdMap['upload'][$upload['data']]);
219  }
220  }
221  if (empty($this->fileCmdMap['upload'])) {
222  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::USER_ERROR, 108, 'No file was uploaded!', []);
223  $this->‪addMessageToFlashMessageQueue('FileUtility.NoFileWasUploaded');
224  }
225  }
226 
227  // Check if there were new folder names expected, but non given
228  if ($this->fileCmdMap['newfolder']) {
229  foreach ($this->fileCmdMap['newfolder'] as $key => $cmdArr) {
230  if (empty($cmdArr['data'])) {
231  unset($this->fileCmdMap['newfolder'][$key]);
232  }
233  }
234  if (empty($this->fileCmdMap['newfolder'])) {
235  $this->‪writeLog(SystemLogFileAction::NEW_FOLDER, SystemLogErrorClassification::USER_ERROR, 108, 'No name for new folder given!', []);
236  $this->‪addMessageToFlashMessageQueue('FileUtility.NoNameForNewFolderGiven');
237  }
238  }
239 
240  // Traverse each set of actions
241  foreach ($this->fileCmdMap as $action => $actionData) {
242  // Traverse all action data. More than one file might be affected at the same time.
243  if (is_array($actionData)) {
244  $result[$action] = [];
245  foreach ($actionData as $cmdArr) {
246  // Clear file stats
247  clearstatcache();
248  // Branch out based on command:
249  switch ($action) {
250  case 'delete':
251  $result[$action][] = $this->‪func_delete($cmdArr);
252  break;
253  case 'copy':
254  $result[$action][] = $this->‪func_copy($cmdArr);
255  break;
256  case 'move':
257  $result[$action][] = $this->‪func_move($cmdArr);
258  break;
259  case 'rename':
260  $result[$action][] = $this->‪func_rename($cmdArr);
261  break;
262  case 'newfolder':
263  $result[$action][] = $this->‪func_newfolder($cmdArr);
264  break;
265  case 'newfile':
266  $result[$action][] = $this->‪func_newfile($cmdArr);
267  break;
268  case 'editfile':
269  $result[$action][] = $this->‪func_edit($cmdArr);
270  break;
271  case 'upload':
272  $result[$action][] = $this->‪func_upload($cmdArr);
273  break;
274  case 'replace':
275  $result[$action][] = $this->‪replaceFile($cmdArr);
276  break;
277  }
278  // Hook for post-processing the action
279  foreach (‪$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_extfilefunc.php']['processData'] ?? [] as $className) {
280  $hookObject = GeneralUtility::makeInstance($className);
281  if (!$hookObject instanceof ‪ExtendedFileUtilityProcessDataHookInterface) {
282  throw new \UnexpectedValueException($className . ' must implement interface ' . ExtendedFileUtilityProcessDataHookInterface::class, 1279719168);
283  }
284  $hookObject->processData_postProcessAction($action, $cmdArr, $result[$action], $this);
285  }
286  }
287  }
288  }
289  }
290  return $result;
291  }
292 
298  public function ‪getErrorMessages()
299  {
301  }
302 
310  public function ‪writeLog($action, $error, $details_nr, $details, $data)
311  {
312  if (is_object($this->‪getBackendUser())) {
313  $this->‪getBackendUser()->writelog(SystemLogType::FILE, $action, $error, $details_nr, $details, $data);
314  }
315  if ($error > 0) {
316  $this->errorMessages[] = vsprintf($details, $data);
317  }
318  }
319 
328  protected function ‪addMessageToFlashMessageQueue($localizationKey, array $replaceMarkers = [], $severity = ‪FlashMessage::ERROR)
329  {
330  if (TYPO3_MODE !== 'BE') {
331  return;
332  }
333  $label = $this->‪getLanguageService()->‪sL('LLL:EXT:core/Resources/Private/Language/fileMessages.xlf:' . $localizationKey);
334  $message = vsprintf($label, $replaceMarkers);
335  $flashMessage = GeneralUtility::makeInstance(
336  FlashMessage::class,
337  $message,
338  '',
339  $severity,
340  true
341  );
342  $this->‪addFlashMessage($flashMessage);
343  }
344 
345  /*************************************
346  *
347  * File operation functions
348  *
349  **************************************/
356  public function ‪func_delete(array $cmds)
357  {
358  $result = false;
359  // Example identifier for $cmds['data'] => "4:mypath/tomyfolder/myfile.jpg"
360  // for backwards compatibility: the combined file identifier was the path+filename
361  try {
362  $fileObject = $this->‪getFileObject($cmds['data']);
363  } catch (‪ResourceDoesNotExistException $e) {
364  $flashMessage = GeneralUtility::makeInstance(
365  FlashMessage::class,
366  sprintf(
367  $this->‪getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:message.description.fileNotFound'),
368  $cmds['data']
369  ),
370  $this->‪getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:message.header.fileNotFound'),
372  true
373  );
374  $this->‪addFlashMessage($flashMessage);
375 
376  return false;
377  }
378  // checks to delete the file
379  if ($fileObject instanceof ‪File) {
380  // check if the file still has references
381  // Exclude sys_file_metadata records as these are no use references
382  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('sys_refindex');
383  $queryBuilder->getRestrictions()->removeAll()->add(GeneralUtility::makeInstance(DeletedRestriction::class));
384  $refIndexRecords = $queryBuilder
385  ->select('tablename', 'recuid', 'ref_uid')
386  ->from('sys_refindex')
387  ->where(
388  $queryBuilder->expr()->eq(
389  'ref_table',
390  $queryBuilder->createNamedParameter('sys_file', \PDO::PARAM_STR)
391  ),
392  $queryBuilder->expr()->eq(
393  'ref_uid',
394  $queryBuilder->createNamedParameter($fileObject->getUid(), \PDO::PARAM_INT)
395  ),
396  $queryBuilder->expr()->neq(
397  'tablename',
398  $queryBuilder->createNamedParameter('sys_file_metadata', \PDO::PARAM_STR)
399  ),
400  $queryBuilder->expr()->eq(
401  'deleted',
402  $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)
403  )
404  )
405  ->execute()
406  ->fetchAll();
407  $deleteFile = true;
408  if (!empty($refIndexRecords)) {
409  $shortcutContent = [];
410  $brokenReferences = [];
411 
412  foreach ($refIndexRecords as $fileReferenceRow) {
413  if ($fileReferenceRow['tablename'] === 'sys_file_reference') {
414  $row = $this->‪transformFileReferenceToRecordReference($fileReferenceRow);
415  $shortcutRecord = ‪BackendUtility::getRecord($row['tablename'], $row['recuid']);
416 
417  if ($shortcutRecord) {
418  $shortcutContent[] = '[record:' . $row['tablename'] . ':' . $row['recuid'] . ']';
419  } else {
420  $brokenReferences[] = $fileReferenceRow['ref_uid'];
421  }
422  } else {
423  $shortcutContent[] = '[record:' . $fileReferenceRow['tablename'] . ':' . $fileReferenceRow['recuid'] . ']';
424  }
425  }
426  if (!empty($brokenReferences)) {
427  // render a message that the file has broken references
428  $flashMessage = GeneralUtility::makeInstance(
429  FlashMessage::class,
430  sprintf($this->‪getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:message.description.fileHasBrokenReferences'), count($brokenReferences)),
431  $this->‪getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:message.header.fileHasBrokenReferences'),
433  true
434  );
435  $this->‪addFlashMessage($flashMessage);
436  }
437  if (!empty($shortcutContent)) {
438  // render a message that the file could not be deleted
439  $flashMessage = GeneralUtility::makeInstance(
440  FlashMessage::class,
441  sprintf($this->‪getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:message.description.fileNotDeletedHasReferences'), $fileObject->getName()) . ' ' . implode(', ', $shortcutContent),
442  $this->‪getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:message.header.fileNotDeletedHasReferences'),
444  true
445  );
446  $this->‪addFlashMessage($flashMessage);
447  $deleteFile = false;
448  }
449  }
450 
451  if ($deleteFile) {
452  try {
453  $result = $fileObject->delete();
454 
455  // show the user that the file was deleted
456  $flashMessage = GeneralUtility::makeInstance(
457  FlashMessage::class,
458  sprintf($this->‪getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:message.description.fileDeleted'), $fileObject->getName()),
459  $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:message.header.fileDeleted'),
461  true
462  );
463  $this->‪addFlashMessage($flashMessage);
464  // Log success
465  $this->‪writeLog(SystemLogFileAction::DELETE, SystemLogErrorClassification::MESSAGE, 1, 'File "%s" deleted', [$fileObject->getIdentifier()]);
467  $this->‪writeLog(SystemLogFileAction::DELETE, SystemLogErrorClassification::USER_ERROR, 112, 'You are not allowed to access the file', [$fileObject->getIdentifier()]);
468  $this->‪addMessageToFlashMessageQueue('FileUtility.YouAreNotAllowedToAccessTheFile', [$fileObject->getIdentifier()]);
469  } catch (‪NotInMountPointException $e) {
470  $this->‪writeLog(SystemLogFileAction::DELETE, SystemLogErrorClassification::USER_ERROR, 111, 'Target was not within your mountpoints! T="%s"', [$fileObject->getIdentifier()]);
471  $this->‪addMessageToFlashMessageQueue('FileUtility.TargetWasNotWithinYourMountpoints', [$fileObject->getIdentifier()]);
472  } catch (\RuntimeException $e) {
473  $this->‪writeLog(SystemLogFileAction::DELETE, SystemLogErrorClassification::USER_ERROR, 110, 'Could not delete file "%s". Write-permission problem?', [$fileObject->getIdentifier()]);
474  $this->‪addMessageToFlashMessageQueue('FileUtility.CouldNotDeleteFile', [$fileObject->getIdentifier()]);
475  }
476  }
477  } else {
479  if (!$this->‪folderHasFilesInUse($fileObject)) {
480  try {
481  $result = $fileObject->delete(true);
482  if ($result) {
483  // notify the user that the folder was deleted
485  $flashMessage = GeneralUtility::makeInstance(
486  FlashMessage::class,
487  sprintf($this->‪getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:message.description.folderDeleted'), $fileObject->getName()),
488  $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:message.header.folderDeleted'),
490  true
491  );
492  $this->‪addFlashMessage($flashMessage);
493  // Log success
494  $this->‪writeLog(SystemLogFileAction::DELETE, SystemLogErrorClassification::MESSAGE, 3, 'Directory "%s" deleted', [$fileObject->getIdentifier()]);
495  }
497  $this->‪writeLog(SystemLogFileAction::DELETE, SystemLogErrorClassification::USER_ERROR, 120, 'Could not delete directory! Is directory "%s" empty? (You are not allowed to delete directories recursively).', [$fileObject->getIdentifier()]);
498  $this->‪addMessageToFlashMessageQueue('FileUtility.CouldNotDeleteDirectory', [$fileObject->getIdentifier()]);
500  $this->‪writeLog(SystemLogFileAction::DELETE, SystemLogErrorClassification::USER_ERROR, 123, 'You are not allowed to access the directory', [$fileObject->getIdentifier()]);
501  $this->‪addMessageToFlashMessageQueue('FileUtility.YouAreNotAllowedToAccessTheDirectory', [$fileObject->getIdentifier()]);
502  } catch (‪NotInMountPointException $e) {
503  $this->‪writeLog(SystemLogFileAction::DELETE, SystemLogErrorClassification::USER_ERROR, 121, 'Target was not within your mountpoints! T="%s"', [$fileObject->getIdentifier()]);
504  $this->‪addMessageToFlashMessageQueue('FileUtility.TargetWasNotWithinYourMountpoints', [$fileObject->getIdentifier()]);
505  } catch (‪FileOperationErrorException $e) {
506  $this->‪writeLog(SystemLogFileAction::DELETE, SystemLogErrorClassification::USER_ERROR, 120, 'Could not delete directory "%s"! Write-permission problem?', [$fileObject->getIdentifier()]);
507  $this->‪addMessageToFlashMessageQueue('FileUtility.CouldNotDeleteDirectory', [$fileObject->getIdentifier()]);
508  }
509  }
510  }
511 
512  return $result;
513  }
514 
523  public function ‪folderHasFilesInUse(‪Folder $folder)
524  {
526  if (empty($files)) {
527  return false;
528  }
529 
531  $fileUids = [];
532  foreach ($files as $file) {
533  $fileUids[] = $file->‪getUid();
534  }
535 
536  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('sys_refindex');
537  $queryBuilder->getRestrictions()->removeAll()->add(GeneralUtility::makeInstance(DeletedRestriction::class));
538  $numberOfReferences = $queryBuilder
539  ->count('hash')
540  ->from('sys_refindex')
541  ->where(
542  $queryBuilder->expr()->eq(
543  'ref_table',
544  $queryBuilder->createNamedParameter('sys_file', \PDO::PARAM_STR)
545  ),
546  $queryBuilder->expr()->in(
547  'ref_uid',
548  $queryBuilder->createNamedParameter($fileUids, Connection::PARAM_INT_ARRAY)
549  ),
550  $queryBuilder->expr()->neq(
551  'tablename',
552  $queryBuilder->createNamedParameter('sys_file_metadata', \PDO::PARAM_STR)
553  ),
554  $queryBuilder->expr()->eq(
555  'deleted',
556  $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)
557  )
558  )->execute()->fetchColumn(0);
559 
560  $hasReferences = $numberOfReferences > 0;
561  if ($hasReferences) {
563  $flashMessage = GeneralUtility::makeInstance(
564  FlashMessage::class,
565  $this->‪getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:message.description.folderNotDeletedHasFilesWithReferences'),
566  $this->‪getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:message.header.folderNotDeletedHasFilesWithReferences'),
568  true
569  );
570  $this->‪addFlashMessage($flashMessage);
571  }
572 
573  return $hasReferences;
574  }
575 
583  protected function ‪transformFileReferenceToRecordReference(array $referenceRecord)
584  {
585  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('sys_refindex');
586  $queryBuilder->getRestrictions()->removeAll();
587  $fileReference = $queryBuilder
588  ->select('uid_foreign', 'tablenames', 'fieldname', 'sorting_foreign')
589  ->from('sys_file_reference')
590  ->where(
591  $queryBuilder->expr()->eq(
592  'uid',
593  $queryBuilder->createNamedParameter($referenceRecord['recuid'], \PDO::PARAM_INT)
594  )
595  )
596  ->execute()
597  ->fetch();
598 
599  return [
600  'recuid' => $fileReference['uid_foreign'],
601  'tablename' => $fileReference['tablenames'],
602  'field' => $fileReference['fieldname'],
603  'flexpointer' => '',
604  'softref_key' => '',
605  'sorting' => $fileReference['sorting_foreign']
606  ];
607  }
608 
617  protected function ‪getFileObject($identifier)
618  {
619  $object = $this->fileFactory->retrieveFileOrFolderObject($identifier);
620  if (!is_object($object)) {
621  throw new InvalidFileException('The item ' . $identifier . ' was not a file or directory!!', 1320122453);
622  }
623  if ($object->getStorage()->getUid() === 0) {
624  throw new InsufficientFileAccessPermissionsException('You are not allowed to access files outside your storages', 1375889830);
625  }
626  return $object;
627  }
628 
642  protected function ‪func_copy($cmds)
643  {
644  $sourceFileObject = $this->‪getFileObject($cmds['data']);
646  $targetFolderObject = $this->‪getFileObject($cmds['target']);
647  // Basic check
648  if (!$targetFolderObject instanceof Folder) {
649  $this->‪writeLog(SystemLogFileAction::COPY, SystemLogErrorClassification::SYSTEM_ERROR, 100, 'Destination "%s" was not a directory', [$cmds['target']]);
650  $this->‪addMessageToFlashMessageQueue('FileUtility.DestinationWasNotADirectory', [$cmds['target']]);
651  return false;
652  }
653  // If this is TRUE, we append _XX to the file name if
654  $appendSuffixOnConflict = (string)$cmds['altName'];
655  $resultObject = null;
656  $conflictMode = $appendSuffixOnConflict !== '' ? ‪DuplicationBehavior::RENAME : ‪DuplicationBehavior::CANCEL;
657  // Copying the file
658  if ($sourceFileObject instanceof File) {
659  try {
660  $resultObject = $sourceFileObject->copyTo($targetFolderObject, null, $conflictMode);
661  } catch (InsufficientUserPermissionsException $e) {
662  $this->‪writeLog(SystemLogFileAction::COPY, SystemLogErrorClassification::USER_ERROR, 114, 'You are not allowed to copy files', []);
663  $this->‪addMessageToFlashMessageQueue('FileUtility.YouAreNotAllowedToCopyFiles');
664  } catch (InsufficientFileAccessPermissionsException $e) {
665  $this->‪writeLog(SystemLogFileAction::COPY, SystemLogErrorClassification::USER_ERROR, 110, 'Could not access all necessary resources. Source file or destination maybe was not within your mountpoints? T="%s", D="%s"', [$sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
666  $this->‪addMessageToFlashMessageQueue('FileUtility.CouldNotAccessAllNecessaryResources', [$sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
667  } catch (IllegalFileExtensionException $e) {
668  $this->‪writeLog(SystemLogFileAction::COPY, SystemLogErrorClassification::USER_ERROR, 111, 'Extension of file name "%s" is not allowed in "%s"!', [$sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
669  $this->‪addMessageToFlashMessageQueue('FileUtility.ExtensionOfFileNameIsNotAllowedIn', [$sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
670  } catch (ExistingTargetFileNameException $e) {
671  $this->‪writeLog(SystemLogFileAction::COPY, SystemLogErrorClassification::USER_ERROR, 112, 'File "%s" already exists in folder "%s"!', [$sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
672  $this->‪addMessageToFlashMessageQueue('FileUtility.FileAlreadyExistsInFolder', [$sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
673  } catch (NotImplementedMethodException $e) {
674  $this->‪writeLog(SystemLogFileAction::MOVE, SystemLogErrorClassification::USER_ERROR, 128, 'The function to copy a file between storages is not yet implemented', []);
675  $this->‪addMessageToFlashMessageQueue('FileUtility.TheFunctionToCopyAFileBetweenStoragesIsNotYetImplemented');
676  } catch (\RuntimeException $e) {
677  $this->‪writeLog(SystemLogFileAction::COPY, SystemLogErrorClassification::SYSTEM_ERROR, 109, 'File "%s" WAS NOT copied to "%s"! Write-permission problem?', [$sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
678  $this->‪addMessageToFlashMessageQueue('FileUtility.FileWasNotCopiedTo', [$sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
679  }
680  if ($resultObject) {
681  $this->‪writeLog(SystemLogFileAction::COPY, SystemLogErrorClassification::MESSAGE, 1, 'File "%s" copied to "%s"', [$sourceFileObject->getIdentifier(), $resultObject->getIdentifier()]);
682  $this->‪addMessageToFlashMessageQueue('FileUtility.FileCopiedTo', [$sourceFileObject->getIdentifier(), $resultObject->getIdentifier()], ‪FlashMessage::OK);
683  }
684  } else {
685  // Else means this is a Folder
686  $sourceFolderObject = $sourceFileObject;
687  try {
688  $resultObject = $sourceFolderObject->copyTo($targetFolderObject, null, $conflictMode);
689  } catch (InsufficientUserPermissionsException $e) {
690  $this->‪writeLog(SystemLogFileAction::COPY, SystemLogErrorClassification::USER_ERROR, 125, 'You are not allowed to copy directories', []);
691  $this->‪addMessageToFlashMessageQueue('FileUtility.YouAreNotAllowedToCopyDirectories');
692  } catch (InsufficientFileAccessPermissionsException $e) {
693  $this->‪writeLog(SystemLogFileAction::COPY, SystemLogErrorClassification::USER_ERROR, 110, 'Could not access all necessary resources. Source file or destination maybe was not within your mountpoints? T="%s", D="%s"', [$sourceFolderObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
694  $this->‪addMessageToFlashMessageQueue('FileUtility.CouldNotAccessAllNecessaryResources', [$sourceFolderObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
695  } catch (InsufficientFolderAccessPermissionsException $e) {
696  $this->‪writeLog(SystemLogFileAction::COPY, SystemLogErrorClassification::USER_ERROR, 121, 'You don\'t have full access to the destination directory "%s"!', [$targetFolderObject->getIdentifier()]);
697  $this->‪addMessageToFlashMessageQueue('FileUtility.YouDontHaveFullAccessToTheDestinationDirectory', [$targetFolderObject->getIdentifier()]);
698  } catch (InvalidTargetFolderException $e) {
699  $this->‪writeLog(SystemLogFileAction::COPY, SystemLogErrorClassification::USER_ERROR, 122, 'Cannot copy folder "%s" into target folder "%s", because there is already a folder or file with that name in the target folder!', [$sourceFolderObject->getName(), $targetFolderObject->getName()]);
700  $this->‪addMessageToFlashMessageQueue('FileUtility.CannotCopyFolderIntoTargetFolderBecauseTheTargetFolderIsAlreadyWithinTheFolderToBeCopied', [$sourceFolderObject->getName(), $targetFolderObject->getIdentifier()]);
701  } catch (ExistingTargetFolderException $e) {
702  $this->‪writeLog(SystemLogFileAction::COPY, SystemLogErrorClassification::USER_ERROR, 123, 'Target "%s" already exists!', [$targetFolderObject->getIdentifier()]);
703  $this->‪addMessageToFlashMessageQueue('FileUtility.TargetAlreadyExists', [$targetFolderObject->getIdentifier()]);
704  } catch (NotImplementedMethodException $e) {
705  $this->‪writeLog(SystemLogFileAction::MOVE, SystemLogErrorClassification::USER_ERROR, 129, 'The function to copy a folder between storages is not yet implemented', []);
706  $this->‪addMessageToFlashMessageQueue('FileUtility.TheFunctionToCopyAFolderBetweenStoragesIsNotYetImplemented');
707  } catch (\RuntimeException $e) {
708  $this->‪writeLog(SystemLogFileAction::COPY, SystemLogErrorClassification::SYSTEM_ERROR, 119, 'Directory "%s" WAS NOT copied to "%s"! Write-permission problem?', [$sourceFolderObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
709  $this->‪addMessageToFlashMessageQueue('FileUtility.DirectoryWasNotCopiedTo', [$sourceFolderObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
710  }
711  if ($resultObject) {
712  $this->‪writeLog(SystemLogFileAction::COPY, SystemLogErrorClassification::MESSAGE, 2, 'Directory "%s" copied to "%s"', [$sourceFolderObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
713  $this->‪addMessageToFlashMessageQueue('FileUtility.DirectoryCopiedTo', [$sourceFolderObject->getIdentifier(), $targetFolderObject->getIdentifier()], ‪FlashMessage::OK);
714  }
715  }
716  return $resultObject;
717  }
718 
732  protected function ‪func_move($cmds)
733  {
734  $sourceFileObject = $this->‪getFileObject($cmds['data']);
735  $targetFolderObject = $this->‪getFileObject($cmds['target']);
736  // Basic check
737  if (!$targetFolderObject instanceof Folder) {
738  $this->‪writeLog(SystemLogFileAction::MOVE, SystemLogErrorClassification::SYSTEM_ERROR, 100, 'Destination "%s" was not a directory', [$cmds['target']]);
739  $this->‪addMessageToFlashMessageQueue('FileUtility.DestinationWasNotADirectory', [$cmds['target']]);
740  return false;
741  }
742  $alternativeName = (string)$cmds['altName'];
743  $resultObject = null;
744  // Moving the file
745  if ($sourceFileObject instanceof File) {
746  try {
747  if ($alternativeName !== '') {
748  // Don't allow overwriting existing files, but find a new name
749  $resultObject = $sourceFileObject->moveTo($targetFolderObject, $alternativeName, ‪DuplicationBehavior::RENAME);
750  } else {
751  // Don't allow overwriting existing files
752  $resultObject = $sourceFileObject->moveTo($targetFolderObject, null, ‪DuplicationBehavior::CANCEL);
753  }
754  $this->‪writeLog(SystemLogFileAction::MOVE, SystemLogErrorClassification::MESSAGE, 1, 'File "%s" moved to "%s"', [$sourceFileObject->getIdentifier(), $resultObject->getIdentifier()]);
755  $this->‪addMessageToFlashMessageQueue('FileUtility.FileMovedTo', [$sourceFileObject->getIdentifier(), $resultObject->getIdentifier()], ‪FlashMessage::OK);
756  } catch (InsufficientUserPermissionsException $e) {
757  $this->‪writeLog(SystemLogFileAction::MOVE, SystemLogErrorClassification::USER_ERROR, 114, 'You are not allowed to move files', []);
758  $this->‪addMessageToFlashMessageQueue('FileUtility.YouAreNotAllowedToMoveFiles');
759  } catch (InsufficientFileAccessPermissionsException $e) {
760  $this->‪writeLog(SystemLogFileAction::MOVE, SystemLogErrorClassification::USER_ERROR, 110, 'Could not access all necessary resources. Source file or destination maybe was not within your mountpoints? T="%s", D="%s"', [$sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
761  $this->‪addMessageToFlashMessageQueue('FileUtility.CouldNotAccessAllNecessaryResources', [$sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
762  } catch (IllegalFileExtensionException $e) {
763  $this->‪writeLog(SystemLogFileAction::MOVE, SystemLogErrorClassification::USER_ERROR, 111, 'Extension of file name "%s" is not allowed in "%s"!', [$sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
764  $this->‪addMessageToFlashMessageQueue('FileUtility.ExtensionOfFileNameIsNotAllowedIn', [$sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
765  } catch (ExistingTargetFileNameException $e) {
766  $this->‪writeLog(SystemLogFileAction::MOVE, SystemLogErrorClassification::USER_ERROR, 112, 'File "%s" already exists in folder "%s"!', [$sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
767  $this->‪addMessageToFlashMessageQueue('FileUtility.FileAlreadyExistsInFolder', [$sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
768  } catch (NotImplementedMethodException $e) {
769  $this->‪writeLog(SystemLogFileAction::MOVE, SystemLogErrorClassification::USER_ERROR, 126, 'The function to move a file between storages is not yet implemented', []);
770  $this->‪addMessageToFlashMessageQueue('FileUtility.TheFunctionToMoveAFileBetweenStoragesIsNotYetImplemented');
771  } catch (\RuntimeException $e) {
772  $this->‪writeLog(SystemLogFileAction::MOVE, SystemLogErrorClassification::SYSTEM_ERROR, 109, 'File "%s" WAS NOT copied to "%s"! Write-permission problem?', [$sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
773  $this->‪addMessageToFlashMessageQueue('FileUtility.FileWasNotCopiedTo', [$sourceFileObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
774  }
775  } else {
776  // Else means this is a Folder
777  $sourceFolderObject = $sourceFileObject;
778  try {
779  if ($alternativeName !== '') {
780  // Don't allow overwriting existing files, but find a new name
781  $resultObject = $sourceFolderObject->moveTo($targetFolderObject, $alternativeName, ‪DuplicationBehavior::RENAME);
782  } else {
783  // Don't allow overwriting existing files
784  $resultObject = $sourceFolderObject->moveTo($targetFolderObject, null, ‪DuplicationBehavior::RENAME);
785  }
786  $this->‪writeLog(SystemLogFileAction::MOVE, SystemLogErrorClassification::MESSAGE, 2, 'Directory "%s" moved to "%s"', [$sourceFolderObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
787  $this->‪addMessageToFlashMessageQueue('FileUtility.DirectoryMovedTo', [$sourceFolderObject->getIdentifier(), $targetFolderObject->getIdentifier()], ‪FlashMessage::OK);
788  } catch (InsufficientUserPermissionsException $e) {
789  $this->‪writeLog(SystemLogFileAction::MOVE, SystemLogErrorClassification::USER_ERROR, 125, 'You are not allowed to move directories', []);
790  $this->‪addMessageToFlashMessageQueue('FileUtility.YouAreNotAllowedToMoveDirectories');
791  } catch (InsufficientFileAccessPermissionsException $e) {
792  $this->‪writeLog(SystemLogFileAction::MOVE, SystemLogErrorClassification::USER_ERROR, 110, 'Could not access all necessary resources. Source file or destination maybe was not within your mountpoints? T="%s", D="%s"', [$sourceFolderObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
793  $this->‪addMessageToFlashMessageQueue('FileUtility.CouldNotAccessAllNecessaryResources', [$sourceFolderObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
794  } catch (InsufficientFolderAccessPermissionsException $e) {
795  $this->‪writeLog(SystemLogFileAction::MOVE, SystemLogErrorClassification::USER_ERROR, 121, 'You don\'t have full access to the destination directory "%s"!', [$targetFolderObject->getIdentifier()]);
796  $this->‪addMessageToFlashMessageQueue('FileUtility.YouDontHaveFullAccessToTheDestinationDirectory', [$targetFolderObject->getIdentifier()]);
797  } catch (InvalidTargetFolderException $e) {
798  $this->‪writeLog(SystemLogFileAction::MOVE, SystemLogErrorClassification::USER_ERROR, 122, 'Cannot move folder "%s" into target folder "%s", because the target folder is already within the folder to be moved!', [$sourceFolderObject->getName(), $targetFolderObject->getName()]);
799  $this->‪addMessageToFlashMessageQueue('FileUtility.CannotMoveFolderIntoTargetFolderBecauseTheTargetFolderIsAlreadyWithinTheFolderToBeMoved', [$sourceFolderObject->getName(), $targetFolderObject->getName()]);
800  } catch (ExistingTargetFolderException $e) {
801  $this->‪writeLog(SystemLogFileAction::MOVE, SystemLogErrorClassification::USER_ERROR, 123, 'Target "%s" already exists!', [$targetFolderObject->getIdentifier()]);
802  $this->‪addMessageToFlashMessageQueue('FileUtility.TargetAlreadyExists', [$targetFolderObject->getIdentifier()]);
803  } catch (NotImplementedMethodException $e) {
804  $this->‪writeLog(SystemLogFileAction::MOVE, SystemLogErrorClassification::USER_ERROR, 127, 'The function to move a folder between storages is not yet implemented', []);
805  $this->‪addMessageToFlashMessageQueue('FileUtility.TheFunctionToMoveAFolderBetweenStoragesIsNotYetImplemented', []);
806  } catch (\RuntimeException $e) {
807  $this->‪writeLog(SystemLogFileAction::MOVE, SystemLogErrorClassification::SYSTEM_ERROR, 119, 'Directory "%s" WAS NOT moved to "%s"! Write-permission problem?', [$sourceFolderObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
808  $this->‪addMessageToFlashMessageQueue('FileUtility.DirectoryWasNotMovedTo', [$sourceFolderObject->getIdentifier(), $targetFolderObject->getIdentifier()]);
809  }
810  }
811  return $resultObject;
812  }
813 
825  public function ‪func_rename($cmds)
826  {
827  $sourceFileObject = $this->‪getFileObject($cmds['data']);
828  $sourceFile = $sourceFileObject->getName();
829  $targetFile = $cmds['target'];
830  $resultObject = null;
831  if ($sourceFileObject instanceof File) {
832  try {
833  // Try to rename the File
834  $resultObject = $sourceFileObject->rename($targetFile, $this->existingFilesConflictMode);
835  if ($resultObject->getName() !== $targetFile) {
836  $this->‪writeLog(SystemLogFileAction::RENAME, SystemLogErrorClassification::USER_ERROR, 1, 'File renamed from "%s" to "%s". Filename had to be sanitized!', [$sourceFile, $targetFile]);
837  $this->‪addMessageToFlashMessageQueue('FileUtility.FileNameSanitized', [$targetFile, $resultObject->getName()], ‪FlashMessage::WARNING);
838  } else {
839  $this->‪writeLog(SystemLogFileAction::RENAME, SystemLogErrorClassification::MESSAGE, 1, 'File renamed from "%s" to "%s"', [$sourceFile, $targetFile]);
840  }
841  if ($sourceFile === $resultObject->getName()) {
842  $this->‪addMessageToFlashMessageQueue('FileUtility.FileRenamedSameName', [$sourceFile], ‪FlashMessage::INFO);
843  } else {
844  $this->‪addMessageToFlashMessageQueue('FileUtility.FileRenamedFromTo', [$sourceFile, $resultObject->getName()], ‪FlashMessage::OK);
845  }
846  } catch (InsufficientUserPermissionsException $e) {
847  $this->‪writeLog(SystemLogFileAction::RENAME, SystemLogErrorClassification::USER_ERROR, 102, 'You are not allowed to rename files!', []);
848  $this->‪addMessageToFlashMessageQueue('FileUtility.YouAreNotAllowedToRenameFiles');
849  } catch (IllegalFileExtensionException $e) {
850  $this->‪writeLog(SystemLogFileAction::RENAME, SystemLogErrorClassification::USER_ERROR, 101, 'Extension of file name "%s" or "%s" was not allowed!', [$sourceFileObject->getName(), $targetFile]);
851  $this->‪addMessageToFlashMessageQueue('FileUtility.ExtensionOfFileNameOrWasNotAllowed', [$sourceFileObject->getName(), $targetFile]);
852  } catch (ExistingTargetFileNameException $e) {
853  $this->‪writeLog(SystemLogFileAction::RENAME, SystemLogErrorClassification::USER_ERROR, 120, 'Destination "%s" existed already!', [$targetFile]);
854  $this->‪addMessageToFlashMessageQueue('FileUtility.DestinationExistedAlready', [$targetFile]);
855  } catch (NotInMountPointException $e) {
856  $this->‪writeLog(SystemLogFileAction::RENAME, SystemLogErrorClassification::USER_ERROR, 121, 'Destination path "%s" was not within your mountpoints!', [$targetFile]);
857  $this->‪addMessageToFlashMessageQueue('FileUtility.DestinationPathWasNotWithinYourMountpoints', [$targetFile]);
858  } catch (\RuntimeException $e) {
859  $this->‪writeLog(SystemLogFileAction::RENAME, SystemLogErrorClassification::USER_ERROR, 100, 'File "%s" was not renamed! Write-permission problem in "%s"?', [$sourceFileObject->getName(), $targetFile]);
860  $this->‪addMessageToFlashMessageQueue('FileUtility.FileWasNotRenamed', [$sourceFileObject->getName(), $targetFile]);
861  }
862  } else {
863  // Else means this is a Folder
864  try {
865  // Try to rename the Folder
866  $resultObject = $sourceFileObject->rename($targetFile);
867  $newFolderName = $resultObject->getName();
868  $this->‪writeLog(SystemLogFileAction::RENAME, SystemLogErrorClassification::MESSAGE, 2, 'Directory renamed from "%s" to "%s"', [$sourceFile, $targetFile]);
869  if ($sourceFile === $newFolderName) {
870  $this->‪addMessageToFlashMessageQueue('FileUtility.DirectoryRenamedSameName', [$sourceFile], ‪FlashMessage::INFO);
871  } else {
872  if ($newFolderName === $targetFile) {
873  $this->‪addMessageToFlashMessageQueue('FileUtility.DirectoryRenamedFromTo', [$sourceFile, $newFolderName], ‪FlashMessage::OK);
874  } else {
875  $this->‪addMessageToFlashMessageQueue('FileUtility.DirectoryRenamedFromToCharReplaced', [$sourceFile, $newFolderName], ‪FlashMessage::WARNING);
876  }
877  }
878  } catch (InsufficientUserPermissionsException $e) {
879  $this->‪writeLog(SystemLogFileAction::RENAME, SystemLogErrorClassification::USER_ERROR, 111, 'You are not allowed to rename directories!', []);
880  $this->‪addMessageToFlashMessageQueue('FileUtility.YouAreNotAllowedToRenameDirectories');
881  } catch (ExistingTargetFileNameException $e) {
882  $this->‪writeLog(SystemLogFileAction::RENAME, SystemLogErrorClassification::USER_ERROR, 120, 'Destination "%s" existed already!', [$targetFile]);
883  $this->‪addMessageToFlashMessageQueue('FileUtility.DestinationExistedAlready', [$targetFile]);
884  } catch (NotInMountPointException $e) {
885  $this->‪writeLog(SystemLogFileAction::RENAME, SystemLogErrorClassification::USER_ERROR, 121, 'Destination path "%s" was not within your mountpoints!', [$targetFile]);
886  $this->‪addMessageToFlashMessageQueue('FileUtility.DestinationPathWasNotWithinYourMountpoints', [$targetFile]);
887  } catch (\RuntimeException $e) {
888  $this->‪writeLog(SystemLogFileAction::RENAME, SystemLogErrorClassification::USER_ERROR, 110, 'Directory "%s" was not renamed! Write-permission problem in "%s"?', [$sourceFileObject->getName(), $targetFile]);
889  $this->‪addMessageToFlashMessageQueue('FileUtility.DirectoryWasNotRenamed', [$sourceFileObject->getName(), $targetFile]);
890  }
891  }
892  return $resultObject;
893  }
894 
905  public function ‪func_newfolder($cmds)
906  {
907  $resultObject = false;
908  $targetFolderObject = $this->‪getFileObject($cmds['target']);
909  if (!$targetFolderObject instanceof Folder) {
910  $this->‪writeLog(SystemLogFileAction::NEW_FOLDER, SystemLogErrorClassification::SYSTEM_ERROR, 104, 'Destination "%s" was not a directory', [$cmds['target']]);
911  $this->‪addMessageToFlashMessageQueue('FileUtility.DestinationWasNotADirectory', [$cmds['target']]);
912  return false;
913  }
914  $folderName = $cmds['data'];
915  try {
916  $resultObject = $targetFolderObject->createFolder($folderName);
917  $this->‪writeLog(SystemLogFileAction::NEW_FOLDER, SystemLogErrorClassification::MESSAGE, 1, 'Directory "%s" created in "%s"', [$folderName, $targetFolderObject->getIdentifier()]);
918  $this->‪addMessageToFlashMessageQueue('FileUtility.DirectoryCreatedIn', [$folderName, $targetFolderObject->getIdentifier()], ‪FlashMessage::OK);
919  } catch (InvalidFileNameException $e) {
920  $this->‪writeLog(SystemLogFileAction::NEW_FOLDER, SystemLogErrorClassification::USER_ERROR, 104, 'Invalid folder name "%s"!', [$folderName]);
921  $this->‪addMessageToFlashMessageQueue('FileUtility.YouAreNotAllowedToCreateDirectories', [$folderName]);
922  } catch (InsufficientFolderWritePermissionsException $e) {
923  $this->‪writeLog(SystemLogFileAction::NEW_FOLDER, SystemLogErrorClassification::USER_ERROR, 103, 'You are not allowed to create directories!', []);
924  $this->‪addMessageToFlashMessageQueue('FileUtility.YouAreNotAllowedToCreateDirectories');
925  } catch (NotInMountPointException $e) {
926  $this->‪writeLog(SystemLogFileAction::NEW_FOLDER, SystemLogErrorClassification::USER_ERROR, 102, 'Destination path "%s" was not within your mountpoints!', [$targetFolderObject->getIdentifier()]);
927  $this->‪addMessageToFlashMessageQueue('FileUtility.DestinationPathWasNotWithinYourMountpoints', [$targetFolderObject->getIdentifier()]);
928  } catch (ExistingTargetFolderException $e) {
929  $this->‪writeLog(SystemLogFileAction::NEW_FOLDER, SystemLogErrorClassification::USER_ERROR, 101, 'File or directory "%s" existed already!', [$folderName]);
930  $this->‪addMessageToFlashMessageQueue('FileUtility.FileOrDirectoryExistedAlready', [$folderName]);
931  } catch (\RuntimeException $e) {
932  $this->‪writeLog(SystemLogFileAction::NEW_FOLDER, SystemLogErrorClassification::USER_ERROR, 100, 'Directory "%s" not created. Write-permission problem in "%s"?', [$folderName, $targetFolderObject->getIdentifier()]);
933  $this->‪addMessageToFlashMessageQueue('FileUtility.DirectoryNotCreated', [$folderName, $targetFolderObject->getIdentifier()]);
934  }
935  return $resultObject;
936  }
937 
947  public function ‪func_newfile($cmds)
948  {
949  $targetFolderObject = $this->‪getFileObject($cmds['target']);
950  if (!$targetFolderObject instanceof Folder) {
951  $this->‪writeLog(SystemLogFileAction::NEW_FILE, SystemLogErrorClassification::SYSTEM_ERROR, 104, 'Destination "%s" was not a directory', [$cmds['target']]);
952  $this->‪addMessageToFlashMessageQueue('FileUtility.DestinationWasNotADirectory', [$cmds['target']]);
953  return false;
954  }
955  $resultObject = null;
956  $fileName = $cmds['data'];
957  try {
958  $resultObject = $targetFolderObject->createFile($fileName);
959  $this->‪writeLog(SystemLogFileAction::NEW_FILE, SystemLogErrorClassification::MESSAGE, 1, 'File created: "%s"', [$fileName]);
960  if ($resultObject->getName() !== $fileName) {
961  $this->‪addMessageToFlashMessageQueue('FileUtility.FileNameSanitized', [$fileName, $resultObject->getName()], ‪FlashMessage::WARNING);
962  }
963  $this->‪addMessageToFlashMessageQueue('FileUtility.FileCreated', [$resultObject->getName()], ‪FlashMessage::OK);
964  } catch (IllegalFileExtensionException $e) {
965  $this->‪writeLog(SystemLogFileAction::NEW_FILE, SystemLogErrorClassification::USER_ERROR, 106, 'Extension of file "%s" was not allowed!', [$fileName]);
966  $this->‪addMessageToFlashMessageQueue('FileUtility.ExtensionOfFileWasNotAllowed', [$fileName]);
967  } catch (InsufficientFolderWritePermissionsException $e) {
968  $this->‪writeLog(SystemLogFileAction::NEW_FILE, SystemLogErrorClassification::USER_ERROR, 103, 'You are not allowed to create files!', []);
969  $this->‪addMessageToFlashMessageQueue('FileUtility.YouAreNotAllowedToCreateFiles');
970  } catch (NotInMountPointException $e) {
971  $this->‪writeLog(SystemLogFileAction::NEW_FILE, SystemLogErrorClassification::USER_ERROR, 102, 'Destination path "%s" was not within your mountpoints!', [$targetFolderObject->getIdentifier()]);
972  $this->‪addMessageToFlashMessageQueue('FileUtility.DestinationPathWasNotWithinYourMountpoints', [$targetFolderObject->getIdentifier()]);
973  } catch (ExistingTargetFileNameException $e) {
974  $this->‪writeLog(SystemLogFileAction::NEW_FILE, SystemLogErrorClassification::USER_ERROR, 101, 'File existed already in "%s"!', [$targetFolderObject->getIdentifier()]);
975  $this->‪addMessageToFlashMessageQueue('FileUtility.FileExistedAlreadyIn', [$targetFolderObject->getIdentifier()]);
976  } catch (InvalidFileNameException $e) {
977  $this->‪writeLog(SystemLogFileAction::NEW_FILE, SystemLogErrorClassification::USER_ERROR, 106, 'File name "%s" was not allowed!', [$fileName]);
978  $this->‪addMessageToFlashMessageQueue('FileUtility.FileNameWasNotAllowed', [$fileName]);
979  } catch (\RuntimeException $e) {
980  $this->‪writeLog(SystemLogFileAction::NEW_FILE, SystemLogErrorClassification::USER_ERROR, 100, 'File "%s" was not created! Write-permission problem in "%s"?', [$fileName, $targetFolderObject->getIdentifier()]);
981  $this->‪addMessageToFlashMessageQueue('FileUtility.FileWasNotCreated', [$fileName, $targetFolderObject->getIdentifier()]);
982  }
983  return $resultObject;
984  }
985 
992  public function ‪func_edit($cmds)
993  {
994  // Example identifier for $cmds['target'] => "4:mypath/tomyfolder/myfile.jpg"
995  // for backwards compatibility: the combined file identifier was the path+filename
996  $fileIdentifier = $cmds['target'];
997  $fileObject = $this->‪getFileObject($fileIdentifier);
998  if (!$fileObject instanceof ‪File) {
999  $this->‪writeLog(SystemLogFileAction::EDIT, SystemLogErrorClassification::SYSTEM_ERROR, 123, 'Target "%s" was not a file!', [$fileIdentifier]);
1000  $this->‪addMessageToFlashMessageQueue('FileUtility.TargetWasNotAFile', [$fileIdentifier]);
1001  return false;
1002  }
1003  if (!$fileObject->isTextFile()) {
1004  $extList = ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['textfile_ext'];
1005  $this->‪writeLog(SystemLogFileAction::EDIT, SystemLogErrorClassification::USER_ERROR, 102, 'File extension "%s" is not a textfile format! (%s)', [$fileObject->getExtension(), $extList]);
1006  $this->‪addMessageToFlashMessageQueue('FileUtility.FileExtensionIsNotATextfileFormat', [$fileObject->getExtension(), $extList]);
1007  return false;
1008  }
1009  try {
1010  // Example identifier for $cmds['target'] => "2:targetpath/targetfolder/"
1011  $content = $cmds['data'];
1012  $fileObject->setContents($content);
1013  clearstatcache();
1014  $this->‪writeLog(SystemLogFileAction::EDIT, SystemLogErrorClassification::MESSAGE, 1, 'File saved to "%s", bytes: %s, MD5: %s ', [$fileObject->getIdentifier(), $fileObject->getSize(), md5($content)]);
1015  $this->‪addMessageToFlashMessageQueue('FileUtility.FileSavedToBytesMd5', [$fileObject->getIdentifier(), $fileObject->getSize(), md5($content)], ‪FlashMessage::OK);
1016  return true;
1018  $this->‪writeLog(SystemLogFileAction::EDIT, SystemLogErrorClassification::USER_ERROR, 104, 'You are not allowed to edit files!', []);
1019  $this->‪addMessageToFlashMessageQueue('FileUtility.YouAreNotAllowedToEditFiles');
1020  return false;
1022  $this->‪writeLog(SystemLogFileAction::EDIT, SystemLogErrorClassification::USER_ERROR, 100, 'File "%s" was not saved! Write-permission problem?', [$fileObject->getIdentifier()]);
1023  $this->‪addMessageToFlashMessageQueue('FileUtility.FileWasNotSaved', [$fileObject->getIdentifier()]);
1024  return false;
1025  } catch (‪IllegalFileExtensionException|\RuntimeException $e) {
1026  $this->‪writeLog(SystemLogFileAction::EDIT, SystemLogErrorClassification::USER_ERROR, 100, 'File "%s" was not saved! File extension rejected!', [$fileObject->getIdentifier()]);
1027  $this->‪addMessageToFlashMessageQueue('FileUtility.FileWasNotSaved', [$fileObject->getIdentifier()]);
1028  return false;
1029  }
1030  }
1031 
1062  public function ‪func_upload($cmds)
1063  {
1064  $uploadPosition = $cmds['data'];
1065  $uploadedFileData = $_FILES['upload_' . $uploadPosition];
1066  if (empty($uploadedFileData['name']) || is_array($uploadedFileData['name']) && empty($uploadedFileData['name'][0])) {
1067  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::SYSTEM_ERROR, 108, 'No file was uploaded!', []);
1068  $this->‪addMessageToFlashMessageQueue('FileUtility.NoFileWasUploaded');
1069  return false;
1070  }
1071  // Example identifier for $cmds['target'] => "2:targetpath/targetfolder/"
1072  $targetFolderObject = $this->‪getFileObject($cmds['target']);
1073  // Uploading with non HTML-5-style, thus, make an array out of it, so we can loop over it
1074  if (!is_array($uploadedFileData['name'])) {
1075  $uploadedFileData = [
1076  'name' => [$uploadedFileData['name']],
1077  'type' => [$uploadedFileData['type']],
1078  'tmp_name' => [$uploadedFileData['tmp_name']],
1079  'size' => [$uploadedFileData['size']]
1080  ];
1081  }
1082  $resultObjects = [];
1083  $numberOfUploadedFilesForPosition = count($uploadedFileData['name']);
1084  // Loop through all uploaded files
1085  for ($i = 0; $i < $numberOfUploadedFilesForPosition; $i++) {
1086  $fileInfo = [
1087  'name' => $uploadedFileData['name'][$i],
1088  'type' => $uploadedFileData['type'][$i],
1089  'tmp_name' => $uploadedFileData['tmp_name'][$i],
1090  'size' => $uploadedFileData['size'][$i]
1091  ];
1092  try {
1094  $fileObject = $targetFolderObject->addUploadedFile($fileInfo, (string)$this->existingFilesConflictMode);
1095  $fileObject = GeneralUtility::makeInstance(ResourceFactory::class)->getFileObjectByStorageAndIdentifier($targetFolderObject->getStorage()->getUid(), $fileObject->getIdentifier());
1096  if ($this->existingFilesConflictMode->equals(‪DuplicationBehavior::REPLACE)) {
1097  $this->‪getIndexer($fileObject->getStorage())->‪updateIndexEntry($fileObject);
1098  }
1099  $resultObjects[] = $fileObject;
1100  $this->internalUploadMap[$uploadPosition] = $fileObject->‪getCombinedIdentifier();
1101  if ($fileObject->getName() !== $fileInfo['name']) {
1102  $this->‪addMessageToFlashMessageQueue('FileUtility.FileNameSanitized', [$fileInfo['name'], $fileObject->getName()], ‪FlashMessage::WARNING);
1103  }
1104  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::MESSAGE, 1, 'Uploading file "%s" to "%s"', [$fileInfo['name'], $targetFolderObject->getIdentifier()]);
1105  $this->‪addMessageToFlashMessageQueue('FileUtility.UploadingFileTo', [$fileInfo['name'], $targetFolderObject->getIdentifier()], ‪FlashMessage::OK);
1106  } catch (InsufficientFileWritePermissionsException $e) {
1107  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::USER_ERROR, 107, 'You are not allowed to override "%s"!', [$fileInfo['name']]);
1108  $this->‪addMessageToFlashMessageQueue('FileUtility.YouAreNotAllowedToOverride', [$fileInfo['name']]);
1109  } catch (UploadException $e) {
1110  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::SYSTEM_ERROR, 106, 'The upload has failed, no uploaded file found!', []);
1111  $this->‪addMessageToFlashMessageQueue('FileUtility.TheUploadHasFailedNoUploadedFileFound');
1112  } catch (InsufficientUserPermissionsException $e) {
1113  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::USER_ERROR, 105, 'You are not allowed to upload files!', []);
1114  $this->‪addMessageToFlashMessageQueue('FileUtility.YouAreNotAllowedToUploadFiles');
1115  } catch (UploadSizeException $e) {
1116  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::USER_ERROR, 104, 'The uploaded file "%s" exceeds the size-limit', [$fileInfo['name']]);
1117  $this->‪addMessageToFlashMessageQueue('FileUtility.TheUploadedFileExceedsTheSize-limit', [$fileInfo['name']]);
1118  } catch (InsufficientFolderWritePermissionsException $e) {
1119  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::USER_ERROR, 103, 'Destination path "%s" was not within your mountpoints!', [$targetFolderObject->getIdentifier()]);
1120  $this->‪addMessageToFlashMessageQueue('FileUtility.DestinationPathWasNotWithinYourMountpoints', [$targetFolderObject->getIdentifier()]);
1121  } catch (IllegalFileExtensionException $e) {
1122  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::USER_ERROR, 102, 'Extension of file name "%s" is not allowed in "%s"!', [$fileInfo['name'], $targetFolderObject->getIdentifier()]);
1123  $this->‪addMessageToFlashMessageQueue('FileUtility.ExtensionOfFileNameIsNotAllowedIn', [$fileInfo['name'], $targetFolderObject->getIdentifier()]);
1124  } catch (ExistingTargetFileNameException $e) {
1125  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::USER_ERROR, 101, 'No unique filename available in "%s"!', [$targetFolderObject->getIdentifier()]);
1126  $this->‪addMessageToFlashMessageQueue('FileUtility.NoUniqueFilenameAvailableIn', [$targetFolderObject->getIdentifier()]);
1127  } catch (\RuntimeException $e) {
1128  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::USER_ERROR, 100, 'Uploaded file could not be moved! Write-permission problem in "%s"?', [$targetFolderObject->getIdentifier()]);
1129  $this->‪addMessageToFlashMessageQueue('FileUtility.UploadedFileCouldNotBeMoved', [$targetFolderObject->getIdentifier()]);
1130  }
1131  }
1132 
1133  return $resultObjects;
1134  }
1135 
1146  protected function ‪replaceFile(array $cmdArr)
1147  {
1148  $fileObjectToReplace = null;
1149  $uploadPosition = $cmdArr['data'];
1150  $fileInfo = $_FILES['replace_' . $uploadPosition];
1151  if (empty($fileInfo['name'])) {
1152  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::SYSTEM_ERROR, 108, 'No file was uploaded for replacing!', []);
1153  $this->‪addMessageToFlashMessageQueue('FileUtility.NoFileWasUploadedForReplacing');
1154  return false;
1155  }
1156 
1157  $keepFileName = ($cmdArr['keepFilename'] == 1) ? true : false;
1158  $resultObjects = [];
1159 
1160  try {
1161  $fileObjectToReplace = $this->‪getFileObject($cmdArr['uid']);
1162  $folder = $fileObjectToReplace->‪getParentFolder();
1163  $resourceStorage = $fileObjectToReplace->‪getStorage();
1164 
1165  $fileObject = $resourceStorage->‪addUploadedFile($fileInfo, $folder, $fileObjectToReplace->getName(), ‪DuplicationBehavior::REPLACE);
1166 
1167  // Check if there is a file that is going to be uploaded that has a different name as the replacing one
1168  // but exists in that folder as well.
1169  // rename to another name, but check if the name is already given
1170  if ($keepFileName === false) {
1171  // if a file with the same name already exists, we need to change it to _01 etc.
1172  // if the file does not exist, we can do a simple rename
1173  $resourceStorage->moveFile($fileObject, $folder, $fileInfo['name'], ‪DuplicationBehavior::RENAME);
1174  }
1175 
1176  $resultObjects[] = $fileObject;
1177  $this->internalUploadMap[$uploadPosition] = $fileObject->getCombinedIdentifier();
1178 
1179  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::MESSAGE, 1, 'Replacing file "%s" to "%s"', [$fileInfo['name'], $fileObjectToReplace->getIdentifier()]);
1180  $this->‪addMessageToFlashMessageQueue('FileUtility.ReplacingFileTo', [$fileInfo['name'], $fileObjectToReplace->getIdentifier()], ‪FlashMessage::OK);
1181  } catch (InsufficientFileWritePermissionsException $e) {
1182  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::USER_ERROR, 107, 'You are not allowed to override "%s"!', [$fileInfo['name']]);
1183  $this->‪addMessageToFlashMessageQueue('FileUtility.YouAreNotAllowedToOverride', [$fileInfo['name']]);
1184  } catch (UploadException $e) {
1185  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::SYSTEM_ERROR, 106, 'The upload has failed, no uploaded file found!', []);
1186  $this->‪addMessageToFlashMessageQueue('FileUtility.TheUploadHasFailedNoUploadedFileFound');
1187  } catch (InsufficientUserPermissionsException $e) {
1188  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::USER_ERROR, 105, 'You are not allowed to upload files!', []);
1189  $this->‪addMessageToFlashMessageQueue('FileUtility.YouAreNotAllowedToUploadFiles');
1190  } catch (UploadSizeException $e) {
1191  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::USER_ERROR, 104, 'The uploaded file "%s" exceeds the size-limit', [$fileInfo['name']]);
1192  $this->‪addMessageToFlashMessageQueue('FileUtility.TheUploadedFileExceedsTheSize-limit', [$fileInfo['name']]);
1193  } catch (InsufficientFolderWritePermissionsException $e) {
1194  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::USER_ERROR, 103, 'Destination path "%s" was not within your mountpoints!', [$fileObjectToReplace->getIdentifier()]);
1195  $this->‪addMessageToFlashMessageQueue('FileUtility.DestinationPathWasNotWithinYourMountpoints', [$fileObjectToReplace->getIdentifier()]);
1196  } catch (IllegalFileExtensionException $e) {
1197  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::USER_ERROR, 102, 'Extension of file name "%s" is not allowed in "%s"!', [$fileInfo['name'], $fileObjectToReplace->getIdentifier()]);
1198  $this->‪addMessageToFlashMessageQueue('FileUtility.ExtensionOfFileNameIsNotAllowedIn', [$fileInfo['name'], $fileObjectToReplace->getIdentifier()]);
1199  } catch (ExistingTargetFileNameException $e) {
1200  $this->‪writeLog(SystemLogFileAction::UPLOAD, SystemLogErrorClassification::USER_ERROR, 101, 'No unique filename available in "%s"!', [$fileObjectToReplace->getIdentifier()]);
1201  $this->‪addMessageToFlashMessageQueue('FileUtility.NoUniqueFilenameAvailableIn', [$fileObjectToReplace->getIdentifier()]);
1202  } catch (\RuntimeException $e) {
1203  throw $e;
1204  }
1205  return $resultObjects;
1206  }
1207 
1213  protected function ‪addFlashMessage(‪FlashMessage $flashMessage)
1214  {
1216  $flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class);
1217 
1219  $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
1220  $defaultFlashMessageQueue->enqueue($flashMessage);
1221  }
1229  protected function ‪getIndexer(‪ResourceStorage $storage)
1230  {
1231  return GeneralUtility::makeInstance(Indexer::class, $storage);
1232  }
1233 
1237  protected function ‪getBackendUser()
1238  {
1239  return ‪$GLOBALS['BE_USER'];
1240  }
1241 
1247  protected function ‪getLanguageService()
1248  {
1249  return ‪$GLOBALS['LANG'];
1250  }
1251 }
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\addMessageToFlashMessageQueue
‪addMessageToFlashMessageQueue($localizationKey, array $replaceMarkers=[], $severity=FlashMessage::ERROR)
Definition: ExtendedFileUtility.php:321
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\folderHasFilesInUse
‪bool folderHasFilesInUse(Folder $folder)
Definition: ExtendedFileUtility.php:516
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\getBackendUser
‪TYPO3 CMS Core Authentication BackendUserAuthentication getBackendUser()
Definition: ExtendedFileUtility.php:1230
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\func_delete
‪bool func_delete(array $cmds)
Definition: ExtendedFileUtility.php:349
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\addFlashMessage
‪addFlashMessage(FlashMessage $flashMessage)
Definition: ExtendedFileUtility.php:1206
‪TYPO3\CMS\Core\Resource\Exception\InsufficientFileWritePermissionsException
Definition: InsufficientFileWritePermissionsException.php:22
‪TYPO3\CMS\Core\Resource\Exception\InsufficientUserPermissionsException
Definition: InsufficientUserPermissionsException.php:24
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\getExistingFilesConflictMode
‪string getExistingFilesConflictMode()
Definition: ExtendedFileUtility.php:137
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtilityProcessDataHookInterface
Definition: ExtendedFileUtilityProcessDataHookInterface.php:22
‪TYPO3\CMS\Core\Resource\Exception\ExistingTargetFolderException
Definition: ExistingTargetFolderException.php:24
‪TYPO3\CMS\Core\Resource\DuplicationBehavior
Definition: DuplicationBehavior.php:24
‪TYPO3\CMS\Core\Resource\DuplicationBehavior\CANCEL
‪const CANCEL
Definition: DuplicationBehavior.php:46
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\setExistingFilesConflictMode
‪setExistingFilesConflictMode($existingFilesConflictMode)
Definition: ExtendedFileUtility.php:148
‪TYPO3\CMS\Core\Resource\Exception\InsufficientFolderAccessPermissionsException
Definition: InsufficientFolderAccessPermissionsException.php:24
‪TYPO3\CMS\Core\Utility\File\BasicFileUtility
Definition: BasicFileUtility.php:35
‪TYPO3\CMS\Core\Resource\Folder\getParentFolder
‪FolderInterface getParentFolder()
Definition: Folder.php:536
‪TYPO3\CMS\Core\Resource\Index\Indexer\updateIndexEntry
‪File updateIndexEntry(File $fileObject)
Definition: Indexer.php:97
‪TYPO3\CMS\Core\Resource\Index\Indexer
Definition: Indexer.php:34
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\getFileObject
‪File Folder getFileObject($identifier)
Definition: ExtendedFileUtility.php:610
‪TYPO3\CMS\Core\Resource\ResourceStorage\addUploadedFile
‪FileInterface addUploadedFile(array $uploadedFileData, Folder $targetFolder=null, $targetFileName=null, $conflictMode=DuplicationBehavior::CANCEL)
Definition: ResourceStorage.php:2119
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\processData
‪mixed processData()
Definition: ExtendedFileUtility.php:197
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\getLanguageService
‪LanguageService getLanguageService()
Definition: ExtendedFileUtility.php:1240
‪TYPO3\CMS\Core\Resource\Folder\FILTER_MODE_USE_OWN_AND_STORAGE_FILTERS
‪const FILTER_MODE_USE_OWN_AND_STORAGE_FILTERS
Definition: Folder.php:69
‪TYPO3\CMS\Core\Resource\Exception\ExistingTargetFileNameException
Definition: ExistingTargetFileNameException.php:24
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\func_edit
‪bool func_edit($cmds)
Definition: ExtendedFileUtility.php:985
‪TYPO3\CMS\Core\Resource\ResourceInterface\getStorage
‪ResourceStorage getStorage()
‪TYPO3\CMS\Core\SysLog\Action\File
Definition: File.php:24
‪TYPO3\CMS\Core\Localization\LanguageService\sL
‪string sL($input)
Definition: LanguageService.php:194
‪TYPO3\CMS\Core\Resource\Exception\IllegalFileExtensionException
Definition: IllegalFileExtensionException.php:24
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\writeLog
‪writeLog($action, $error, $details_nr, $details, $data)
Definition: ExtendedFileUtility.php:303
‪TYPO3\CMS\Core\Resource\Exception\InsufficientFileAccessPermissionsException
Definition: InsufficientFileAccessPermissionsException.php:24
‪TYPO3\CMS\Core\Resource\Exception\InvalidTargetFolderException
Definition: InvalidTargetFolderException.php:24
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\replaceFile
‪array bool replaceFile(array $cmdArr)
Definition: ExtendedFileUtility.php:1139
‪TYPO3\CMS\Core\Resource\Exception\UploadException
Definition: UploadException.php:22
‪TYPO3\CMS\Core\Type\Enumeration\cast
‪static static cast($value)
Definition: Enumeration.php:186
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility
Definition: ExtendedFileUtility.php:70
‪TYPO3\CMS\Core\Messaging\AbstractMessage\WARNING
‪const WARNING
Definition: AbstractMessage.php:30
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\func_upload
‪File[] bool func_upload($cmds)
Definition: ExtendedFileUtility.php:1055
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\getErrorMessages
‪array getErrorMessages()
Definition: ExtendedFileUtility.php:291
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\$fileFactory
‪TYPO3 CMS Core Resource ResourceFactory $fileFactory
Definition: ExtendedFileUtility.php:130
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\setActionPermissions
‪setActionPermissions(array $permissions=[])
Definition: ExtendedFileUtility.php:183
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\func_newfolder
‪TYPO3 CMS Core Resource Folder false func_newfolder($cmds)
Definition: ExtendedFileUtility.php:898
‪TYPO3\CMS\Core\Resource\Exception\UploadSizeException
Definition: UploadSizeException.php:22
‪TYPO3\CMS\Core\Resource\Folder
Definition: Folder.php:37
‪TYPO3\CMS\Core\Resource\ResourceFactory
Definition: ResourceFactory.php:41
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\func_move
‪TYPO3 CMS Core Resource File false func_move($cmds)
Definition: ExtendedFileUtility.php:725
‪TYPO3\CMS\Core\Resource\Exception\ResourceDoesNotExistException
Definition: ResourceDoesNotExistException.php:24
‪TYPO3\CMS\Core\Resource\File
Definition: File.php:24
‪TYPO3\CMS\Core\Resource\DuplicationBehavior\RENAME
‪const RENAME
Definition: DuplicationBehavior.php:32
‪TYPO3\CMS\Core\SysLog\Error
Definition: Error.php:24
‪TYPO3\CMS\Core\Resource\Exception\InvalidFileException
Definition: InvalidFileException.php:24
‪TYPO3\CMS\Core\Resource\AbstractFile\getCombinedIdentifier
‪string getCombinedIdentifier()
Definition: AbstractFile.php:447
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\func_newfile
‪string func_newfile($cmds)
Definition: ExtendedFileUtility.php:940
‪TYPO3\CMS\Core\Utility\File
Definition: BasicFileUtility.php:16
‪TYPO3\CMS\Core\Resource\AbstractFile\getUid
‪int getUid()
Definition: AbstractFile.php:202
‪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:218
‪TYPO3\CMS\Backend\Utility\BackendUtility
Definition: BackendUtility.php:75
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\getIndexer
‪TYPO3 CMS Core Resource Index Indexer getIndexer(ResourceStorage $storage)
Definition: ExtendedFileUtility.php:1222
‪TYPO3\CMS\Backend\Utility\BackendUtility\getRecord
‪static array null getRecord($table, $uid, $fields=' *', $where='', $useDeleteClause=true)
Definition: BackendUtility.php:95
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\$flashMessages
‪array $flashMessages
Definition: ExtendedFileUtility.php:120
‪TYPO3\CMS\Core\Messaging\AbstractMessage\OK
‪const OK
Definition: AbstractMessage.php:29
‪TYPO3\CMS\Core\Resource\Exception
Definition: Exception.php:22
‪TYPO3\CMS\Core\Database\Connection
Definition: Connection.php:36
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\func_copy
‪TYPO3 CMS Core Resource File false func_copy($cmds)
Definition: ExtendedFileUtility.php:635
‪TYPO3\CMS\Core\Type\Enumeration\getConstants
‪static array getConstants($include_default=false)
Definition: Enumeration.php:170
‪TYPO3\CMS\Core\Messaging\AbstractMessage\INFO
‪const INFO
Definition: AbstractMessage.php:28
‪TYPO3\CMS\Core\Resource\ResourceStorage
Definition: ResourceStorage.php:122
‪TYPO3\CMS\Core\Messaging\FlashMessage
Definition: FlashMessage.php:24
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\start
‪start($fileCmds)
Definition: ExtendedFileUtility.php:169
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\$fileCmdMap
‪array $fileCmdMap
Definition: ExtendedFileUtility.php:124
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Type\Exception\InvalidEnumerationValueException
Definition: InvalidEnumerationValueException.php:24
‪TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction
Definition: DeletedRestriction.php:28
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\$internalUploadMap
‪array $internalUploadMap
Definition: ExtendedFileUtility.php:108
‪TYPO3\CMS\Core\Resource\Exception\InsufficientFolderWritePermissionsException
Definition: InsufficientFolderWritePermissionsException.php:22
‪TYPO3\CMS\Core\Utility\Exception\NotImplementedMethodException
Definition: NotImplementedMethodException.php:27
‪TYPO3\CMS\Core\Resource\DuplicationBehavior\REPLACE
‪const REPLACE
Definition: DuplicationBehavior.php:39
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:42
‪TYPO3\CMS\Core\Database\ConnectionPool
Definition: ConnectionPool.php:46
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Core\Resource\Exception\FileOperationErrorException
Definition: FileOperationErrorException.php:22
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\func_rename
‪TYPO3 CMS Core Resource File func_rename($cmds)
Definition: ExtendedFileUtility.php:818
‪TYPO3\CMS\Core\Resource\Exception\NotInMountPointException
Definition: NotInMountPointException.php:24
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\$errorMessages
‪array $errorMessages
Definition: ExtendedFileUtility.php:114
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\$existingFilesConflictMode
‪TYPO3 CMS Core Resource DuplicationBehavior $existingFilesConflictMode
Definition: ExtendedFileUtility.php:76
‪TYPO3\CMS\Core\Resource\Exception
Definition: AbstractFileOperationException.php:16
‪TYPO3\CMS\Core\Messaging\FlashMessageService
Definition: FlashMessageService.php:27
‪TYPO3\CMS\Core\Resource\Exception\InvalidFileNameException
Definition: InvalidFileNameException.php:24
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\transformFileReferenceToRecordReference
‪array transformFileReferenceToRecordReference(array $referenceRecord)
Definition: ExtendedFileUtility.php:576
‪TYPO3\CMS\Core\Messaging\AbstractMessage\ERROR
‪const ERROR
Definition: AbstractMessage.php:31
‪TYPO3\CMS\Core\SysLog\Type
Definition: Type.php:24
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\$actionPerms
‪array $actionPerms
Definition: ExtendedFileUtility.php:84