From f8537a645411023a56eae68b47a52665354c7945 Mon Sep 17 00:00:00 2001 From: Quitta Date: Sun, 18 Aug 2013 02:17:02 +0200 Subject: [PATCH] response is being sent from the correct support group atm --- .../ams_lib/autoload/mail_handler.php | 105 +++--------------- .../ryzom_ams/ams_lib/autoload/ticket.php | 16 ++- .../ryzom_ams/www/html/autoload/webusers.php | 2 - 3 files changed, 28 insertions(+), 95 deletions(-) diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/mail_handler.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/mail_handler.php index baa0a852f..b65e04c70 100644 --- a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/mail_handler.php +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/mail_handler.php @@ -12,30 +12,29 @@ class Mail_Handler{ } - public static function send_ticketing_mail($ticketObj, $content, $type, $author) { + public static function send_ticketing_mail($ticketObj, $content, $type, $sendingGroupId = 0) { global $TICKET_MAILING_SUPPORT; if($TICKET_MAILING_SUPPORT){ - $txt = ""; - $subject = ""; + //$txt = ""; + //$subject = ""; + if($sendingGroupId == 0){ + //if it is not forwarded (==public == which returns 0) then make it NULL which is needed to be placed in the DB. + $sendingGroupId = NULL; + } if($type == "REPLY"){ $txt = "---------- Ticket #". $ticketObj->getTId() . " ----------\n You received a new reply on your ticket: " . $ticketObj->getTitle() . "\n --------------------\n\n"; $subject = "New reply on [Ticket #" . $ticketObj->getTId() ."]"; $endTxt = "\n\n----------\nYou can reply on this message to answer directly on the ticket!"; $txt = $txt . $content . $endTxt; - self::send_mail($ticketObj->getAuthor(),$subject,$txt, $ticketObj->getTId(),$author); + self::send_mail($ticketObj->getAuthor(),$subject,$txt, $ticketObj->getTId(),$sendingGroupId); }else if($type == "NEW"){ $txt = "---------- Ticket #". $ticketObj->getTId() . " ----------\n Your ticket: " . $ticketObj->getTitle() . " is newly created"; - if($ticketObj->getAuthor() != $author){ - $txt = $txt . " by " . Ticket_User::get_username_from_id($author); - }else{ - $author = $ticketObj->getAuthor(); - } $txt = $txt . "\n --------------------\n\n"; $subject = "New ticket created [Ticket #" . $ticketObj->getTId() ."]"; $endTxt = "\n\n----------\nYou can reply on this message to answer directly on the ticket!"; $txt = $txt . $content . $endTxt; - self::send_mail($ticketObj->getAuthor(),$subject,$txt, $ticketObj->getTId()); + self::send_mail($ticketObj->getAuthor(),$subject,$txt, $ticketObj->getTId(), $sendingGroupId); } } @@ -62,8 +61,8 @@ class Mail_Handler{ $default_groupname = $cfg['mail']['default_groupname']; /* $inbox_host = $cfg['mail']['host']; - $oms_reply_to = "Ryzom Ticketing Support "; - global $MAIL_DIR;*/ + $oms_reply_to = "Ryzom Ticketing Support ";*/ + global $MAIL_DIR; // Deliver new mail @@ -154,7 +153,7 @@ class Mail_Handler{ if($tid) { //TODO: base file on Ticket + timestamp $file = fopen($MAIL_DIR."/mail/ticket".$tid.".".time(), 'w'); - fwrite($file, $entire_email); + fwrite($file, imap_fetchheader($mbox, $i) . imap_body($mbox, $i)); fclose($file); //mark message $i of $mbox for deletion! @@ -255,7 +254,7 @@ class Mail_Handler{ } } - print("\n Email found that is a reply to a ticket!\n"); + print("\n Email found that is a reply to a ticket at:".$group->getGroupEmail()); return $ticket_id; }else if($from != "FALSE"){ @@ -263,91 +262,21 @@ class Mail_Handler{ //if ticket_id isn't found, create a new ticket! //if an existing email address mailed the ticket - $newTicketId = Ticket::create_Ticket($subject, $txt,1, $from, $from); + //if not default group, then forward it by giving the $group->getSGroupId's param + $newTicketId = Ticket::create_Ticket($subject, $txt,1, $from, $from, $group->getSGroupId()); - //if not default group, then forward it! - if($group->getSGroupId()){ - Ticket::forwardTicket(0, $newTicketId, $group->getSGroupId()); - } - print("\n Email found that is a new ticket!\n"); + print("\n Email regarding new ticket found at:".$group->getGroupEmail()); return $newTicketId; }else{ //if it's a email that has nothing to do with ticketing, return 0; - print("\n Email found that isn't a reply or new ticket!\n"); + print("\n Email found that isn't a reply or new ticket, at:".$group->getGroupEmail()); return 0; } } - /*function ams_create_email($from, $subject, $body, $html, $recipient = 0, $sender = NULL) { - - //TODO: - if($recipient == 0 && !is_string($recipient)) { - global $user; - $recipient = $user->uid; - } - - if($sender !== NULL && !is_numeric($sender)) $sender = self::get_id_from_username($sender); - if(!is_numeric($recipient)) $recipient = self::get_id_from_username($recipient); - - $message = array( - 'creator' => $sender, - 'owner' => $recipient, - 'type' => 'email', - 'summary' => $subject, - 'data' => array ( - 'subject' => $subject, - 'body' => $body, - 'html' => $html, - 'sender' => oms_get_username_from_id($sender), - 'from' => $from, - 'recipient' => oms_get_username_from_id($recipient), - 'time' => time(), - ), - ); - - //TO ASK: - oms_task_create($message); - oms_task_index($message, array('subject', 'body', 'sender', 'recipient')); - //--------------------------- - return $message['id_task']; - }*/ - - - - /*function oms_get_email($id) { - - $message = oms_task_load($id); - if($message) { - oms_prepare_email($message); - return $message; - } else { - return FALSE; - } - - }*/ - - - - /*function oms_prepare_email(&$message) { - - $data = $message['data']; - $data['id_message'] = $message['id_task']; - $data['read'] = ($message['status'] != 'NEW' && $message['status'] != 'UNREAD'); - $message = $data; - - }*/ - - - - /*function oms_email_mark_read($mid) { - - db_exec("update task set status = 'READ' where id_task = ? and type = 'email' and module = 'email'", array($mid)); - - }*/ - function decode_utf8($str) { diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket.php index cba0d1211..db03aab97 100644 --- a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket.php +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket.php @@ -81,9 +81,9 @@ class Ticket{ /*FUNCTION: create_Ticket() * creates a ticket + first initial reply and fills in the content of it! - * + * for_support_group defines to which support group the ticket has to be forwarded */ - public static function create_Ticket( $title, $content, $category, $author, $real_author) { + public static function create_Ticket( $title, $content, $category, $author, $real_author, $for_support_group = 0) { $ticket = new Ticket(); $values = array("Title" => $title, "Status"=> 1, "Queue"=> 0, "Ticket_Category" => $category, "Author" => $author, "Priority" => 0); @@ -96,8 +96,14 @@ class Ticket{ }else{ Ticket_Log::createLogEntry( $ticket_id, $real_author, 2, $author); } - Ticket_Reply::createReply($content, $author, $ticket_id, 0, $author); - Mail_Handler::send_ticketing_mail($ticket, $content, "NEW", $real_author); + Ticket_Reply::createReply($content, $author, $ticket_id, 0, $author); + + //send email that new ticket has been created + if($for_support_group){ + Ticket::forwardTicket(0, $ticket_id, $for_support_group); + } + + Mail_Handler::send_ticketing_mail($ticket, $content, "NEW", $real_author, $ticket->getForwardedGroupId()); return $ticket_id; } @@ -160,7 +166,7 @@ class Ticket{ //notify ticket author that a new reply is added! if($ticket->getAuthor() != $author){ - Mail_Handler::send_ticketing_mail($ticket, $content, "REPLY", $author); + Mail_Handler::send_ticketing_mail($ticket, $content, "REPLY", $ticket->getForwardedGroupId()); } diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/autoload/webusers.php b/code/ryzom/tools/server/ryzom_ams/www/html/autoload/webusers.php index 88c9cc062..3f49e5e88 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/autoload/webusers.php +++ b/code/ryzom/tools/server/ryzom_ams/www/html/autoload/webusers.php @@ -82,8 +82,6 @@ class WebUsers extends Users{ $statement = $dbw->execute("SELECT * FROM ams_user WHERE Email=:email", array('email' => $email)); $row = $statement->fetch(); if(!empty($row)){ - print "shouldn't be here!" . $row . "seee"; - return $row['UId']; }else{ return "FALSE";