$searchterm) { if (strlen($searchterm) < 2) { unset($searchterms[$key]); } } $search = trim(implode(" ", $searchterms)); } $site = get_site(); if ($CFG->forcelogin) { require_login(); } if (iscreator()) { 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; } $creatorediting = !empty($USER->categoryediting); $adminediting = (isadmin() and $creatorediting); } else { $adminediting = false; $creatorediting = false; } /// Editing functions if ($adminediting) { /// Hide or show a course if ($hide or $show and confirm_sesskey()) { if ($hide) { $course = get_record("course", "id", $hide); $visible = 0; } else { $course = get_record("course", "id", $show); $visible = 1; } if ($course) { if (! set_field("course", "visible", $visible, "id", $course->id)) { notify("Could not update that course!"); } } } } if ($adminediting && $perpage != 99999) { $perpage = 30; } $displaylist = array(); $parentlist = array(); make_categories_list($displaylist, $parentlist, ""); $strcourses = get_string("courses"); $strsearch = get_string("search"); $strsearchresults = get_string("searchresults"); $strcategory = get_string("category"); $strselect = get_string("select"); $strselectall = get_string("selectall"); $strdeselectall = get_string("deselectall"); $stredit = get_string("edit"); if (!$search) { print_header("$site->fullname : $strsearch", $site->fullname, "$strcourses -> $strsearch", "", ""); print_simple_box_start("center"); echo "
"; echo "
"; print_course_search("", false, "plain"); echo "

"; print_string("searchhelp"); echo "

"; echo "
"; print_simple_box_end(); print_footer(); exit; } if (!empty($moveto) and $data = data_submitted() and confirm_sesskey()) { // Some courses are being moved if (! $destcategory = get_record("course_categories", "id", $data->moveto)) { error("Error finding the category"); } $courses = array(); foreach ( $data as $key => $value ) { if (preg_match('/^c\d+$/', $key)) { array_push($courses, substr($key, 1)); } } move_courses($courses, $data->moveto); } $courses = get_courses_search($searchterms, "fullname ASC", $page*$perpage, $perpage, $totalcount); $searchform = print_course_search($search, true, "navbar"); if (!empty($courses) && iscreator()) { $searchform .= update_categories_search_button($search,$page,$perpage); } print_header("$site->fullname : $strsearchresults", $site->fullname, "$strcourses -> $strsearch -> '".s($search, true)."'", "", "", "", $searchform); $lastcategory = -1; if ($courses) { print_heading("$strsearchresults: $totalcount"); $encodedsearch = urlencode(stripslashes($search)); print_paging_bar($totalcount, $page, $perpage, "search.php?search=$encodedsearch&perpage=$perpage&",'page',($perpage == 99999)); if ($perpage != 99999 && $totalcount > $perpage) { echo "

"; echo "".get_string("showall", "", $totalcount).""; echo "

"; } if (!$adminediting) { foreach ($courses as $course) { $course->fullname = highlight("$search", $course->fullname); $course->summary = highlight("$search", $course->summary); $course->summary .= "

"; $course->summary .= "$strcategory: category\">"; $course->summary .= $displaylist[$course->category]; $course->summary .= "

"; print_course($course); print_spacer(5,5); } } else { // slightly more sophisticated echo "
"; echo "sesskey\">"; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; foreach ($courses as $course) { $course->fullname = highlight("$search", $course->fullname); $linkcss = $course->visible ? "" : " class=\"dimmed\" "; echo ""; echo ""; echo ""; echo ""; echo ""; } echo ""; echo "
$strcourses$strcategory$strselect$stredit
id\">$course->fullname".$displaylist[$course->category].""; echo "id\">"; echo ""; if (empty($THEME->custompix)) { $pixpath = "$CFG->wwwroot/pix"; } else { $pixpath = "$CFG->wwwroot/theme/$CFG->theme/pix"; } echo "wwwroot/course/edit.php?id=$course->id\"> "; echo "wwwroot/course/teacher.php?id=$course->id\"> "; echo "id\"> "; if (!empty($course->visible)) { echo "id&sesskey=$USER->sesskey\"> "; } else { echo "id&sesskey=$USER->sesskey\"> "; } echo "id\"> "; echo "id&wdir=/backupdata\"> "; echo "
"; echo "
"; echo "\n"; echo "\n"; choose_from_menu ($displaylist, "moveto", "", get_string("moveselectedcoursesto"), "javascript:document.movecourses.submit()"); echo "
"; } print_paging_bar($totalcount, $page, $perpage, "search.php?search=$encodedsearch&perpage=$perpage&",'page',($perpage == 99999)); if ($perpage != 99999 && $totalcount > $perpage) { echo "

"; echo "".get_string("showall", "", $totalcount).""; echo "

"; } } else { print_heading(get_string("nocoursesfound", "", s($search, true))); } echo "

"; print_course_search($search); print_footer(); ?>