Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge branch 'wip-MDL-26500-21' of git://github.com/danpoltawski/mood…

…le into MOODLE_21_STABLE
  • Loading branch information...
commit c168d35af5af8c43c0db647eed8dd2142a870769 2 parents 030fc2d + 0fcd56e
Eloy Lafuente (stronk7) authored April 24, 2012
4  blog/rsslib.php
@@ -164,7 +164,9 @@ function blog_rss_get_feed($context, $args) {
164 164
             $item->title = $blog_entry->subject;
165 165
             $item->pubdate = $blog_entry->lastmodified;
166 166
             $item->link = $CFG->wwwroot.'/blog/index.php?entryid='.$blog_entry->id;
167  
-            $item->description = format_text($blog_entry->summary, $blog_entry->format);
  167
+            $summary = file_rewrite_pluginfile_urls($blog_entry->summary, 'pluginfile.php',
  168
+                $sitecontext->id, 'blog', 'post', $blog_entry->id);
  169
+            $item->description = format_text($summary, $blog_entry->format);
168 170
             if ( !empty($CFG->usetags) && ($blogtags = tag_get_tags_array('post', $blog_entry->id)) ) {
169 171
                 if ($blogtags) {
170 172
                     $item->tags = $blogtags;
26  mod/forum/rsslib.php
@@ -45,13 +45,11 @@ function forum_rss_get_feed($context, $args) {
45 45
 
46 46
     $forumid  = clean_param($args[3], PARAM_INT);
47 47
     $cm = get_coursemodule_from_instance('forum', $forumid, 0, false, MUST_EXIST);
48  
-    if ($cm) {
49  
-        $modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
  48
+    $modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
50 49
 
51  
-        //context id from db should match the submitted one
52  
-        if ($context->id != $modcontext->id || !has_capability('mod/forum:viewdiscussion', $modcontext)) {
53  
-            return null;
54  
-        }
  50
+    //context id from db should match the submitted one
  51
+    if ($context->id != $modcontext->id || !has_capability('mod/forum:viewdiscussion', $modcontext)) {
  52
+        return null;
55 53
     }
56 54
 
57 55
     $forum = $DB->get_record('forum', array('id' => $forumid), '*', MUST_EXIST);
@@ -75,7 +73,7 @@ function forum_rss_get_feed($context, $args) {
75 73
     $dontrecheckcutoff = time()-60;
76 74
     if ( $dontrecheckcutoff > $cachedfilelastmodified && forum_rss_newstuff($forum, $cm, $cachedfilelastmodified)) {
77 75
         //need to regenerate the cached version
78  
-        $result = forum_rss_feed_contents($forum, $sql);
  76
+        $result = forum_rss_feed_contents($forum, $sql, $modcontext);
79 77
         if (!empty($result)) {
80 78
             $status = rss_save_file('mod_forum',$filename,$result);
81 79
         }
@@ -172,7 +170,7 @@ function forum_rss_feed_discussions_sql($forum, $cm, $newsince=0) {
172 170
     }
173 171
 
174 172
     $forumsort = "d.timemodified DESC";
175  
-    $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";
  173
+    $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";
176 174
 
177 175
     $sql = "SELECT $postdata, d.id as discussionid, d.name as discussionname, d.timemodified, d.usermodified, d.groupid, d.timestart, d.timeend,
178 176
                    u.firstname as userfirstname, u.lastname as userlastname, u.email, u.picture, u.imagealt
@@ -258,10 +256,12 @@ function forum_rss_get_group_sql($cm, $groupmode, $currentgroup, $modcontext=nul
258 256
  * This function return the XML rss contents about the forum
259 257
  * It returns false if something is wrong
260 258
  *
261  
- * @param object $forum
262  
- * @param bool
  259
+ * @param stdClass $forum the forum object
  260
+ * @param string   $sql   The SQL used to retrieve the contents from the database
  261
+ * @param object $context the context this forum relates to
  262
+ * @return bool|string false if the contents is empty, otherwise the contents of the feed is returned
263 263
  */
264  
-function forum_rss_feed_contents($forum, $sql) {
  264
+function forum_rss_feed_contents($forum, $sql, $context) {
265 265
     global $CFG, $DB;
266 266
 
267 267
     $status = true;
@@ -300,7 +300,9 @@ function forum_rss_feed_contents($forum, $sql) {
300 300
             }
301 301
 
302 302
             $formatoptions->trusted = $rec->posttrust;
303  
-            $item->description = format_text($rec->postmessage,$rec->postformat,$formatoptions,$forum->course);
  303
+            $message = file_rewrite_pluginfile_urls($rec->postmessage, 'pluginfile.php', $context->id,
  304
+                'mod_forum', 'post', $rec->postid);
  305
+            $item->description = format_text($message, $rec->postformat, $formatoptions, $forum->course);
304 306
 
305 307
             //TODO: implement post attachment handling
306 308
             /*if (!$isdiscussion) {
29  mod/glossary/rsslib.php
@@ -15,19 +15,17 @@ function glossary_rss_get_feed($context, $args) {
15 15
 
16 16
         $glossaryid  = clean_param($args[3], PARAM_INT);
17 17
         $cm = get_coursemodule_from_instance('glossary', $glossaryid, 0, false, MUST_EXIST);
18  
-        if ($cm) {
19  
-            $modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
20  
-            if ($COURSE->id == $cm->course) {
21  
-                $course = $COURSE;
22  
-            } else {
23  
-                $course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST);
24  
-            }
25  
-            $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id, MUST_EXIST);
26  
-            //context id from db should match the submitted one
27  
-            //no specific capability required to view glossary entries so just check user is enrolled
28  
-            if ($context->id != $modcontext->id || !can_access_course($coursecontext, $USER)) {
29  
-                return null;
30  
-            }
  18
+        $modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
  19
+        if ($COURSE->id == $cm->course) {
  20
+            $course = $COURSE;
  21
+        } else {
  22
+            $course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST);
  23
+        }
  24
+        $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id, MUST_EXIST);
  25
+        //context id from db should match the submitted one
  26
+        //no specific capability required to view glossary entries so just check user is enrolled
  27
+        if ($context->id != $modcontext->id || !can_access_course($coursecontext, $USER)) {
  28
+            return null;
31 29
         }
32 30
 
33 31
         $glossary = $DB->get_record('glossary', array('id' => $glossaryid), '*', MUST_EXIST);
@@ -72,7 +70,10 @@ function glossary_rss_get_feed($context, $args) {
72 70
 
73 71
                 $item->pubdate = $rec->entrytimecreated;
74 72
                 $item->link = $CFG->wwwroot."/mod/glossary/showentry.php?courseid=".$glossary->course."&eid=".$rec->entryid;
75  
-                $item->description = format_text($rec->entrydefinition,$rec->entryformat,$formatoptions,$glossary->course);
  73
+
  74
+                $definition = file_rewrite_pluginfile_urls($rec->entrydefinition, 'pluginfile.php',
  75
+                    $modcontext->id, 'mod_glossary', 'entry', $rec->entryid);
  76
+                $item->description = format_text($definition, $rec->entryformat, $formatoptions, $glossary->course);
76 77
                 $items[] = $item;
77 78
             }
78 79
 

0 notes on commit c168d35

Please sign in to comment.
Something went wrong with that request. Please try again.