From: willcast Date: Wed, 19 Nov 2003 17:47:40 +0000 (+0000) Subject: - Case sensitive search when click on a letter, fixed. X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=b6862360af8412253b3cfa2f8b8751467aea0461;p=moodle.git - Case sensitive search when click on a letter, fixed. - Adding a display format manager. It controls the behavior of the display format when the user enter the glossary and when an auto-link is shown. - Adding support to the new fullname function. --- diff --git a/lang/en/glossary.php b/lang/en/glossary.php index 51b326aef7..2c23cc4f5f 100644 --- a/lang/en/glossary.php +++ b/lang/en/glossary.php @@ -35,6 +35,12 @@ $string['cnffullmatch'] = 'Define if an entry, when linked, should match the cas $string['cnflinkentry'] = 'Define if an entry should be automatically linked by default'; $string['cnflinkglossaries'] = 'Define if a glossary should be automatically linked by default'; $string['cnfstudentcanpost'] = 'Define if the students can or cannot post entries by default'; +$string['cnfrelatedview'] = 'Select the display format to be used for automatic linking and entry view.'; +$string['cnfdefaultmode'] = 'Select the default frame to show when the glossary is first viewed.'; +$string['cnfdefaulthook'] = 'Select the default selection to show when the glossary is first viewed'; +$string['cnfsortkey'] = 'Select the sorting key by default.'; +$string['cnfsortorder'] = 'Select the sorting order by default.'; +$string['cnfshowgroup'] = 'Specify if the group break should be shown or not.'; $string['comment'] = 'Comment'; $string['commentdeleted'] = 'The comment has been deleted.'; $string['comments'] = 'Comments'; @@ -53,6 +59,7 @@ $string['deletingnoneemptycategory'] = 'Deleting this category will not delete t $string['descending'] = '(descending)'; $string['destination'] = 'Destination'; $string['displayformat'] = 'Display format'; +$string['displayformats'] = 'Display formats'; $string['displayformat2'] = 'Full with author'; $string['displayformat3'] = 'Encyclopedia'; $string['displayformat4'] = 'FAQ'; diff --git a/mod/glossary/TODO.txt b/mod/glossary/TODO.txt index 38ede943e6..e05b3d7f18 100644 --- a/mod/glossary/TODO.txt +++ b/mod/glossary/TODO.txt @@ -6,6 +6,7 @@ Things that are in the inkpot yet: * Default view * Default Order * Show (or do not) the group breaks. + * Default view for automatic links, entry view, etc. * What else? Post in http://moodle.org/mod/forum/view.php?id=742 - Allow grading of entries diff --git a/mod/glossary/config.html b/mod/glossary/config.html index 60bcf6cd8d..e8d96a10c3 100644 --- a/mod/glossary/config.html +++ b/mod/glossary/config.html @@ -188,9 +188,85 @@ + + Display Formats Setup + + + +fid = 0; + $displayformat->relatedview = 0; + $displayformat->visible = 1; + $displayformat->id = insert_record("glossary_displayformats",$displayformat); + } + if ( !$displayformat = get_record("glossary_displayformats","fid",1) ) { + unset($displayformat); + $displayformat->fid = 1; + $displayformat->relatedview = 1; + $displayformat->visible = 1; + $displayformat->id = insert_record("glossary_displayformats",$displayformat); + } + + $formats = array(); + $formats[0] = get_string("displayformatdefault", "glossary"); + $formats[1] = get_string("displayformatcontinuous", "glossary"); + + $basedir = opendir("$CFG->dirroot/mod/glossary/formats"); + while ($dir = readdir($basedir)) { + $firstchar = substr($dir, 0, 1); + if ($firstchar == "." or $dir == "CVS" or $dir == "_vti_cnf") { + continue; + } + if (filetype("$CFG->dirroot/mod/glossary/formats/$dir") == "dir") { + continue; + } + if ( $pos = strpos($dir, ".") ) { + $dir = substr($dir, 0, $pos ); + if ($dir != 0 and $dir != 1) { // excluding basic formats + if ( !$displayformat = get_record("glossary_displayformats","fid",$dir) ) { + unset($displayformat); + $displayformat->fid = $dir; + $displayformat->relatedview = $dir; + $displayformat->visible = 1; + $displayformat->id = insert_record("glossary_displayformats",$displayformat); + } + $formats[$dir] = get_string("displayformat$dir", "glossary"); + } + } + } + asort($formats); + + echo ''; + for ($i = 0; $i <= count($formats); $i++) { + if ( $formats[$i] ) { + $format = get_record("glossary_displayformats","fid",$i); + echo ''; + echo ''; + $eicon = "wwwroot/mod/glossary/formats.php?id=$i&mode=edit\">"; + if ( $format->visible ) { + $vtitle = get_string("hide"); + $vicon = "hide.gif"; + } else { + $vtitle = get_string("show"); + $vicon = "show.gif"; + } + $vicon = "wwwroot/mod/glossary/formats.php?id=$i&mode=visible\">"; + + echo ''; + echo ''; + } + } + echo '
' . $formats[$i] . ' ' . $eicon . '  ' . $vicon . '
'; + +?> + + + - "> + "> diff --git a/mod/glossary/db/mysql.php b/mod/glossary/db/mysql.php index 71fba487b1..130941f6f4 100644 --- a/mod/glossary/db/mysql.php +++ b/mod/glossary/db/mysql.php @@ -173,6 +173,51 @@ function glossary_upgrade($oldversion) { execute_sql( "ALTER TABLE `{$CFG->prefix}glossary` ADD `entbypage` TINYINT(3) UNSIGNED NOT NULL DEFAULT '10' AFTER `globalglossary`" ); + } + + if ( $oldversion < 2003111800 ) { + execute_sql("CREATE TABLE `{$CFG->prefix}glossary_displayformats` ( + `id` INT(10) unsigned NOT NULL auto_increment, + `fid` INT(10) UNSIGNED NOT NULL default '0', + `visible` TINYINT(2) UNSIGNED NOT NULL default '1', + `relatedview` TINYINT(3) NOT NULL default '-1', + `showgroup` TINYINT(2) UNSIGNED NOT NULL default '1', + `defaultmode` VARCHAR(50) NOT NULL default '', + `defaulthook` VARCHAR(50) NOT NULL default '', + `sortkey` VARCHAR(50) NOT NULL default '', + `sortorder` VARCHAR(50) NOT NULL default '', + PRIMARY KEY (`id`) + ) TYPE=MyISAM COMMENT='Setting of the display formats'"); + + // Default format + execute_sql(" INSERT INTO {$CFG->prefix}glossary_displayformats + (fid, relatedview, defaultmode, defaulthook, sortkey, sortorder, showgroup, visible) + VALUES (0,0,'letter','ALL','CREATION','asc',1,1)"); + // Continuous format + execute_sql(" INSERT INTO {$CFG->prefix}glossary_displayformats + (fid, relatedview, defaultmode, defaulthook, sortkey, sortorder, showgroup, visible) + VALUES (1,1,'date','ALL','CREATION','asc',0,1)"); + // Full w/author View + execute_sql(" INSERT INTO {$CFG->prefix}glossary_displayformats + (fid, relatedview, defaultmode, defaulthook, sortkey, sortorder, showgroup, visible) + VALUES (2,2,'letter','ALL','CREATION','asc',1,1)"); + // Encyclopedia + execute_sql(" INSERT INTO {$CFG->prefix}glossary_displayformats + (fid, relatedview, defaultmode, defaulthook, sortkey, sortorder, showgroup, visible) + VALUES (3,3,'letter','ALL','CREATION','asc',1,1)"); + // FAQ View + execute_sql(" INSERT INTO {$CFG->prefix}glossary_displayformats + (fid, relatedview, defaultmode, defaulthook, sortkey, sortorder, showgroup, visible) + VALUES (4,4,'date','ALL','CREATION','asc',0,1)"); + // Full w/o author View + execute_sql(" INSERT INTO {$CFG->prefix}glossary_displayformats + (fid, relatedview, defaultmode, defaulthook, sortkey, sortorder, showgroup, visible) + VALUES (5,5,'letter','ALL','CREATION','asc',1,1)"); + // Entry list + execute_sql(" INSERT INTO {$CFG->prefix}glossary_displayformats + (fid, relatedview, defaultmode, defaulthook, sortkey, sortorder, showgroup, visible) + VALUES (6,0,'letter','ALL','CREATION','asc',1,1)"); + } return true; } diff --git a/mod/glossary/db/mysql.sql b/mod/glossary/db/mysql.sql index 84b547f519..16f8c17184 100644 --- a/mod/glossary/db/mysql.sql +++ b/mod/glossary/db/mysql.sql @@ -98,6 +98,23 @@ CREATE TABLE prefix_glossary_comments ( PRIMARY KEY (id) ) TYPE=MyISAM COMMENT='comments on glossary entries'; +CREATE TABLE prefix_glossary_displayformats ( + id int(10) unsigned NOT NULL auto_increment, + fid int(10) unsigned NOT NULL default '0', + visible tinyint(2) unsigned NOT NULL default '1', + + relatedview tinyint(3) NOT NULL default '-1', + showgroup tinyint(2) unsigned NOT NULL default '1', + + defaultmode varchar(50) NOT NULL default '', + defaulthook varchar(50) NOT NULL default '', + + sortkey varchar(50) NOT NULL default '', + sortorder varchar(50) NOT NULL default '', + + PRIMARY KEY (id) +) TYPE=MyISAM COMMENT='Setting of the display formats'; + # # Dumping data for table `log_display` # diff --git a/mod/glossary/dynalink.php b/mod/glossary/dynalink.php index ea7a89fc4d..40eb8944b4 100644 --- a/mod/glossary/dynalink.php +++ b/mod/glossary/dynalink.php @@ -12,7 +12,6 @@ $GLOSSARY_CONCEPT_IS_ENTRY = 0; $GLOSSARY_CONCEPT_IS_CATEGORY = 1; -// $glossarieslist = get_records_select("glossary", "usedynalink != 0 and (course = $courseid or global != 0)","id"); $glossarieslist = get_records_select("glossary", "usedynalink != 0 and (course = $courseid or globalglossary != 0)","globalglossary, id"); if ( $glossarieslist ) { $glossaries = ""; @@ -35,7 +34,7 @@ } $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","id,glossaryid,name concept, 1 casesensitive,$GLOSSARY_CONCEPT_IS_CATEGORY category, 1 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"); if ( $entries and $categories ) { $concepts = array_merge($entries, $categories); usort($concepts,'glossary_sort_entries_by_lenght'); @@ -49,19 +48,23 @@ $lastglossary = 0; $lastcategory = 0; foreach ( $concepts as $concept ) { - if ( $lastglossary != $concept->glossaryid ) { - $glossary = get_record("glossary","id",$concept->glossaryid); - $lastglossary = $glossary->id; - } if ( $concept->category ) { if ( $lastcategory != $concept->id ) { $category = get_record("glossary_categories","id",$concept->id); $lastcategory = $concept->id; + if ( $cm->instance != $category->glossaryid ) { + $cm = get_coursemodule_from_instance("glossary", $category->glossaryid, $courseid); + } } - $cm = get_coursemodule_from_instance("glossary", $glossary->id, $courseid); + $title = strip_tags("$glossary->name: " . get_string("category","glossary"). " $category->name"); $href_tag_begin = "wwwroot/mod/glossary/view.php?id=$cm->id&mode=cat&hook=$concept->id\">"; } else { + if ( $lastglossary != $concept->glossaryid ) { + $glossary = get_record("glossary","id",$concept->glossaryid); + $lastglossary = $glossary->id; + } + $concepttitle = urlencode($concept->concept); $title = strip_tags("$glossary->name: $concepttitle"); $href_tag_begin = "wwwroot/mod/glossary/showentry.php?courseid=$courseid&concept=$concepttitle\" ". @@ -73,9 +76,12 @@ $currentconcept = str_replace("*", "\*", $currentconcept); if ( $currentconcept = trim(strip_tags($currentconcept)) ) { if ( !$concept->category ) { - if ( $aliases = get_records("glossary_alias","entryid",$concept->id) ) { + if ( $aliases = get_records("glossary_alias","entryid",$concept->id, "alias") ) { foreach ($aliases as $alias) { - $currentconcept .= "|" . trim(strip_tags(str_replace("|", "\|", $alias->alias))); + $currentalias = str_replace("|", "\|", $alias->alias); + $currentalias = str_replace("'", "\'", $currentalias); + $currentalias = str_replace("*", "\*", $currentalias); + $currentconcept .= "|" . trim($currentalias); } } } @@ -97,6 +103,7 @@ if ($list_of_words_cp{strlen($list_of_words_cp)-1}=="|") { $list_of_words_cp{strlen($list_of_words_cp)-1}=""; } + $list_of_words_cp = trim($list_of_words_cp); if ($fullmatch) { $invalidprefixs = "([a-zA-Z0-9])"; @@ -153,18 +160,19 @@ } else { $text = eregi_replace("$list_of_words_cp", "$href_tag_begin"."\\1"."$href_tag_end", $text); } - $text = str_replace(array_keys($final),$final,$text); + + if ( $final ) { + $text = str_replace(array_keys($final),$final,$text); + } if ( $links ) { $text = str_replace(array_keys($links),$links,$text); } if ( $excludes ) { $text = str_replace(array_keys($excludes),$excludes,$text); } - if ( $fullmatch ) { - if ( isset($words) ) { - if ($words) { - $text = str_replace(array_keys($words),$words,$text); - } + if ( $fullmatch and isset($words) ) { + if ($words) { + $text = str_replace(array_keys($words),$words,$text); } } return $text; diff --git a/mod/glossary/edit.php b/mod/glossary/edit.php index 289c9d8453..513e995c54 100644 --- a/mod/glossary/edit.php +++ b/mod/glossary/edit.php @@ -52,6 +52,7 @@ if ( $confirm ) { $newentry->casesensitive = $form->casesensitive; $newentry->fullmatch = $form->fullmatch; $newentry->timemodified = $timenow; + $newentry->approved = $glossary->defaultapproval or isteacher($course->id); if ($form->concept == '' or trim($form->text) == '' ) { $errors = get_string('fillfields','glossary'); @@ -108,7 +109,7 @@ if ( $confirm ) { if (! update_record("glossary_entries", $newentry)) { error("Could not update your glossary"); } else { - add_to_log($course->id, "glossary", "update entry", "view.php?id=$cm->id&mode=entry&hook=$newentry->id", "$newentry->id"); + add_to_log($course->id, "glossary", "update entry", "view.php?id=$cm->id&mode=entry&hook=$newentry->id", $newentry->id); } } else { error("Could not update this glossary entry because this concept already exist."); @@ -117,7 +118,6 @@ if ( $confirm ) { $newentry->userid = $USER->id; $newentry->timecreated = $timenow; $newentry->sourceglossaryid = 0; - $newentry->approved = $glossary->defaultapproval or isteacher($course->id); $newentry->teacherentry = isteacher($course->id); $permissiongranted = 1; @@ -137,7 +137,7 @@ if ( $confirm ) { unset($newentry->attachment); } set_field("glossary_entries", "attachment", $newfilename, "id", $newentry->id); - add_to_log($course->id, "glossary", "add entry", "view.php?id=$cm->id&mode=entry&hook=$newentry->id", "$newentry->id"); + add_to_log($course->id, "glossary", "add entry", "view.php?id=$cm->id&mode=entry&hook=$newentry->id", $newentry->id); } } else { error("Could not insert this glossary entry because this concept already exist."); diff --git a/mod/glossary/formats.php b/mod/glossary/formats.php new file mode 100644 index 0000000000..323a00b61f --- /dev/null +++ b/mod/glossary/formats.php @@ -0,0 +1,295 @@ +fid = $id; + $displayformat->id = insert_record("glossary_displayformats",$displayformat); + } + + $form = data_submitted(); + if ( $mode == 'visible' ) { + if ( $displayformat ) { + if ( $displayformat->visible ) { + $displayformat->visible = 0; + } else { + $displayformat->visible = 1; + } + update_record("glossary_displayformats",$displayformat); + } + redirect($_SERVER["HTTP_REFERER"]); + die; + } elseif ( $mode == 'edit' and $form) { + + $displayformat->relatedview = $form->relatedview; + $displayformat->showgroup = $form->showgroup; + $displayformat->defaultmode = $form->defaultmode; + $displayformat->defaulthook = $form->defaulthook; + $displayformat->sortkey = $form->sortkey; + $displayformat->sortorder = $form->sortorder; + + update_record("glossary_displayformats",$displayformat); + redirect("../../admin/module.php?module=glossary#formats"); + die; + } + + $stradmin = get_string("administration"); + $strconfiguration = get_string("configuration"); + $strmanagemodules = get_string("managemodules"); + $strmodulename = get_string("modulename", "glossary"); + $strdisplayformats = get_string("displayformats","glossary"); + + print_header("$site->shortname: $strmodulename: $strconfiguration", $site->fullname, + "$stradmin -> ". + "$strconfiguration -> ". + "$strmanagemodules -> $strmodulename -> $strdisplayformats"); + + print_heading($strmodulename . ': ' . get_string("displayformats","glossary")); + + echo ''; + echo '
'; + echo get_string("configwarning"); + echo '
'; + + $yes = get_string("yes"); + $no = get_string("no"); + + echo '
'; + echo ''; + ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + '; + + print_footer(); +?> diff --git a/mod/glossary/formats/2.php b/mod/glossary/formats/2.php index b8a825b39f..884ad2b2e9 100644 --- a/mod/glossary/formats/2.php +++ b/mod/glossary/formats/2.php @@ -25,7 +25,7 @@ function glossary_print_entry_by_format($course, $cm, $glossary, $entry, $mode=" glossary_print_entry_concept($entry); echo "
"; - echo "$strby $user->firstname $user->lastname"; + echo "$strby " . fullname($user, isteacher($course->id)) . ""; echo "  (".get_string("lastedited").": ". userdate($entry->timemodified).")"; echo ""; diff --git a/mod/glossary/formats/3.php b/mod/glossary/formats/3.php index d3c582d330..6ff8ef69f4 100644 --- a/mod/glossary/formats/3.php +++ b/mod/glossary/formats/3.php @@ -20,7 +20,7 @@ function glossary_print_entry_by_format($course, $cm, $glossary, $entry, $mode=" echo ""; glossary_print_entry_concept($entry); echo "
"; - echo "$strby $user->firstname $user->lastname"; + echo "$strby " . fullname($user, isteacher($course->id)) . ""; echo "  (".get_string("lastedited").": ". userdate($entry->timemodified).")"; echo ""; diff --git a/mod/glossary/formats/6.php b/mod/glossary/formats/6.php index 315c4707e1..19b53e94b3 100644 --- a/mod/glossary/formats/6.php +++ b/mod/glossary/formats/6.php @@ -10,7 +10,7 @@ function glossary_print_entry_by_format($course, $cm, $glossary, $entry,$mode="" echo "\n"; echo "
+ +
+

Related Display Format:

+ + +

+

Default Mode:

+ + +

+

Default Hook:

+ + +

+

Default Sort Key:

+ + +

+

Default Sort Order:

+ + +

+

Include Group Breaks:

+ + +

+
+ ">
"; if ($entry) { - echo "id&mode=entry&hook=$entry->id&displayformat=2\">"; + echo "id&mode=entry&hook=$entry->id\">"; glossary_print_entry_concept($entry); echo ' '; diff --git a/mod/glossary/lib.php b/mod/glossary/lib.php index de6db25506..cb989f16ba 100644 --- a/mod/glossary/lib.php +++ b/mod/glossary/lib.php @@ -879,7 +879,7 @@ for ($row = 0; $row < $numrows; $row++) { $currentcolor = $tabcolor; $currentstyle = 'generaltab'; } - echo ""; + echo ""; if ($tabproccessed != $currenttab and $data[$tabproccessed]->link) { echo "link . "\">"; } @@ -925,7 +925,7 @@ for ($row = 0; $row < $numrows; $row++) { $currentcolor = $tabcolor; $currentstyle = 'generaltab'; } - echo ""; + echo ""; if ($tabproccessed != $currenttab and $data[$tabproccessed]->link) { echo "link . "\">"; } @@ -1289,8 +1289,10 @@ function glossary_print_dynaentry($courseid, $entries, $displayformat = -1) { } $dp = $displayformat; // Hard-coded until the Display formats manager is done. - if ( $dp == -1 and $glossary->displayformat == 6 ) { - $dp = 2; + if ( $dprecord = get_record("glossary_displayformats","fid", $glossary->displayformat) ) { + if ( $dprecord->relatedview >= 0 ) { + $dp = $dprecord->relatedview; + } } glossary_print_entry($course, $cm, $glossary, $entry, "","",0,$dp); } diff --git a/mod/glossary/mod.html b/mod/glossary/mod.html index d979d46404..35e2a4bf0a 100644 --- a/mod/glossary/mod.html +++ b/mod/glossary/mod.html @@ -250,7 +250,10 @@ if (!$mainglossary or $mainglossary->id == $form->instance ) { if ( $pos = strpos($dir, ".") ) { $dir = substr($dir, 0, $pos ); if ($dir != 0 and $dir != 1) { // excluding basic formats - $formats[$dir] = get_string("displayformat$dir", "glossary"); + $dp = get_record("glossary_displayformats","fid",$dir); + if ( !$dp or $dp->visible ) { + $formats[$dir] = get_string("displayformat$dir", "glossary"); + } } } } diff --git a/mod/glossary/print.php b/mod/glossary/print.php index ad2ee87d5e..69c600e8a7 100644 --- a/mod/glossary/print.php +++ b/mod/glossary/print.php @@ -105,6 +105,17 @@ break; } + switch ( $sortkey ) { + case "CREATION": + $sortkey = "timecreated"; + break; + + case "UPDATE": + $sortkey = "timemodified"; + default: + break; + } + include_once("sql.php"); $entriesshown = 0; @@ -119,95 +130,96 @@ echo '' . $site->fullname . '
'; echo get_string("course") . ': ' . $course->fullname . '
'; echo get_string("modulename","glossary") . ': ' . $glossary->name . '

'; + if ( $allentries ) { + foreach ($allentries as $entry) { + /// Setting the pivot for the current entry + $pivot = $entry->pivot; + if ( !$fullpivot ) { + $pivot = $pivot[0]; + } + + /// + /// Validating special cases not covered by the SQL statement + /// - foreach ($allentries as $entry) { - /// Setting the pivot for the current entry - $pivot = $entry->pivot; - if ( !$fullpivot ) { - $pivot = $pivot[0]; - } - - /// - /// Validating special cases not covered by the SQL statement - /// - - /// if we're browsing by alphabet and the current concept does not begin with - /// the letter we are look for. - $showentry = 1; - if ( $mode == 'letter' and $hook != 'SPECIAL' and $hook != 'ALL' ) { - if ( substr($entry->concept, 0, strlen($hook)) != $hook ) { - $showentry = 0; - } - } - - /// if we're browsing for letter, looking for special characters not covered - /// in the alphabet - if ( $showentry and $hook == 'SPECIAL' ) { - $initial = $entry->concept[0]; - for ($i = 0; $i < count($alphabet); $i++) { - $curletter = $alphabet[$i]; - if ( $curletter == $initial ) { - + /// if we're browsing by alphabet and the current concept does not begin with + /// the letter we are look for. + $showentry = 1; + if ( $mode == 'letter' and $hook != 'SPECIAL' and $hook != 'ALL' ) { + if ( substr($entry->concept, 0, strlen($hook)) != $hook ) { $showentry = 0; - break; } - } - } - - /// if we're browsing categories, looking for entries not categorised. - if ( $showentry and $mode == 'cat' and $hook == GLOSSARY_SHOW_NOT_CATEGORISED ) { - if ( record_exists("glossary_entries_categories", "entryid", $entry->id)) { - $showentry = 0; } - } - - /// if the entry is not approved, deal with it based on the current view and - /// user. - if ( $showentry and $mode != 'approval' ) { - if ( !$entry->approved and isteacher($course->id, $entry->userid) ) { - $showentry = 0; - } - } - - /// ok, if it's a valid entry.. Print it. - if ( $showentry ) { - - if ( $currentpivot != strtoupper($pivot) ) { - - // print the group break if apply - if ( $printpivot ) { - $currentpivot = strtoupper($pivot); - if ( !$tableisopen ) { - echo ''; - $tableisopen = 1; - } - - echo ''; - $pivottoshow = $currentpivot; - if ( isset($entry->uid) ) { - // printing the user icon if defined (only when browsing authors) - echo ''; - echo ''; } + } + + /// if we're browsing categories, looking for entries not categorised. + if ( $showentry and $mode == 'cat' and $hook == GLOSSARY_SHOW_NOT_CATEGORISED ) { + if ( record_exists("glossary_entries_categories", "entryid", $entry->id)) { + $showentry = 0; + } } - - echo ''; - echo ''; - echo ''; + /// ok, if it's a valid entry.. Print it. + if ( $showentry ) { + + if ( !$tableisopen ) { + echo '
'; - $pivottoshow = $entry->uname; - } else { - echo ''; + + /// if we're browsing for letter, looking for special characters not covered + /// in the alphabet + if ( $showentry and $hook == 'SPECIAL' ) { + $initial = $entry->concept[0]; + for ($i = 0; $i < count($alphabet); $i++) { + $curletter = $alphabet[$i]; + if ( $curletter == $initial ) { + + $showentry = 0; + break; } - - echo "$pivottoshow" ; - echo '
'. $entry->concept . ': '; - if ( $entry->attachment) { - glossary_print_entry_attachment($entry); + /// if the entry is not approved, deal with it based on the current view and + /// user. + if ( $showentry and $mode != 'approval' ) { + if ( !$entry->approved and isteacher($course->id, $entry->userid) ) { + $showentry = 0; + } } - echo strip_tags($entry->definition); - echo '

'; + $tableisopen = 1; + } + if ( $currentpivot != strtoupper($pivot) ) { + // print the group break if apply + if ( $printpivot ) { + $currentpivot = strtoupper($pivot); + + echo ''; + $pivottoshow = $currentpivot; + if ( isset($entry->uid) ) { + // printing the user icon if defined (only when browsing authors) + echo ''; + echo ''; + } + } + + echo ''; + echo ''; + echo ''; + } } } if ($tableisopen) { diff --git a/mod/glossary/sql.php b/mod/glossary/sql.php index 030029b009..5b7ff5bc77 100644 --- a/mod/glossary/sql.php +++ b/mod/glossary/sql.php @@ -14,7 +14,6 @@ /// 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; - $printpivot = 1; $userid = ''; if ( $USER->id ) { @@ -77,7 +76,6 @@ $where = "AND substr(ucase($usernamefield),1," . strlen($hook) . ") = '" . strtoupper($hook) . "'"; break; case 'mysql': - $usernametoshow = "CONCAT(CONCAT(u.firstname,' '), u.lastname)"; if ( $sortkey == 'FIRSTNAME' ) { $usernamefield = "CONCAT(CONCAT(u.firstname,' '), u.lastname)"; } else { @@ -90,7 +88,7 @@ $where = ''; } - $sqlselect = "SELECT ge.id, $usernamefield pivot, $usernametoshow uname, u.id uid, ge.*"; + $sqlselect = "SELECT ge.id, $usernamefield 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) @@ -170,7 +168,7 @@ $where = 'AND substr(ucase(concept),1,' . strlen($hook) . ') = \'' . strtoupper($hook) . '\''; break; case 'mysql': - $where = 'AND left(ucase(concept),' . strlen($hook) . ") = '$hook'"; + $where = 'AND left(ucase(concept),' . strlen($hook) . ") = '" . strtoupper($hook) . "'"; break; } } diff --git a/mod/glossary/version.php b/mod/glossary/version.php index 8ef1e439b7..27014bd401 100644 --- a/mod/glossary/version.php +++ b/mod/glossary/version.php @@ -5,7 +5,7 @@ /// This fragment is called by moodle_needs_upgrading() and /admin/index.php ///////////////////////////////////////////////////////////////////////////////// -$module->version = 2003111500; // The current module version (Date: YYYYMMDDXX) +$module->version = 2003111800; // The current module version (Date: YYYYMMDDXX) $module->cron = 0; // Period for cron to check this module (secs) $release = "0.5 development"; // User-friendly version number diff --git a/mod/glossary/view.php b/mod/glossary/view.php index ec29dcff7c..adc93a6f3e 100644 --- a/mod/glossary/view.php +++ b/mod/glossary/view.php @@ -58,6 +58,10 @@ } } else { $printpivot = 1; + if ( $mode == '' and $hook == '' and $show == '') { + $mode = 'letter'; + $hook = 'ALL'; + } } if ( $displayformat == -1 ) {
'; + $user = get_record("user","id",$entry->uid); + $pivottoshow = fullname($user, isteacher($course->id)); + } else { + echo ''; + } + + echo "$pivottoshow" ; + echo '
'. $entry->concept . ': '; + + if ( $entry->attachment) { + glossary_print_entry_attachment($entry); + } + echo strip_tags($entry->definition); + + echo '