home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 April / CMCD0404.ISO / Software / Freeware / Programare / dotproject / modules / ticketsmith / comment.php < prev    next >
Encoding:
PHP Script  |  2004-01-28  |  3.5 KB  |  104 lines

  1. <?php /* TICKETSMITH $Id: comment.php,v 1.17 2004/01/28 05:47:36 ajdonnison Exp $ */
  2.  
  3. if (!$canEdit) {
  4.     $AppUI->redirect( "m=public&a=access_denied" );
  5. }
  6.  
  7. $ticket = dPgetParam( $_GET, 'ticket', '' );
  8. $ticket_type = dPgetParam( $_GET, 'ticket_type', '' );
  9.  
  10. // setup the title block
  11. $titleBlock = new CTitleBlock( 'Post Comment', 'gconf-app-icon.png', $m, "$m.$a" );
  12. $titleBlock->addCrumb( "?m=ticketsmith", "tickets list" );
  13. $titleBlock->addCrumb( "?m=ticketsmith&a=view&ticket=$ticket", "view this ticket" );
  14. $titleBlock->show();
  15.  
  16. require("modules/ticketsmith/config.inc.php");
  17. require("modules/ticketsmith/common.inc.php");
  18.  
  19. /* set title */
  20. $title = "Post Comment";
  21.  
  22. /* prepare ticket parent */
  23. if (!$ticket_parent) {
  24.     $ticket_parent = $ticket;
  25. }
  26.  
  27. $author_name = dPgetParam( $_POST, 'author_name', '' );
  28. $author_email = dPgetParam( $_POST, 'author_email', '' );
  29. $comment = dPgetParam( $_POST, 'comment', '' );
  30. $body = dPgetParam( $_POST, 'body', '' );
  31.  
  32. if (@$comment) {
  33.  
  34.     /* prepare fields */
  35.     list($author_name, $author_email) = query2array("SELECT CONCAT_WS(' ',user_first_name,user_last_name) as name, user_email as email FROM users WHERE user_id = '$AppUI->user_id'");
  36.     $subject = db_escape( query2result("SELECT subject FROM tickets WHERE ticket = '$ticket_parent'") );
  37.     $comment = db_escape( $comment );
  38.     $author = $author_name . " <" . $author_email . ">";
  39.     $timestamp = time();
  40.     $body = escape_string($body);
  41.  
  42.     /* prepare query */
  43.     $query = "INSERT INTO tickets (author, subject, body, timestamp, type, parent, assignment) ";
  44.     $query .= "VALUES ('$author','$subject','$comment','$timestamp','Staff Comment','$ticket_parent','9999')";
  45.  
  46.     /* insert comment */
  47.     do_query($query);
  48.  
  49.     /* update parent ticket's timestamp */
  50.     do_query("UPDATE tickets SET activity = '$timestamp' WHERE ticket = '$ticket_parent'");
  51.  
  52.     /* return to ticket view */
  53.     echo("<META HTTP-EQUIV=\"Refresh\" CONTENT=\"0;URL=index.php?m=ticketsmith&a=view&ticket=$ticket_parent\">");
  54.  
  55.     exit();
  56.  
  57. } else {
  58.  
  59.     /* start table */
  60.     print("<table class=std bgcolor=\"#eeeeee\" width=\"100%\">\n");
  61.     print("<tr>\n");
  62.     print("<th colspan=\"2\" align=\"center\" >\n");
  63.     print("<div class=\"heading\">".$AppUI->_($title)."</div>\n");
  64.     print("</th>\n");
  65.     print("</tr>\n");
  66.  
  67.     /* start form */
  68.     print("<form name='ticketform' action=\"index.php?m=ticketsmith&a=comment&ticket=$ticket\" method=\"post\">\n");
  69.  
  70.     /* determine poster */
  71.     print("<tr>\n");
  72.     print("<td align=\"left\"><strong>".$AppUI->_('From')."</strong></td>");
  73.     list($author_name, $author_email) = query2array("SELECT CONCAT_WS(' ',user_first_name,user_last_name) as name, user_email as email FROM users WHERE user_id = '$AppUI->user_id'");
  74.     print("<td align=\"left\">" . $author_name . " <" . $author_email . "></td>\n");
  75.     print("</tr>");
  76.  
  77.     /* output textarea */
  78.     print("<tr>\n");
  79.     print("<td align=\"left\"><br /></td>");
  80.     print("<td align=\"left\">");
  81.     print("<tt>\n");
  82.     print("<textarea name=\"comment\" wrap=\"hard\" cols=\"72\" rows=\"20\">\n");
  83.     print("</textarea>\n");
  84.     print("</tt>\n");
  85.     print("</td>\n");
  86.  
  87.     /* output submit button */
  88.     print('<tr><td><br /></td><td><font size=\"-1\"><input type="submit" class=button value="'.$AppUI->_('Post Comment').'"></font></td></tr>');
  89.  
  90.     /* footer links */
  91.     print("<tr>\n");
  92.     print("<td><br /></td>");
  93.     print("<td> </td>");
  94.     print("</tr>\n");
  95.  
  96.     /* end table */
  97.     print("</table>\n");
  98.  
  99.     /* end form */
  100.     print("</form>\n");
  101. }
  102.  
  103. ?>
  104.