]>
git.agnieray.net Git - galette.git/blob - galette/install/steps/db_checks.php
455fa97efe28e3cfd50bfb2d2a144f64002fbeec
3 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
6 * Galette installation, database checks step
10 * Copyright © 2013-2023 The Galette Team
12 * This file is part of Galette (https://galette.eu).
14 * Galette is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation, either version 3 of the License, or
17 * (at your option) any later version.
19 * Galette is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with Galette. If not, see <http://www.gnu.org/licenses/>.
30 * @author Johan Cwiklinski <johan@x-tnd.be>
31 * @copyright 2013-2023 The Galette Team
32 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
33 * @link https://galette.eu
34 * @since Available since 0.8 - 2013-01-11
37 use Galette\Core\Install
as GaletteInstall
;
38 use Galette\Core\Db
as GaletteDb
;
41 $db_connected = $install->testDbConnexion();
42 } catch (Throwable
$e) {
49 if (!isset($show_form)) {
53 if ($db_connected === true) {
55 $zdb = new GaletteDb();
58 if (!$zdb->isEngineSUpported()) {
59 $supported_db = false;
63 /** FIXME: when tables already exists and DROP not allowed at this time
64 * the showed error is about CREATE, whenever CREATE is allowed */
65 //We delete the table if exists, no error at this time
66 $zdb->dropTestTable();
68 $results = $zdb->grantCheck($install->getMode());
73 //test returned values
74 if ($results['create'] instanceof Exception
) {
76 'message' => _T("CREATE operation not allowed"),
77 'debug' => $results['create']->getMessage(),
81 } elseif ($results['create'] != '') {
83 'message' => _T("CREATE operation allowed"),
88 if ($results['insert'] instanceof Exception
) {
90 'message' => _T("INSERT operation not allowed"),
91 'debug' => $results['insert']->getMessage(),
95 } elseif ($results['insert'] != '') {
97 'message' => _T("INSERT operation allowed"),
102 if ($results['update'] instanceof Exception
) {
104 'message' => _T("UPDATE operation not allowed"),
105 'debug' => $results['update']->getMessage(),
109 } elseif ($results['update'] != '') {
111 'message' => _T("UPDATE operation allowed"),
116 if ($results['select'] instanceof Exception
) {
118 'message' => _T("SELECT operation not allowed"),
119 'debug' => $results['select']->getMessage(),
123 } elseif ($results['select'] != '') {
125 'message' => _T("SELECT operation allowed"),
130 if ($results['delete'] instanceof Exception
) {
132 'message' => _T("DELETE operation not allowed"),
133 'debug' => $results['delete']->getMessage(),
137 } elseif ($results['delete'] != '') {
139 'message' => _T("DELETE operation allowed"),
144 if ($results['drop'] instanceof Exception
) {
146 'message' => _T("DROP operation not allowed"),
147 'debug' => $results['drop']->getMessage(),
151 } elseif ($results['drop'] != '') {
153 'message' => _T("DROP operation allowed"),
158 if ($install->isUpgrade()) {
159 if ($results['alter'] instanceof Exception
) {
161 'message' => _T("ALTER operation not allowed"),
162 'debug' => $results['alter']->getMessage(),
166 } elseif ($results['alter'] != '') {
168 'message' => _T("ALTER operation allowed"),
180 <div
class="ui segment">
181 <div
class="content field">
182 <div
class="ui text container">
186 if (!isset($install_plugin)) {
188 <h2
><?php
echo _T("Check of the database"); ?
></h2
>
190 echo '<p>' . _T("Database exists and connection parameters are OK.") . '</p>';
193 if ($supported_db === false) {
194 echo '<p class="ui red message">' . _T("Incompatible database version.") .
195 '<br/>' . $zdb->getUnsupportedMessage() . '</p>';
196 } else if ($db_connected === true && $permsdb_ok === true) {
197 if (!isset($install_plugin)) {
198 echo '<p class="ui green message">' . _T("Connection to database successfull") .
199 '<br/>' . _T("Permissions to database are OK.") . '</p>';
202 echo '<p class="ui green message">' . _T("Permissions to database are OK.") . '</p>';
205 if ($db_connected !== true) {
207 echo '<div class="ui red message">';
208 echo '<div class="ui small header">' . _T("Unable to connect to the database") . '</div>';
209 echo '<p>' . $db_connected->getMessage() . '</p>';
215 <p
><?php
echo _T("Database can't be reached. Please go back to enter the connection parameters again."); ?
></p
>
217 } elseif ($supported_db === true) {
218 if (!isset($install_plugin)) {
220 <h2
><?php
echo _T("Permissions on the base"); ?
></h2
>
224 echo '<div class="ui red message">';
226 if ($install->isInstall()) {
227 echo _T("GALETTE hasn't got enough permissions on the database to continue the installation.");
228 } elseif ($install->isUpgrade()) {
229 echo _T("GALETTE hasn't got enough permissions on the database to continue the update.");
237 foreach ($result as $r) {
240 <span
><?php
echo $r['message'] ?
></span
>
241 <span
><?php
echo $install->getValidationImage($r['res']); ?
></span
>
255 if (!isset($install_plugin)) {
257 <form action
="installer.php" method
="POST" class="ui form">
258 <div
class="ui mobile tablet computer reversed equal width grid">
259 <div
class="right aligned column">
260 <button type
="submit"<?php
if (!$conndb_ok ||
!$permsdb_ok) { echo ' disabled="disabled"'; } ?
> class="ui right labeled icon button"><i
class="angle double right icon"></i
> <?php
echo _T("Next step"); ?
></button
>
262 if ($conndb_ok && $permsdb_ok) {
265 <input type
="hidden" name
="install_dbperms_ok" value
="1"/>
270 <div
class="left aligned column">
271 <button type
="submit" id
="btnback" name
="stepback_btn" formnovalidate
class="ui labeled icon button"><i
class="angle double left icon"></i
> <?php
echo _T("Back"); ?
></button
>