FIX Search on social networks
This commit is contained in:
parent
0d17026276
commit
b32ee6320d
@ -500,7 +500,15 @@ if (strlen($search_fax)) {
|
||||
if (!empty($conf->socialnetworks->enabled)) {
|
||||
foreach ($socialnetworks as $key => $value) {
|
||||
if ($value['active'] && strlen($search_[$key])) {
|
||||
$sql .= " AND p.socialnetworks LIKE '%\"".$key."\":\"".$search_[$key]."%'";
|
||||
$searchkeyinjsonformat = preg_replace('/"$/', '', preg_replace('/^"/', '', json_encode($search_[$key])));
|
||||
if (in_array($db->type, array('mysql', 'mysqli'))) {
|
||||
$sql .= " AND p.socialnetworks REGEXP '\"".$db->escapeforlike($db->escape($key))."\":\"[^\"]*".$db->escapeforlike($db->escape($searchkeyinjsonformat))."'";
|
||||
} elseif ($db->type == 'pgsql') {
|
||||
$sql .= " AND p.socialnetworks ~ '\"".$db->escapeforlike($db->escape($key))."\":\"[^\"]*".$db->escapeforlike($db->escape($searchkeyinjsonformat))."'";
|
||||
} else {
|
||||
// Works with all database but not reliable because search only for social network code starting with earched value
|
||||
$sql .= " AND p.socialnetworks LIKE '%\"".$db->escapeforlike($db->escape($key))."\":\"".$db->escapeforlike($db->escape($searchkeyinjsonformat))."%'";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -555,6 +563,7 @@ if ($view == "recent") {
|
||||
} else {
|
||||
$sql .= $db->order($sortfield, $sortorder);
|
||||
}
|
||||
//print $sql;
|
||||
|
||||
// Count total nb of records
|
||||
$nbtotalofrecords = '';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user