]> git.agnieray.net Git - galette.git/blob - galette/includes/routes/management.routes.php
Make dynamic file fields work on contributions and transactions
[galette.git] / galette / includes / routes / management.routes.php
1 <?php
2
3 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
4
5 /**
6 * Management routes
7 *
8 * PHP version 5
9 *
10 * Copyright © 2014-2020 The Galette Team
11 *
12 * This file is part of Galette (http://galette.tuxfamily.org).
13 *
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.
18 *
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.
23 *
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/>.
26 *
27 * @category Routes
28 * @package Galette
29 *
30 * @author Johan Cwiklinski <johan@x-tnd.be>
31 * @copyright 2014-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
33 * @link http://galette.tuxfamily.org
34 * @since 0.8.2dev 2014-11-11
35 */
36
37 use Galette\Controllers\GaletteController;
38 use Galette\Controllers\PluginsController;
39 use Galette\Controllers\HistoryController;
40 use Galette\Controllers\DynamicTranslationsController;
41 use Galette\Controllers\Crud;
42 use Galette\Controllers\PdfController;
43 use Galette\Controllers\CsvController;
44 use Galette\Controllers\AdminToolsController;
45 use Galette\Controllers\TextController;
46 use Galette\DynamicFields\DynamicField;
47
48 //galette's dashboard
49 $app->get(
50 '/dashboard',
51 [GaletteController::class, 'dashboard']
52 )->setName('dashboard')->add($authenticate);
53
54 //preferences page
55 $app->get(
56 '/preferences',
57 [GaletteController::class, 'preferences']
58 )->setName('preferences')->add($authenticate);
59
60 //preferences procedure
61 $app->post(
62 '/preferences',
63 [GaletteController::class, 'storePreferences']
64 )->setName('store-preferences')->add($authenticate);
65
66 $app->get(
67 '/test/email',
68 [GaletteController::class, 'testEmail']
69 )->setName('testEmail')->add($authenticate);
70
71 //charts
72 $app->get(
73 '/charts',
74 [GaletteController::class, 'charts']
75 )->setName('charts')->add($authenticate);
76
77 //plugins
78 $app->get(
79 '/plugins',
80 [PluginsController::class, 'showPlugins']
81 )->setName('plugins')->add($authenticate);
82
83 //plugins (de)activation
84 $app->get(
85 '/plugins/{action:activate|deactivate}/{module_id}',
86 [PluginsController::class, 'togglePlugin']
87 )->setName('pluginsActivation')->add($authenticate);
88
89 $app->map(
90 ['GET', 'POST'],
91 '/plugins/initialize-database/{id}',
92 [PluginsController::class, 'initPluginDb']
93 )->setName('pluginInitDb')->add($authenticate);
94
95 //galette logs
96 $app->get(
97 '/logs[/{option:page|order}/{value}]',
98 function ($request, $response, $args) use ($routeparser) {
99 return $response
100 ->withStatus(302)
101 ->withHeader(
102 'Location',
103 $routeparser->urlFor('history', $args)
104 );
105 }
106 );
107 $app->get(
108 '/history[/{option:page|order}/{value}]',
109 [HistoryController::class, 'list']
110 )->setName('history')->add($authenticate);
111
112 $app->post(
113 '/history/filter',
114 [HistoryController::class, 'historyFilter']
115 )->setName('history_filter')->add($authenticate);
116
117 $app->get(
118 '/logs/flush',
119 function ($request, $response) use ($routeparser) {
120 return $response
121 ->withStatus(302)
122 ->withHeader(
123 'Location',
124 $routeparser->urlFor('flushHistory')
125 );
126 }
127 );
128 $app->get(
129 '/history/flush',
130 [HistoryController::class, 'confirmHistoryFlush']
131 )->setName('flushHistory')->add($authenticate);
132
133 $app->post(
134 '/history/flush',
135 [HistoryController::class, 'flushHistory']
136 )->setName('doFlushHistory')->add($authenticate);
137
138 //mailings management
139 $app->get(
140 '/mailings[/{option:page|order|reset}/{value}]',
141 [Crud\MailingsController::class, 'list']
142 )->setName('mailings')->add($authenticate);
143
144 $app->post(
145 '/mailings/filter',
146 [Crud\MailingsController::class, 'filter']
147 )->setName('mailings_filter')->add($authenticate);
148
149 $app->get(
150 '/mailings/remove' . '/{id:\d+}',
151 [Crud\MailingsController::class, 'confirmDelete']
152 )->setName('removeMailing')->add($authenticate);
153
154 $app->post(
155 '/mailings/remove/{id:\d+}',
156 [Crud\MailingsController::class, 'delete']
157 )->setName('doRemoveMailing')->add($authenticate);
158
159 //galette exports
160 $app->get(
161 '/export',
162 [CsvController::class, 'export']
163 )->setName('export')->add($authenticate);
164
165 $app->get(
166 '/{type:export|import}/remove/{file}',
167 [CsvController::class, 'confirmRemoveFile']
168 )->setName('removeCsv')->add($authenticate);
169
170 $app->post(
171 '/{type:export|import}/remove/{file}',
172 [CsvController::class, 'removeFile']
173 )->setName('doRemoveCsv')->add($authenticate);
174
175 $app->post(
176 '/export',
177 [CsvController::class, 'doExport']
178 )->setName('doExport')->add($authenticate);
179
180 $app->get(
181 '/{type:export|import}/get/{file}',
182 [CsvController::class, 'getFile']
183 )->setName('getCsv')->add($authenticate);
184
185 $app->get(
186 '/import',
187 [CsvController::class, 'import']
188 )->setName('import')->add($authenticate);
189
190 $app->post(
191 '/import',
192 [CsvController::class, 'doImports']
193 )->setName('doImport')->add($authenticate);
194
195 $app->post(
196 '/import/upload',
197 [CsvController::class, 'uploadImportFile']
198 )->setname('uploadImportFile')->add($authenticate);
199
200 $app->get(
201 '/import/model',
202 [CsvController::class, 'importModel']
203 )->setName('importModel')->add($authenticate);
204
205 $app->get(
206 '/import/model/get',
207 [CsvController::class, 'getImportModel']
208 )->setName('getImportModel')->add($authenticate);
209
210 $app->post(
211 '/import/model/store',
212 [CsvController::class, 'storeModel']
213 )->setName('storeImportModel')->add($authenticate);
214
215 $app->get(
216 '/models/pdf[/{id:\d+}]',
217 [PdfController::class, 'models']
218 )->setName('pdfModels')->add($authenticate);
219
220 $app->post(
221 '/models/pdf',
222 [PdfController::class, 'storeModels']
223 )->setName('pdfModels')->add($authenticate);
224
225 $app->get(
226 '/titles',
227 [Crud\TitlesController::class, 'list']
228 )->setName('titles')->add($authenticate);
229
230 $app->post(
231 '/titles',
232 [Crud\TitlesController::class, 'doAdd']
233 )->setName('titles')->add($authenticate);
234
235 $app->get(
236 '/titles/remove/{id:\d+}',
237 [Crud\TitlesController::class, 'confirmDelete']
238 )->setName('removeTitle')->add($authenticate);
239
240 $app->post(
241 '/titles/remove/{id:\d+}',
242 [Crud\TitlesController::class, 'delete']
243 )->setName('doRemoveTitle')->add($authenticate);
244
245 $app->get(
246 '/titles/edit/{id:\d+}',
247 [Crud\TitlesController::class, 'edit']
248 )->setname('editTitle')->add($authenticate);
249
250 $app->post(
251 '/titles/edit/{id:\d+}',
252 [Crud\TitlesController::class, 'doEdit']
253 )->setname('editTitle')->add($authenticate);
254
255 $app->get(
256 '/texts[/{lang}/{ref}]',
257 [TextController::class, 'list']
258 )->setName('texts')->add($authenticate);
259
260 $app->post(
261 '/texts/change',
262 [TextController::class, 'change']
263 )->setName('changeText')->add($authenticate);
264
265 $app->post(
266 '/texts',
267 [TextController::class, 'edit']
268 )->setName('texts')->add($authenticate);
269
270 $app->get(
271 '/{class:contributions-types|status}',
272 [Crud\EntitledsController::class, 'list']
273 )->setName('entitleds')->add($authenticate);
274
275 $app->get(
276 '/{class:contributions-types|status}/edit/{id:\d+}',
277 [Crud\EntitledsController::class, 'edit']
278 )->setName('editEntitled')->add($authenticate);
279
280 $app->get(
281 '/{class:contributions-types|status}/add',
282 [Crud\EntitledsController::class, 'add']
283 )->setName('addEntitled')->add($authenticate);
284
285 $app->post(
286 '/{class:contributions-types|status}/edit/{id:\d+}',
287 [Crud\EntitledsController::class, 'doEdit']
288 )->setName('doEditEntitled')->add($authenticate);
289
290 $app->post(
291 '/{class:contributions-types|status}/add',
292 [Crud\EntitledsController::class, 'doAdd']
293 )->setName('doAddEntitled')->add($authenticate);
294
295 $app->get(
296 '/{class:contributions-types|status}/remove/{id:\d+}',
297 [Crud\EntitledsController::class, 'confirmDelete']
298 )->setName('removeEntitled')->add($authenticate);
299
300 $app->post(
301 '/{class:contributions-types|status}/remove/{id:\d+}',
302 [Crud\EntitledsController::class, 'delete']
303 )->setName('doRemoveEntitled')->add($authenticate);
304
305 $app->get(
306 '/dynamic-translations[/{text_orig}]',
307 [DynamicTranslationsController::class, 'dynamicTranslations']
308 )->setName('dynamicTranslations')->add($authenticate);
309
310 $app->post(
311 '/dynamic-translations',
312 [DynamicTranslationsController::class, 'doDynamicTranslations']
313 )->setName('editDynamicTranslation')->add($authenticate);
314
315 $app->get(
316 '/lists/{table}/configure',
317 [GaletteController::class, 'configureListFields']
318 )->setName('configureListFields')->add($authenticate);
319
320 $app->post(
321 '/lists/{table}/configure',
322 [GaletteController::class, 'storeListFields']
323 )->setName('storeListFields')->add($authenticate);
324
325 $app->get(
326 '/fields/core/configure',
327 [GaletteController::class, 'configureCoreFields']
328 )->setName('configureCoreFields')->add($authenticate);
329
330 $app->post(
331 '/fields/core/configure',
332 [GaletteController::class, 'storeCoreFieldsConfig']
333 )->setName('storeCoreFieldsConfig')->add($authenticate);
334
335 $app->get(
336 '/fields/dynamic/configure[/{form_name:adh|contrib|trans}]',
337 [Crud\DynamicFieldsController::class, 'list']
338 )->setName('configureDynamicFields')->add($authenticate);
339
340 $app->get(
341 '/fields/dynamic/move/{form_name:adh|contrib|trans}' .
342 '/{direction:' . DynamicField::MOVE_UP . '|' . DynamicField::MOVE_DOWN . '}/{id:\d+}',
343 [Crud\DynamicFieldsController::class, 'move']
344 )->setName('moveDynamicField')->add($authenticate);
345
346 $app->get(
347 '/fields/dynamic/remove/{form_name:adh|contrib|trans}/{id:\d+}',
348 [Crud\DynamicFieldsController::class, 'confirmDelete']
349 )->setName('removeDynamicField')->add($authenticate);
350
351 $app->post(
352 '/fields/dynamic/remove/{form_name:adh|contrib|trans}/{id:\d+}',
353 [Crud\DynamicFieldsController::class, 'delete']
354 )->setName('doRemoveDynamicField')->add($authenticate);
355
356 $app->get(
357 '/fields/dynamic/add/{form_name:adh|contrib|trans}',
358 [Crud\DynamicFieldsController::class, 'add']
359 )->setName('addDynamicField')->add($authenticate);
360
361 $app->get(
362 '/fields/dynamic/edit/{form_name:adh|contrib|trans}/{id:\d+}',
363 [Crud\DynamicFieldsController::class, 'edit']
364 )->setName('editDynamicField')->add($authenticate);
365
366 $app->post(
367 '/fields/dynamic/add/{form_name:adh|contrib|trans}',
368 [Crud\DynamicFieldsController::class, 'doAdd']
369 )->setName('doAddDynamicField')->add($authenticate);
370
371 $app->post(
372 '/fields/dynamic/edit/{form_name:adh|contrib|trans}/{id:\d+}',
373 [Crud\DynamicFieldsController::class, 'doEdit']
374 )->setName('doEditDynamicField')->add($authenticate);
375
376 $app->get(
377 '/admin-tools',
378 [AdminToolsController::class, 'adminTools']
379 )->setName('adminTools')->add($authenticate);
380
381 $app->post(
382 '/admin-tools',
383 [AdminToolsController::class, 'process']
384 )->setName('doAdminTools')->add($authenticate);
385
386 $app->get(
387 '/payment-types',
388 [Crud\PaymentTypeController::class, 'list']
389 )->setName('paymentTypes')->add($authenticate);
390
391 $app->post(
392 '/payment-types',
393 [Crud\PaymentTypeController::class, 'doAdd']
394 )->setName('paymentTypes')->add($authenticate);
395
396 $app->get(
397 '/payment-type/remove/{id:\d+}',
398 [Crud\PaymentTypeController::class, 'confirmDelete']
399 )->setName('removePaymentType')->add($authenticate);
400
401 $app->post(
402 '/payment-type/remove/{id:\d+}',
403 [Crud\PaymentTypeController::class, 'delete']
404 )->setName('doRemovePaymentType')->add($authenticate);
405
406 $app->get(
407 '/payment-type/edit/{id:\d+}',
408 [Crud\PaymentTypeController::class, 'edit']
409 )->setname('editPaymentType')->add($authenticate);
410
411 $app->post(
412 '/payment-type/edit/{id:\d+}',
413 [Crud\PaymentTypeController::class, 'doEdit']
414 )->setname('editPaymentType')->add($authenticate);
415
416 $app->get(
417 '/{form_name:adh|contrib|trans}/{id:\d+}/file/{fid:\d+}/{pos:\d+}/{name}',
418 [Crud\DynamicFieldsController::class, 'getDynamicFile']
419 )->setName('getDynamicFile')->add($authenticate);