}
}
-
-function print_course($course) {
+/**
+ * Print a description of a course, suitable for browsing in a list.
+ *
+ * @param object $course the course object.
+ * @param string $highlightterms (optional) some search terms that should be highlighted in the display.
+ */
+function print_course($course, $highlightterms = '') {
global $CFG, $USER, $DB;
if (isset($course->context)) {
echo '<div class="info">';
echo '<div class="name"><a title="'.get_string('entercourse').'"'.
$linkcss.' href="'.$CFG->wwwroot.'/course/view.php?id='.$course->id.'">'.
- format_string($course->fullname).'</a></div>';
+ highlight($highlightterms, format_string($course->fullname)).'</a></div>';
/// first find all roles that are supposed to be displayed
$options = NULL;
$options->noclean = true;
$options->para = false;
- echo format_text($course->summary, FORMAT_MOODLE, $options, $course->id);
+ echo highlight($highlightterms, format_text($course->summary, FORMAT_MOODLE, $options, $course->id));
echo '</div>';
echo '</div>';
}
continue;
}
echo '<li>';
- print_course($course, "100%");
+ print_course($course);
echo "</li>\n";
}
echo "</ul>\n";
require_login();
}
- if (has_capability('moodle/course:create', get_context_instance(CONTEXT_SYSTEM))) {
+ if (update_category_button()) {
if ($edit !== -1) {
$USER->categoryediting = $edit;
- // If the edit mode we are leaving has higher per page than the one we are entering,
- // with pages, chances are you will get a no courses found error. So when we are switching
- // modes, set page to 0.
- $page = 0;
}
+ $adminediting = !empty($USER->categoryediting);
+ } else {
+ $adminediting = false;
}
/// Editing functions
-
if (has_capability('moodle/course:visibility', get_context_instance(CONTEXT_SYSTEM))) {
-
/// Hide or show a course
-
if ($hide or $show and confirm_sesskey()) {
if ($hide) {
$course = $DB->get_record("course", array("id"=>$hide));
}
}
}
-
}
if (has_capability('moodle/course:create', get_context_instance(CONTEXT_SYSTEM)) && $perpage != 99999) {
}
if (!empty($moveto) and $data = data_submitted() and confirm_sesskey()) { // Some courses are being moved
-
if (! $destcategory = $DB->get_record("course_categories", array("id"=>$data->moveto))) {
print_error('cannotfindcategory', '', '', $data->moveto);
}
}
}
else {
- $courses = get_courses_search($searchterms, "fullname ASC",
+ $courses = get_courses_search($searchterms, "fullname ASC",
$page, $perpage, $totalcount);
}
print_header("$site->fullname : $strsearchresults", $site->fullname, $navigation, "", "", "", $searchform);
-
$lastcategory = -1;
if ($courses) {
-
print_heading("$strsearchresults: $totalcount");
-
$encodedsearch = urlencode($search);
-
+
///add the module parameter to the paging bar if they exists
$modulelink = "";
if (!empty($modulelist) and confirm_sesskey()) {
$modulelink = "&modulelist=".$modulelist."&sesskey=".$USER->sesskey;
}
-
- print_navigation_bar($totalcount,$page,$perpage,$encodedsearch,$modulelink);
- if (!has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM))) {
+ print_navigation_bar($totalcount, $page, $perpage, $encodedsearch, $modulelink);
+
+ if (!$adminediting) {
foreach ($courses as $course) {
- $course->fullname = highlight(trim($search, '+'), $course->fullname);
- $course->summary = highlight(trim($search, '+'), $course->summary);
$course->summary .= "<br /><p class=\"category\">";
$course->summary .= "$strcategory: <a href=\"category.php?id=$course->category\">";
$course->summary .= $displaylist[$course->category];
$course->summary .= "</a></p>";
- print_course($course);
+ print_course($course, $search);
print_spacer(5,5);
}
- } else { // slightly more sophisticated
-
+ } else {
+ /// Show editing UI.
echo "<form id=\"movecourses\" action=\"search.php\" method=\"post\">\n";
echo "<div><input type=\"hidden\" name=\"sesskey\" value=\"$USER->sesskey\" />\n";
echo "<input type=\"hidden\" name=\"search\" value=\"".s($search)."\" />\n";
echo "<th scope=\"col\">$strselect</th>\n";
echo "<th scope=\"col\">$stredit</th></tr>\n";
- foreach ($courses as $course) {
-
+ foreach ($courses as $course) {
+
if (isset($course->context)) {
$coursecontext = $course->context;
} else {
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
}
- $course->fullname = highlight(trim($search, '+'), $course->fullname);
$linkcss = $course->visible ? "" : " class=\"dimmed\" ";
// are we displaying the front page (courseid=1)?
echo "<tr>\n";
echo "<td><a $linkcss href=\"view.php?id=$course->id\">"
- . format_string($course->fullname) . "</a></td>\n";
+ . highlight($search, format_string($course->fullname)) . "</a></td>\n";
echo "<td>".$displaylist[$course->category]."</td>\n";
echo "<td>\n";