3 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
6 * Galette admin tools controller
10 * Copyright © 2020 The Galette Team
12 * This file is part of Galette (http://galette.tuxfamily.org).
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 2020 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
34 * @link http://galette.tuxfamily.org
35 * @since Available since 0.9.4dev - 2020-05-03
38 namespace Galette\Controllers
;
40 use Slim\Http\Request
;
41 use Slim\Http\Response
;
42 use Galette\Core\CheckModules
;
43 use Galette\Entity\Texts
;
44 use Galette\Repository\Members
;
45 use Galette\Repository\PdfModels
;
49 * Galette main controller
51 * @category Controllers
52 * @name AdminToolsController
54 * @author Johan Cwiklinski <johan@x-tnd.be>
55 * @copyright 2020 The Galette Team
56 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
57 * @link http://galette.tuxfamily.org
58 * @since Available since 0.9.4dev - 2020-05-03
61 class AdminToolsController
extends AbstractController
64 * Administration tools page
66 * @param Request $request PSR Request
67 * @param Response $response PSR Response
71 public function adminTools(Request
$request, Response
$response) :Response
74 'page_title' => _T('Administration tools')
77 $cm = new CheckModules();
78 $modules_ok = $cm->isValid();
80 $this->flash
->addMessage(
81 _T("Some PHP modules are missing. Please install them or contact your support.<br/>More information on required modules may be found in the documentation.")
95 * Process Administration tools
97 * @param Request $request PSR Request
98 * @param Response $response PSR Response
102 public function process(Request
$request, Response
$response) :Response
104 $post = $request->getParsedBody();
106 $error_detected = [];
107 $success_detected = [];
109 if (isset($post['inittexts'])) {
110 //proceed emails texts reinitialization
111 $texts = new Texts($this->preferences
);
112 $res = $texts->installInit(false);
114 $success_detected[] = _T("Texts has been successfully reinitialized.");
116 $error_detected[] = _T("An error occurred reinitializing texts :(");
120 if (isset($post['initfields'])) {
121 //proceed fields configuration reinitialization
122 $fc = $this->fields_config
;
123 $res = $fc->installInit();
125 $success_detected[] = _T("Fields configuration has been successfully reinitialized.");
127 $error_detected[] = _T("An error occurred reinitializing fields configuration :(");
131 if (isset($post['initpdfmodels'])) {
132 //proceed emails texts reinitialization
133 $models = new PdfModels($this->zdb
, $this->preferences
, $this->login
);
134 $res = $models->installInit($this->pdfmodels_fields
, false);
136 $success_detected[] = _T("PDF models has been successfully reinitialized.");
138 $error_detected[] = _T("An error occurred reinitializing PDF models :(");
142 if (isset($post['emptylogins'])) {
143 //proceed empty logins and passwords
144 //those ones cannot be null
145 $members = new Members();
146 $res = $members->emptylogins();
148 $success_detected[] = str_replace(
150 $members->getCount(),
151 _T("Logins and passwords has been successfully filled (%i processed).")
154 $error_detected[] = _T("An error occurred filling empty logins and passwords :(");
159 if (count($error_detected) > 0) {
160 foreach ($error_detected as $error) {
161 $this->flash
->addMessage(
167 if (count($success_detected) > 0) {
168 foreach ($success_detected as $success) {
169 $this->flash
->addMessage(
178 ->withHeader('Location', $this->router
->pathFor('adminTools'));