Chat window now opens with no messages inside.
[Assignment-Trapper.git] / assignment_feed.php
blob2c30d09444fe53c33bb4f3cbd2d432fbb1bc8847
1 <?php
3 include_once("auth_root.php");
5 include_once("conn.php");
7 /* TODO: Lock out account if this user keeps hitting this page. */
9 /* get most recent date for assignment change - this will be the publication date */
10 $sql = 'select DATE_FORMAT(max(timeposted),"%a, %d %b %Y %T CST") from schedule';
12 $result = mysql_query($sql);
13 if (!$result) { die("SQL ERROR"); }
14 $row = mysql_fetch_array($result);
16 $pub_date = $row['0'];
18 //if($role != 0) { die("Account \"".$user_name."\" Is Not Authorized To View This Page.<br><br>This Event Will Be Logged And Reported."); }
20 if($role == 0) {
21 $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';
23 } else {
24 // get list of classes this student is in
25 $classes = "(";
26 $i = 0;
27 $sql = 'select class_id from enrollment where user_id='.$user_id;
28 // echo $sql;
29 $result = mysql_query($sql);
30 if (!$result) { die("SQL ERROR: Get Classes"); }
31 while( $row = mysql_fetch_array($result))
33 if($i == 0 ) {
34 $classes .= "schedule.class_id=".$row['class_id'];
35 } else {
36 $classes .= " or schedule.class_id=".$row['class_id'];
38 $i++;
40 $classes .= ")";
42 $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';
45 //echo $sql;
47 $result = mysql_query($sql);
49 $server_url = "http://".$_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF'];
50 $server_url_base = "http://".$_SERVER['SERVER_NAME'];
51 //echo $server_url;
53 if (!$result) { die("SQL ERROR"); }
55 $i = 0;
56 while($row = mysql_fetch_array($result))
59 $row['title'] = htmlspecialchars($row['title']);
60 $row['type_name'] = htmlspecialchars($row['title']);
62 $items .= '
63 <item>
64 <title>'.$row['title'].' - '.$row['type_name'].'</title>
65 <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:
66 '.$row['section_id'].'&lt;p&gt;Avaliable Date: '.$row['ava_date'].'
67 &lt;p&gt;Due Date: '.$row['due_date'].'</description>
68 <link>'.$server_url_base.'/at/detail_root.php?sched='.$row['sched_id'].'&amp;random='.$row['timeposted_num'].'</link>
69 <author>steven.schronk@my.tccd.edu (Schronk, Steven)</author>
70 <category domain="assignmnet feed">assignments</category>
71 <guid>'.$server_url_base.'/at/detail_root.php?sched='.$row['sched_id'].'</guid>
72 <pubDate>'.$row['timeposted'].'</pubDate>
73 </item>
75 $i++;
78 $now = date("D, d M Y H:i:s T");
82 echo '<?xml version="1.0" encoding="UTF-8" ?>';
86 <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
87 <channel>
88 <title>Assignment Trapper - Assignment Update Feed</title>
89 <description>Latest assignment changes.</description>
90 <link><?php echo $server_url; ?></link>
91 <lastBuildDate><?php echo $pub_date; ?></lastBuildDate>
92 <pubDate><?php echo $pub_date; ?></pubDate>
93 <language>en-US</language>
94 <copyright>Copyright 2011 Steven Schronk</copyright>
95 <managingEditor>steven@schronk.com (Steven Schronk)</managingEditor>
96 <webMaster>steven@schronk.com (Steven Schronk)</webMaster>
97 <ttl>10</ttl>
98 <atom:link href="http://www.opentextbook.info/at/comment_feed.php" rel="self" type="application/rss+xml" />
99 <image>
100 <title>Assignment Trapper - Assignment Update Feed</title>
101 <url><?php echo $server_url_base; ?>/at/gfx/bug.png</url>
102 <link><?php echo $server_url_base; ?>/at/assignment_feed.php</link>
103 <width>32</width>
104 <height>32</height>
105 </image>
107 <?php echo $items; ?>
109 </channel>
110 </rss>