Added discussion feature to site.
[Assignment-Trapper.git] / discussion.php
blob354af52a40aefc2e7776997d0b4892c412fac9a4
1 <?php
3 include_once("auth.php");
4 include_once("header.php");
5 include_once("time.php");
7 if(isset($_GET['sched'])) {
8 $_GET['sched'] = mysql_real_escape_string($_GET['sched']);
9 $form = "sched=".$_GET['sched'];
10 $sql = 'select name, role, post_content, post_time from discussion_post, users where users.user_id = discussion_post.user_id and sched_id='.$_GET['sched'];
11 $sql2 = "select chapter, section_id, title, class_id, schedule.assign_type, ava_date, due_date, sched_id, NOW()-due_date as status, type_name, graded, NOW()-ava_date as ava from schedule, types where (schedule.assign_type = types.assign_type) and sched_id=".$_GET["sched"]." order by due_date desc, ava_date desc";
12 $result2 = mysql_query($sql2);
13 $row = mysql_fetch_array($result2);
15 $html .= '<table class="gridtable">
16 <tr>
17 <th>#</th><th>Status</th><th>Title</th><th>Type</th><th>Chapter</th><th>Section</th><th>Avalable Date</th><th>Due Date</th><th>Human Time</th>
18 </tr>';
20 $html .= '<tr>';
22 $html .= '<td>'.$row['sched_id'].'</td>';
24 // assignment started?
25 if($row['ava'] < 0){
26 $html .= "<td><img src=gfx/bullet_black.png>";
27 $started = false;
28 } else {
29 // assignment open?
30 if($row['status'] > 0 || $row['ava'] < 0) { $html .= "<td><img src=gfx/bullet_delete.png>"; } else { $html .= "<td><img src=gfx/bullet_add.png>"; }
31 $started = true;
34 // assignment graded?
35 if($row['graded']) { $html .= "<img src=gfx/bullet_disk.png>"; } else { $html .= "<img src=gfx/bullet_wrench.png>"; }
37 $html .= $help_icon;
38 $html .= $file_count;
39 $html .= $discussion;
40 $html .= '<td><a href="detail_root.php?sched='.$row['sched_id'].'">'.$row['title'].'</a></td><td>'.$row['type_name'].'</td><td>'.$row['chapter'].'</td>';
41 $html .= '<td>'.$row['section_id'].'</td><td>'.$row['ava_date'].'</td><td>'.$row['due_date'].'</td>';
43 if($started) {
44 $html .= '<td>'.absHumanTiming($row['due_date']).'</td>';
45 } else {
46 $html .= '<td>'.absHumanTiming($row['ava_date']).'</td>';
49 if($role != 0 ) { $html .= '<td><a href=help_me.php?sched='.$_GET["sched"].'>'.$help_stat.'</a></td>'; }
50 $html .= '</tr>';
51 $html .= '</table>';
53 } else if(isset($_GET['topic'])) {
54 $_GET['topic'] = mysql_real_escape_string($_GET['topic']);
55 $form = "topic=".$_GET['topic'];
56 $sql = 'select name, role, post_content, post_time from discussion_post, users where users.user_id = discussion_post.user_id and topic_id='.$_GET['topic'];
57 $sql2 = 'select topic_name, topic_description, discussion_sticky from discussion_topic where topic_id='.$_GET['topic'];
58 $result2 = mysql_query($sql2);
59 $row2 = mysql_fetch_array($result2);
60 $html .= '<div class="class_block">';
61 if($row2["discussion_sticky"] == 1 ) { $html .= '<img src="./gfx/lightbulb.png">'; } else { $html .= '<img src="./gfx/lightbulb_off.png">'; }
62 $html .= '<a href="./discussion.php?topic='.$_GET['topic'].'" class="topictitle">'.$row2["topic_name"].'</a>
63 <br><br>'.$row2["topic_description"].'</div>';
64 } else { die("Must Send Topic or Assignment Number"); }
66 $html .= '<br><br>';
68 $result = mysql_query($sql);
69 while($row = mysql_fetch_array($result)){
71 if($row['role'] == 0 ) { $icon = '<div class="com_head_fac"><img src="gfx/user_suit.png">'; } else { $icon = '<div class="com_head"><img src="gfx/user_green.png">'; }
73 $html .= '<div class="comment">'.$icon .'<span class="com_name">'.$row["name"].'</span><span class="com_date">'.$row["post_time"].'</span><span class="com_human">'.absHumanTiming($row["post_time"]).'</span></div><div class="com_body">'.$row["post_content"].'</div>
74 </div><br><br>';
77 echo $html;
80 <div class="comment_box">Add Comment:<form action="discussion_comment.php?<?php echo $form; ?>" method="post">
81 <textarea name="comment" id="comment" cols="85" rows="6"></textarea><br><br>
82 <input type="submit" value="Add Comment" />
83 </form></div>