]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-11167, admin blocks page should not show blocks not placed on course pages
authortoyomoyo <toyomoyo>
Fri, 19 Oct 2007 07:54:30 +0000 (07:54 +0000)
committertoyomoyo <toyomoyo>
Fri, 19 Oct 2007 07:54:30 +0000 (07:54 +0000)
admin/blocks.php
course/search.php

index 3b296beeb9f47cf8e9662d00aae4a4fe7d1a0d1d..9e89eb65c56c23ca9039e3c3c51e352c4de6e389 100644 (file)
             $settings = '<a href="block.php?block='.$blockid.'">'.$strsettings.'</a>';
         }
 
-        $count = count_records('block_instance', 'blockid', $blockid);
+        // MDL-11167, blocks can be placed on mymoodle, or the blogs page
+        // and it should not show up on course search page
+        $count = count_records_sql('SELECT COUNT(*) 
+                                        FROM '.$CFG->prefix.'block_instance 
+                                        WHERE blockid = '.$blockid.' AND
+                                        pagetype = "course-view"');
         if ($count>0) {
             $blocklist = "<a href=\"{$CFG->wwwroot}/course/search.php?blocklist=$blockid&amp;sesskey={$USER->sesskey}\" ";
             $blocklist .= "title=\"$strshowblockcourse\" >$count</a>";
index c7ff0d658f3947c949bccf92c40976900ddd9a70..a497cee6985c07e4800b924d6208f820a60e9b93 100644 (file)
         $courses = array();
         foreach ($blocks as $block) {
             $courseid = $block->pageid;
-            if ($courseid==0) {
+            // MDL-11167, blocks can be placed on mymoodle, or the blogs page
+            // and it should not show up on course search page
+            if ($courseid==0 || $block->pagetype != 'course-view') {
                 continue;
             }
             if (!$course = get_record('course', 'id', $courseid)) {