MDL-8087
authorthepurpleblob <thepurpleblob>
Wed, 21 Feb 2007 11:42:48 +0000 (11:42 +0000)
committerthepurpleblob <thepurpleblob>
Wed, 21 Feb 2007 11:42:48 +0000 (11:42 +0000)
Modules and Blocks lists now link to course search page for
actual instances.

admin/blocks.php
admin/modules.php
course/search.php
lang/en_utf8/moodle.php

index ccc7ccb45fdeb883909096f9b156f6349ff3f4ef..2a839526749da9195491605bbe50cc73d1a47dab 100644 (file)
@@ -17,7 +17,6 @@
     $delete   = optional_param('delete', 0, PARAM_INT);
     $multiple = optional_param('multiple', 0, PARAM_INT);
 
-
 /// Print headings
 
     $strmanageblocks = get_string('manageblocks');
@@ -29,6 +28,7 @@
     $strcourses = get_string('blockinstances', 'admin');
     $strname = get_string('name');
     $strmultiple = get_string('blockmultiple', 'admin');
+    $strshowblockcourse = get_string('showblockcourse');
 
     admin_externalpage_print_header($adminroot);
 
         }
 
         $count = count_records('block_instance', 'blockid', $blockid);
+        if ($count>0) {
+            $blocklist = "<a href=\"{$CFG->wwwroot}/course/search.php?blocklist=$blockid&amp;sesskey={$USER->sesskey}\" ";
+            $blocklist .= "title=\"$strshowblockcourse\" >$count</a>";
+        }
+        else {
+            $blocklist = "$count";
+        }
         $class = ''; // Nothing fancy, by default
 
         if ($blocks[$blockid]->visible) {
 
         $table->add_data(array(
             '<span'.$class.'>'.$blockobject->get_title().'</span>',
-            $count,
+            $blocklist,
             $blockobject->get_version(),
             $visible,
             $multiple,
index a86eedc50d6693047412c7365b7a63f67045fd58..f95327a1919c0afe0c898b4a096966d6253f182f 100644 (file)
@@ -23,6 +23,7 @@
     $strsettings = get_string("settings");
     $stractivities = get_string("activities");
     $stractivitymodule = get_string("activitymodule");
+    $strshowmodulecourse = get_string('showmodulecourse');
 
     admin_externalpage_print_header($adminroot);
 
         }
 
         $count = count_records("$module->name");
+        if ($count>0) {
+            $countlink = "<a href=\"{$CFG->wwwroot}/course/search.php?modulelist=$module->name" .
+                "&amp;sesskey={$USER->sesskey}\" title=\"$strshowmodulecourse\">$count</a>";
+        }
+        else {
+            $countlink = "$count";
+        }
 
         if ($module->visible) {
             $visible = "<a href=\"modules.php?hide=$module->name&amp;sesskey=$USER->sesskey\" title=\"$strhide\">".
             $visible = "";
             $class = "";
         }
-        $table->data[] = array ("<span $class>$icon $modulename</span>", $count, $module->version, $visible, $delete, $settings);
+        $table->data[] = array ("<span $class>$icon $modulename</span>", $countlink, $module->version, $visible, $delete, $settings);
     }
     print_table($table);
 
index 747033c03a5ad05cd726431318f0de42229fed2a..4283d76f4ce9202364c8d7ae923ac7d541940141 100644 (file)
@@ -5,13 +5,15 @@
     require_once("../config.php");
     require_once("lib.php");
 
-    $search  = optional_param('search', '', PARAM_RAW);  // search words
-    $page    = optional_param('page', 0, PARAM_INT);     // which page to show
-    $perpage = optional_param('perpage', 10, PARAM_INT); // how many per page
-    $moveto  = optional_param('moveto', 0, PARAM_INT);   // move to category
-    $edit    = optional_param('edit', -1, PARAM_BOOL);
-    $hide    = optional_param('hide', 0, PARAM_INT);
-    $show    = optional_param('show', 0, PARAM_INT);
+    $search    = optional_param('search', '', PARAM_RAW);  // search words
+    $page      = optional_param('page', 0, PARAM_INT);     // which page to show
+    $perpage   = optional_param('perpage', 10, PARAM_INT); // how many per page
+    $moveto    = optional_param('moveto', 0, PARAM_INT);   // move to category
+    $edit      = optional_param('edit', -1, PARAM_BOOL);
+    $hide      = optional_param('hide', 0, PARAM_INT);
+    $show      = optional_param('show', 0, PARAM_INT);
+    $blocklist = optional_param('blocklist', 0, PARAM_INT);
+    $modulelist= optional_param('modulelist', '', PARAM_ALPHAEXT);
 
     $search = trim(strip_tags($search)); // trim & clean raw searched string
 
@@ -80,8 +82,9 @@
     $strselectall = get_string("selectall");
     $strdeselectall = get_string("deselectall");
     $stredit = get_string("edit");
+    $strfrontpage = get_string('frontpage', 'admin');
 
-    if (!$search) {
+    if (empty($search) and empty($blocklist) and empty($modulelist)) {
         print_header("$site->fullname : $strsearch", $site->fullname, 
                      "<a href=\"index.php\">$strcourses</a> -> $strsearch", "", "");
         print_simple_box_start("center");
         move_courses($courses, $data->moveto);
     }
 
-    $courses = get_courses_search($searchterms, "fullname ASC", 
-                                  $page*$perpage, $perpage, $totalcount);
+    // get list of courses containing blocks if required
+    if (!empty($blocklist) and confirm_sesskey()) {
+        $blockid = $blocklist;
+        if (!$blocks = get_records('block_instance', 'blockid', $blockid)) {
+            error( "Could not read data for blockid=$blockid" );
+        }
+
+        // run through blocks and get (unique) courses
+        $courses = array();
+        foreach ($blocks as $block) {
+            $courseid = $block->pageid;
+            if ($courseid==0) {
+                continue;
+            }
+            if (!$course = get_record('course', 'id', $courseid)) {
+                error( "Could not read data for courseid=$courseid" );
+            }
+            $courses[$courseid] = $course;
+        }
+    }
+    // get list of courses containing modules if required
+    elseif (!empty($modulelist) and confirm_sesskey()) {
+        $modulename = $modulelist;
+        if (!$modules = get_records($modulename)) {
+            error( "Could not read data for module=$modulename" );
+        }
+
+        // run through modules and get (unique) courses
+        $courses = array();
+        foreach ($modules as $module) {
+            $courseid = $module->course;
+            if ($courseid==0) {
+                continue;
+            }
+            if (!$course = get_record('course', 'id', $courseid)) {
+                error( "Could not read data for courseid=$courseid" );
+            }
+            $courses[$courseid] = $course;
+        }
+    }
+    else {
+        $courses = get_courses_search($searchterms, "fullname ASC", 
+            $page*$perpage, $perpage, $totalcount);
+    }
 
     $searchform = print_course_search($search, true, "navbar");
 
             foreach ($courses as $course) {                        
                 
                 $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
-                
+
                 $course->fullname = highlight("$search", $course->fullname);
                 $linkcss = $course->visible ? "" : " class=\"dimmed\" ";
+
+                // are we displaying the front page (courseid=1)?
+                if ($course->id == 1) {
+                    echo "<tr>";
+                    echo "<td><a href=\"$CFG->wwwroot\">$strfrontpage</a></td>";
+
+                    // can't do anything else with the front page
+                    echo "  <td>&nbsp;</td>"; // category place
+                    echo "  <td>&nbsp;</td>"; // select place
+                    echo "  <td>&nbsp;</td>"; // edit place
+                    echo "</tr>";
+                    continue;
+                }
+
                 echo "<tr>";
                 echo "<td><a $linkcss href=\"view.php?id=$course->id\">$course->fullname</a></td>";
                 echo "<td>".$displaylist[$course->category]."</td>";
index e1ab129bbdcbbf8f7d838c9abff318d38ad87551..d1ea99b62d2952e504c070281097d20dbe27c05f 100644 (file)
@@ -1227,8 +1227,10 @@ $string['showallcourses'] = 'Show all courses';
 $string['showalltopics'] = 'Show all topics';
 $string['showallusers'] = 'Show all users';
 $string['showallweeks'] = 'Show all weeks';
+$string['showblockcourse'] = 'Show list of courses containing block';
 $string['showgrades'] = 'Show grades';
 $string['showlistofcourses'] = 'Show list of courses';
+$string['showmodulecourse'] = 'Show list of courses containing activity';
 $string['showonly'] = 'Show only';
 $string['showonlytopic'] = 'Show only topic $a';
 $string['showonlyweek'] = 'Show only week $a';