MDL-42607 mod_forum:fixed some inefficiencies in forum RSS generation
This commit is contained in:
+1
-1
@@ -216,7 +216,7 @@ function rss_get_file_name($instance, $sql, $params = array()) {
|
||||
// serialize it and then concatenate it with the sql.
|
||||
// The reason for this is to generate a unique filename
|
||||
// for queries using the same sql but different parameters.
|
||||
asort($parms);
|
||||
asort($params);
|
||||
$serializearray = serialize($params);
|
||||
return $instance->id.'_'.md5($sql . $serializearray);
|
||||
} else {
|
||||
|
||||
+21
-3
@@ -228,13 +228,17 @@ function forum_rss_feed_posts_sql($forum, $cm, $newsince=0) {
|
||||
$sql = "SELECT p.id AS postid,
|
||||
d.id AS discussionid,
|
||||
d.name AS discussionname,
|
||||
d.groupid,
|
||||
d.timestart,
|
||||
d.timeend,
|
||||
u.id AS userid,
|
||||
$usernamefields,
|
||||
p.subject AS postsubject,
|
||||
p.message AS postmessage,
|
||||
p.created AS postcreated,
|
||||
p.messageformat AS postformat,
|
||||
p.messagetrust AS posttrust
|
||||
p.messagetrust AS posttrust,
|
||||
p.parent as postparent
|
||||
FROM {forum_discussions} d,
|
||||
{forum_posts} p,
|
||||
{user} u
|
||||
@@ -315,12 +319,26 @@ function forum_rss_feed_contents($forum, $sql, $params, $context) {
|
||||
foreach ($recs as $rec) {
|
||||
$item = new stdClass();
|
||||
|
||||
if ($isdiscussion && !forum_user_can_see_discussion($forum, $rec->discussionid, $context)) {
|
||||
$discussion = new stdClass();
|
||||
$discussion->id = $rec->discussionid;
|
||||
$discussion->groupid = $rec->groupid;
|
||||
$discussion->timestart = $rec->timestart;
|
||||
$discussion->timeend = $rec->timeend;
|
||||
|
||||
$post = null;
|
||||
if (!$isdiscussion) {
|
||||
$post = new stdClass();
|
||||
$post->id = $rec->postid;
|
||||
$post->parent = $rec->postparent;
|
||||
$post->userid = $rec->userid;
|
||||
}
|
||||
|
||||
if ($isdiscussion && !forum_user_can_see_discussion($forum, $discussion, $context)) {
|
||||
// This is a discussion which the user has no permission to view
|
||||
$item->title = get_string('forumsubjecthidden', 'forum');
|
||||
$message = get_string('forumbodyhidden', 'forum');
|
||||
$item->author = get_string('forumauthorhidden', 'forum');
|
||||
} else if (!$isdiscussion && !forum_user_can_see_post($forum, $rec->discussionid, $rec->postid, $USER, $cm)) {
|
||||
} else if (!$isdiscussion && !forum_user_can_see_post($forum, $discussion, $post, $USER, $cm)) {
|
||||
// This is a post which the user has no permission to view
|
||||
$item->title = get_string('forumsubjecthidden', 'forum');
|
||||
$message = get_string('forumbodyhidden', 'forum');
|
||||
|
||||
Reference in New Issue
Block a user