Modules and Blocks lists now link to course search page for
actual instances.
This commit is contained in:
thepurpleblob 2007-02-21 11:42:48 +00:00
parent 2ab4e4b87b
commit 616ad119ad
4 changed files with 90 additions and 14 deletions

View 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);
@ -184,6 +184,13 @@
}
$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) {
@ -208,7 +215,7 @@
$table->add_data(array(
'<span'.$class.'>'.$blockobject->get_title().'</span>',
$count,
$blocklist,
$blockobject->get_version(),
$visible,
$multiple,

View 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);
@ -170,6 +171,13 @@
}
$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\">".
@ -185,7 +193,7 @@
$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);

View 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");
@ -112,8 +115,50 @@
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");
@ -166,9 +211,23 @@
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>";

View 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';