Permalink
Browse files

MDL-30482 create new capability for viewing glossary entries

  • Loading branch information...
1 parent 1a52d9e commit 03adb289ec8396e15f18cbb45dddca1e834ed1c9 @mackensen mackensen committed with nebgor Nov 26, 2011
Showing with 17 additions and 2 deletions.
  1. +14 −0 mod/glossary/db/access.php
  2. +1 −0 mod/glossary/lang/en/glossary.php
  3. +1 −2 mod/glossary/rsslib.php
  4. +1 −0 mod/glossary/view.php
View
14 mod/glossary/db/access.php
@@ -30,6 +30,20 @@
$capabilities = array(
+ 'mod/glossary:read' => array(
+
+ 'captype' => 'read',
+ 'contextlevel' => CONTEXT_MODULE,
+ 'archetypes' => array(
+ 'guest' => CAP_ALLOW,
+ 'student' => CAP_ALLOW,
+ 'teacher' => CAP_ALLOW,
+ 'editingteacher' => CAP_ALLOW,
+ 'manager' => CAP_ALLOW
+ )
+ ),
+
+
'mod/glossary:write' => array(
'riskbitmask' => RISK_SPAM,
View
1 mod/glossary/lang/en/glossary.php
@@ -178,6 +178,7 @@
$string['glossary:managecomments'] = 'Manage comments';
$string['glossary:manageentries'] = 'Manage entries';
$string['glossary:rate'] = 'Rate entries';
+$string['glossary:read'] = 'Read entries';
$string['glossarytype'] = 'Glossary type';
$string['glossarytype_help'] = 'A main glossary is a glossary in which entries from secondary glossaries can be imported. There can only be one main glossary in a course. if glossary entry import is not required, all glossaries in the course can be secondary glossaries.';
$string['glossary:view'] = 'View glossary';
View
3 mod/glossary/rsslib.php
@@ -23,8 +23,7 @@ function glossary_rss_get_feed($context, $args) {
$course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST);
}
//context id from db should match the submitted one
- //no specific capability required to view glossary entries so just check user is enrolled
- if ($context->id != $modcontext->id || !can_access_course($course, $USER)) {
+ if ($context->id != $modcontext->id || !has_capability('mod/glossary:read', $modcontext)) {
return null;
}
}
View
1 mod/glossary/view.php
@@ -49,6 +49,7 @@
require_course_login($course->id, true, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
+require_capability('mod/glossary:read', $context);
// Prepare format_string/text options
$fmtoptions = array(

0 comments on commit 03adb28

Please sign in to comment.