]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-16075 adding missing lang strings
authorskodak <skodak>
Sun, 7 Sep 2008 23:20:51 +0000 (23:20 +0000)
committerskodak <skodak>
Sun, 7 Sep 2008 23:20:51 +0000 (23:20 +0000)
lang/en_utf8/glossary.php
mod/glossary/lib.php

index 01d7526c3695a936ff4b1a5f7e2365a76801254a..01b7e3fc569273dade431f713238015815a194c8 100644 (file)
@@ -15,6 +15,7 @@ $string['allowprintview'] = 'Allow print view';
 $string['allowratings'] = 'Allow entries to be rated?';
 $string['answer'] = 'Answer';
 $string['approve'] = 'Approve';
+$string['areaintro'] = 'Glossary introduction';
 $string['areyousuredelete'] = 'Are you sure you want to delete this entry?';
 $string['areyousuredeletecomment'] = 'Are you sure you want to delete this comment?';
 $string['areyousureexport'] = 'Are you sure you want to export this entry to';
index 60ae1a86dece887cba91ec6c97145a2898240145..c3ffbcb0eb48a5039f4e581eef3e2a9d064f19d9 100644 (file)
@@ -1179,56 +1179,83 @@ function glossary_print_attachments($entry, $cm, $type=NULL, $align="left") {
     }
 }
 
+/**
+ * Lists all browsable file areas
+ */
+function glossary_get_file_areas($course, $cm, $context) {
+    $areas = array();
+    if (has_capability('moodle/course:managefiles', $context)) {
+        $areas['glossary_intro'] = get_string('areaintro', 'glossary');
+    }
+    return $areas;
+}
+
 /**
  * Serves the glossary attachments. Implements needed access control ;-)
  */
 function glossary_pluginfile($course, $cminfo, $context, $filearea, $args) {
     global $CFG, $DB;
 
-    if ($filearea !== 'glossary_attachment') {
-        return false;
-    }
-
     if (!$cminfo->uservisible) {
         return false;
     }
 
-    $entryid = (int)array_shift($args);
+    if ($filearea === 'glossary_intro') {
+        // all users may access it
+        $relativepath = '/'.implode('/', $args);
+        $fullpath = $context->id.'glossary_intro0'.$relativepath;
 
-    if (!$entry = $DB->get_record('glossary_entries', array('id'=>$entryid))) {
-        return false;
-    }
+        $fs = get_file_storage();
+        if (!$file = $fs->get_file_by_hash(sha1($fullpath)) or $file->is_directory()) {
+            return false;
+        }
 
-    if (!$glossary = $DB->get_record('glossary', array('id'=>$cminfo->instance))) {
-        return false;
-    }
+        $lifetime = isset($CFG->filelifetime) ? $CFG->filelifetime : 86400;
 
-    if ($glossary->defaultapproval and !$entry->approved and !has_capability('mod/glossary:approve', $context)) {
-        return false;
-    }
+        // finally send the file
+        send_stored_file($file, $lifetime, 0);
 
-    if ($entry->glossaryid == $cminfo->instance) {
-        $filecontext = $context;
+    } else if ($filearea === 'glossary_attachment') {
+        $entryid = (int)array_shift($args);
 
-    } else if ($entry->sourceglossaryid == $cminfo->instance) {
-        if (!$maincm = get_coursemodule_from_instance('glossary', $entry->glossaryid)) {
-            print_error('invalidcoursemodule');
+        if (!$entry = $DB->get_record('glossary_entries', array('id'=>$entryid))) {
+            return false;
         }
-        $filecontext = get_context_instance(CONTEXT_MODULE, $maincm->id);
 
-    } else {
-        return false;
-    }
+        if (!$glossary = $DB->get_record('glossary', array('id'=>$cminfo->instance))) {
+            return false;
+        }
 
-    $fs = get_file_storage();
-    $relativepath = '/'.implode('/', $args);
-    $fullpath = $filecontext->id.$filearea.$entryid.$relativepath;
-    if (!$file = $fs->get_file_by_hash(sha1($fullpath)) or $file->is_directory()) {
-        return false;
+        if ($glossary->defaultapproval and !$entry->approved and !has_capability('mod/glossary:approve', $context)) {
+            return false;
+        }
+
+        if ($entry->glossaryid == $cminfo->instance) {
+            $filecontext = $context;
+
+        } else if ($entry->sourceglossaryid == $cminfo->instance) {
+            if (!$maincm = get_coursemodule_from_instance('glossary', $entry->glossaryid)) {
+                print_error('invalidcoursemodule');
+            }
+            $filecontext = get_context_instance(CONTEXT_MODULE, $maincm->id);
+
+        } else {
+            return false;
+        }
+
+        $relativepath = '/'.implode('/', $args);
+        $fullpath = $filecontext->id.$filearea.$entryid.$relativepath;
+
+        $fs = get_file_storage();
+        if (!$file = $fs->get_file_by_hash(sha1($fullpath)) or $file->is_directory()) {
+            return false;
+        }
+
+        // finally send the file
+        send_stored_file($file, 0, 0, true); // download MUST be forced - security!
     }
 
-    // finally send the file
-    send_stored_file($file, 0, 0, true); // download MUST be forced - security!
+    return false;
 }
 
 function glossary_print_tabbed_table_end() {