Prevent +/- operators (REGEXP) on glossary searches for MSSQL and Oracle. MDL-7312

Merged from MOODLE_17_STABLE
This commit is contained in:
stronk7 2006-10-31 20:34:12 +00:00
parent b4a1805ab0
commit 6f4bdb9c9b
2 changed files with 13 additions and 0 deletions

View file

@ -987,6 +987,12 @@ function glossary_search($course, $searchterms, $extended = 0, $glossary = NULL)
$definitionsearch.= " OR ";
}
/// Under Oracle and MSSQL, trim the + and - operators and perform
/// simpler LIKE search
if ($CFG->dbtype == 'oci8po' || $CFG->dbtype == 'mssql' || $CFG->dbtype == 'mssql_n' || $CFG->dbtype == 'odbc_mssql') {
$searchterm = trim($searchterm, '+-');
}
if (substr($searchterm,0,1) == "+") {
$searchterm = substr($searchterm,1);
$conceptsearch.= " e.concept $REGEXP '(^|[^a-zA-Z0-9])$searchterm([^a-zA-Z0-9]|$)' ";

View file

@ -160,6 +160,13 @@
if ($definitionsearch) {
$definitionsearch .= " AND ";
}
/// Under Oracle and MSSQL, trim the + and - operators and perform
/// simpler LIKE search
if ($CFG->dbtype == 'oci8po' || $CFG->dbtype == 'mssql' || $CFG->dbtype == 'mssql_n' || $CFG->dbtype == 'odbc_mssql') {
$searchterm = trim($searchterm, '+-');
}
if (substr($searchterm,0,1) == "+") {
$searchterm = substr($searchterm,1);
$conceptsearch .= " ge.concept $REGEXP '(^|[^a-zA-Z0-9])$searchterm([^a-zA-Z0-9]|$)' ";