Cleanup: Updated copyright comments
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / report / class.tx_install_report_installstatus.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2009-2011 Ingo Renner <ingo@typo3.org>
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 *
17 * This script is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * This copyright notice MUST APPEAR in all copies of the script!
23 ***************************************************************/
24
25
26 require_once(t3lib_extMgm::extPath('install', 'requirements.php'));
27
28
29 /**
30 * Provides an installation status report
31 *
32 * @author Ingo Renner <ingo@typo3.org>
33 * @package TYPO3
34 * @subpackage tx_install
35 *
36 * $Id$
37 */
38 class tx_install_report_InstallStatus implements tx_reports_StatusProvider {
39
40 protected $reportList = 'FileSystem,RemainingUpdates';
41
42 /**
43 * Compiles a collection of system status checks as a status report.
44 *
45 * @return array List of statuses
46 * @see typo3/sysext/reports/interfaces/tx_reports_StatusProvider::getStatus()
47 */
48 public function getStatus() {
49 $reports = array();
50 $reportMethods = explode(',', $this->reportList);
51
52 foreach ($reportMethods as $reportMethod) {
53 $reports[$reportMethod] = $this->{'get' . $reportMethod . 'Status'}();
54 }
55
56 return $reports;
57 }
58
59 /**
60 * Checks for several directories being writable.
61 *
62 * @return tx_reports_reports_status_Status An tx_reports_reports_status_Status object indicating the status of the file system
63 */
64 protected function getFileSystemStatus() {
65 $value = $GLOBALS['LANG']->sL('LLL:EXT:install/report/locallang.xml:status_writable');
66 $message = '';
67 $severity = tx_reports_reports_status_Status::OK;
68
69 // Requirement level
70 // -1 = not required, but if it exists may be writable or not
71 // 0 = not required, if it exists the dir should be writable
72 // 1 = required, don't has to be writable
73 // 2 = required, has to be writable
74
75 $checkWritable = array(
76 'typo3temp/' => 2,
77 'typo3temp/pics/' => 2,
78 'typo3temp/temp/' => 2,
79 'typo3temp/llxml/' => 2,
80 'typo3temp/cs/' => 2,
81 'typo3temp/GB/' => 2,
82 'typo3temp/locks/' => 2,
83 'typo3conf/' => 2,
84 'typo3conf/ext/' => 0,
85 'typo3conf/l10n/' => 0,
86 TYPO3_mainDir . 'ext/' => -1,
87 'uploads/' => 2,
88 'uploads/pics/' => 0,
89 'uploads/media/' => 0,
90 'uploads/tf/' => 0,
91 $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'] => -1,
92 $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'] . '_temp_/' => 0,
93 );
94
95 foreach ($checkWritable as $relPath => $requirementLevel) {
96 if (!@is_dir(PATH_site . $relPath)) {
97 // If the directory is missing, try to create it
98 t3lib_div::mkdir(PATH_site . $relPath);
99 }
100
101 if (!@is_dir(PATH_site . $relPath)) {
102 if ($requirementLevel > 0) {
103 // directory is required
104 $value = $GLOBALS['LANG']->sL('LLL:EXT:install/report/locallang.xml:status_missingDirectory');
105 $message .= sprintf($GLOBALS['LANG']->sL('LLL:EXT:install/report/locallang.xml:status_directoryDoesNotExistCouldNotCreate'), $relPath) . '<br />';
106 $severity = tx_reports_reports_status_Status::ERROR;
107 } else {
108 $message .= sprintf($GLOBALS['LANG']->sL('LLL:EXT:install/report/locallang.xml:status_directoryDoesNotExist'), $relPath);
109 if ($requirementLevel == 0) {
110 $message .= ' ' . $GLOBALS['LANG']->sL('LLL:EXT:install/report/locallang.xml:status_directoryShouldAlsoBeWritable');
111 }
112 $message .= '<br />';
113
114 if ($severity < tx_reports_reports_status_Status::WARNING) {
115 $value = $GLOBALS['LANG']->sL('LLL:EXT:install/report/locallang.xml:status_nonExistingDirectory');
116 $severity = tx_reports_reports_status_Status::WARNING;
117 }
118 }
119 } else {
120 if (!is_writable(PATH_site . $relPath)) {
121 switch ($requirementLevel) {
122 case 0:
123 $message .= sprintf($GLOBALS['LANG']->sL('LLL:EXT:install/report/locallang.xml:status_directoryShouldBeWritable'), PATH_site . $relPath) . '<br />';
124
125 if ($severity < tx_reports_reports_status_Status::WARNING) {
126 $value = $GLOBALS['LANG']->sL('LLL:EXT:install/report/locallang.xml:status_recommendedWritableDirectory');
127 $severity = tx_reports_reports_status_Status::WARNING;
128 }
129 break;
130 case 2:
131 $value = $GLOBALS['LANG']->sL('LLL:EXT:install/report/locallang.xml:status_requiredWritableDirectory');
132 $message .= sprintf($GLOBALS['LANG']->sL('LLL:EXT:install/report/locallang.xml:status_directoryMustBeWritable'), PATH_site . $relPath) . '<br />';
133 $severity = tx_reports_reports_status_Status::ERROR;
134 break;
135 }
136 }
137 }
138 }
139
140 return t3lib_div::makeInstance('tx_reports_reports_status_Status',
141 $GLOBALS['LANG']->sL('LLL:EXT:install/report/locallang.xml:status_fileSystem'),
142 $value,
143 $message,
144 $severity
145 );
146 }
147
148 /**
149 * Checks if there are still updates to perform
150 *
151 * @return tx_reports_reports_status_Status An tx_reports_reports_status_Status object representing whether the installation is not completely updated yet
152 */
153 protected function getRemainingUpdatesStatus() {
154 $value = $GLOBALS['LANG']->getLL('status_updateComplete');
155 $message = '';
156 $severity = tx_reports_reports_status_Status::OK;
157
158 if (!t3lib_div::compat_version(TYPO3_branch)) {
159 $value = $GLOBALS['LANG']->getLL('status_updateIncomplete');
160 $severity = tx_reports_reports_status_Status::WARNING;
161
162 $url = 'install/index.php?redirect_url=index.php'
163 . urlencode('?TYPO3_INSTALL[type]=update');
164 $message = sprintf(
165 $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:warning.install_update'),
166 '<a href="' . $url . '">',
167 '</a>'
168 );
169 }
170
171 return t3lib_div::makeInstance('tx_reports_reports_status_Status',
172 $GLOBALS['LANG']->sL('LLL:EXT:install/report/locallang.xml:status_remainingUpdates'), $value, $message, $severity
173 );
174 }
175
176 }
177
178 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/install/report/class.tx_install_report_installstatus.php'])) {
179 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/install/report/class.tx_install_report_installstatus.php']);
180 }
181
182 ?>