]> git.mjollnir.org Git - moodle.git/commitdiff
Prevent +/- operators (REGEXP) on glossary searches for MSSQL and Oracle. MDL-7312
authorstronk7 <stronk7>
Tue, 31 Oct 2006 20:34:12 +0000 (20:34 +0000)
committerstronk7 <stronk7>
Tue, 31 Oct 2006 20:34:12 +0000 (20:34 +0000)
Merged from MOODLE_17_STABLE

mod/glossary/lib.php
mod/glossary/sql.php

index fd9fc0d14f1ce696f2c331999459c33e0f1ce114..ae90f92078836d68a41fdb5f2607915310f26707 100644 (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]|$)' ";
index c78ed29dc81c0b5d06ca87d3cd701b51c9efc4fe..767c20bca24fc40b6d7f3aa2f1b573cce7d438ef 100644 (file)
                 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]|$)' ";