Skip to content
Permalink
Browse files

MDL-42607 mod_forum:fixed some inefficiencies in forum RSS generation

  • Loading branch information...
andyjdavis committed Dec 31, 2013
1 parent e71a533 commit a90069245d7e64b62fe2a3259160a19741fc0fa4
Showing with 22 additions and 4 deletions.
  1. +1 −1 lib/rsslib.php
  2. +21 −3 mod/forum/rsslib.php
@@ -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 {
@@ -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');

0 comments on commit a900692

Please sign in to comment.
You can’t perform that action at this time.