Added discussion feature to site.
[Assignment-Trapper.git] / assignment_feed.php
blobc2a355f19c49895ec4d175b9321d2787a973da9f
1 <?php
3 date_default_timezone_set('America/Chicago');
5 include_once("auth_root.php");
7 include_once("conn.php");
9 $items = "";
11 /* TODO: Lock out account if this user keeps hitting this page. */
13 /* get most recent date for assignment change - this will be the publication date */
14 $sql = 'select DATE_FORMAT(max(timeposted),"%a, %d %b %Y %T CST") from schedule';
16 $result = mysql_query($sql);
17 if (!$result) { die("SQL ERROR"); }
18 $row = mysql_fetch_array($result);
20 $pub_date = $row['0'];
22 //if($role != 0) { die("Account \"".$user_name."\" Is Not Authorized To View This Page.<br><br>This Event Will Be Logged And Reported."); }
24 if($role == 0) {
25 $sql = 'select class_name, title, chapter, type_name, section_id, ava_date, due_date, sched_id, DATE_FORMAT(schedule.timeposted,"%a, %d %b %Y %T CST") AS timeposted, DATE_FORMAT(schedule.timeposted, "%Y%c%d%H%i%S") AS timeposted_num from schedule, class, types where (types.assign_type = schedule.assign_type) and (class.class_id = schedule.class_id) order by schedule.timeposted desc limit 30';
27 } else {
28 // get list of classes this student is in
29 $classes = "(";
30 $i = 0;
31 $sql = 'select class_id from enrollment where user_id='.$user_id;
32 // echo $sql;
33 $result = mysql_query($sql);
34 if (!$result) { die("SQL ERROR: Get Classes"); }
35 while( $row = mysql_fetch_array($result))
37 if($i == 0 ) {
38 $classes .= "schedule.class_id=".$row['class_id'];
39 } else {
40 $classes .= " or schedule.class_id=".$row['class_id'];
42 $i++;
44 $classes .= ")";
46 $sql = 'select class_name, title, chapter, type_name, section_id, ava_date, due_date, sched_id, DATE_FORMAT(schedule.timeposted,"%a, %d %b %Y %T CST") AS timeposted, DATE_FORMAT(schedule.timeposted, "%Y%c%d%H%i%S") AS timeposted_num from schedule, class, types where (types.assign_type = schedule.assign_type) and (class.class_id = schedule.class_id) and '.$classes.' order by schedule.timeposted desc limit 30';
49 //echo $sql;
51 $result = mysql_query($sql);
53 $server_url = "http://".$_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF'];
54 $server_url_base = "http://".$_SERVER['SERVER_NAME'];
55 //echo $server_url;
57 if (!$result) { die("SQL ERROR"); }
59 $i = 0;
60 while($row = mysql_fetch_array($result))
63 $row['title'] = htmlspecialchars($row['title']);
64 $row['type_name'] = htmlspecialchars($row['title']);
66 $items .= '
67 <item>
68 <title>'.$row['title'].' - '.$row['type_name'].'</title>
69 <description>An assignment for '.$row['class_name'].' has been updated.&lt;p&gt;Name: '.$row['title'].'&lt;p&gt;Chapter: '.$row['chapter'].'&lt;p&gt;Type: '.$row['type_name'].'&lt;p&gt;Section:
70 '.$row['section_id'].'&lt;p&gt;Avaliable Date: '.$row['ava_date'].'
71 &lt;p&gt;Due Date: '.$row['due_date'].'</description>
72 <link>'.$server_url_base.'/at/detail_root.php?sched='.$row['sched_id'].'&amp;random='.$row['timeposted_num'].'</link>
73 <author>steven.schronk@my.tccd.edu (Schronk, Steven)</author>
74 <category domain="assignmnet feed">assignments</category>
75 <guid>'.$server_url_base.'/at/detail_root.php?sched='.$row['sched_id'].'</guid>
76 <pubDate>'.$row['timeposted'].'</pubDate>
77 </item>
79 $i++;
82 $now = date("D, d M Y H:i:s T");
86 echo '<?xml version="1.0" encoding="UTF-8" ?>';
90 <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
91 <channel>
92 <title>Assignment Trapper - Assignment Update Feed</title>
93 <description>Latest assignment changes.</description>
94 <link><?php echo $server_url; ?></link>
95 <lastBuildDate><?php echo $pub_date; ?></lastBuildDate>
96 <pubDate><?php echo $pub_date; ?></pubDate>
97 <language>en-US</language>
98 <copyright>Copyright 2011 Steven Schronk</copyright>
99 <managingEditor>steven@schronk.com (Steven Schronk)</managingEditor>
100 <webMaster>steven@schronk.com (Steven Schronk)</webMaster>
101 <ttl>10</ttl>
102 <atom:link href="http://www.opentextbook.info/at/comment_feed.php" rel="self" type="application/rss+xml" />
103 <image>
104 <title>Assignment Trapper - Assignment Update Feed</title>
105 <url><?php echo $server_url_base; ?>/at/gfx/bug.png</url>
106 <link><?php echo $server_url_base; ?>/at/assignment_feed.php</link>
107 <width>32</width>
108 <height>32</height>
109 </image>
111 <?php echo $items; ?>
113 </channel>
114 </rss>