Non puoi selezionare più di 25 argomenti
Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
50 righe
1.5 KiB
50 righe
1.5 KiB
<? |
|
|
|
class settingsManager { |
|
|
|
static function getSettings($gruppo=false) { |
|
global $config; |
|
$return = jsonToArray($config["jsonFolder"]."/settings.json"); |
|
if (!empty($gruppo)) { |
|
foreach($return AS $id => $set) { |
|
if ($set["gruppo"] != $gruppo) { unset($return[$id]); } |
|
} |
|
} |
|
return $return; |
|
} |
|
|
|
static function getValue($id,$codice_ente="") { |
|
$setting = self::getSettings(); |
|
$return = false; |
|
if (!empty($setting[$id])) { |
|
$return = $setting[$id]["default"] ?? false; |
|
if (!empty($codice_ente) || !empty($_SESSION["ente"]->codice)) { |
|
if (empty($codice_ente)) { $codice_ente = $_SESSION["ente"]->codice; } |
|
global $pdo; |
|
$return = $pdo->go("SELECT value FROM b_settings WHERE id = :id AND codice_ente = :codice_ente", |
|
[":id"=>$id,":codice_ente"=>$codice_ente])->fetch(PDO::FETCH_ASSOC)["value"] ?? $return; |
|
} |
|
} |
|
return $return; |
|
} |
|
|
|
static function putValue($id,$value,$codice_ente) { |
|
if (!empty(self::getSettings()[$id])) { |
|
$set = []; |
|
$set["codice_ente"] = $codice_ente; |
|
$set["id"] = $id; |
|
$set["value"] = $value; |
|
|
|
$salva = new salva(); |
|
$salva->debug = false; |
|
|
|
$salva->nome_tabella = "b_settings"; |
|
$salva->operazione = "REPLACE"; |
|
$salva->oggetto = $set; |
|
return $salva->save(); |
|
} else { |
|
return false; |
|
} |
|
} |
|
|
|
}
|
|
|