Browse files

MDL-30376 mod_glossary: Integration tidy up

  • Loading branch information...
1 parent 87b61e3 commit 1d841d8a2dd0c5ccbd16ab75df6ddba28f482930 Sam Hemelryk committed Dec 1, 2011
Showing with 10 additions and 4 deletions.
  1. +3 −2 mod/glossary/lib.php
  2. +7 −2 mod/glossary/rsslib.php
View
5 mod/glossary/lib.php
@@ -2747,7 +2747,7 @@ function glossary_extend_navigation($navigation, $course, $module, $cm) {
* @param navigation_node $glossarynode The node to add module settings to
*/
function glossary_extend_settings_navigation(settings_navigation $settings, navigation_node $glossarynode) {
- global $PAGE, $DB, $CFG, $USER, $COURSE;
+ global $PAGE, $DB, $CFG, $USER;
$mode = optional_param('mode', '', PARAM_ALPHA);
$hook = optional_param('hook', 'ALL', PARAM_CLEAN);
@@ -2770,7 +2770,8 @@ function glossary_extend_settings_navigation(settings_navigation $settings, navi
$glossary = $DB->get_record('glossary', array("id" => $PAGE->cm->instance));
- if (!empty($CFG->enablerssfeeds) && !empty($CFG->glossary_enablerssfeeds) && $glossary->rsstype && $glossary->rssarticles && can_access_course($COURSE, $USER)) {
+ $coursecontext = get_context_instance(CONTEXT_COURSE, $PAGE->course->id, MUST_EXIST);
+ if (!empty($CFG->enablerssfeeds) && !empty($CFG->glossary_enablerssfeeds) && $glossary->rsstype && $glossary->rssarticles && can_access_course($coursecontext, $USER)) {
require_once("$CFG->libdir/rsslib.php");
$string = get_string('rsstype','forum');
View
9 mod/glossary/rsslib.php
@@ -17,10 +17,15 @@ function glossary_rss_get_feed($context, $args) {
$cm = get_coursemodule_from_instance('glossary', $glossaryid, 0, false, MUST_EXIST);
if ($cm) {
$modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
-
+ if ($COURSE->id == $cm->course) {
+ $course = $COURSE;
+ } else {
+ $course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST);
+ }
+ $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id, 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 || !can_access_course($coursecontext, $USER)) {
return null;
}
}

0 comments on commit 1d841d8

Please sign in to comment.