mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 05:58:34 +01:00
search MDL-19822 Upgraded deprecated calls and added set_url calls
This commit is contained in:
parent
beebcf2606
commit
c86bdd5d3f
@ -77,7 +77,7 @@ function chat_make_link($cm_id, $start, $end) {
|
||||
/**
|
||||
* fetches all the records for a given session and assemble them as a unique track
|
||||
* we revamped here the code of report.php for making sessions, but without any output.
|
||||
* note that we should collect sessions "by groups" if groupmode() is SEPARATEGROUPS.
|
||||
* note that we should collect sessions "by groups" if $groupmode is SEPARATEGROUPS.
|
||||
* @param int $chat_id the database
|
||||
* @param int $fromtime
|
||||
* @param int $totime
|
||||
@ -91,7 +91,11 @@ function chat_get_session_tracks($chat_id, $fromtime = 0, $totime = 0) {
|
||||
$course = $DB->get_record('course', array('id' => $chat->course));
|
||||
$coursemodule = $DB->get_field('modules', 'id', array('name' => 'data'));
|
||||
$cm = $DB->get_record('course_modules', array('course' => $course->id, 'module' => $coursemodule, 'instance' => $chat->id));
|
||||
$groupmode = groupmode($course, $cm);
|
||||
if (isset($cm->groupmode) && empty($course->groupmodeforce)) {
|
||||
$groupmode = $cm->groupmode;
|
||||
} else {
|
||||
$groupmode = $course->groupmode;
|
||||
}
|
||||
|
||||
$fromtimeclause = ($fromtime) ? "AND timestamp >= {$fromtime}" : '';
|
||||
$totimeclause = ($totime) ? "AND timestamp <= {$totime}" : '';
|
||||
@ -283,7 +287,12 @@ function chat_check_text_access($path, $itemtype, $this_id, $user, $group_id, $c
|
||||
//group consistency check : checks the following situations about groups
|
||||
// trap if user is not same group and groups are separated
|
||||
$course = $DB->get_record('course', array('id' => $chat->course));
|
||||
if ((groupmode($course, $cm) == SEPARATEGROUPS) && !ismember($group_id) && !has_capability('moodle/site:accessallgroups', $context)){
|
||||
if (isset($cm->groupmode) && empty($course->groupmodeforce)) {
|
||||
$groupmode = $cm->groupmode;
|
||||
} else {
|
||||
$groupmode = $course->groupmode;
|
||||
}
|
||||
if (($groupmode == SEPARATEGROUPS) && !ismember($group_id) && !has_capability('moodle/site:accessallgroups', $context)){
|
||||
if (!empty($CFG->search_access_debug)) echo "search reject : chat element is in separated group ";
|
||||
return false;
|
||||
}
|
||||
|
@ -371,7 +371,12 @@ function data_check_text_access($path, $itemtype, $this_id, $user, $group_id, $c
|
||||
//group consistency check : checks the following situations about groups
|
||||
// trap if user is not same group and groups are separated
|
||||
$course = $DB->get_record('course', 'id', $data->course);
|
||||
if ((groupmode($course, $cm) == SEPARATEGROUPS) && !ismember($group_id) && !has_capability('moodle/site:accessallgroups', $context)){
|
||||
if (isset($cm->groupmode) && empty($course->groupmodeforce)) {
|
||||
$groupmode = $cm->groupmode;
|
||||
} else {
|
||||
$groupmode = $course->groupmode;
|
||||
}
|
||||
if (($groupmode == SEPARATEGROUPS) && !ismember($group_id) && !has_capability('moodle/site:accessallgroups', $context)){
|
||||
if (!empty($CFG->search_access_debug)) echo "search reject : separated group owned resource ";
|
||||
return false;
|
||||
}
|
||||
|
@ -177,15 +177,25 @@ function forum_db_names() {
|
||||
* @param int $forum_id a forum identifier
|
||||
* @uses $CFG, $USER, $DB
|
||||
* @return an array of posts
|
||||
* @todo get rid of old isteacher() call
|
||||
*/
|
||||
function forum_get_discussions_fast($forum_id) {
|
||||
global $CFG, $USER, $DB;
|
||||
|
||||
$timelimit='';
|
||||
if (!empty($CFG->forum_enabletimedposts)) {
|
||||
if (!((has_capability('moodle/site:doanything', get_context_instance(CONTEXT_SYSTEM))
|
||||
&& !empty($CFG->admineditalways)) || isteacher(get_field('forum', 'course', 'id', $forum_id)))) {
|
||||
|
||||
$courseid = $DB->get_field('forum', 'course', array('id'=>$forum_id));
|
||||
|
||||
if ($courseid) {
|
||||
$coursecontext = get_context_instance(CONTEXT_COURSE, $courseid);
|
||||
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
} else {
|
||||
$coursecontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
$systemcontext = $coursecontext;
|
||||
}
|
||||
|
||||
if (!((has_capability('moodle/site:doanything', $systemcontext) && !empty($CFG->admineditalways))
|
||||
|| has_any_capability(array('moodle/legacy:teacher', 'moodle/legacy:editingteacher', 'moodle/legacy:admin'), $coursecontext, $userid, false))) {
|
||||
$now = time();
|
||||
$timelimit = " AND ((d.timestart = 0 OR d.timestart <= '$now') AND (d.timeend = 0 OR d.timeend > '$now')";
|
||||
if (!empty($USER->id)) {
|
||||
@ -283,7 +293,7 @@ function forum_get_child_posts_fast($parent, $forum_id) {
|
||||
* @return true if access is allowed, false elsewhere
|
||||
*/
|
||||
function forum_check_text_access($path, $itemtype, $this_id, $user, $group_id, $context_id){
|
||||
global $CFG, $USER, $DB;
|
||||
global $CFG, $USER, $DB, $SESSION;
|
||||
|
||||
include_once("{$CFG->dirroot}/{$path}/lib.php");
|
||||
|
||||
@ -307,9 +317,25 @@ function forum_check_text_access($path, $itemtype, $this_id, $user, $group_id, $
|
||||
}
|
||||
|
||||
// group check : entries should be in accessible groups
|
||||
$current_group = get_current_group($discussion->course);
|
||||
if (isset($SESSION->currentgroup[$discussion->course])) {
|
||||
$current_group = $SESSION->currentgroup[$discussion->course];
|
||||
} else {
|
||||
$current_group = groups_get_all_groups($discussion->course, $USER->id);
|
||||
if (is_array($current_group)) {
|
||||
$current_group = array_shift(array_keys($current_group));
|
||||
$SESSION->currentgroup[$discussion->course] = $current_group;
|
||||
} else {
|
||||
$current_group = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$course = $DB->get_record('course', array('id' => $discussion->course));
|
||||
if ($group_id >= 0 && (groupmode($course, $cm) == SEPARATEGROUPS) && ($group_id != $current_group) && !has_capability('mod/forum:viewdiscussionsfromallgroups', $context)){
|
||||
if (isset($cm->groupmode) && empty($course->groupmodeforce)) {
|
||||
$groupmode = $cm->groupmode;
|
||||
} else {
|
||||
$groupmode = $course->groupmode;
|
||||
}
|
||||
if ($group_id >= 0 && ($groupmode == SEPARATEGROUPS) && ($group_id != $current_group) && !has_capability('mod/forum:viewdiscussionsfromallgroups', $context)){
|
||||
if (!empty($CFG->search_access_debug)) echo "search reject : separated grouped forum item";
|
||||
return false;
|
||||
}
|
||||
|
@ -203,7 +203,8 @@ function lesson_check_text_access($path, $itemtype, $this_id, $user, $group_id,
|
||||
}
|
||||
|
||||
// the user have it seen yet ? did he tried one time at least
|
||||
$attempt = get_record('lesson_attempts', 'lessonid', $lesson->id, 'pageid', $page->id, 'userid', $USER->id);
|
||||
$attempt = $DB->get_record('lesson_attempts', array('lessonid'=>$lesson->id,'pageid'=>$page->id, 'userid'=>$USER->id));
|
||||
|
||||
if (!$attempt && !$lessonsuperuser){
|
||||
if (!empty($CFG->search_access_debug)) echo "search reject : never tried this lesson ";
|
||||
return false;
|
||||
|
@ -257,7 +257,7 @@ function wiki_db_names() {
|
||||
* @return true if access is allowed, false elsewhere
|
||||
*/
|
||||
function wiki_check_text_access($path, $itemtype, $this_id, $user, $group_id, $context_id){
|
||||
global $CFG, $DB;
|
||||
global $CFG, $DB, $SESSION;
|
||||
|
||||
// get the wiki object and all related stuff
|
||||
$page = $DB->get_record('wiki_pages', array('id' => $this_id));
|
||||
@ -275,8 +275,24 @@ function wiki_check_text_access($path, $itemtype, $this_id, $user, $group_id, $c
|
||||
|
||||
//group consistency check : checks the following situations about groups
|
||||
// trap if user is not same group and groups are separated
|
||||
$current_group = get_current_group($course->id);
|
||||
if ((groupmode($course) == SEPARATEGROUPS) && $group_id != $current_group && !has_capability('moodle/site:accessallgroups', $context)) {
|
||||
if (isset($SESSION->currentgroup[$course->id])) {
|
||||
$current_group = $SESSION->currentgroup[$course->id];
|
||||
} else {
|
||||
$current_group = groups_get_all_groups($course->id, $USER->id);
|
||||
if (is_array($current_group)) {
|
||||
$current_group = array_shift(array_keys($current_group));
|
||||
$SESSION->currentgroup[$course->id] = $current_group;
|
||||
} else {
|
||||
$current_group = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($cm->groupmode) && empty($course->groupmodeforce)) {
|
||||
$groupmode = $cm->groupmode;
|
||||
} else {
|
||||
$groupmode = $course->groupmode;
|
||||
}
|
||||
if (($groupmode == SEPARATEGROUPS) && $group_id != $current_group && !has_capability('moodle/site:accessallgroups', $context)) {
|
||||
if (!empty($CFG->search_access_debug)) echo "search reject : separated group owner wiki ";
|
||||
return false;
|
||||
}
|
||||
|
@ -47,6 +47,7 @@
|
||||
// print page header
|
||||
$site = get_site();
|
||||
|
||||
$PAGE->set_url(new moodle_url($CFG->wwwroot.'/search/indexersplash.php'));
|
||||
$PAGE->navbar->add($strsearch, new moodle_url($CFG->wwwroot.'/search/index.php'));
|
||||
$PAGE->navbar->add($strquery, new moodle_url($CFG->wwwroot.'/search/stats.php'));
|
||||
$PAGE->navbar->add(get_string('runindexer','search'));
|
||||
|
@ -56,6 +56,15 @@
|
||||
$advanced = (optional_param('a', '0', PARAM_INT) == '1') ? true : false;
|
||||
$query_string = stripslashes(optional_param('query_string', '', PARAM_CLEAN));
|
||||
|
||||
$url = new moodle_url($CFG->wwwroot.'/search/query.php');
|
||||
if ($page_number !== -1) {
|
||||
$url->param('page', $page_number);
|
||||
}
|
||||
if ($advanced) {
|
||||
$url->param('a', '1');
|
||||
}
|
||||
$PAGE->set_url($url);
|
||||
|
||||
/// discard harmfull searches
|
||||
|
||||
if (!isset($CFG->block_search_utf8dir)){
|
||||
|
@ -402,7 +402,7 @@ class SearchQuery {
|
||||
$unenroled = !in_array($course_id, array_keys($myCourses));
|
||||
|
||||
// if guests are allowed, logged guest can see
|
||||
$isallowedguest = (isguest()) ? $DB->get_field('course', 'guest', array('id' => $course_id)) : false ;
|
||||
$isallowedguest = (isguestuser()) ? $DB->get_field('course', 'guest', array('id' => $course_id)) : false ;
|
||||
|
||||
if ($unenroled && !$isallowedguest){
|
||||
return false;
|
||||
|
@ -46,6 +46,7 @@ require_once($CFG->dirroot.'/search/lib.php');
|
||||
|
||||
$site = get_site();
|
||||
|
||||
$PAGE->set_url($CFG->wwwroot.'/search/stats.php');
|
||||
$PAGE->navbar->add($strsearch, new moodle_url($CFG->wwwroot.'/search/index.php'));
|
||||
$PAGE->navbar->add($strquery, new moodle_url($CFG->wwwroot.'/search/stats.php'));
|
||||
$PAGE->set_title($strsearch);
|
||||
@ -125,7 +126,6 @@ require_once($CFG->dirroot.'/search/lib.php');
|
||||
|
||||
echo $OUTPUT->table($admin_table);
|
||||
echo $OUTPUT->spacer($spacer) . '<br />';
|
||||
print_spacer(20);
|
||||
}
|
||||
|
||||
/// this is the standard summary table for normal users, shows document counts
|
||||
|
Loading…
x
Reference in New Issue
Block a user