Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

- Dealing with incompatibilities related to posgresql.

  • Loading branch information...
commit c9128b637b7902721db55d5510eeddf9ef105767 1 parent a5e48d9
willcast authored
Showing with 25 additions and 8 deletions.
  1. +10 −2 mod/glossary/dynalink.php
  2. +15 −6 mod/glossary/sql.php
View
12 mod/glossary/dynalink.php
@@ -11,6 +11,14 @@ function glossary_dynamic_link($courseid, $text) {
$GLOSSARY_CONCEPT_IS_ENTRY = 0;
$GLOSSARY_CONCEPT_IS_CATEGORY = 1;
+ switch ($CFG->dbtype) {
+ case 'postgres7':
+ $as = 'as';
+ break;
+ case 'mysql':
+ $as = '';
+ break;
+ }
$glossarieslist = get_records_select("glossary", "usedynalink != 0 and (course = $courseid or globalglossary != 0)","globalglossary, id");
if ( $glossarieslist ) {
@@ -33,8 +41,8 @@ function glossary_dynamic_link($courseid, $text) {
break;
}
- $entries = get_records_select("glossary_entries", "glossaryid IN ($glossaries) AND usedynalink != 0 and approved != 0 and concept != ''","$ebylenght glossaryid","id,glossaryid, concept,casesensitive,$GLOSSARY_CONCEPT_IS_ENTRY category,fullmatch");
- $categories = get_records_select("glossary_categories", "glossaryid IN ($glossaries) AND usedynalink != 0", "$cbylenght glossaryid","id,glossaryid, name concept, 1 casesensitive,$GLOSSARY_CONCEPT_IS_CATEGORY category, 1 fullmatch");
+ $entries = get_records_select("glossary_entries", "glossaryid IN ($glossaries) AND usedynalink != 0 and approved != 0 and concept != ''","$ebylenght glossaryid","id,glossaryid, concept,casesensitive,$GLOSSARY_CONCEPT_IS_ENTRY $as category,fullmatch");
+ $categories = get_records_select("glossary_categories", "glossaryid IN ($glossaries) AND usedynalink != 0", "$cbylenght glossaryid","id,glossaryid, name $as concept, 1 $as casesensitive,$GLOSSARY_CONCEPT_IS_CATEGORY $as category, 1 $as fullmatch");
if ( $entries and $categories ) {
$concepts = array_merge($entries, $categories);
usort($concepts,'glossary_sort_entries_by_lenght');
View
21 mod/glossary/sql.php
@@ -13,6 +13,15 @@
/// 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';
+ break;
+ case 'mysql':
+ $as = '';
+ break;
+ }
+
switch ( $sortkey ) {
case "CREATION":
$sqlsortkey = "timecreated";
@@ -34,7 +43,7 @@
case GLOSSARY_CATEGORY_VIEW:
if ($hook == GLOSSARY_SHOW_ALL_CATEGORIES ) {
- $sqlselect = "SELECT gec.id, gc.name pivot, ge.*";
+ $sqlselect = "SELECT gec.id, gc.name $as pivot, ge.*";
$sqlfrom = "FROM {$CFG->prefix}glossary_entries ge,
{$CFG->prefix}glossary_entries_categories gec,
{$CFG->prefix}glossary_categories gc";
@@ -51,7 +60,7 @@
} elseif ($hook == GLOSSARY_SHOW_NOT_CATEGORISED ) {
$printpivot = 0;
- $sqlselect = "SELECT concept pivot, ge.*";
+ $sqlselect = "SELECT concept $as pivot, ge.*";
$sqlfrom = "FROM {$CFG->prefix}glossary_entries ge";
$sqlwhere = "WHERE (glossaryid = '$glossary->id' OR sourceglossaryid = '$glossary->id') AND
(ge.approved != 0 $userid)";
@@ -62,7 +71,7 @@
} else {
$printpivot = 0;
- $sqlselect = "SELECT ce.id, c.name pivot, ge.*";
+ $sqlselect = "SELECT ce.id, c.name $as pivot, ge.*";
$sqlfrom = "FROM {$CFG->prefix}glossary_entries ge, {$CFG->prefix}glossary_entries_categories ce, {$CFG->prefix}glossary_categories c";
$sqlwhere = "WHERE ge.id = ce.entryid AND ce.categoryid = $hook AND
ce.categoryid = c.id AND ge.approved != 0 AND
@@ -99,7 +108,7 @@
$where = '';
}
- $sqlselect = "SELECT ge.id, $usernamefield pivot, u.id uid, ge.*";
+ $sqlselect = "SELECT ge.id, $usernamefield $as pivot, u.id uid, ge.*";
$sqlfrom = "FROM {$CFG->prefix}glossary_entries ge, {$CFG->prefix}user u";
$sqlwhere = "WHERE ge.userid = u.id AND
(ge.approved != 0 $userid)
@@ -123,7 +132,7 @@
}
}
- $sqlselect = "SELECT ge.concept pivot, ge.*";
+ $sqlselect = "SELECT ge.concept $as pivot, ge.*";
$sqlfrom = "FROM {$CFG->prefix}glossary_entries ge";
$sqlwhere = "WHERE (ge.glossaryid = $glossary->id OR ge.sourceglossaryid = $glossary->id) AND
ge.approved = 0 $where";
@@ -137,7 +146,7 @@
case GLOSSARY_DATE_VIEW:
case GLOSSARY_STANDARD_VIEW:
default:
- $sqlselect = "SELECT ge.concept pivot, ge.*";
+ $sqlselect = "SELECT ge.concept $as pivot, ge.*";
$sqlfrom = "FROM {$CFG->prefix}glossary_entries ge";
$where = '';

0 comments on commit c9128b6

Please sign in to comment.
Something went wrong with that request. Please try again.