Add lang parameter to getObjectsInCateg function (#31070)
* add lang parameter to getObjectsInCateg * fix phan --------- Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
This commit is contained in:
parent
a8d5e5907e
commit
ef39801dc7
1 changed files with 11 additions and 2 deletions
|
|
@ -889,12 +889,14 @@ class Categorie extends CommonObject
|
|||
* @param string $sortfield Sort fields
|
||||
* @param string $sortorder Sort order ('ASC' or 'DESC');
|
||||
* @param string $filter Filter as an Universal Search string.
|
||||
* Example: '((client:=:1) OR ((client:>=:2) AND (client:<=:3))) AND (client:!=:8) AND (nom:like:'a%')'
|
||||
* Example: '((client:=:1) OR ((client:>=:2) AND (client:<=:3))) AND (client:!=:8) AND (nom:like:'a%')'
|
||||
* For multilingual fields, use: '(ol.label:like:'%value%')' and set $filterlang parameter
|
||||
* @param string $filtermode No more used
|
||||
* @param string $filterlang Language to use in Universal Search for multilingual fields ('fr_FR', 'en_US'...)
|
||||
* @return CommonObject[]|int[]|int Return -1 if KO, array of instance of object if OK
|
||||
* @see containsObject()
|
||||
*/
|
||||
public function getObjectsInCateg($type, $onlyids = 0, $limit = 0, $offset = 0, $sortfield = '', $sortorder = 'ASC', $filter = '', $filtermode = 'AND')
|
||||
public function getObjectsInCateg($type, $onlyids = 0, $limit = 0, $offset = 0, $sortfield = '', $sortorder = 'ASC', $filter = '', $filtermode = 'AND', $filterlang = '')
|
||||
{
|
||||
global $user;
|
||||
|
||||
|
|
@ -906,6 +908,9 @@ class Categorie extends CommonObject
|
|||
$sql = "SELECT c.fk_".(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type])." as fk_object";
|
||||
$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";
|
||||
if (!empty($filterlang)) {
|
||||
$sql .= ", ".MAIN_DB_PREFIX.(empty($this->MAP_OBJ_TABLE[$type]) ? $type : $this->MAP_OBJ_TABLE[$type])."_lang as ol";
|
||||
}
|
||||
$sql .= " WHERE o.entity IN (".getEntity($obj->element).")";
|
||||
$sql .= " AND c.fk_categorie = ".((int) $this->id);
|
||||
// Compatibility with actioncomm table which has id instead of rowid
|
||||
|
|
@ -914,6 +919,10 @@ class Categorie extends CommonObject
|
|||
} else {
|
||||
$sql .= " AND c.fk_".(empty($this->MAP_CAT_FK[$type]) ? $type : $this->MAP_CAT_FK[$type])." = o.rowid";
|
||||
}
|
||||
if (!empty($filterlang)) {
|
||||
$sql .= " AND ol.fk_".(empty($this->MAP_OBJ_TABLE[$type]) ? $type : $this->MAP_OBJ_TABLE[$type])." = o.rowid";
|
||||
$sql .= " AND ol.lang = '".$this->db->escape($filterlang)."'";
|
||||
}
|
||||
// Protection for external users
|
||||
if (($type == 'customer' || $type == 'supplier') && $user->socid > 0) {
|
||||
$sql .= " AND o.rowid = ".((int) $user->socid);
|
||||
|
|
|
|||
Loading…
Reference in a new issue