2017-08-04 16:28:16 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
include_once __DIR__.'/../../core.php';
|
|
|
|
|
|
|
|
switch (filter('op')) {
|
|
|
|
case 'update':
|
|
|
|
foreach ($post as $id => $value) {
|
|
|
|
$results = $dbo->fetchArray('SELECT * FROM `zz_settings` WHERE `idimpostazione`='.prepare($id).' AND editable = 1');
|
|
|
|
$result = $results[0];
|
|
|
|
|
2018-07-07 13:56:22 +02:00
|
|
|
$continue = true;
|
|
|
|
|
2017-08-04 16:28:16 +02:00
|
|
|
// integer
|
|
|
|
if ($result['tipo'] == 'integer') {
|
|
|
|
if (!preg_match('/^\d*$/', $value)) {
|
2018-07-07 13:56:22 +02:00
|
|
|
App::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
|
|
|
]));
|
|
|
|
|
|
|
|
$continue = false;
|
2017-08-04 16:28:16 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// list
|
|
|
|
// verifico che il valore scelto sia nella lista enumerata nel db
|
|
|
|
elseif (preg_match("/list\[(.+?)\]/", $result['tipo'], $m)) {
|
2018-07-07 13:56:22 +02:00
|
|
|
$is_valid = false;
|
2017-08-04 16:28:16 +02:00
|
|
|
$m = explode(',', $m[1]);
|
|
|
|
for ($i = 0; $i < count($m); ++$i) {
|
|
|
|
if ($m[$i] == $value) {
|
2018-07-07 13:56:22 +02:00
|
|
|
$is_valid = true;
|
2017-08-04 16:28:16 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-07 13:56:22 +02:00
|
|
|
if (!$is_valid) {
|
|
|
|
App::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
|
|
|
]));
|
|
|
|
|
|
|
|
$continue = false;
|
2017-08-04 16:28:16 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Boolean (checkbox)
|
|
|
|
elseif ($result['tipo'] == 'boolean') {
|
|
|
|
$value = (empty($value) || $value == 'off') ? false : true;
|
|
|
|
}
|
|
|
|
|
2018-07-07 13:56:22 +02:00
|
|
|
if (!$continue) {
|
2017-08-04 16:28:16 +02:00
|
|
|
$dbo->query('UPDATE `zz_settings` SET `valore`='.prepare($value).' WHERE `idimpostazione`='.prepare($id));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-07 13:56:22 +02:00
|
|
|
if ($continue) {
|
|
|
|
App::flash()->info(tr('Impostazioni aggiornate correttamente!'));
|
2017-08-04 16:28:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|