Skip to content

Commit

Permalink
Merge branch 'wip-MDL-26500-21' of git://github.com/danpoltawski/mood…
Browse files Browse the repository at this point in the history
…le into MOODLE_21_STABLE
  • Loading branch information
stronk7 committed Apr 23, 2012
2 parents 030fc2d + 0fcd56e commit c168d35
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 27 deletions.
4 changes: 3 additions & 1 deletion blog/rsslib.php
Expand Up @@ -164,7 +164,9 @@ function blog_rss_get_feed($context, $args) {
$item->title = $blog_entry->subject; $item->title = $blog_entry->subject;
$item->pubdate = $blog_entry->lastmodified; $item->pubdate = $blog_entry->lastmodified;
$item->link = $CFG->wwwroot.'/blog/index.php?entryid='.$blog_entry->id; $item->link = $CFG->wwwroot.'/blog/index.php?entryid='.$blog_entry->id;
$item->description = format_text($blog_entry->summary, $blog_entry->format); $summary = file_rewrite_pluginfile_urls($blog_entry->summary, 'pluginfile.php',
$sitecontext->id, 'blog', 'post', $blog_entry->id);
$item->description = format_text($summary, $blog_entry->format);
if ( !empty($CFG->usetags) && ($blogtags = tag_get_tags_array('post', $blog_entry->id)) ) { if ( !empty($CFG->usetags) && ($blogtags = tag_get_tags_array('post', $blog_entry->id)) ) {
if ($blogtags) { if ($blogtags) {
$item->tags = $blogtags; $item->tags = $blogtags;
Expand Down
26 changes: 14 additions & 12 deletions mod/forum/rsslib.php
Expand Up @@ -45,13 +45,11 @@ function forum_rss_get_feed($context, $args) {


$forumid = clean_param($args[3], PARAM_INT); $forumid = clean_param($args[3], PARAM_INT);
$cm = get_coursemodule_from_instance('forum', $forumid, 0, false, MUST_EXIST); $cm = get_coursemodule_from_instance('forum', $forumid, 0, false, MUST_EXIST);
if ($cm) { $modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
$modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);


//context id from db should match the submitted one //context id from db should match the submitted one
if ($context->id != $modcontext->id || !has_capability('mod/forum:viewdiscussion', $modcontext)) { if ($context->id != $modcontext->id || !has_capability('mod/forum:viewdiscussion', $modcontext)) {
return null; return null;
}
} }


$forum = $DB->get_record('forum', array('id' => $forumid), '*', MUST_EXIST); $forum = $DB->get_record('forum', array('id' => $forumid), '*', MUST_EXIST);
Expand All @@ -75,7 +73,7 @@ function forum_rss_get_feed($context, $args) {
$dontrecheckcutoff = time()-60; $dontrecheckcutoff = time()-60;
if ( $dontrecheckcutoff > $cachedfilelastmodified && forum_rss_newstuff($forum, $cm, $cachedfilelastmodified)) { if ( $dontrecheckcutoff > $cachedfilelastmodified && forum_rss_newstuff($forum, $cm, $cachedfilelastmodified)) {
//need to regenerate the cached version //need to regenerate the cached version
$result = forum_rss_feed_contents($forum, $sql); $result = forum_rss_feed_contents($forum, $sql, $modcontext);
if (!empty($result)) { if (!empty($result)) {
$status = rss_save_file('mod_forum',$filename,$result); $status = rss_save_file('mod_forum',$filename,$result);
} }
Expand Down Expand Up @@ -172,7 +170,7 @@ function forum_rss_feed_discussions_sql($forum, $cm, $newsince=0) {
} }


$forumsort = "d.timemodified DESC"; $forumsort = "d.timemodified DESC";
$postdata = "p.id, p.subject, p.created as postcreated, p.modified, p.discussion, p.userid, p.message as postmessage, p.messageformat AS postformat, p.messagetrust AS posttrust"; $postdata = "p.id AS postid, p.subject, p.created as postcreated, p.modified, p.discussion, p.userid, p.message as postmessage, p.messageformat AS postformat, p.messagetrust AS posttrust";


$sql = "SELECT $postdata, d.id as discussionid, d.name as discussionname, d.timemodified, d.usermodified, d.groupid, d.timestart, d.timeend, $sql = "SELECT $postdata, d.id as discussionid, d.name as discussionname, d.timemodified, d.usermodified, d.groupid, d.timestart, d.timeend,
u.firstname as userfirstname, u.lastname as userlastname, u.email, u.picture, u.imagealt u.firstname as userfirstname, u.lastname as userlastname, u.email, u.picture, u.imagealt
Expand Down Expand Up @@ -258,10 +256,12 @@ function forum_rss_get_group_sql($cm, $groupmode, $currentgroup, $modcontext=nul
* This function return the XML rss contents about the forum * This function return the XML rss contents about the forum
* It returns false if something is wrong * It returns false if something is wrong
* *
* @param object $forum * @param stdClass $forum the forum object
* @param bool * @param string $sql The SQL used to retrieve the contents from the database
* @param object $context the context this forum relates to
* @return bool|string false if the contents is empty, otherwise the contents of the feed is returned
*/ */
function forum_rss_feed_contents($forum, $sql) { function forum_rss_feed_contents($forum, $sql, $context) {
global $CFG, $DB; global $CFG, $DB;


$status = true; $status = true;
Expand Down Expand Up @@ -300,7 +300,9 @@ function forum_rss_feed_contents($forum, $sql) {
} }


$formatoptions->trusted = $rec->posttrust; $formatoptions->trusted = $rec->posttrust;
$item->description = format_text($rec->postmessage,$rec->postformat,$formatoptions,$forum->course); $message = file_rewrite_pluginfile_urls($rec->postmessage, 'pluginfile.php', $context->id,
'mod_forum', 'post', $rec->postid);
$item->description = format_text($message, $rec->postformat, $formatoptions, $forum->course);


//TODO: implement post attachment handling //TODO: implement post attachment handling
/*if (!$isdiscussion) { /*if (!$isdiscussion) {
Expand Down
29 changes: 15 additions & 14 deletions mod/glossary/rsslib.php
Expand Up @@ -15,19 +15,17 @@ function glossary_rss_get_feed($context, $args) {


$glossaryid = clean_param($args[3], PARAM_INT); $glossaryid = clean_param($args[3], PARAM_INT);
$cm = get_coursemodule_from_instance('glossary', $glossaryid, 0, false, MUST_EXIST); $cm = get_coursemodule_from_instance('glossary', $glossaryid, 0, false, MUST_EXIST);
if ($cm) { $modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
$modcontext = get_context_instance(CONTEXT_MODULE, $cm->id); if ($COURSE->id == $cm->course) {
if ($COURSE->id == $cm->course) { $course = $COURSE;
$course = $COURSE; } else {
} else { $course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST);
$course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST); }
} $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id, MUST_EXIST);
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id, MUST_EXIST); //context id from db should match the submitted one
//context id from db should match the submitted one //no specific capability required to view glossary entries so just check user is enrolled
//no specific capability required to view glossary entries so just check user is enrolled if ($context->id != $modcontext->id || !can_access_course($coursecontext, $USER)) {
if ($context->id != $modcontext->id || !can_access_course($coursecontext, $USER)) { return null;
return null;
}
} }


$glossary = $DB->get_record('glossary', array('id' => $glossaryid), '*', MUST_EXIST); $glossary = $DB->get_record('glossary', array('id' => $glossaryid), '*', MUST_EXIST);
Expand Down Expand Up @@ -72,7 +70,10 @@ function glossary_rss_get_feed($context, $args) {


$item->pubdate = $rec->entrytimecreated; $item->pubdate = $rec->entrytimecreated;
$item->link = $CFG->wwwroot."/mod/glossary/showentry.php?courseid=".$glossary->course."&eid=".$rec->entryid; $item->link = $CFG->wwwroot."/mod/glossary/showentry.php?courseid=".$glossary->course."&eid=".$rec->entryid;
$item->description = format_text($rec->entrydefinition,$rec->entryformat,$formatoptions,$glossary->course);
$definition = file_rewrite_pluginfile_urls($rec->entrydefinition, 'pluginfile.php',
$modcontext->id, 'mod_glossary', 'entry', $rec->entryid);
$item->description = format_text($definition, $rec->entryformat, $formatoptions, $glossary->course);
$items[] = $item; $items[] = $item;
} }


Expand Down

0 comments on commit c168d35

Please sign in to comment.