Some improvements in RSS:

- Article's author is showed if present.
- In forum posts feeds, show post->subject instead of discussion->name
- Description contents in every article are passed to format_text() to
  show contents like the rest of Moodle.
This commit is contained in:
stronk7 2004-05-09 18:34:33 +00:00
parent edc23b1686
commit ca87cbe100
3 changed files with 14 additions and 7 deletions

View file

@ -108,6 +108,7 @@ $string['blocks'] = 'Blocks';
$string['blocksetup'] = 'Setting up block tables'; $string['blocksetup'] = 'Setting up block tables';
$string['blocksuccess'] = '$a tables have been set up correctly'; $string['blocksuccess'] = '$a tables have been set up correctly';
$string['bycourseorder'] = 'By course order'; $string['bycourseorder'] = 'By course order';
$string['byname'] = 'by $a';
$string['cancel'] = 'Cancel'; $string['cancel'] = 'Cancel';
$string['categories'] = 'Course categories'; $string['categories'] = 'Course categories';
$string['category'] = 'Category'; $string['category'] = 'Category';

View file

@ -130,7 +130,8 @@
u.firstname userfirstname, u.firstname userfirstname,
u.lastname userlastname, u.lastname userlastname,
p.message postmessage, p.message postmessage,
p.created postcreated p.created postcreated,
p.format postformat
FROM {$CFG->prefix}forum_discussions d, FROM {$CFG->prefix}forum_discussions d,
{$CFG->prefix}forum_posts p, {$CFG->prefix}forum_posts p,
{$CFG->prefix}user u {$CFG->prefix}user u
@ -152,7 +153,7 @@
$item->author = fullname($user); $item->author = fullname($user);
$item->pubdate = $rec->postcreated; $item->pubdate = $rec->postcreated;
$item->link = $CFG->wwwroot."/mod/forum/discuss.php?d=".$rec->discussionid; $item->link = $CFG->wwwroot."/mod/forum/discuss.php?d=".$rec->discussionid;
$item->description = $rec->postmessage; $item->description = format_text($rec->postmessage,$rec->postformat,NULL,$forum->course);
$items[] = $item; $items[] = $item;
$articlesleft--; $articlesleft--;
if ($articlesleft < 1) { if ($articlesleft < 1) {
@ -173,12 +174,13 @@
if ($recs = get_records_sql ("SELECT p.id postid, if ($recs = get_records_sql ("SELECT p.id postid,
d.id discussionid, d.id discussionid,
d.name discussionname,
u.id userid, u.id userid,
u.firstname userfirstname, u.firstname userfirstname,
u.lastname userlastname, u.lastname userlastname,
p.subject postsubject,
p.message postmessage, p.message postmessage,
p.created postcreated p.created postcreated,
p.format postformat
FROM {$CFG->prefix}forum_discussions d, FROM {$CFG->prefix}forum_discussions d,
{$CFG->prefix}forum_posts p, {$CFG->prefix}forum_posts p,
{$CFG->prefix}user u {$CFG->prefix}user u
@ -193,13 +195,13 @@
foreach ($recs as $rec) { foreach ($recs as $rec) {
unset($item); unset($item);
unset($user); unset($user);
$item->title = $rec->discussionname; $item->title = $rec->postsubject;
$user->firstname = $rec->userfirstname; $user->firstname = $rec->userfirstname;
$user->lastname = $rec->userlastname; $user->lastname = $rec->userlastname;
$item->author = fullname($user); $item->author = fullname($user);
$item->pubdate = $rec->postcreated; $item->pubdate = $rec->postcreated;
$item->link = $CFG->wwwroot."/mod/forum/discuss.php?d=".$rec->discussionid."&parent=".$rec->postid; $item->link = $CFG->wwwroot."/mod/forum/discuss.php?d=".$rec->discussionid."&parent=".$rec->postid;
$item->description = $rec->postmessage; $item->description = format_text($rec->postmessage,$rec->postformat,NULL,$forum->course);
$items[] = $item; $items[] = $item;
$articlesleft--; $articlesleft--;
if ($articlesleft < 1) { if ($articlesleft < 1) {

View file

@ -181,7 +181,7 @@ function rss_standard_header($title = NULL, $link = NULL, $description = NULL) {
//This function returns the rss XML code for every item passed in the array //This function returns the rss XML code for every item passed in the array
//item->title: The title of the item //item->title: The title of the item
//item->author: The author of the item //item->author: The author of the item. Optional !!
//item->pubdate: The pubdate of the item //item->pubdate: The pubdate of the item
//item->link: The link url of the item //item->link: The link url of the item
//item->description: The content of the item //item->description: The content of the item
@ -197,6 +197,10 @@ function rss_add_items($items) {
$result .= rss_full_tag("title",3,false,$item->title); $result .= rss_full_tag("title",3,false,$item->title);
$result .= rss_full_tag("link",3,false,$item->link); $result .= rss_full_tag("link",3,false,$item->link);
$result .= rss_full_tag("pubDate",3,false,date("r",$item->pubdate)); $result .= rss_full_tag("pubDate",3,false,date("r",$item->pubdate));
//Include the author if exists
if (isset($item->author)) {
$item->description = get_string("byname","",$item->author)."<p>".$item->description;
}
$result .= rss_full_tag("description",3,false,$item->description); $result .= rss_full_tag("description",3,false,$item->description);
$result .= rss_end_tag("item",2,true); $result .= rss_end_tag("item",2,true);