root/devel/lms/rss.php

Revision 659, 4.0 kB (checked in by misja, 2 years ago)

Taking gettext to a new level, see message <http://lists.elgg.org/pipermail/development/2006-October/000590.html>. In a nutshell: all gettext calls are replaced by gettext, revamped gettext handling plus some additional fixes.

  • Property svn:eol-style set to native
Line 
1 <?php
2 /**
3 We're either going to return an rss feed of the users recent activity,
4 or we're going to return an invalid rss fragment which means that
5 the lms will have to do something else (like display a 'join' link)
6 */
7
8 require_once(dirname(dirname(__FILE__)).'/includes.php');
9 require_once($CFG->dirroot.'lib/lmslib.php');
10
11 // the POST parameters we expect are:
12 $installid = optional_param('installid');
13 $username = optional_param('username');
14 $firstname = optional_param('firstname');
15 $lastname = optional_param('lastname');
16 $email = optional_param('email');
17 $signature = optional_param('signature');
18
19 $user = find_lms_user($installid,$username,$signature,null,$firstname,$lastname,$email);
20 if (is_string($user)) {
21     echo $user;
22     die();
23 }
24 // else we have a the user object.
25
26 // now start doing the rss feed
27 $starttime = time()-(86400*30);
28 $rssdescription = sprintf(__gettext("Activity for %s, hosted on %s."),$user->name,$CFG->sitename);
29 $mainurl = $CFG->wwwroot.'_activity/';
30 echo '
31 <rss version="2.0"   xmlns:dc="http://purl.org/dc/elements/1.1/">
32     <channel xml:base="'.$mainurl.'">
33         <title><![CDATA['.$user->name.' : '.__gettext("Activity").']]></title>
34         <description><![CDATA['.$rssdescription.']]></description>
35         <link>'.$mainurl.'</link>
36 ';
37 $something = false;
38 if ($activities = get_records_sql('SELECT u.username,wc.*,wp.ident AS weblogpost,wp.title AS weblogtitle, wp.weblog AS weblog
39                                    FROM '.$CFG->prefix.'weblog_comments wc LEFT JOIN '.$CFG->prefix.'weblog_posts wp ON wp.ident = wc.post_id
40                                    LEFT JOIN '.$CFG->prefix.'users u on u.ident = wp.weblog
41                                    WHERE wc.posted >= ? AND wp.owner = ?
42                                    ORDER BY wc.posted DESC LIMIT 10',array($starttime,$user->ident))) {
43     $postedby = __gettext("%s posted on weblog post:");
44     foreach($activities as $activity) {
45         $title = sprintf($postedby,stripslashes($activity->postedname)) . " " . stripslashes($activity->weblogtitle);
46         $link = $CFG->wwwroot.$activity->username . "/weblog/" . $activity->weblogpost . ".html";
47         $pubdate = strftime("%B %d, %Y",$activity->posted);
48         $body = stripslashes($activity->body);
49         echo "
50         <item>
51             <title><![CDATA[$title]]></title>
52             <link>$link</link>
53             <pubDate>$pubdate</pubDate>
54             <description><![CDATA[$body]]></description>
55         </item>
56 ";
57         $something = true;
58     }
59 }
60 if ($activities = get_records_sql('SELECT DISTINCT u.username,u.name as weblogname, wc.*,wp.weblog, wp.ident AS weblogpost, wp.title AS weblogtitle, wp.weblog AS weblog
61                                    FROM '.$CFG->prefix.'weblog_watchlist wl LEFT JOIN '.$CFG->prefix.'weblog_comments wc ON wc.post_id = wl.weblog_post
62                                    LEFT JOIN '.$CFG->prefix.'weblog_posts wp ON wp.ident = wc.post_id
63                                    LEFT JOIN '.$CFG->prefix.'users u ON u.ident = wp.weblog
64                                    WHERE wl.owner = ? AND wc.posted >= ? ORDER BY wc.posted DESC',array($user->ident,$starttime))) {
65     $postedby = __gettext("%s posted on weblog post '%s'");
66     foreach($activities as $activity) {
67         $title = sprintf($postedby,stripslashes($activity->postedname), stripslashes($activity->weblogtitle));
68         $link = $CFG->wwwroot.$activity->username . "/weblog/" . $activity->weblogpost . ".html";
69         $pubdate = strftime("%B %d, %Y",$activity->posted);
70         $body = stripslashes($activity->body);
71         echo "
72         <item>
73             <title><![CDATA[$title]]></title>
74             <link>$link</link>
75             <pubDate>$pubdate</pubDate>
76             <description><![CDATA[$body]]></description>
77         </item>
78 ";
79         $something = true;
80      }
81 }
82 if (empty($something)) {
83     $title = __gettext('No activity');
84     $link = $mainurl;
85     echo "
86         <item>
87             <title><![CDATA[$title]]></title>
88             <link>$link</link>
89             <description><![CDATA[$title]]></description>
90         </item>
91 ";
92 }
93 echo '
94     </channel>
95 </rss>';
96
97 ?>
Note: See TracBrowser for help on using the browser.