/**
* 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
$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}" : '';
//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;
}
//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;
}
* @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)) {
* @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");
}
// 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;
}
}
// 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;
* @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));
//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;
}
// 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'));
$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)){
$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;
$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);
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