]> git.mjollnir.org Git - moodle.git/commitdiff
Now glossary is using the proper sql_substr() function
authorstronk7 <stronk7>
Mon, 30 Oct 2006 18:34:21 +0000 (18:34 +0000)
committerstronk7 <stronk7>
Mon, 30 Oct 2006 18:34:21 +0000 (18:34 +0000)
Merged from MOODLE_17_STABLE

mod/glossary/sql.php

index a8c83715117d6b505aa503deb29aa3336330f8f0..2f7cb3781d056a8dcdcf74c777755dc922da6c35 100644 (file)
     case GLOSSARY_AUTHOR_VIEW:
 
         $where = '';
-        switch ($CFG->dbtype) {
-        case 'postgres7':
-            $usernametoshow = "u.firstname || ' ' || u.lastname";
-            if ( $sqlsortkey == 'FIRSTNAME' ) {
-                $usernamefield = "u.firstname || ' ' || u.lastname";
-            } else {
-                $usernamefield = "u.lastname || ' ' || u.firstname";
-            }
-            $where = "AND substr(upper($usernamefield),1," .  $textlib->strlen($hook, current_charset()) . ") = '" . $textlib->strtoupper($hook, current_charset()) . "'";
-        break;
-        case 'mysql':
-            if ( $sqlsortkey == 'FIRSTNAME' ) {
-                $usernamefield = sql_fullname('u.firstname' , 'u.lastname');
-            } else {
-                $usernamefield = sql_fullname('u.lastname' , 'u.firsttname');
-            }
-            $where = "AND left(upper($usernamefield)," .  $textlib->strlen($hook, current_charset()) . ") = '$hook'";
-        break;
+
+        if ( $sqlsortkey == 'FIRSTNAME' ) {
+            $usernamefield = sql_fullname('u.firstname' , 'u.lastname');
+        } else {
+            $usernamefield = sql_fullname('u.lastname' , 'u.firstname');
         }
+        $where = "AND " . sql_substr() . "(upper($usernamefield),1," .  $textlib->strlen($hook, current_charset()) . ") = '" . $textlib->strtoupper($hook, current_charset()) . "'";
+
         if ( $hook == 'ALL' ) {
             $where = '';
         }
 
         $where = '';
         if ($hook != 'ALL' and $hook != 'SPECIAL') {
-            switch ($CFG->dbtype) {
-            case 'postgres7':
-                $where = 'AND substr(upper(concept),1,' .  $textlib->strlen($hook, current_charset()) . ') = \'' . $textlib->strtoupper($hook, current_charset()) . '\'';
-            break;
-            case 'mysql':
-                $where = 'AND left(upper(concept),' .  $textlib->strlen($hook, current_charset()) . ") = '$hook'";
-            break;
-            }
+            $where = 'AND ' . sql_substr() . '(upper(concept),1,' .  $textlib->strlen($hook, current_charset()) . ') = \'' . $textlib->strtoupper($hook, current_charset()) . '\'';
         }
 
         $sqlselect  = "SELECT ge.*, ge.concept AS glossarypivot";
 
         case 'letter': 
             if ($hook != 'ALL' and $hook != 'SPECIAL') {
-                switch ($CFG->dbtype) {
-                case 'postgres7':
-                    $where = 'AND substr(upper(concept),1,' .  $textlib->strlen($hook, current_charset()) . ') = \'' . $textlib->strtoupper($hook, current_charset()) . '\'';
-                break;
-                case 'mysql':
-                    $where = 'AND left(upper(concept),' .  $textlib->strlen($hook, current_charset()) . ") = '" . $textlib->strtoupper($hook, current_charset()) . "'";
-                break;
-                }
+                $where = 'AND ' . sql_substr() . '(upper(concept),1,' .  $textlib->strlen($hook, current_charset()) . ') = \'' . $textlib->strtoupper($hook, current_charset()) . '\'';
             }
             if ($hook == 'SPECIAL') {
                 //Create appropiate IN contents
                     }
                     $sqlalphabet .= '\''.$alphabet[$i].'\'';
                 }
-                switch ($CFG->dbtype) {
-                case 'postgres7':
-                    $where = 'AND substr(upper(concept),1,1) NOT IN (' . $textlib->strtoupper($sqlalphabet, current_charset()) . ')';
-                break;
-                case 'mysql':
-                    $where = 'AND left(upper(concept),1) NOT IN (' . $textlib->strtoupper($sqlalphabet, current_charset()) . ')';
-                break;
-                }
+                $where = 'AND ' . sql_substr() . '(upper(concept),1,1) NOT IN (' . $textlib->strtoupper($sqlalphabet, current_charset()) . ')';
             }
         break;
         }