diff --git a/mod/glossary/sql.php b/mod/glossary/sql.php index cfa9dc38faf7f..b1ff210ae5938 100644 --- a/mod/glossary/sql.php +++ b/mod/glossary/sql.php @@ -14,10 +14,23 @@ $sqlsortkey = NULL; $textlib = textlib_get_instance(); -/// Pivot is the field that set the break by groups (category, initial, author name, etc) +/// 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; -/// 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'; @@ -27,17 +40,10 @@ break; } - switch ( $sortkey ) { - case "CREATION": - $sqlsortkey = "timecreated"; - break; - - case "UPDATE": - $sqlsortkey = "timemodified"; - 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 $fullpivot = 1; $userid = ''; diff --git a/mod/glossary/view.php b/mod/glossary/view.php index 7b37e267868b9..e31cb75cf4e42 100644 --- a/mod/glossary/view.php +++ b/mod/glossary/view.php @@ -13,7 +13,7 @@ $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', 'CREATION', PARAM_ALPHA);// Sorted view: CREATION | UPDATE | FIRSTNAME | LASTNAME... + $sortkey = optional_param('sortkey', '', 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)