Fix search on pages

This commit is contained in:
Laurent Destailleur 2020-05-14 18:44:05 +02:00
parent 7daef0d146
commit 4cf7f68b6c

View File

@ -329,14 +329,23 @@ class WebsitePage extends CommonObject
$sqlwhere = array();
if (count($filter) > 0) {
foreach ($filter as $key => $value) {
if ($key == 't.rowid' || $key == 't.fk_website') {
if ($key == 't.rowid' || $key == 't.fk_website' || $key == 'status') {
$sqlwhere[] = $key.'='.$value;
} elseif ($key == 'type_container') {
$sqlwhere[] = $key."='".$value."'";
} elseif ($key == 'lang' || $key == 't.lang') {
$listoflang = array();
$foundnull = 0;
foreach(explode(',', $value) as $tmpvalue) {
if ($tmpvalue == 'null') {
$foundnull++;
continue;
}
$listoflang[] = "'".$this->db->escape(substr(str_replace("'", '', $tmpvalue), 0, 2))."'";
}
$sqlwhere[] = $key." IN (".join(',', $listoflang).")";
$stringtouse = $key." IN (".join(',', $listoflang).")";
if ($foundnull) $stringtouse = '('.$stringtouse.' OR '.$key.' IS NULL)';
$sqlwhere[] = $stringtouse;
} else {
$sqlwhere[] = $key.' LIKE \'%'.$this->db->escape($value).'%\'';
}