MDL-34910 blog Fixing mod level related issues
authorDavid Monllao <davidm@moodle.com>
Wed, 31 Oct 2012 03:56:36 +0000 (11:56 +0800)
committerDavid Monllao <davidm@moodle.com>
Wed, 31 Oct 2012 04:58:42 +0000 (12:58 +0800)
blog/edit_form.php
blog/locallib.php

index b66a6e4..919fed1 100644 (file)
@@ -158,8 +158,8 @@ class blog_edit_form extends moodleform {
             $modcontextid = $data['modassoc'];
             $modcontext = context::instance_by_id($modcontextid, IGNORE_MISSING);
 
-            $canassociatemodule = has_capability('moodle/blog:associatecourse', $modcontext);
-            if ($modcontext->contextlevel == CONTEXT_MODULE && $canassociatemodule) {
+            $canassociatemodule = has_capability('moodle/blog:associatemodule', $modcontext);
+            if ($canassociatemodule) {
                 // get context of the mod's course
                 $coursecontext = $modcontext->get_course_context(true);
 
index 168faf1..304b3da 100644 (file)
@@ -665,12 +665,12 @@ class blog_listing {
             if (empty($userid) || (!empty($userid) && $userid == $USER->id)) {
 
                 $canaddentries = true;
+                $courseid = optional_param('courseid', null, PARAM_INT);
                 if ($modid = optional_param('modid', null, PARAM_INT)) {
                     if (!has_capability('moodle/blog:associatemodule', context_module::instance($modid))) {
                         $canaddentries = false;
                     }
-                }
-                if ($courseid = optional_param('courseid', null, PARAM_INT)) {
+                } else if ($courseid) {
                     if (!has_capability('moodle/blog:associatecourse', context_course::instance($courseid))) {
                         $canaddentries = false;
                     }