ca45eeb21bafb8ae41cd215b16deb39922ae9745
[Packages/TYPO3.CMS.git] / typo3 / sysext / rsaauth / Classes / BackendWarnings.php
1 <?php
2 namespace TYPO3\CMS\Rsaauth;
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
17 /**
18 * This class contains a hook to the backend warnings collection. It checks
19 * RSA configuration and create a warning if the configuration is wrong.
20 */
21 class BackendWarnings
22 {
23 /**
24 * Checks RSA configuration and creates warnings if necessary.
25 *
26 * @param array $warnings Warnings
27 * @return void
28 */
29 public function displayWarningMessages_postProcess(array &$warnings)
30 {
31 $backend = \TYPO3\CMS\Rsaauth\Backend\BackendFactory::getBackend();
32 if ($backend instanceof \TYPO3\CMS\Rsaauth\Backend\CommandLineBackend) {
33 // Not using the PHP extension!
34 $lang = $this->getLanguageService();
35 $warnings['rsaauth_cmdline'] = $lang->sL('LLL:EXT:rsaauth/Resources/Private/Language/locallang.xlf:hook_using_cmdline');
36 // Check the path
37 $extconf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['rsaauth']);
38 $path = trim($extconf['temporaryDirectory']);
39 if ($path == '') {
40 // Path is empty
41 $warnings['rsaauth'] = $lang->sL('LLL:EXT:rsaauth/Resources/Private/Language/locallang.xlf:hook_empty_directory');
42 } elseif (!\TYPO3\CMS\Core\Utility\GeneralUtility::isAbsPath($path)) {
43 // Path is not absolute
44 $warnings['rsaauth'] = $lang->sL('LLL:EXT:rsaauth/Resources/Private/Language/locallang.xlf:hook_directory_not_absolute');
45 } elseif (!@is_dir($path)) {
46 // Path does not represent a directory
47 $warnings['rsaauth'] = $lang->sL('LLL:EXT:rsaauth/Resources/Private/Language/locallang.xlf:hook_directory_not_exist');
48 } elseif (!@is_writable($path)) {
49 // Directory is not writable
50 $warnings['rsaauth'] = $lang->sL('LLL:EXT:rsaauth/Resources/Private/Language/locallang.xlf:hook_directory_not_writable');
51 } elseif (substr($path, 0, strlen(PATH_site)) == PATH_site) {
52 // Directory is inside the site root
53 $warnings['rsaauth'] = $lang->sL('LLL:EXT:rsaauth/Resources/Private/Language/locallang.xlf:hook_directory_inside_siteroot');
54 }
55 }
56 }
57
58 /**
59 * Returns LanguageService
60 *
61 * @return \TYPO3\CMS\Lang\LanguageService
62 */
63 protected function getLanguageService()
64 {
65 return $GLOBALS['LANG'];
66 }
67 }