MDL-28615 forum: Fixed up a couple of minor regressions
This commit is contained in:
+10
-5
@@ -7982,8 +7982,8 @@ function forum_page_type_list($pagetype, $parentcontext, $currentcontext) {
|
|||||||
* @param stdClass $user The user who's posts we are looking for
|
* @param stdClass $user The user who's posts we are looking for
|
||||||
* @param bool $discussionsonly If true only look for discussions started by the user
|
* @param bool $discussionsonly If true only look for discussions started by the user
|
||||||
* @param bool $includecontexts If set to trye contexts for the courses will be preloaded
|
* @param bool $includecontexts If set to trye contexts for the courses will be preloaded
|
||||||
* @param type $limitfrom The offset of records to return
|
* @param int $limitfrom The offset of records to return
|
||||||
* @param type $limitnum The number of records to return
|
* @param int $limitnum The number of records to return
|
||||||
* @return array An array of courses
|
* @return array An array of courses
|
||||||
*/
|
*/
|
||||||
function forum_get_courses_user_posted_in($user, $discussionsonly = false, $includecontexts = true, $limitfrom = null, $limitnum = null) {
|
function forum_get_courses_user_posted_in($user, $discussionsonly = false, $includecontexts = true, $limitfrom = null, $limitnum = null) {
|
||||||
@@ -8034,8 +8034,8 @@ function forum_get_courses_user_posted_in($user, $discussionsonly = false, $incl
|
|||||||
* all courses the user has posted within
|
* all courses the user has posted within
|
||||||
* @param bool $discussionsonly If true then only forums where the user has started
|
* @param bool $discussionsonly If true then only forums where the user has started
|
||||||
* a discussion will be returned.
|
* a discussion will be returned.
|
||||||
* @param type $limitfrom The offset of records to return
|
* @param int $limitfrom The offset of records to return
|
||||||
* @param type $limitnum The number of records to return
|
* @param int $limitnum The number of records to return
|
||||||
* @return array An array of forums the user has posted within in the provided courses
|
* @return array An array of forums the user has posted within in the provided courses
|
||||||
*/
|
*/
|
||||||
function forum_get_forums_user_posted_in($user, array $courseids = null, $discussionsonly = false, $limitfrom = null, $limitnum = null) {
|
function forum_get_forums_user_posted_in($user, array $courseids = null, $discussionsonly = false, $limitfrom = null, $limitnum = null) {
|
||||||
@@ -8085,6 +8085,8 @@ function forum_get_forums_user_posted_in($user, array $courseids = null, $discus
|
|||||||
* cannot access one or more of the courses to search
|
* cannot access one or more of the courses to search
|
||||||
* @param bool $discussionsonly If set to true only discussion starting posts
|
* @param bool $discussionsonly If set to true only discussion starting posts
|
||||||
* will be returned.
|
* will be returned.
|
||||||
|
* @param int $limitfrom The offset of records to return
|
||||||
|
* @param int $limitnum The number of records to return
|
||||||
* @return stdClass An object the following properties
|
* @return stdClass An object the following properties
|
||||||
* ->totalcount: the total number of posts made by the requested user
|
* ->totalcount: the total number of posts made by the requested user
|
||||||
* that the current user can see.
|
* that the current user can see.
|
||||||
@@ -8181,7 +8183,8 @@ function forum_get_posts_by_user($user, array $courses, $musthaveaccess = false,
|
|||||||
// Get the groups the requested user is a member of
|
// Get the groups the requested user is a member of
|
||||||
$usergroups = array_keys(groups_get_all_groups($course->id, $user->id, $course->defaultgroupingid, 'g.id, g.name'));
|
$usergroups = array_keys(groups_get_all_groups($course->id, $user->id, $course->defaultgroupingid, 'g.id, g.name'));
|
||||||
// Check whether they are members of the same group. If they are great.
|
// Check whether they are members of the same group. If they are great.
|
||||||
if (!array_intersect($mygroups, $usergroups)) {
|
$intersect = array_intersect($mygroups, $usergroups);
|
||||||
|
if (empty($intersect)) {
|
||||||
// But they're not... if it was a specific course throw an error otherwise
|
// But they're not... if it was a specific course throw an error otherwise
|
||||||
// just skip this course so that it is not searched.
|
// just skip this course so that it is not searched.
|
||||||
if ($musthaveaccess) {
|
if ($musthaveaccess) {
|
||||||
@@ -8222,6 +8225,8 @@ function forum_get_posts_by_user($user, array $courses, $musthaveaccess = false,
|
|||||||
$forumsearchparams = array();
|
$forumsearchparams = array();
|
||||||
// Will record forums where the user can freely access everything
|
// Will record forums where the user can freely access everything
|
||||||
$forumsearchfullaccess = array();
|
$forumsearchfullaccess = array();
|
||||||
|
// DB caching friendly
|
||||||
|
$now = round(time(), -2);
|
||||||
// For each course to search we want to find the forums the user has posted in
|
// For each course to search we want to find the forums the user has posted in
|
||||||
// and providing the current user can access the forum create a search condition
|
// and providing the current user can access the forum create a search condition
|
||||||
// for the forum to get the requested users posts.
|
// for the forum to get the requested users posts.
|
||||||
|
|||||||
+15
-5
@@ -45,14 +45,22 @@ $isspecificcourse = !is_null($courseid);
|
|||||||
$iscurrentuser = ($USER->id == $userid);
|
$iscurrentuser = ($USER->id == $userid);
|
||||||
|
|
||||||
$url = new moodle_url('/mod/forum/user.php', array('id' => $userid));
|
$url = new moodle_url('/mod/forum/user.php', array('id' => $userid));
|
||||||
if ($isspecificcourse) $url->param('course', $courseid);
|
if ($isspecificcourse) {
|
||||||
if ($discussionsonly) $url->param('mode', 'discussions');
|
$url->param('course', $courseid);
|
||||||
|
}
|
||||||
|
if ($discussionsonly) {
|
||||||
|
$url->param('mode', 'discussions');
|
||||||
|
}
|
||||||
|
|
||||||
$PAGE->set_url($url);
|
$PAGE->set_url($url);
|
||||||
$PAGE->set_pagelayout('standard');
|
$PAGE->set_pagelayout('standard');
|
||||||
|
|
||||||
if ($page != 0) $url->param('page', $page);
|
if ($page != 0) {
|
||||||
if ($perpage != 5) $url->param('perpage', $perpage);
|
$url->param('page', $page);
|
||||||
|
}
|
||||||
|
if ($perpage != 5) {
|
||||||
|
$url->param('perpage', $perpage);
|
||||||
|
}
|
||||||
|
|
||||||
add_to_log(($isspecificcourse)?$courseid:SITEID, "forum", "user report", 'user.php?'.$url->get_query_string(), $userid);
|
add_to_log(($isspecificcourse)?$courseid:SITEID, "forum", "user report", 'user.php?'.$url->get_query_string(), $userid);
|
||||||
|
|
||||||
@@ -191,7 +199,9 @@ if (empty($result->posts)) {
|
|||||||
echo $OUTPUT->header();
|
echo $OUTPUT->header();
|
||||||
echo $OUTPUT->heading($pagetitle);
|
echo $OUTPUT->heading($pagetitle);
|
||||||
echo $OUTPUT->notification($notification);
|
echo $OUTPUT->notification($notification);
|
||||||
echo $OUTPUT->continue_button($url);
|
if (!$url->compare($PAGE->url)) {
|
||||||
|
echo $OUTPUT->continue_button($url);
|
||||||
|
}
|
||||||
echo $OUTPUT->footer();
|
echo $OUTPUT->footer();
|
||||||
die;
|
die;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user