From: willcast Date: Thu, 6 Nov 2003 15:07:34 +0000 (+0000) Subject: - Allowing to selectively export categories or entries based on current frame and... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=046a797c1a1381e3788319730fafe124529a463b;p=moodle.git - Allowing to selectively export categories or entries based on current frame and view. --- diff --git a/mod/glossary/export.php b/mod/glossary/export.php index 06fe42c880..5585bb90ab 100644 --- a/mod/glossary/export.php +++ b/mod/glossary/export.php @@ -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 '

' . get_string("exportedfile","glossary") . '

' ?> \ No newline at end of file diff --git a/mod/glossary/lib.php b/mod/glossary/lib.php index c387647173..18f8270975 100644 --- a/mod/glossary/lib.php +++ b/mod/glossary/lib.php @@ -439,7 +439,6 @@ function glossary_print_entry_by_default($course, $cm, $glossary, $entry,$tab="" echo ""; glossary_print_entry_concept($entry); echo ": "; - glossary_print_entry_aliases($entry); glossary_print_entry_definition($entry); glossary_print_entry_lower_section($course, $cm, $glossary, $entry,$tab,$cat); echo ""; @@ -1138,7 +1137,7 @@ function glossary_print_dynaentry($courseid, $entries) { echo ""; } -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));