### Eclipse Workspace Patch 1.0 #P moodle18dev Index: mod/glossary/lib.php =================================================================== RCS file: /cvsroot/moodle/moodle/mod/glossary/lib.php,v retrieving revision 1.168.2.7 diff -u -r1.168.2.7 lib.php --- mod/glossary/lib.php 24 Sep 2007 17:11:43 -0000 1.168.2.7 +++ mod/glossary/lib.php 19 Dec 2007 17:28:15 -0000 @@ -1625,7 +1625,9 @@ echo ''; } -function glossary_generate_export_file($glossary, $hook = "", $hook = 0) { +/// Modified by Joseph Rezeau 19 DEC 2007 to enable *selective export* of entries by category, etc. +/// implies changes in mod/glossary export.php, exportfile.php and view.php files +function glossary_generate_export_file($glossary, $mode = "", $cat="", $hook = 0, $sortkey = '', $fullsearch = 0) { global $CFG; $co = "\n"; @@ -1645,33 +1647,32 @@ $co .= glossary_full_tag("GLOBALGLOSSARY",2,false,$glossary->globalglossary); $co .= glossary_full_tag("ENTBYPAGE",2,false,$glossary->entbypage); - if ( $entries = get_records("glossary_entries","glossaryid",$glossary->id) ) { - $co .= glossary_start_tag("ENTRIES",2,true); - foreach ($entries as $entry) { - $permissiongranted = 1; - if ( $hook ) { - switch ( $hook ) { - case "ALL": - case "SPECIAL": - break; - default: - $permissiongranted = ($entry->concept[ strlen($hook)-1 ] == $hook); - break; - } - } - if ( $hook ) { - switch ( $hook ) { - case GLOSSARY_SHOW_ALL_CATEGORIES: - break; - case GLOSSARY_SHOW_NOT_CATEGORISED: - $permissiongranted = !record_exists("glossary_entries_categories","entryid",$entry->id); - break; - default: - $permissiongranted = record_exists("glossary_entries_categories","entryid",$entry->id, "categoryid",$hook); - break; - } - } - if ( $entry->approved and $permissiongranted ) { + switch ( $mode = strtolower($mode) ) { + case 'cat': /// Looking for a certain category + $tab = GLOSSARY_CATEGORY_VIEW; + break; + + case 'author': /// Looking for entries, browsed by author + $tab = GLOSSARY_AUTHOR_VIEW; + break; + + /// Looking for entries that begin with a certain letter, ALL or SPECIAL characters + /// Also includes Search entries and Search full text + default: + $tab = GLOSSARY_STANDARD_VIEW; + break; + } + $allentries = ''; + $sortorder = ''; + $offset = ''; + $entriesbypage = ''; + + include_once("sql.php"); + + if ( $allentries ) { + $co .= glossary_start_tag("ENTRIES",2,true); + foreach ($allentries as $entry) { + if ( $entry->approved ) { $co .= glossary_start_tag("ENTRY",3,true); $co .= glossary_full_tag("CONCEPT",4,false,trim($entry->concept)); $co .= glossary_full_tag("DEFINITION",4,false,trusttext_strip($entry->definition));