Permalink
Browse files

Re-applying unmerged changes to 16_STABLE after branch disaster

  • Loading branch information...
1 parent f10bf82 commit 4c74467eaefd06831e8ac279982b9ab81eb74891 stronk7 committed Mar 25, 2007
Showing with 25 additions and 39 deletions.
  1. +23 −37 mod/glossary/sql.php
  2. +2 −2 mod/glossary/view.php
View
@@ -11,24 +11,13 @@
/// Initialise some variables
$sqlorderby = '';
+ $sqlsortkey = NULL;
+ $textlib = textlib_get_instance();
-/// Calculate the SQL sortkey to be used by the SQL statements later
- switch ( $sortkey ) {
- case "CREATION":
- $sqlsortkey = "timecreated";
- break;
- case "UPDATE":
- $sqlsortkey = "timemodified";
- break;
- case "FIRSTNAME":
- $sqlsortkey = "firstname";
- break;
- case "LASTNAME":
- $sqlsortkey = "lastname";
- break;
- }
- $sqlsortorder = $sortorder;
+/// Pivot is the field that set the break by groups (category, initial, author name, etc)
+/// fullpivot indicate if the whole pivot should be compared agasint the db or just the first letter
+/// printpivot indicate if the pivot should be printed or not
switch ($CFG->dbtype) {
case 'postgres7':
$as = 'as';
@@ -38,10 +27,17 @@
break;
}
-/// Pivot is the field that set the break by groups (category, initial, author name, etc)
+ switch ( $sortkey ) {
+ case "CREATION":
+ $sqlsortkey = "timecreated";
+ break;
+
+ case "UPDATE":
+ $sqlsortkey = "timemodified";
+ break;
+ }
+ $sqlsortorder = $sortorder;
-/// fullpivot indicate if the whole pivot should be compared agasint the db or just the first letter
-/// printpivot indicate if the pivot should be printed or not
$fullpivot = 1;
$userid = '';
@@ -90,10 +86,6 @@
break;
case GLOSSARY_AUTHOR_VIEW:
- if (!isset($sqlsortkey)) {
- $sqlsortkey = NULL;
- }
-
$where = '';
switch ($CFG->dbtype) {
case 'postgres7':
@@ -103,15 +95,15 @@
} else {
$usernamefield = "u.lastname || ' ' || u.firstname";
}
- $where = "AND substr(upper($usernamefield),1," . strlen($hook) . ") = '" . strtoupper($hook) . "'";
+ $where = "AND substr(upper($usernamefield),1," . $textlib->strlen($hook, current_charset()) . ") = '" . $textlib->strtoupper($hook, current_charset()) . "'";
break;
case 'mysql':
if ( $sqlsortkey == 'FIRSTNAME' ) {
$usernamefield = "CONCAT(CONCAT(u.firstname,' '), u.lastname)";
} else {
$usernamefield = "CONCAT(CONCAT(u.lastname,' '), u.firstname)";
}
- $where = "AND left(ucase($usernamefield)," . strlen($hook) . ") = '$hook'";
+ $where = "AND left(ucase($usernamefield)," . $textlib->strlen($hook, current_charset()) . ") = '$hook'";
break;
}
if ( $hook == 'ALL' ) {
@@ -130,18 +122,14 @@
$fullpivot = 0;
$printpivot = 0;
- if (!isset($sqlsortkey)) {
- $sqlsortkey = NULL;
- }
-
$where = '';
if ($hook != 'ALL' and $hook != 'SPECIAL') {
switch ($CFG->dbtype) {
case 'postgres7':
- $where = 'AND substr(upper(concept),1,' . strlen($hook) . ') = \'' . strtoupper($hook) . '\'';
+ $where = 'AND substr(upper(concept),1,' . $textlib->strlen($hook, current_charset()) . ') = \'' . $textlib->strtoupper($hook, current_charset()) . '\'';
break;
case 'mysql':
- $where = 'AND left(ucase(concept),' . strlen($hook) . ") = '$hook'";
+ $where = 'AND left(ucase(concept),' . $textlib->strlen($hook, current_charset()) . ") = '$hook'";
break;
}
}
@@ -275,10 +263,10 @@
if ($hook != 'ALL' and $hook != 'SPECIAL') {
switch ($CFG->dbtype) {
case 'postgres7':
- $where = 'AND substr(upper(concept),1,' . strlen($hook) . ') = \'' . strtoupper($hook) . '\'';
+ $where = 'AND substr(upper(concept),1,' . $textlib->strlen($hook, current_charset()) . ') = \'' . $textlib->strtoupper($hook, current_charset()) . '\'';
break;
case 'mysql':
- $where = 'AND left(ucase(concept),' . strlen($hook) . ") = '" . strtoupper($hook) . "'";
+ $where = 'AND left(ucase(concept),' . $textlib->strlen($hook, current_charset()) . ") = '" . $textlib->strtoupper($hook, current_charset()) . "'";
break;
}
}
@@ -294,10 +282,10 @@
}
switch ($CFG->dbtype) {
case 'postgres7':
- $where = 'AND substr(upper(concept),1,1) NOT IN (' . strtoupper($sqlalphabet) . ')';
+ $where = 'AND substr(upper(concept),1,1) NOT IN (' . $textlib->strtoupper($sqlalphabet, current_charset()) . ')';
break;
case 'mysql':
- $where = 'AND left(ucase(concept),1) NOT IN (' . strtoupper($sqlalphabet) . ')';
+ $where = 'AND left(ucase(concept),1) NOT IN (' . $textlib->strtoupper($sqlalphabet, current_charset()) . ')';
break;
}
}
@@ -333,7 +321,5 @@
break;
}
}
-
$allentries = get_records_sql("$sqlselect $sqlfrom $sqlwhere $sqlorderby $sqllimit");
-
?>
View
@@ -13,14 +13,14 @@
$mode = optional_param('mode', '', PARAM_ALPHA); // term entry cat date letter search author approval
$hook = optional_param('hook', '', PARAM_CLEAN); // the term, entry, cat, etc... to look for based on mode
$fullsearch = optional_param('fullsearch', 0,PARAM_INT); // full search (concept and definition) when searching?
- $sortkey = optional_param('sortkey', '', PARAM_ALPHA);// Sorted view: CREATION | UPDATE | FIRSTNAME | LASTNAME...
+ $sortkey = optional_param('sortkey', 'CREATION', PARAM_ALPHA);// Sorted view: CREATION | UPDATE | FIRSTNAME | LASTNAME...
$sortorder = optional_param('sortorder', 'ASC', PARAM_ALPHA); // it defines the order of the sorting (ASC or DESC)
$offset = optional_param('offset', 0,PARAM_INT); // entries to bypass (for paging purposes)
$page = optional_param('page', 0,PARAM_INT); // Page to show (for paging purposes)
$show = optional_param('show', '', PARAM_ALPHA); // [ concept | alias ] => mode=term hook=$show
if (!empty($id)) {
- if (! $cm = get_record("course_modules", "id", $id)) {
+ if (! $cm = get_coursemodule_from_id('glossary', $id)) {
error("Course Module ID was incorrect");
}
if (! $course = get_record("course", "id", $cm->course)) {

0 comments on commit 4c74467

Please sign in to comment.