|
@@ -540,7 +540,7 @@ class Categorie extends CommonObject
|
|
|
$sql .= ", visible = ".(int) $this->visible;
|
|
|
$sql .= ", fk_parent = ".(int) $this->fk_parent;
|
|
|
$sql .= ", fk_user_modif = ".(int) $user->id;
|
|
|
- $sql .= " WHERE rowid = ".$this->id;
|
|
|
+ $sql .= " WHERE rowid = ".((int) $this->id);
|
|
|
|
|
|
dol_syslog(get_class($this)."::update", LOG_DEBUG);
|
|
|
if ($this->db->query($sql)) {
|
|
@@ -686,7 +686,7 @@ class Categorie extends CommonObject
|
|
|
if ($this->db->query($sql)) {
|
|
|
if (!empty($conf->global->CATEGORIE_RECURSIV_ADD)) {
|
|
|
$sql = 'SELECT fk_parent FROM '.MAIN_DB_PREFIX.'categorie';
|
|
|
- $sql .= " WHERE rowid = ".$this->id;
|
|
|
+ $sql .= " WHERE rowid = ".((int) $this->id);
|
|
|
|
|
|
dol_syslog(get_class($this)."::add_type", LOG_DEBUG);
|
|
|
$resql = $this->db->query($sql);
|
|
@@ -774,7 +774,7 @@ class Categorie extends CommonObject
|
|
|
$this->db->begin();
|
|
|
|
|
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_".(empty($this->MAP_CAT_TABLE[$type]) ? $type : $this->MAP_CAT_TABLE[$type]);
|
|
|
- $sql .= " WHERE fk_categorie = ".$this->id;
|
|
|
+ $sql .= " WHERE fk_categorie = ".((int) $this->id);
|
|
|
$sql .= " AND fk_".(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type])." = ".((int) $obj->id);
|
|
|
|
|
|
dol_syslog(get_class($this).'::del_type', LOG_DEBUG);
|
|
@@ -826,11 +826,11 @@ class Categorie extends CommonObject
|
|
|
$sql .= " FROM ".MAIN_DB_PREFIX."categorie_".(empty($this->MAP_CAT_TABLE[$type]) ? $type : $this->MAP_CAT_TABLE[$type])." as c";
|
|
|
$sql .= ", ".MAIN_DB_PREFIX.(empty($this->MAP_OBJ_TABLE[$type]) ? $type : $this->MAP_OBJ_TABLE[$type])." as o";
|
|
|
$sql .= " WHERE o.entity IN (".getEntity($obj->element).")";
|
|
|
- $sql .= " AND c.fk_categorie = ".$this->id;
|
|
|
+ $sql .= " AND c.fk_categorie = ".((int) $this->id);
|
|
|
$sql .= " AND c.fk_".(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type])." = o.rowid";
|
|
|
// Protection for external users
|
|
|
if (($type == 'customer' || $type == 'supplier') && $user->socid > 0) {
|
|
|
- $sql .= " AND o.rowid = ".$user->socid;
|
|
|
+ $sql .= " AND o.rowid = ".((int) $user->socid);
|
|
|
}
|
|
|
if ($limit > 0 || $offset > 0) {
|
|
|
$sql .= $this->db->plimit($limit + 1, $offset);
|
|
@@ -870,7 +870,7 @@ class Categorie extends CommonObject
|
|
|
public function containsObject($type, $object_id)
|
|
|
{
|
|
|
$sql = "SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."categorie_".(empty($this->MAP_CAT_TABLE[$type]) ? $type : $this->MAP_CAT_TABLE[$type]);
|
|
|
- $sql .= " WHERE fk_categorie = ".$this->id." AND fk_".(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type])." = ".((int) $object_id);
|
|
|
+ $sql .= " WHERE fk_categorie = ".((int) $this->id)." AND fk_".(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type])." = ".((int) $object_id);
|
|
|
dol_syslog(get_class($this)."::containsObject", LOG_DEBUG);
|
|
|
$resql = $this->db->query($sql);
|
|
|
if ($resql) {
|
|
@@ -1501,7 +1501,7 @@ class Categorie extends CommonObject
|
|
|
$sql .= " WHERE ct.fk_categorie = c.rowid AND ct.fk_".(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type])." = ".(int) $id;
|
|
|
// This seems useless because the table already contains id of category of 1 unique type. So commented.
|
|
|
// So now it works also with external added categories.
|
|
|
- //$sql .= " AND c.type = ".$this->MAP_ID[$type];
|
|
|
+ //$sql .= " AND c.type = ".((int) $this->MAP_ID[$type]);
|
|
|
$sql .= " AND c.entity IN (".getEntity('category').")";
|
|
|
|
|
|
$res = $this->db->query($sql);
|
|
@@ -1796,7 +1796,7 @@ class Categorie extends CommonObject
|
|
|
foreach ($langs_available as $key => $value) {
|
|
|
$sql = "SELECT rowid";
|
|
|
$sql .= " FROM ".MAIN_DB_PREFIX."categorie_lang";
|
|
|
- $sql .= " WHERE fk_category=".$this->id;
|
|
|
+ $sql .= " WHERE fk_category=".((int) $this->id);
|
|
|
$sql .= " AND lang = '".$this->db->escape($key)."'";
|
|
|
|
|
|
$result = $this->db->query($sql);
|
|
@@ -1806,10 +1806,10 @@ class Categorie extends CommonObject
|
|
|
$sql2 = "UPDATE ".MAIN_DB_PREFIX."categorie_lang";
|
|
|
$sql2 .= " SET label='".$this->db->escape($this->label)."',";
|
|
|
$sql2 .= " description='".$this->db->escape($this->description)."'";
|
|
|
- $sql2 .= " WHERE fk_category=".$this->id." AND lang='".$this->db->escape($key)."'";
|
|
|
+ $sql2 .= " WHERE fk_category=".((int) $this->id)." AND lang='".$this->db->escape($key)."'";
|
|
|
} else {
|
|
|
$sql2 = "INSERT INTO ".MAIN_DB_PREFIX."categorie_lang (fk_category, lang, label, description)";
|
|
|
- $sql2 .= " VALUES(".$this->id.",'".$key."','".$this->db->escape($this->label);
|
|
|
+ $sql2 .= " VALUES(".$this->id.",'".$this->db->escape($key)."','".$this->db->escape($this->label);
|
|
|
$sql2 .= "','".$this->db->escape($this->multilangs["$key"]["description"])."')";
|
|
|
}
|
|
|
dol_syslog(get_class($this).'::setMultiLangs', LOG_DEBUG);
|
|
@@ -1822,10 +1822,10 @@ class Categorie extends CommonObject
|
|
|
$sql2 = "UPDATE ".MAIN_DB_PREFIX."categorie_lang";
|
|
|
$sql2 .= " SET label='".$this->db->escape($this->multilangs["$key"]["label"])."',";
|
|
|
$sql2 .= " description='".$this->db->escape($this->multilangs["$key"]["description"])."'";
|
|
|
- $sql2 .= " WHERE fk_category=".$this->id." AND lang='".$this->db->escape($key)."'";
|
|
|
+ $sql2 .= " WHERE fk_category=".((int) $this->id)." AND lang='".$this->db->escape($key)."'";
|
|
|
} else {
|
|
|
$sql2 = "INSERT INTO ".MAIN_DB_PREFIX."categorie_lang (fk_category, lang, label, description)";
|
|
|
- $sql2 .= " VALUES(".$this->id.",'".$key."','".$this->db->escape($this->multilangs["$key"]["label"]);
|
|
|
+ $sql2 .= " VALUES(".$this->id.",'".$this->db->escape($key)."','".$this->db->escape($this->multilangs["$key"]["label"]);
|
|
|
$sql2 .= "','".$this->db->escape($this->multilangs["$key"]["description"])."')";
|
|
|
}
|
|
|
|
|
@@ -1864,7 +1864,7 @@ class Categorie extends CommonObject
|
|
|
|
|
|
$sql = "SELECT lang, label, description";
|
|
|
$sql .= " FROM ".MAIN_DB_PREFIX."categorie_lang";
|
|
|
- $sql .= " WHERE fk_category=".$this->id;
|
|
|
+ $sql .= " WHERE fk_category=".((int) $this->id);
|
|
|
|
|
|
$result = $this->db->query($sql);
|
|
|
if ($result) {
|