TYPO3 CMS  TYPO3_7-6
UserStorageCapabilityService.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
18 
23 {
33  public function renderIsPublic(array $propertyArray)
34  {
35  $isPublic = $GLOBALS['TCA']['sys_file_storage']['columns']['is_public']['config']['default'];
36  $fileRecord = $propertyArray['row'];
37 
38  // Makes sure the storage object can be retrieved which is not the case when new storage.
39  if ((int)$propertyArray['row']['uid'] > 0) {
40  $storage = ResourceFactory::getInstance()->getStorageObject($fileRecord['uid']);
41  $storageRecord = $storage->getStorageRecord();
42  $isPublic = $storage->isPublic() && $storageRecord['is_public'];
43 
44  // Display a warning to the BE User in case settings is not inline with storage capability.
45  if ($storageRecord['is_public'] && !$storage->isPublic()) {
46  $message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Messaging\FlashMessage::class,
47  $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:warning.message.storage_is_no_public'),
48  $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:warning.header.storage_is_no_public'),
49  \TYPO3\CMS\Core\Messaging\FlashMessage::WARNING
50  );
51 
53  $flashMessageService = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Messaging\FlashMessageService::class);
55  $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
56  $defaultFlashMessageQueue->enqueue($message);
57  }
58  }
59 
60  return $this->renderFileInformationContent($fileRecord, $isPublic);
61  }
62 
70  protected function renderFileInformationContent(array $fileRecord, $isPublic)
71  {
72  $template = '
73  <div class="t3-form-field-item">
74  <div class="checkbox">
75  <label>
76  <input name="data[sys_file_storage][{uid}][is_public]" value="0" type="hidden">
77  <input class="checkbox" value="1" name="data[sys_file_storage][{uid}][is_public]_0" type="checkbox" %s>
78  </label>
79  </div>
80  </div>';
81 
82  $content = sprintf($template,
83  $isPublic ? 'checked="checked"' : ''
84  );
85 
86  return str_replace('{uid}', $fileRecord['uid'], $content);
87  }
88 }
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']