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

  1. <?php /* TICKETSMITH $Id: followup.php,v 1.16 2004/01/28 05:47:36 ajdonnison Exp $ */
  2.  
  3. if (!$canRead) {
  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 Followup', '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. require_once( $AppUI->getSystemClass( 'libmail' ) );
  20.  
  21. /* set title */
  22. $title = "Post Followup";
  23.  
  24. /* setup fields */
  25. $fields = array("headings" => array("Subject", "Cc", "<br />"),
  26.                 "columns"  => array("subject", "cc", "body"),
  27.                 "types"    => array("subject", "cc", "followup"));
  28.  
  29. /* prepare ticket parent */
  30. if (!$ticket_parent) {
  31.     $ticket_parent = $ticket;
  32. }
  33.  
  34. //echo '<pre>';print_r($_POST);echo '</pre>';die;
  35. $recipient = dPgetParam( $_POST, 'recipient', '' );
  36. $subject = dPgetParam( $_POST, 'subject', '' );
  37. $cc = dPgetParam( $_POST, 'cc', '' );
  38. $followup = dPgetParam( $_POST, 'followup', '' );
  39.  
  40. if (@$followup) {
  41.  
  42.     /* prepare fields */
  43.     $timestamp = time();
  44.     list($from_name, $from_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'");
  45.     $author = "$from_name <$from_email>";
  46.     if (!$recipient) {
  47.         $recipient = query2result("SELECT author FROM tickets WHERE ticket = '$ticket_parent'");
  48.     }
  49.  
  50.     /* prepare posted stuff */
  51.     $recipient = stripslashes($recipient);
  52.     $subject = stripslashes($subject);
  53.     $followup = stripslashes($followup);
  54.     $cc = stripslashes($cc);
  55.  
  56.     $mail = new Mail;
  57.     if (isset($CONFIG['reply_name']) && $CONFIG["reply_name"] != "") {
  58.         $mail->From($CONFIG["reply_name"] . " <" . $CONFIG["reply_to"] . ">");
  59.     } else {
  60.         $mail->From( $author );
  61.         $mail->ReplyTo( $CONFIG["reply_to"] );
  62.     }
  63.     $mail->To( $recipient );
  64.     if ($cc) {
  65.         $mail->Cc( $cc );
  66.     }
  67.     $mail->Subject( "[#$ticket_parent] " . trim( $subject ) );
  68.     $mail->Body( $followup );
  69.     $mail->Send() || fatal_error("Unable to mail followup.  Quit without recording followup to database.");
  70.  
  71.     /* escape special characters */
  72.     $author = db_escape( $author );
  73.     $recipient = db_escape( $recipient );
  74.     $subject = db_escape( $subject );
  75.     $followup = db_escape( $followup );
  76.     $cc = db_escape( $cc );
  77.  
  78.     /* do database insert */
  79.     $query = "INSERT INTO tickets (author, subject, recipient, body, cc, timestamp, type, assignment, parent) ";
  80.     $query .= "VALUES ('$author','$subject','$recipient','$followup','$cc','$timestamp','Staff Followup','9999','$ticket_parent')";
  81.     do_query($query);
  82.  
  83.     /* update parent activity */
  84.     do_query("UPDATE tickets SET activity = '$timestamp' WHERE ticket = '$ticket_parent'");
  85.  
  86.     /* redirect to parent */
  87.     echo("<META HTTP-EQUIV=\"Refresh\" CONTENT=\"0;URL=index.php?m=ticketsmith&a=view&ticket=$ticket_parent\">");
  88.  
  89.     exit();
  90.  
  91. } else {
  92.  
  93.     /* start table */
  94.     print("<table class=std width=100%>\n");
  95.     print("<tr>\n");
  96.     print("<th colspan=2 align=center>\n");
  97.     print("<div class=heading> ".$AppUI->_($title)."</div>\n");
  98.     print("</th>\n");
  99.     print("</tr>\n");
  100.  
  101.     /* start form */
  102.     print("<form name='ticketform' action=\"index.php?m=ticketsmith&a=followup&ticket=$ticket\" method=post>\n");
  103.  
  104.     /* get ticket */
  105.     $ticket_info = query2hash("SELECT * FROM tickets WHERE ticket = $ticket");
  106.  
  107.     /* output From: line */
  108.     print("<tr>\n");
  109.     print("<td align=left><strong>".$AppUI->_('From')."</strong></td>");
  110.     list($from_name, $from_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'");
  111.     print("<td align=left>" . $from_name . " <" . $from_email . "></td>\n");
  112.     print("</tr>\n");
  113.  
  114.     /* output To: line */
  115.     print("<tr>\n");
  116.     print("<td align=left><strong>".$AppUI->_('To')."</strong></td>");
  117.     $recipient = query2result("SELECT author FROM tickets WHERE ticket = '$ticket_parent'");
  118.     print("<td align=left>" . format_field($recipient, "recipient") . "</td>\n");
  119.     print("</tr>\n");
  120.  
  121.     /* output ticket */
  122.     for ($loop = 0; $loop < count($fields["headings"]); $loop++) {
  123.         print("<tr>\n");
  124.     // do not translate if heading is "<br />"
  125.     if ( $fields["headings"][$loop] == "<br />") {
  126.     }
  127.     else {
  128.         $fields["headings"][$loop] = $AppUI->_($fields["headings"][$loop]);
  129.     }
  130.         print("<td align=left><strong>" . $fields["headings"][$loop] . "</strong></td>");
  131.         print("<td align=left>" . format_field($ticket_info[$fields["columns"][$loop]], $fields["types"][$loop]) . "</td>\n");
  132.         print("</tr>\n");
  133.     }
  134.  
  135.     /* output submit button */
  136.     print('<tr><td><br /></td><td><font size=-1><input class=button type=submit value="'.$AppUI->_('Post Followup').'"></font></td></tr>');
  137.  
  138.     /* output actions */
  139.     print("<tr>\n");
  140.     print("<td align=left valign=top><br /></td>");
  141.     print("<td align=left valign=top> </td>\n");
  142.     print("</tr>\n");
  143.  
  144.     /* end table */
  145.     print("</table>\n");
  146.  
  147.     /* end form */
  148.     print("</form>\n");
  149. }
  150.  
  151. ?>
  152.