Permalink
Browse files

- Allowing to selectively export categories or entries based on curre…

…nt frame and view.
  • Loading branch information...
1 parent ab28847 commit 046a797c1a1381e3788319730fafe124529a463b willcast committed Nov 6, 2003
Showing with 32 additions and 7 deletions.
  1. +7 −4 mod/glossary/export.php
  2. +25 −3 mod/glossary/lib.php
View
@@ -6,7 +6,7 @@
require_variable($id); // Course Module ID
- optional_variable($l,"ALL");
+ optional_variable($l,"");
optional_variable($cat,0);
if (! $cm = get_record("course_modules", "id", $id)) {
@@ -52,16 +52,19 @@
}
/// Tabbed browsing sections
+ $lastl = $l;
+ $lastcat = $cat;
$tab = GLOSSARY_EXPORT_VIEW;
include("tabs.html");
- glossary_generate_export_file($glossary,$l,$cat);
+ glossary_generate_export_file($glossary,$lastl,$lastcat);
print_string("glosssaryexported","glossary");
+ $ffurl = "/$course->id/glossary/" . clean_filename($glossary->name) ."/glossary.xml";
if ($CFG->slasharguments) {
- $ffurl = "../../file.php/$course->id/glossary/" . clean_filename($glossary->name) ."/glossary.xml";
+ $ffurl = "../../file.php$ffurl" ;
} else {
- $ffurl = "../../file.php?file=/$course->id/glossary/" . clean_filename($glossary->name) ."/glossary.xml";
+ $ffurl = "../../file.php?file=$ffurl";
}
echo '<p><center><a href="' . $ffurl . '" target=_blank>' . get_string("exportedfile","glossary") . '</a></center><p>'
?>
View
@@ -439,7 +439,6 @@ function glossary_print_entry_by_default($course, $cm, $glossary, $entry,$tab=""
echo "<b>";
glossary_print_entry_concept($entry);
echo ":</b> ";
- glossary_print_entry_aliases($entry);
glossary_print_entry_definition($entry);
glossary_print_entry_lower_section($course, $cm, $glossary, $entry,$tab,$cat);
echo "</td>";
@@ -1138,7 +1137,7 @@ function glossary_print_dynaentry($courseid, $entries) {
echo "</tr></table></center>";
}
-function glossary_generate_export_file($glossary,$l, $cat) {
+function glossary_generate_export_file($glossary, $l = "", $cat = 0) {
global $CFG;
glossary_check_moddata_dir($glossary);
$h = glossary_open_xml($glossary);
@@ -1159,7 +1158,30 @@ function glossary_generate_export_file($glossary,$l, $cat) {
if ( $entries = get_records("glossary_entries","glossaryid",$glossary->id) ) {
$status = fwrite ($h,glossary_start_tag("ENTRIES",2,true));
foreach ($entries as $entry) {
- if ( $entry->approved ) {
+ $permissiongranted = 1;
+ if ( $l ) {
+ switch ( $l ) {
+ case "ALL":
+ case "SPECIAL":
+ break;
+ default:
+ $permissiongranted = ($entry->concept[ strlen($l)-1 ] == $l);
+ break;
+ }
+ }
+ if ( $cat ) {
+ switch ( $cat ) {
+ 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",$cat);
+ break;
+ }
+ }
+ if ( $entry->approved and $permissiongranted ) {
$status = fwrite($h,glossary_start_tag("ENTRY",3,true));
fwrite($h,glossary_full_tag("CONCEPT",4,false,$entry->concept));
fwrite($h,glossary_full_tag("DEFINITION",4,false,$entry->definition));

0 comments on commit 046a797

Please sign in to comment.