/src/warn.php

https://github.com/ramielrowe/Radford-Reservation-System · PHP · 136 lines · 113 code · 23 blank · 0 comment · 11 complexity · 8e887e20fdbf446835485449bb056526 MD5 · raw file

  1. <?php
  2. if($pageid == "warnuser"){
  3. $user = mysql_fetch_assoc(getUserByID($_GET['user_id']));
  4. echo "
  5. <center><h3>Warn ".$user['name']."</h3></center>
  6. <form action=\"./index.php?pageid=submitwarning\" method=\"POST\">
  7. <input type=\"hidden\" name=\"user_id\" value=\"".$_GET['user_id']."\">
  8. <table class=\"warning\">
  9. <tr>
  10. <td colspan=2 class=\"centeredcellbold\">Warn Reason</td>
  11. </tr>
  12. <tr>
  13. <td colspan=2 class=\"centeredcellbold\"><textarea cols=\"55\" rows=\"7\" name=\"reason\"></textarea></td>
  14. </tr>
  15. <tr>
  16. <td class=\"centeredcell\"><select name=\"type\"><option value=\"1\">Active</option><option value=\"2\">Notification</option><option value=\"3\">Inactive</option></select></td>
  17. <td class=\"centeredcell\"><input type=\"submit\" value=\"Warn\"></textarea></td>
  18. </tr>
  19. </table>
  20. </form>
  21. ";
  22. }
  23. else if($pageid == "submitwarning"){
  24. warnUser($_POST['user_id'],$_POST['reason'],$_POST['type']);
  25. $user = mysql_fetch_assoc(getUserByID($_POST['user_id']));
  26. echo "<center><h3>".$user['name']." Warned</h3><a href=\"./index.php?pageid=edituser&user=".$user['user_id']."\">View User</a></center>";
  27. }
  28. else if($pageid == "viewwarnings"){
  29. if(getSessionVariable('user_level') < getConfigVar("admin_rank") && getSessionVariable('user_id') != $_GET['user_id']){
  30. echo "<center><h3><font color=\"#FF0000\">Error: You are not authorized to view other user's warnings.</font></h3></center>";
  31. }
  32. else{
  33. $warnings = getWarningsForUser($_GET['user_id']);
  34. $user = mysql_fetch_assoc(getUserByID($_GET['user_id']));
  35. $options = "";
  36. while($row = mysql_fetch_assoc($warnings)){
  37. $options = $options."<option value=\"".$row['warn_id']."\">".$row['time']." - ".getWarningType($row['type'])."</option>";
  38. }
  39. echo "<center><h3>View Warnings For ".$user['name']."</h3>";
  40. if($options != ""){
  41. echo "<form action=\"index.php\" method=\"GET\">
  42. <input type=\"hidden\" name=\"pageid\" value=\"editwarning\">
  43. <select name=\"warn_id\">".$options."</select><input type=\"submit\" value=\"View\"></form></center>";
  44. }
  45. else{
  46. echo "<h4>User has no warnings.</h4>";
  47. }
  48. }
  49. }
  50. else if($pageid == "editwarning" || $pageid == "savewarning"){
  51. $message = "";
  52. if($pageid == "savewarning"){
  53. saveWarning($_POST['warn_id'], $_POST['reason'], $_POST['type']);
  54. $warning = mysql_fetch_assoc(getWarningByID($_POST['warn_id']));
  55. $message = "<font color=\"#008800\"><b>Warning Saved</b></font><br><br>";
  56. }else{
  57. $warning = mysql_fetch_assoc(getWarningByID($_GET['warn_id']));
  58. }
  59. $user = mysql_fetch_assoc(getUserByID($warning['user_id']));
  60. $selected = array(RES_WARNING_ACTIVE => "",RES_WARNING_NOTE => "",RES_WARNING_INACTIVE => "");
  61. $selected[$warning['type']] = "SELECTED";
  62. echo "<center><h3>Edit Warning For ".$user['name']."</h3>".$message."</center>
  63. <form action=\"./index.php?pageid=savewarning\" method=\"POST\">
  64. <input type=\"hidden\" name=\"warn_id\" value=\"".$warning['warn_id']."\">
  65. <table class=\"warning\">
  66. <tr>
  67. <td colspan=2 class=\"centeredcellbold\">Warn Reason</th>
  68. </tr>
  69. <tr>
  70. <td colspan=2 class=\"centeredcell\"><textarea cols=\"55\" rows=\"7\" name=\"reason\">".$warning['reason']."</textarea></td>
  71. </tr>
  72. <tr>
  73. <td class=\"centeredcell\"><select name=\"type\"><option value=\"".RES_WARNING_ACTIVE."\" $selected[1]>Active</option><option value=\"".RES_WARNING_NOTE."\" $selected[2]>Notification</option><option value=\"".RES_WARNING_INACTIVE."\" $selected[3]>Inactive</option></select></td>
  74. <td class=\"centeredcell\"><input type=\"submit\" value=\"Save\"></textarea></td>
  75. </tr>
  76. </table>
  77. </form>
  78. </center>";
  79. }
  80. ?>