Chat window now opens with no messages inside.
[Assignment-Trapper.git] / comment.php
blob50568d13decfadd7544d2bd4c24026996be69c69
1 <?php
3 include_once("auth.php");
4 include_once("detail_lib.php");
6 //include_once("header.php");
8 if (!$_GET["comment"]) { die("No Comment Sent"); }
9 if (!$_GET["sched"]) { die("No Schedule ID Sent"); }
11 $_GET["user"] = mysql_real_escape_string($_GET["user"]);
12 $_GET["sched"] = mysql_real_escape_string($_GET["sched"]);
13 $_GET["comment"] = mysql_real_escape_string($_GET["comment"]);
15 // faculty must submit not only the schedule, but the user commented about as well
16 if($role == 0 && !$_GET["user"]) { die("No User ID Sent"); }
18 if($_GET["comment"] == "") { die("Comment Must Not Be Empty"); }
20 if($role == 0) { // faculty comment to student
21 detail_viewed_update($_GET["user"], $_GET["sched"], 0, "std");
22 detail_viewed_update($_GET["user"], $_GET["sched"], 1, "fac");
23 helpme_viewed_update($_GET["user"], $_GET["sched"], 0);
24 $sql = 'insert into comments values("", '.$_GET["user"].', '.$_GET["sched"].','.$user_id.','.$role.', "'.$_GET["comment"].'", NOW())';
25 } else { // student comment to faculty
26 detail_viewed_update($_GET["user"], $_GET["sched"], 1, "std");
27 detail_viewed_update($_GET["user"], $_GET["sched"], 0, "fac");
28 $sql = 'insert into comments values("", '.$user_id.', '.$_GET["sched"].', NULL,'.$role.', "'.$_GET["comment"].'", NOW())';
31 //echo $sql;
33 $result = mysql_query($sql);
35 if (!$result) { die("SQL ERROR"); } else {
37 // send message to user as reciept of file
39 $uid = md5(uniqid(time()));
42 $from_name = "Assignment Trapper";
43 $from_mail = "noreply@opentextbook.info";
45 $message = "Comment about Assignment<br><br>";
46 $message .= '<a href=http://opentextbook.info/at/detail_root.php?sched='.$_GET["sched"].'>Click Here</a> to view.';
48 $header = "From: ".$from_name." <".$from_mail.">\r\n";
49 $header .= "Reply-To: ".$replyto."\r\n";
50 $header .= "MIME-Version: 1.0\r\n";
51 $header .= "Content-Type: multipart/mixed; boundary=\"".$uid."\"\r\n\r\n";
52 $header .= "This is a multi-part message in MIME format.\r\n";
53 $header .= "--".$uid."\r\n";
54 $header .= "Content-type:text/html; charset=iso-8859-1\r\n";
55 $header .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
56 $header .= $message;
58 //mail($user_email, "Comment About Assignment", "", $header);
59 mail("steven.schronk@my.tccd.edu", "Comment About Assignment", "", $header);
63 if($_GET["action"] == 'ret') {
64 echo '<html><meta http-equiv="refresh" content="0;url=detail_root.php?sched='.$_GET["sched"].'&user='.$_GET["user"].'" /></html>';
65 } else {
66 echo '<html><meta http-equiv="refresh" content="0;url=detail_root.php?sched='.$_GET["sched"].'" /></html>';