- Fix UserSettings nel datasource + ricezione su js [Ordini Acquisto] - Aggiunto un debounce alla pressione del tasto invio per mandare le mail
94 lines
2.9 KiB
PHP
94 lines
2.9 KiB
PHP
<?php
|
|
|
|
class GestSetupWebUser extends GestSetup {
|
|
private $setupTable = "wtb_gest_setup_user";
|
|
private $userName = null;
|
|
|
|
public function __construct() {
|
|
$this->init();
|
|
}
|
|
|
|
public function init() {
|
|
return parent::init()->userName(User::get_current_username());
|
|
}
|
|
|
|
public function userName($value) {
|
|
$this->userName = $value;
|
|
return $this;
|
|
}
|
|
|
|
private function check_userGrant() {
|
|
if (!User::group_is(User::RESPONSABILE_EDP, User::AMMINISTRATORE_SISTEMA)) {
|
|
return \Utility\Str::ciEquals($this->userName, User::get_current_username());
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public function get() {
|
|
$Query = new Query;
|
|
$Query->select("CONVERT(TEXT, value) AS value")
|
|
->from($this->setupTable)
|
|
->where("user_name", $this->userName)
|
|
->where("section", $this->getSection())
|
|
->where("gest_name", $this->gest_name)
|
|
->where("key_section", $this->key_section);
|
|
|
|
$Ret = $Query->firstRowFirstValue()->toRet()->execute();
|
|
$value = $Ret->is_OK() ? $Ret->get_data() : null;
|
|
return $this->parseValue($value);
|
|
}
|
|
|
|
public function set($value) {
|
|
$Ret = new Ret;
|
|
if ($this->checkKey()) {
|
|
if ($this->check_userGrant()) {
|
|
|
|
$EntityItem = new \EntityItem($this->setupTable);
|
|
$EntityItem->insert_or_update()
|
|
->set("userName", $this->userName)
|
|
->set("gestName", $this->gest_name)
|
|
->set("section", $this->getSection())
|
|
->set("keySection", $this->key_section)
|
|
->set("value", $value);
|
|
|
|
$Ret = $EntityItem->send();
|
|
|
|
} else {
|
|
$Ret->set_error("Utente non abilitato");
|
|
}
|
|
|
|
} else {
|
|
$Ret->set_error("Chiave setup incompleta");
|
|
}
|
|
|
|
return $Ret;
|
|
}
|
|
|
|
public function delete() {
|
|
$EntityItem = new \EntityItem($this->setupTable);
|
|
$EntityItem->delete()
|
|
->set("userName", $this->userName)
|
|
->set("gestName", $this->gest_name)
|
|
->set("section", $this->getSection())
|
|
->set("keySection", $this->key_section);
|
|
return $EntityItem->send();
|
|
}
|
|
|
|
public function checkKey() {
|
|
return !is_null($this->gest_name) && !is_null($this->getSection()) && !is_null($this->key_section) && !is_null($this->userName);
|
|
}
|
|
|
|
public function getAllBySection() {
|
|
$query = new Query;
|
|
$query->select("key_section, CONVERT(TEXT, value) AS value")
|
|
->from($this->setupTable)
|
|
->where("user_name", $this->userName)
|
|
->where("section", $this->getSection())
|
|
->where("gest_name", $this->gest_name);
|
|
|
|
$ret = $query->toRet()->execute();
|
|
$value = $ret->is_OK() ? $ret->get_data() : null;
|
|
|
|
return $this->parseValue($value);
|
|
}
|
|
} |