]> git.mjollnir.org Git - moodle.git/commitdiff
- Allowing to selectively export categories or entries based on current frame and...
authorwillcast <willcast>
Thu, 6 Nov 2003 15:07:34 +0000 (15:07 +0000)
committerwillcast <willcast>
Thu, 6 Nov 2003 15:07:34 +0000 (15:07 +0000)
mod/glossary/export.php
mod/glossary/lib.php

index 06fe42c88036998d29156c81a1168490c7186604..5585bb90abebb5fe703b1a2702f26ff7c23cd4aa 100644 (file)
@@ -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)) {
     }
 
 /// 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>'
 ?>
\ No newline at end of file
index c387647173d9044ba0a9d5ce4aaec0af2c35dfe6..18f827097509ecaac2b8dfac53ec6928ae2d1196 100644 (file)
@@ -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 @@ global $CFG;
         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));