2017-08-04 16:28:16 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
include_once __DIR__.'/../../core.php';
|
|
|
|
|
|
|
|
switch (filter('op')) {
|
|
|
|
case 'update':
|
2018-07-09 10:44:54 +02:00
|
|
|
$is_all_valid = true;
|
|
|
|
|
2018-08-11 15:37:38 +02:00
|
|
|
foreach (post('setting') as $id => $value) {
|
2018-07-09 10:44:54 +02:00
|
|
|
$is_valid = Settings::setValue($id, $value);
|
2017-08-04 16:28:16 +02:00
|
|
|
|
2018-07-09 10:44:54 +02:00
|
|
|
if (!$is_valid) {
|
|
|
|
$result = Settings::get($id);
|
2018-07-07 13:56:22 +02:00
|
|
|
|
2018-07-09 10:44:54 +02:00
|
|
|
// integer
|
|
|
|
if ($result['tipo'] == 'integer') {
|
2018-07-19 17:29:21 +02:00
|
|
|
flash()->error(tr('Il valore inserito del parametro _NAME_ deve essere un numero intero!', [
|
2017-09-10 14:35:41 +02:00
|
|
|
'_NAME_' => '"'.$result['nome'].'"',
|
2018-07-07 13:56:22 +02:00
|
|
|
]));
|
2017-08-04 16:28:16 +02:00
|
|
|
}
|
|
|
|
|
2018-07-09 10:44:54 +02:00
|
|
|
// list
|
|
|
|
// verifico che il valore scelto sia nella lista enumerata nel db
|
|
|
|
elseif (preg_match("/list\[(.+?)\]/", $result['tipo'], $m)) {
|
2018-07-19 17:29:21 +02:00
|
|
|
flash()->error(tr('Il valore inserito del parametro _NAME_ deve essere un compreso tra i valori previsti!', [
|
2017-09-10 14:35:41 +02:00
|
|
|
'_NAME_' => '"'.$result['nome'].'"',
|
2018-07-07 13:56:22 +02:00
|
|
|
]));
|
2017-08-04 16:28:16 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-09 10:44:54 +02:00
|
|
|
$is_all_valid &= $is_valid;
|
2017-08-04 16:28:16 +02:00
|
|
|
}
|
|
|
|
|
2018-07-09 10:44:54 +02:00
|
|
|
if ($is_all_valid) {
|
2018-07-19 17:29:21 +02:00
|
|
|
flash()->info(tr('Impostazioni aggiornate correttamente!'));
|
2017-08-04 16:28:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|