openstamanager/modules/impostazioni/actions.php

64 lines
2.2 KiB
PHP
Raw Normal View History

<?php
2020-09-07 15:04:06 +02:00
/*
* 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':
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) {
$result = Settings::get($id);
2020-02-05 14:51:39 +01:00
if (preg_match("/multiple\[(.+?)\]/", $result['tipo'], $m)) {
2020-02-05 14:51:39 +01:00
$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'].'"',
]));
}
}
}
2018-07-09 10:44:54 +02:00
$is_all_valid &= $is_valid;
}
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!'));
}
break;
}