]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-15768 - roles in glossary
authormjollnir_ <mjollnir_>
Tue, 19 Aug 2008 09:20:54 +0000 (09:20 +0000)
committermjollnir_ <mjollnir_>
Tue, 19 Aug 2008 09:20:54 +0000 (09:20 +0000)
lang/en_utf8/glossary.php
mod/glossary/db/access.php
mod/glossary/export.php
mod/glossary/lib.php
mod/glossary/version.php

index cba53670dbb0e0355f3e7e4c0660767155016cc6..01d7526c3695a936ff4b1a5f7e2365a76801254a 100644 (file)
@@ -127,6 +127,8 @@ $string['globalglossary'] = 'Global glossary';
 $string['glossary:approve'] = 'Approve unapproved entries';
 $string['glossary:comment'] = 'Create comments';
 $string['glossary:export'] = 'Export entries';
+$string['glossary:exportentry'] = 'Export single entry';
+$string['glossary:exportownentry'] = 'Export single entry of yours';
 $string['glossary:import'] = 'Import entries';
 $string['glossary:managecategories'] = 'Manage categories';
 $string['glossary:managecomments'] = 'Manage comments';
index b00f92691adbc7cb63b7dfa2a2bcbc95248aaa3b..f800926d80d3b3e6d031b0da8600f5ca87f0af81 100644 (file)
@@ -159,6 +159,31 @@ $mod_glossary_capabilities = array(
         )
     ),
 
+    'mod/glossary:exportentry' => array(
+
+        'riskbitmask' => RISK_PERSONAL,
+
+        'captype' => 'read',
+        'contextlevel' => CONTEXT_MODULE,
+        'legacy' => array(
+            'teacher' => CAP_ALLOW,
+            'editingteacher' => CAP_ALLOW,
+            'admin' => CAP_ALLOW
+        )
+    ),
+
+    'mod/glossary:exportownentry' => array(
+
+        'captype' => 'read',
+        'contextlevel' => CONTEXT_MODULE,
+        'legacy' => array(
+            'teacher' => CAP_ALLOW,
+            'editingteacher' => CAP_ALLOW,
+            'admin' => CAP_ALLOW,
+            'student' => CAP_ALLOW,
+        )
+    ),
+
 );
 
 ?>
index d5f0d88707de85e3644e4aac20283f655ec4ab32..9a26d068defc0a8e93cecb737d6c82d28f749423 100644 (file)
@@ -57,7 +57,8 @@
     </div>
     </form>
 <?php
-    if ($DB->count_records('glossary_entries', array('glossaryid' => $glossary->id)) && true) { // @todo penny capability check
+    // don't need cap check here, we share with the general export.
+    if ($DB->count_records('glossary_entries', array('glossaryid' => $glossary->id))) {
         require_once($CFG->libdir . '/portfoliolib.php');
         $p = array(
             'id' => $cm->id,
index 017bcbe183c91e8e9cfa42e5846444b080da5412..d8b43e66e4ea8eaf610a030944d38957574bd83f 100644 (file)
@@ -900,7 +900,9 @@ function glossary_print_entry_icons($course, $cm, $glossary, $entry, $mode='',$h
             $return .= " <font size=\"-1\">" . get_string("exportedentry","glossary") . "</font>";
         }
     }
-    if (true) { // @todo penny add capability check
+    if (has_capability('mod/glossary:exportentry', $context)
+        || ($entry->userid == $USER->id
+            && has_capability('mod/glossary:exportownentry', $context))) {
         require_once($CFG->libdir . '/portfoliolib.php');
         $p = array(
             'id' => $cm->id,
@@ -2428,8 +2430,7 @@ class glossary_csv_portfolio_caller extends portfolio_module_caller_base {
     }
 
     public function check_permissions() {
-        // @todo
-        return true;
+        return has_capability('mod/glossary:export', get_context_instance(CONTEXT_MODULE, $this->cm->id));
     }
 
     public static function display_name() {
@@ -2454,14 +2455,6 @@ class glossary_entry_portfolio_caller extends portfolio_module_caller_base {
             || !$this->entry = $DB->get_record('glossary_entries', array('id' => $callbackargs['entryid']))) {
             portfolio_exporter::raise_error('noentry', 'glossary');
         }
-        /*
-        $aliases = $DB->get_records('glossary_alias', array('entryid' => $this->entry->id));
-        $categories = $DB->get_records_sql('SELECT ec.entryid, c.name
-            FROM {glossary_entries_categories} ec
-            JOIN {glossary_categories} c
-            ON c.id = ec.categoryid
-            WHERE ec.entryid = ?', array($this->entry->id));
-        */
     }
 
     public function expected_time() {
@@ -2469,8 +2462,9 @@ class glossary_entry_portfolio_caller extends portfolio_module_caller_base {
     }
 
     public function check_permissions() {
-        //@ penny todo
-        return true;
+        $context = get_context_instance(CONTEXT_MODULE, $this->cm->id);
+        return has_capability('mod/glossary:exportentry', $context)
+            || ($this->entry->userid == $this->user->id && has_capability('mod/glossary:exportownentry', $context));
     }
 
     public static function display_name() {
index 4fa3d061d658eca4ee704e6325331ecf148404cd..64450c278103c1611ef1c2e4e1fe1b200ce1ef13 100644 (file)
@@ -5,7 +5,7 @@
 ///  This fragment is called by moodle_needs_upgrading() and /admin/index.php
 /////////////////////////////////////////////////////////////////////////////////
 
-$module->version  = 2008081900;
+$module->version  = 2008081901;
 $module->requires = 2008081600;  // Requires this Moodle version
 $module->cron     = 0;           // Period for cron to check this module (secs)