64 lines
2.2 KiB
PHP
Executable File
64 lines
2.2 KiB
PHP
Executable File
<?php
|
|
/*
|
|
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
|
|
* Copyright (C) DevCode s.n.c.
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
include_once __DIR__.'/../../core.php';
|
|
|
|
switch (filter('op')) {
|
|
case 'update':
|
|
$is_all_valid = true;
|
|
|
|
foreach (post('setting') as $id => $value) {
|
|
$result = Settings::get($id);
|
|
|
|
if (preg_match("/multiple\[(.+?)\]/", $result['tipo'], $m)) {
|
|
$value = implode(',', $value);
|
|
}
|
|
|
|
//Se è un'impostazione editabile
|
|
if ($result->editable) {
|
|
$is_valid = Settings::setValue($id, $value);
|
|
|
|
if (!$is_valid) {
|
|
// integer
|
|
if ($result['tipo'] == 'integer') {
|
|
flash()->error(tr('Il valore inserito del parametro _NAME_ deve essere un numero intero!', [
|
|
'_NAME_' => '"'.$result['nome'].'"',
|
|
]));
|
|
}
|
|
|
|
// list
|
|
// verifico che il valore scelto sia nella lista enumerata nel db
|
|
elseif (preg_match("/list\[(.+?)\]/", $result['tipo'], $m)) {
|
|
flash()->error(tr('Il valore inserito del parametro _NAME_ deve essere un compreso tra i valori previsti!', [
|
|
'_NAME_' => '"'.$result['nome'].'"',
|
|
]));
|
|
}
|
|
}
|
|
}
|
|
|
|
$is_all_valid &= $is_valid;
|
|
}
|
|
|
|
if ($is_all_valid) {
|
|
flash()->info(tr('Impostazioni aggiornate correttamente!'));
|
|
}
|
|
|
|
break;
|
|
}
|