Merge branch 'ent-7995-unificar-criterios-de-busqueda-que-no-sean-case-sensitive' into 'develop'
Unify search criteria case insensitive See merge request artica/pandorafms!4496
This commit is contained in:
commit
198959f6cb
|
@ -760,7 +760,11 @@ function mysql_db_format_array_where_clause_sql($values, $join='AND', $prefix=fa
|
|||
if ($field[0] != '`') {
|
||||
// If the field is as <table>.<field>, don't scape.
|
||||
if (strstr($field, '.') === false) {
|
||||
$field = '`'.$field.'`';
|
||||
if (preg_match('/(UPPER|LOWER)(.+)/mi', $field)) {
|
||||
$field = preg_replace('/(UPPER|LOWER])\((.+)\)/mi', '$1(`$2`)', $field);
|
||||
} else {
|
||||
$field = '`'.$field.'`';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -194,11 +194,11 @@ function custom_graphs_get_user($id_user=0, $only_names=false, $returnAllGroup=t
|
|||
function custom_graphs_search($id_group, $search)
|
||||
{
|
||||
if ($id_group != '' && $search != '') {
|
||||
$all_graphs = db_get_all_rows_sql('select * from tgraph where id_group = '.$id_group.' AND name LIKE "%'.$search.'%"');
|
||||
$all_graphs = db_get_all_rows_sql('select * from tgraph where id_group = '.$id_group.' AND (name LIKE "%'.$search.'%" OR description LIKE "'.$search.'")');
|
||||
} else if ($id_group != '') {
|
||||
$all_graphs = db_get_all_rows_sql('select * from tgraph where id_group = '.$id_group.'');
|
||||
} else {
|
||||
$all_graphs = db_get_all_rows_sql('select * from tgraph where name LIKE "%'.$search.'%"');
|
||||
$all_graphs = db_get_all_rows_sql('select * from tgraph where name LIKE "%'.$search.'%" OR description LIKE "'.$search.'"');
|
||||
}
|
||||
|
||||
if ($all_graphs === false) {
|
||||
|
|
|
@ -1,5 +1,19 @@
|
|||
/* global $, jQuery*/
|
||||
|
||||
/**
|
||||
* Custom selector for case instensitive contains.
|
||||
*/
|
||||
jQuery.expr[":"].iContains = jQuery.expr.createPseudo(function(arg) {
|
||||
return function(elem) {
|
||||
return (
|
||||
jQuery(elem)
|
||||
.text()
|
||||
.toUpperCase()
|
||||
.indexOf(arg.toUpperCase()) >= 0
|
||||
);
|
||||
};
|
||||
});
|
||||
|
||||
/**
|
||||
* Add modules from available to selected.
|
||||
*/
|
||||
|
@ -58,14 +72,14 @@ function filterItems(id, str) {
|
|||
$("#" + id + " option[value=0]").remove();
|
||||
|
||||
// Move not matching elements filtered to tmp-id.
|
||||
var tmp = $("#" + id + " option:not(:contains(" + str + "))").toArray();
|
||||
var tmp = $("#" + id + " option:not(:iContains(" + str + "))").toArray();
|
||||
tmp.forEach(function(item) {
|
||||
$("#tmp-" + id).append(item);
|
||||
$(this).remove();
|
||||
});
|
||||
|
||||
// Move matching filter back to id.
|
||||
tmp = $("#tmp-" + id + " option:contains(" + str + ")").toArray();
|
||||
tmp = $("#tmp-" + id + " option:iContains(" + str + ")").toArray();
|
||||
tmp.forEach(function(item) {
|
||||
$("#" + id).append(item);
|
||||
$(this).remove();
|
||||
|
|
|
@ -239,7 +239,8 @@ if ($free_search != '') {
|
|||
WHERE id_agente IN (
|
||||
SELECT id_agente
|
||||
FROM tagente
|
||||
WHERE nombre LIKE "%'.$free_search.'%") OR alias LIKE "%'.$free_search.'%")'.')';
|
||||
WHERE nombre COLLATE utf8_general_ci LIKE "%'.$free_search.'%")
|
||||
OR alias COLLATE utf8_general_ci LIKE "%'.$free_search.'%")'.')';
|
||||
} else {
|
||||
$whereAlertSimple = '';
|
||||
}
|
||||
|
|
|
@ -139,32 +139,32 @@ if ($searchAlerts) {
|
|||
switch ($config['dbtype']) {
|
||||
case 'mysql':
|
||||
$whereAlerts = 'AND (
|
||||
id_alert_template IN (SELECT id FROM talert_templates WHERE name LIKE "%'.$stringSearchSQL.'%") OR
|
||||
id_alert_template IN (SELECT id FROM talert_templates WHERE name COLLATE utf8_general_ci LIKE "%'.$stringSearchSQL.'%") OR
|
||||
id_alert_template IN (
|
||||
SELECT id
|
||||
FROM talert_templates
|
||||
WHERE id_alert_action IN (
|
||||
SELECT id
|
||||
FROM talert_actions
|
||||
WHERE name LIKE "%'.$stringSearchSQL.'%")) OR
|
||||
WHERE name COLLATE utf8_general_ci LIKE "%'.$stringSearchSQL.'%")) OR
|
||||
talert_template_modules.id IN (
|
||||
SELECT id_alert_template_module
|
||||
FROM talert_template_module_actions
|
||||
WHERE id_alert_action IN (
|
||||
SELECT id
|
||||
FROM talert_actions
|
||||
WHERE name LIKE "%'.$stringSearchSQL.'%")) OR
|
||||
WHERE name COLLATE utf8_general_ci LIKE "%'.$stringSearchSQL.'%")) OR
|
||||
id_agent_module IN (
|
||||
SELECT id_agente_modulo
|
||||
FROM tagente_modulo
|
||||
WHERE nombre LIKE "%'.$stringSearchSQL.'%") OR
|
||||
WHERE nombre COLLATE utf8_general_ci LIKE "%'.$stringSearchSQL.'%") OR
|
||||
id_agent_module IN (
|
||||
SELECT id_agente_modulo
|
||||
FROM tagente_modulo
|
||||
WHERE id_agente IN (
|
||||
SELECT id_agente
|
||||
FROM tagente
|
||||
WHERE nombre LIKE "%'.$stringSearchSQL.'%" '.$extra_sql.'))
|
||||
WHERE nombre COLLATE utf8_general_ci LIKE "%'.$stringSearchSQL.'%" '.$extra_sql.'))
|
||||
)';
|
||||
break;
|
||||
|
||||
|
|
Loading…
Reference in New Issue