trigger_detail.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. require("user.inc.php");
  3. require("template.inc.php");
  4. list($status, $hist) = $ctl->cmd("trigger_history", $_GET['trigger']);
  5. if ($_GET['json']) {
  6. header("Content-type: text/plain; charset=UTF-8");
  7. print $hist;
  8. exit;
  9. } elseif ($_GET['tsv']) {
  10. header("Content-type: text/plain; charset=UTF-8");
  11. $hist = json_decode($hist, true);
  12. foreach ($hist as $v) {
  13. print "$v[exp]\t$v[changed_by]\t$v[changed_at]\n";
  14. }
  15. exit;
  16. }
  17. tpl_header();
  18. $hist = json_decode($hist, true);
  19. if (!$hist) {
  20. print "<p>Trigger isn't currently defined.";
  21. tpl_footer();
  22. exit;
  23. }
  24. if ($username):
  25. print "<h2>Edit !$_GET[trigger]</h2>\n";
  26. $exp = htmlspecialchars($hist[0]['exp']);
  27. print <<<EOF
  28. <form method="post" action="trigger_edit.php">
  29. <p>Content:<br><input name="exp" value="$exp" size="100" maxlength="400"><br>
  30. <input type="hidden" name="trigger" value="$_GET[trigger]">
  31. <input type="submit" value="Edit">
  32. </form>
  33. EOF;
  34. endif;
  35. print "<h2>History of !$_GET[trigger]</h2>\n";
  36. print "<ul>\n";
  37. $first = true;
  38. foreach ($hist as $h) {
  39. $text = format_plain_linked($h['exp']);
  40. print "<li>$text<br>By $h[changed_by] at $h[changed_at]";
  41. if (!$first && $username) print <<<EOF
  42. <form style="display: inline;" method="post" action="trigger_revert.php"><input type="hidden" name="tc_id" value="$h[tc_id]"><input type="submit" value="Restore this version"></form>
  43. EOF;
  44. print "\n";
  45. $first = false;
  46. }
  47. print "</ul>\n";
  48. tpl_footer();