mirror of
https://github.com/moodle/moodle.git
synced 2025-08-06 17:36:38 +02:00
MDL-31640 course search: Coding style clean up
This commit is contained in:
parent
1a381535e6
commit
f520dcd9ba
1 changed files with 404 additions and 382 deletions
|
@ -1,9 +1,29 @@
|
||||||
<?php
|
<?php
|
||||||
|
// This file is part of Moodle - http://moodle.org/
|
||||||
|
//
|
||||||
|
// Moodle is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// Moodle is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
/// Displays external information about a course
|
/**
|
||||||
|
* Displays external information about a course
|
||||||
|
* @package core
|
||||||
|
* @category course
|
||||||
|
* @copyright 1999 onwards Martin Dougiamas http://dougiamas.com
|
||||||
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||||
|
*/
|
||||||
|
|
||||||
require_once("../config.php");
|
require_once("../config.php");
|
||||||
require_once("lib.php");
|
require_once($CFG->dirroot.'/course/lib.php');
|
||||||
|
|
||||||
$search = optional_param('search', '', PARAM_RAW); // search words
|
$search = optional_param('search', '', PARAM_RAW); // search words
|
||||||
$page = optional_param('page', 0, PARAM_INT); // which page to show
|
$page = optional_param('page', 0, PARAM_INT); // which page to show
|
||||||
|
@ -57,7 +77,7 @@
|
||||||
require_login();
|
require_login();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Editing is possible if user have system or category level create and manage capability
|
// Editing is possible if user has system or category level create and manage capability
|
||||||
if (can_edit_in_category() || !empty($usercatlist)) {
|
if (can_edit_in_category() || !empty($usercatlist)) {
|
||||||
if ($edit !== -1) {
|
if ($edit !== -1) {
|
||||||
$USER->editing = $edit;
|
$USER->editing = $edit;
|
||||||
|
@ -72,10 +92,10 @@
|
||||||
$adminediting = false;
|
$adminediting = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Editing functions
|
// Editing functions
|
||||||
if (has_capability('moodle/course:visibility', context_system::instance())) {
|
if (has_capability('moodle/course:visibility', context_system::instance())) {
|
||||||
/// Hide or show a course
|
// Hide or show a course
|
||||||
if ($hide or $show and confirm_sesskey()) {
|
if (($hide || $show) && confirm_sesskey()) {
|
||||||
if ($hide) {
|
if ($hide) {
|
||||||
$course = $DB->get_record("course", array("id" => $hide));
|
$course = $DB->get_record("course", array("id" => $hide));
|
||||||
$visible = 0;
|
$visible = 0;
|
||||||
|
@ -93,16 +113,16 @@
|
||||||
$parentlist = array();
|
$parentlist = array();
|
||||||
make_categories_list($displaylist, $parentlist);
|
make_categories_list($displaylist, $parentlist);
|
||||||
|
|
||||||
$strcourses = get_string("courses");
|
$strcourses = new lang_string("courses");
|
||||||
$strsearch = get_string("search");
|
$strsearch = new lang_string("search");
|
||||||
$strsearchresults = get_string("searchresults");
|
$strsearchresults = new lang_string("searchresults");
|
||||||
$strcategory = get_string("category");
|
$strcategory = new lang_string("category");
|
||||||
$strselect = get_string("select");
|
$strselect = new lang_string("select");
|
||||||
$strselectall = get_string("selectall");
|
$strselectall = new lang_string("selectall");
|
||||||
$strdeselectall = get_string("deselectall");
|
$strdeselectall = new lang_string("deselectall");
|
||||||
$stredit = get_string("edit");
|
$stredit = new lang_string("edit");
|
||||||
$strfrontpage = get_string('frontpage', 'admin');
|
$strfrontpage = new lang_string('frontpage', 'admin');
|
||||||
$strnovalidcourses = get_string('novalidcourses');
|
$strnovalidcourses = new lang_string('novalidcourses');
|
||||||
|
|
||||||
if (empty($search) and empty($blocklist) and empty($modulelist) and empty($moveto) and ($edit != -1)) {
|
if (empty($search) and empty($blocklist) and empty($modulelist) and empty($moveto) and ($edit != -1)) {
|
||||||
$PAGE->navbar->add($strcourses, new moodle_url('/course/index.php'));
|
$PAGE->navbar->add($strcourses, new moodle_url('/course/index.php'));
|
||||||
|
@ -140,6 +160,9 @@
|
||||||
// user must have category:manage and course:create capability for the course to be moved.
|
// user must have category:manage and course:create capability for the course to be moved.
|
||||||
$coursecontext = context_course::instance($courseid);
|
$coursecontext = context_course::instance($courseid);
|
||||||
foreach ($capabilities as $capability) {
|
foreach ($capabilities as $capability) {
|
||||||
|
// Require capability here will result in a fatal error should the user not
|
||||||
|
// have the requried category ensuring that no moves occur if they are
|
||||||
|
// trying to move multiple courses.
|
||||||
require_capability($capability, $coursecontext);
|
require_capability($capability, $coursecontext);
|
||||||
array_push($courses, $courseid);
|
array_push($courses, $courseid);
|
||||||
}
|
}
|
||||||
|
@ -190,19 +213,19 @@
|
||||||
else {
|
else {
|
||||||
$totalcount = 0;
|
$totalcount = 0;
|
||||||
}
|
}
|
||||||
} else if (!empty($searchterm)) { //Donot do search for empty search request.
|
} else if (!empty($searchterm)) {
|
||||||
$courses = get_courses_search($searchterms, "fullname ASC",
|
// Donot do search for empty search request.
|
||||||
$page, $perpage, $totalcount);
|
$courses = get_courses_search($searchterms, "fullname ASC", $page, $perpage, $totalcount);
|
||||||
}
|
}
|
||||||
|
|
||||||
$searchform = '';
|
$searchform = '';
|
||||||
// Turn editing should be visible if user have system or category level capability
|
// Turn editing should be visible if user have system or category level capability
|
||||||
if (!empty($courses) && (can_edit_in_category() || !empty($usercatlist))) {
|
if (!empty($courses) && (can_edit_in_category() || !empty($usercatlist))) {
|
||||||
if ($PAGE->user_is_editing()) {
|
if ($PAGE->user_is_editing()) {
|
||||||
$string = get_string("turneditingoff");
|
$string = new lang_string("turneditingoff");
|
||||||
$edit = "off";
|
$edit = "off";
|
||||||
} else {
|
} else {
|
||||||
$string = get_string("turneditingon");
|
$string = new lang_string("turneditingon");
|
||||||
$edit = "on";
|
$edit = "on";
|
||||||
}
|
}
|
||||||
$params = array_merge($urlparams, array('sesskey' => sesskey(), 'edit' => $edit));
|
$params = array_merge($urlparams, array('sesskey' => sesskey(), 'edit' => $edit));
|
||||||
|
@ -251,7 +274,8 @@
|
||||||
print_course($course, $search);
|
print_course($course, $search);
|
||||||
echo $OUTPUT->spacer(array('height'=>5, 'width'=>5, 'br'=>true)); // should be done with CSS instead
|
echo $OUTPUT->spacer(array('height'=>5, 'width'=>5, 'br'=>true)); // should be done with CSS instead
|
||||||
}
|
}
|
||||||
} else { //editing mode
|
} else {
|
||||||
|
// Editing mode
|
||||||
echo "<form id=\"movecourses\" action=\"search.php\" method=\"post\">\n";
|
echo "<form id=\"movecourses\" action=\"search.php\" method=\"post\">\n";
|
||||||
echo "<div><input type=\"hidden\" name=\"sesskey\" value=\"".sesskey()."\" />\n";
|
echo "<div><input type=\"hidden\" name=\"sesskey\" value=\"".sesskey()."\" />\n";
|
||||||
echo "<input type=\"hidden\" name=\"search\" value=\"".s($search)."\" />\n";
|
echo "<input type=\"hidden\" name=\"search\" value=\"".s($search)."\" />\n";
|
||||||
|
@ -380,11 +404,11 @@
|
||||||
/**
|
/**
|
||||||
* Print a list navigation bar
|
* Print a list navigation bar
|
||||||
* Display page numbers, and a link for displaying all entries
|
* Display page numbers, and a link for displaying all entries
|
||||||
* @param integer $totalcount - number of entry to display
|
* @param int $totalcount number of entry to display
|
||||||
* @param integer $page - page number
|
* @param int $page page number
|
||||||
* @param integer $perpage - number of entry per page
|
* @param int $perpage number of entry per page
|
||||||
* @param string $encodedsearch
|
* @param string $encodedsearch
|
||||||
* @param string $modulelink - module name
|
* @param string $modulelink module name
|
||||||
*/
|
*/
|
||||||
function print_navigation_bar($totalcount, $page, $perpage, $encodedsearch, $modulelink) {
|
function print_navigation_bar($totalcount, $page, $perpage, $encodedsearch, $modulelink) {
|
||||||
global $OUTPUT;
|
global $OUTPUT;
|
||||||
|
@ -408,5 +432,3 @@
|
||||||
echo "</p></center>";
|
echo "</p></center>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue