Fix warning

This commit is contained in:
Laurent Destailleur 2020-11-07 19:39:51 +01:00
parent 35728a01bc
commit 924923ec41
3 changed files with 104 additions and 79 deletions

View File

@ -300,9 +300,9 @@ if (empty($reshook))
$multicurrency_price = price2num(GETPOST("multicurrency_price", 'alpha')); $multicurrency_price = price2num(GETPOST("multicurrency_price", 'alpha'));
$multicurrency_code = GETPOST("multicurrency_code", 'alpha'); $multicurrency_code = GETPOST("multicurrency_code", 'alpha');
$ret = $object->update_buyprice($quantity, $newprice, $user, $_POST["price_base_type"], $supplier, $_POST["oselDispo"], $ref_fourn, $tva_tx, $_POST["charges"], $remise_percent, 0, $npr, $delivery_time_days, $supplier_reputation, array(), '', $multicurrency_price, $_POST["multicurrency_price_base_type"], $multicurrency_tx, $multicurrency_code, $supplier_description, $barcode, $fk_barcode_type); $ret = $object->update_buyprice($quantity, $newprice, $user, GETPOST("price_base_type"), $supplier, GETPOST("oselDispo"), $ref_fourn, $tva_tx, GETPOST("charges"), $remise_percent, 0, $npr, $delivery_time_days, $supplier_reputation, array(), '', $multicurrency_price, GETPOST("multicurrency_price_base_type"), $multicurrency_tx, $multicurrency_code, $supplier_description, $barcode, $fk_barcode_type);
} else { } else {
$ret = $object->update_buyprice($quantity, $newprice, $user, $_POST["price_base_type"], $supplier, $_POST["oselDispo"], $ref_fourn, $tva_tx, $_POST["charges"], $remise_percent, 0, $npr, $delivery_time_days, $supplier_reputation, array(), '', 0, 'HT', 1, '', $supplier_description, $barcode, $fk_barcode_type); $ret = $object->update_buyprice($quantity, $newprice, $user, GETPOST("price_base_type"), $supplier, GETPOST("oselDispo"), $ref_fourn, $tva_tx, GETPOST("charges"), $remise_percent, 0, $npr, $delivery_time_days, $supplier_reputation, array(), '', 0, 'HT', 1, '', $supplier_description, $barcode, $fk_barcode_type);
} }
if ($ret < 0) if ($ret < 0)
{ {
@ -655,7 +655,7 @@ if ($id > 0 || $ref)
} }
$currencies = json_encode($currencies); $currencies = json_encode($currencies);
print <<<SCRIPT print <<<END
<script type="text/javascript"> <script type="text/javascript">
function update_price_from_multicurrency() { function update_price_from_multicurrency() {
var multicurrency_price = $('input[name="multicurrency_price"]').val(); var multicurrency_price = $('input[name="multicurrency_price"]').val();
@ -695,7 +695,7 @@ if ($id > 0 || $ref)
}); });
}); });
</script> </script>
SCRIPT; END;
} else { } else {
// Price qty min // Price qty min
print '<tr><td class="fieldrequired">'.$langs->trans("PriceQtyMin").'</td>'; print '<tr><td class="fieldrequired">'.$langs->trans("PriceQtyMin").'</td>';

View File

@ -642,31 +642,36 @@ class User extends CommonObject
$this->db->begin(); $this->db->begin();
if (!empty($rid)) { if (!empty($rid)) {
$module = $perms = $subperms = '';
// Si on a demande ajout d'un droit en particulier, on recupere // Si on a demande ajout d'un droit en particulier, on recupere
// les caracteristiques (module, perms et subperms) de ce droit. // les caracteristiques (module, perms et subperms) de ce droit.
$sql = "SELECT module, perms, subperms"; $sql = "SELECT module, perms, subperms";
$sql .= " FROM ".MAIN_DB_PREFIX."rights_def"; $sql .= " FROM ".MAIN_DB_PREFIX."rights_def";
$sql .= " WHERE id = '".$this->db->escape($rid)."'"; $sql .= " WHERE id = ".((int) $rid);
$sql .= " AND entity = ".$entity; $sql .= " AND entity = ".((int) $entity);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) { if ($result) {
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
if ($obj) {
$module = $obj->module; $module = $obj->module;
$perms = $obj->perms; $perms = $obj->perms;
$subperms = $obj->subperms; $subperms = $obj->subperms;
}
} else { } else {
$error++; $error++;
dol_print_error($this->db); dol_print_error($this->db);
} }
// Where pour la liste des droits a ajouter // Where pour la liste des droits a ajouter
$whereforadd = "id=".$this->db->escape($rid); $whereforadd = "id=".((int) $rid);
// Ajout des droits induits // Ajout des droits induits
if (!empty($subperms)) { if (!empty($subperms)) {
$whereforadd .= " OR (module='$module' AND perms='$perms' AND (subperms='lire' OR subperms='read'))"; $whereforadd .= " OR (module='".$this->db->escape($module)."' AND perms='".$this->db->escape($perms)."' AND (subperms='lire' OR subperms='read'))";
} elseif (!empty($perms)) { } elseif (!empty($perms)) {
$whereforadd .= " OR (module='$module' AND (perms='lire' OR perms='read') AND subperms IS NULL)"; $whereforadd .= " OR (module='".$this->db->escape($module)."' AND (perms='lire' OR perms='read') AND subperms IS NULL)";
} }
} else { } else {
// On a pas demande un droit en particulier mais une liste de droits // On a pas demande un droit en particulier mais une liste de droits
@ -763,6 +768,8 @@ class User extends CommonObject
$this->db->begin(); $this->db->begin();
if (!empty($rid)) { if (!empty($rid)) {
$module = $perms = $subperms = '';
// Si on a demande supression d'un droit en particulier, on recupere // Si on a demande supression d'un droit en particulier, on recupere
// les caracteristiques module, perms et subperms de ce droit. // les caracteristiques module, perms et subperms de ce droit.
$sql = "SELECT module, perms, subperms"; $sql = "SELECT module, perms, subperms";
@ -773,22 +780,25 @@ class User extends CommonObject
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) { if ($result) {
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
if ($obj) {
$module = $obj->module; $module = $obj->module;
$perms = $obj->perms; $perms = $obj->perms;
$subperms = $obj->subperms; $subperms = $obj->subperms;
}
} else { } else {
$error++; $error++;
dol_print_error($this->db); dol_print_error($this->db);
} }
// Where pour la liste des droits a supprimer // Where pour la liste des droits a supprimer
$wherefordel = "id=".$this->db->escape($rid); $wherefordel = "id=".((int) $rid);
// Suppression des droits induits // Suppression des droits induits
if ($subperms == 'lire' || $subperms == 'read') { if ($subperms == 'lire' || $subperms == 'read') {
$wherefordel .= " OR (module='$module' AND perms='$perms' AND subperms IS NOT NULL)"; $wherefordel .= " OR (module='".$this->db->escape($module)."' AND perms='".$this->db->escape($perms)."' AND subperms IS NOT NULL)";
} }
if ($perms == 'lire' || $perms == 'read') { if ($perms == 'lire' || $perms == 'read') {
$wherefordel .= " OR (module='$module')"; $wherefordel .= " OR (module='".$this->db->escape($module)."')";
} }
} else { } else {
// On a demande suppression d'un droit sur la base d'un nom de module ou perms // On a demande suppression d'un droit sur la base d'un nom de module ou perms
@ -877,7 +887,7 @@ class User extends CommonObject
public function clearrights() public function clearrights()
{ {
dol_syslog(get_class($this)."::clearrights reset user->rights"); dol_syslog(get_class($this)."::clearrights reset user->rights");
$this->rights = ''; $this->rights = null;
$this->nb_rights = 0; $this->nb_rights = 0;
$this->all_permissions_are_loaded = 0; $this->all_permissions_are_loaded = 0;
$this->_tab_loaded = array(); $this->_tab_loaded = array();
@ -930,22 +940,24 @@ class User extends CommonObject
if ($resql) { if ($resql) {
$num = $this->db->num_rows($resql); $num = $this->db->num_rows($resql);
$i = 0; $i = 0;
while ($i < $num) { while ($i < $num) {
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
if ($obj) {
$module = $obj->module; $module = $obj->module;
$perms = $obj->perms; $perms = $obj->perms;
$subperms = $obj->subperms; $subperms = $obj->subperms;
if ($perms) { if (! empty($perms)) {
if (!isset($this->rights) || !is_object($this->rights)) { if (!isset($this->rights) || !is_object($this->rights)) {
$this->rights = new stdClass(); // For avoid error $this->rights = new stdClass(); // For avoid error
} }
if ($module) { if (! empty($module)) {
if (!isset($this->rights->$module) || !is_object($this->rights->$module)) { if (!isset($this->rights->$module) || !is_object($this->rights->$module)) {
$this->rights->$module = new stdClass(); $this->rights->$module = new stdClass();
} }
if ($subperms) { if (! empty($subperms)) {
if (!isset($this->rights->$module->$perms) || !is_object($this->rights->$module->$perms)) { if (!isset($this->rights->$module->$perms) || !is_object($this->rights->$module->$perms)) {
$this->rights->$module->$perms = new stdClass(); $this->rights->$module->$perms = new stdClass();
} }
@ -961,6 +973,7 @@ class User extends CommonObject
} }
} }
} }
}
$i++; $i++;
} }
$this->db->free($resql); $this->db->free($resql);
@ -997,18 +1010,20 @@ class User extends CommonObject
while ($i < $num) { while ($i < $num) {
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
if ($obj) {
$module = $obj->module; $module = $obj->module;
$perms = $obj->perms; $perms = $obj->perms;
$subperms = $obj->subperms; $subperms = $obj->subperms;
if ($perms) { if (! empty($perms)) {
if (!isset($this->rights) || !is_object($this->rights)) { if (!isset($this->rights) || !is_object($this->rights)) {
$this->rights = new stdClass(); // For avoid error $this->rights = new stdClass(); // For avoid error
} }
if (! empty($module)) {
if (!isset($this->rights->$module) || !is_object($this->rights->$module)) { if (!isset($this->rights->$module) || !is_object($this->rights->$module)) {
$this->rights->$module = new stdClass(); $this->rights->$module = new stdClass();
} }
if ($subperms) { if (! empty($subperms)) {
if (!isset($this->rights->$module->$perms) || !is_object($this->rights->$module->$perms)) { if (!isset($this->rights->$module->$perms) || !is_object($this->rights->$module->$perms)) {
$this->rights->$module->$perms = new stdClass(); $this->rights->$module->$perms = new stdClass();
} }
@ -1026,6 +1041,8 @@ class User extends CommonObject
} }
} }
} }
}
}
$i++; $i++;
} }
$this->db->free($resql); $this->db->free($resql);

View File

@ -425,6 +425,8 @@ class UserGroup extends CommonObject
if (!empty($rid)) if (!empty($rid))
{ {
$module = $perms = $subperms = '';
// Si on a demande supression d'un droit en particulier, on recupere // Si on a demande supression d'un droit en particulier, on recupere
// les caracteristiques module, perms et subperms de ce droit. // les caracteristiques module, perms et subperms de ce droit.
$sql = "SELECT module, perms, subperms"; $sql = "SELECT module, perms, subperms";
@ -486,8 +488,12 @@ class UserGroup extends CommonObject
$i = 0; $i = 0;
while ($i < $num) while ($i < $num)
{ {
$nid = 0;
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
if ($obj) {
$nid = $obj->id; $nid = $obj->id;
}
$sql = "DELETE FROM ".MAIN_DB_PREFIX."usergroup_rights"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."usergroup_rights";
$sql .= " WHERE fk_usergroup = $this->id AND fk_id=".$nid; $sql .= " WHERE fk_usergroup = $this->id AND fk_id=".$nid;
@ -567,6 +573,7 @@ class UserGroup extends CommonObject
{ {
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
if ($obj) {
$module = $obj->module; $module = $obj->module;
$perms = $obj->perms; $perms = $obj->perms;
$subperms = $obj->subperms; $subperms = $obj->subperms;
@ -585,6 +592,7 @@ class UserGroup extends CommonObject
$this->rights->$module->$perms = 1; $this->rights->$module->$perms = 1;
} }
} }
}
$i++; $i++;
} }