TYPO3 CMS  TYPO3_7-6
ExtensionStatus.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 
21 {
25  protected $ok = '';
26 
30  protected $upToDate = '';
31 
35  protected $error = '';
36 
40  protected $objectManager = null;
41 
45  protected $repositoryRepository = null;
46 
50  protected $listUtility = null;
51 
55  protected $languageService = null;
56 
60  public function __construct()
61  {
62  $this->objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class);
63  $this->repositoryRepository = $this->objectManager->get(\TYPO3\CMS\Extensionmanager\Domain\Repository\RepositoryRepository::class);
64  $this->listUtility = $this->objectManager->get(\TYPO3\CMS\Extensionmanager\Utility\ListUtility::class);
65  $this->languageService = $this->objectManager->get(\TYPO3\CMS\Lang\LanguageService::class);
66  $this->languageService->includeLLFile('EXT:extensionmanager/Resources/Private/Language/locallang.xlf');
67  }
68 
74  public function getStatus()
75  {
76  $status = [];
77  $status['mainRepositoryStatus'] = $this->getMainRepositoryStatus();
78 
79  $extensionStatus = $this->getSecurityStatusOfExtensions();
80  $status['extensionsSecurityStatusInstalled'] = $extensionStatus->loaded;
81  $status['extensionsSecurityStatusNotInstalled'] = $extensionStatus->existing;
82  $status['extensionsOutdatedStatusInstalled'] = $extensionStatus->loadedoutdated;
83  $status['extensionsOutdatedStatusNotInstalled'] = $extensionStatus->existingoutdated;
84 
85  return $status;
86  }
87 
93  protected function getMainRepositoryStatus()
94  {
96  $mainRepository = $this->repositoryRepository->findOneTypo3OrgRepository();
97 
98  if (is_null($mainRepository) === true) {
99  $value = $this->languageService->getLL('report.status.mainRepository.notFound.value');
100  $message = $this->languageService->getLL('report.status.mainRepository.notFound.message');
102  } elseif ($mainRepository->getLastUpdate()->getTimestamp() < $GLOBALS['EXEC_TIME'] - 24 * 60 * 60 * 7) {
103  $value = $this->languageService->getLL('report.status.mainRepository.notUpToDate.value');
104  $message = $this->languageService->getLL('report.status.mainRepository.notUpToDate.message');
106  } else {
107  $value = $this->languageService->getLL('report.status.mainRepository.upToDate.value');
108  $message = '';
109  $severity = \TYPO3\CMS\Reports\Status::OK;
110  }
111 
113  $status = $this->objectManager->get(
114  \TYPO3\CMS\Reports\Status::class,
115  $this->languageService->getLL('report.status.mainRepository.title'),
116  $value,
117  $message,
118  $severity
119  );
120 
121  return $status;
122  }
123 
129  protected function getSecurityStatusOfExtensions()
130  {
131  $extensionInformation = $this->listUtility->getAvailableAndInstalledExtensionsWithAdditionalInformation();
132  $loadedInsecure = [];
133  $existingInsecure = [];
134  $loadedOutdated = [];
135  $existingOutdated = [];
136  foreach ($extensionInformation as $extensionKey => $information) {
137  if (
138  array_key_exists('terObject', $information)
139  && $information['terObject'] instanceof \TYPO3\CMS\Extensionmanager\Domain\Model\Extension
140  ) {
142  $terObject = $information['terObject'];
143  $insecureStatus = $terObject->getReviewState();
144  if ($insecureStatus === -1) {
145  if (
146  array_key_exists('installed', $information)
147  && $information['installed'] === true
148  ) {
149  $loadedInsecure[] = [
150  'extensionKey' => $extensionKey,
151  'version' => $terObject->getVersion(),
152  ];
153  } else {
154  $existingInsecure[] = [
155  'extensionKey' => $extensionKey,
156  'version' => $terObject->getVersion(),
157  ];
158  }
159  } elseif ($insecureStatus === -2) {
160  if (
161  array_key_exists('installed', $information)
162  && $information['installed'] === true
163  ) {
164  $loadedOutdated[] = [
165  'extensionKey' => $extensionKey,
166  'version' => $terObject->getVersion(),
167  ];
168  } else {
169  $existingOutdated[] = [
170  'extensionKey' => $extensionKey,
171  'version' => $terObject->getVersion(),
172  ];
173  }
174  }
175  }
176  }
177 
178  $result = new \stdClass();
179 
180  if (empty($loadedInsecure)) {
181  $value = $this->languageService->getLL('report.status.loadedExtensions.noInsecureExtensionLoaded.value');
182  $message = '';
183  $severity = \TYPO3\CMS\Reports\Status::OK;
184  } else {
185  $value = sprintf(
186  $this->languageService->getLL('report.status.loadedExtensions.insecureExtensionLoaded.value'),
187  count($loadedInsecure)
188  );
189  $extensionList = [];
190  foreach ($loadedInsecure as $insecureExtension) {
191  $extensionList[] = sprintf(
192  $this->languageService->getLL('report.status.loadedExtensions.insecureExtensionLoaded.message.extension'),
193  $insecureExtension['extensionKey'],
194  $insecureExtension['version']
195  );
196  }
197  $message = sprintf(
198  $this->languageService->getLL('report.status.loadedExtensions.insecureExtensionLoaded.message'),
199  implode('', $extensionList)
200  );
202  }
203  $result->loaded = $this->objectManager->get(
204  \TYPO3\CMS\Reports\Status::class,
205  $this->languageService->getLL('report.status.loadedExtensions.title'),
206  $value,
207  $message,
208  $severity
209  );
210 
211  if (empty($existingInsecure)) {
212  $value = $this->languageService->getLL('report.status.existingExtensions.noInsecureExtensionExists.value');
213  $message = '';
214  $severity = \TYPO3\CMS\Reports\Status::OK;
215  } else {
216  $value = sprintf(
217  $this->languageService->getLL('report.status.existingExtensions.insecureExtensionExists.value'),
218  count($existingInsecure)
219  );
220  $extensionList = [];
221  foreach ($existingInsecure as $insecureExtension) {
222  $extensionList[] = sprintf(
223  $this->languageService->getLL('report.status.existingExtensions.insecureExtensionExists.message.extension'),
224  $insecureExtension['extensionKey'],
225  $insecureExtension['version']
226  );
227  }
228  $message = sprintf(
229  $this->languageService->getLL('report.status.existingExtensions.insecureExtensionExists.message'),
230  implode('', $extensionList)
231  );
233  }
234  $result->existing = $this->objectManager->get(
235  \TYPO3\CMS\Reports\Status::class,
236  $this->languageService->getLL('report.status.existingExtensions.title'),
237  $value,
238  $message,
239  $severity
240  );
241 
242  if (empty($loadedOutdated)) {
243  $value = $this->languageService->getLL('report.status.loadedOutdatedExtensions.noOutdatedExtensionLoaded.value');
244  $message = '';
245  $severity = \TYPO3\CMS\Reports\Status::OK;
246  } else {
247  $value = sprintf(
248  $this->languageService->getLL('report.status.loadedOutdatedExtensions.outdatedExtensionLoaded.value'),
249  count($loadedOutdated)
250  );
251  $extensionList = [];
252  foreach ($loadedOutdated as $outdatedExtension) {
253  $extensionList[] = sprintf(
254  $this->languageService->getLL('report.status.loadedOutdatedExtensions.outdatedExtensionLoaded.message.extension'),
255  $outdatedExtension['extensionKey'],
256  $outdatedExtension['version']
257  );
258  }
259  $message = sprintf(
260  $this->languageService->getLL('report.status.loadedOutdatedExtensions.outdatedExtensionLoaded.message'),
261  implode('', $extensionList)
262  );
264  }
265  $result->loadedoutdated = $this->objectManager->get(
266  \TYPO3\CMS\Reports\Status::class,
267  $this->languageService->getLL('report.status.loadedOutdatedExtensions.title'),
268  $value,
269  $message,
270  $severity
271  );
272 
273  if (empty($existingOutdated)) {
274  $value = $this->languageService->getLL('report.status.existingOutdatedExtensions.noOutdatedExtensionExists.value');
275  $message = '';
276  $severity = \TYPO3\CMS\Reports\Status::OK;
277  } else {
278  $value = sprintf(
279  $this->languageService->getLL('report.status.existingOutdatedExtensions.outdatedExtensionExists.value'),
280  count($existingOutdated)
281  );
282  $extensionList = [];
283  foreach ($existingOutdated as $outdatedExtension) {
284  $extensionList[] = sprintf(
285  $this->languageService->getLL('report.status.existingOutdatedExtensions.outdatedExtensionExists.message.extension'),
286  $outdatedExtension['extensionKey'],
287  $outdatedExtension['version']
288  );
289  }
290  $message = sprintf(
291  $this->languageService->getLL('report.status.existingOutdatedExtensions.outdatedExtensionExists.message'),
292  implode('', $extensionList)
293  );
295  }
296  $result->existingoutdated = $this->objectManager->get(
297  \TYPO3\CMS\Reports\Status::class,
298  $this->languageService->getLL('report.status.existingOutdatedExtensions.title'),
299  $value,
300  $message,
301  $severity
302  );
303 
304  return $result;
305  }
306 }
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']