From 703f296be275e08e98a75ac7d918b57bfad748f8 Mon Sep 17 00:00:00 2001 From: willcast Date: Tue, 30 Sep 2003 04:13:33 +0000 Subject: [PATCH] - Multiwords concepts are now shown as a single link when they are dinymically linked. KNOWN BUG: When a concept is contained inside another concept (i.e. HOUSE and DOLL HOUSE) only the smaller concept is shown. Any help would be appreciated. --- mod/glossary/dynalink.php | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/mod/glossary/dynalink.php b/mod/glossary/dynalink.php index e5ada0aeab..6345584c1a 100644 --- a/mod/glossary/dynalink.php +++ b/mod/glossary/dynalink.php @@ -2,28 +2,36 @@ function glossary_dynamic_link($courseid, $text,$glossaryid = NULL) { global $CFG; - static $entries; - static $glossary; - if ( !$glossary ) { - $PermissionGranted = 1; + static $entries; // to avoid repeated calls to database + static $glossary; // even when dealing with the same glossary + + if ( !$glossary and !$glossaryid ) { + $PermissionGranted = 1; // if it is the first call and no glossary was specify } elseif ( $glossaryid ) { - if ( $glossary->id != $glossaryid ) { - $PermissionGranted = 1; + if ( $glossary ) { // if it is not the first call + if ( $glossary->id != $glossaryid ) { // ...and the specified glossary is different from the previous call + $PermissionGranted = 1; + } } else { + $PermissionGranted = 1; // if it is the first call and a glossary was specify } - } else { - $PermissionGranted = 1; } if ( $PermissionGranted ) { - if ( !$glossaryid ) { + if ( !$glossaryid ) { // If no glossary was specify, fetch the main glossary of the course $glossary = get_record("glossary","course",$courseid,"mainglossary",1); - } else { + } else { // if a glossary as specify, fetch this one $glossary = get_record("glossary","course",$courseid,"id",$glossaryid); } } if ( $glossary ) { if ( !$entries ) { - // char_lenght is compatible with PostGreSQL and MySQL. Other DBMS must be implemented + // char_lenght is compatible with PostgreSQL and MySQL. Other DBMS must be implemented + + /* I'm ordering the cursor by the lenght of the concept trying to avoid the bug that occurs + when a concept in contained in other entry's concept (i.e. HOUSE is in DOLL HOUSE). + However, I haven't find a solution yet. + Will (Sept. 30, 2003) + */ if ($CFG->dbtype == "postgres7" or $CFG->dbtype == "mysql") { $ORDER_BY = "CHAR_LENGTH(concept) DESC"; } else { -- 2.39.5