From 7c32cb2aa1df51c30646b5a7c7041d263a5206cb Mon Sep 17 00:00:00 2001 From: Quitta Date: Sat, 17 Aug 2013 19:07:00 +0200 Subject: [PATCH] made 3 options for incomming mail: reply on ticket, new ticket and nothing related to that. When it's nothing related to that the mail will stay in the mailbox untill it get's manually read and deleted! --- .../ams_lib/autoload/mail_handler.php | 44 +++++++++++-------- .../tools/server/ryzom_ams/www/config.php | 2 +- .../ryzom_ams/www/html/autoload/webusers.php | 4 +- 3 files changed, 30 insertions(+), 20 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 ff629e9ee..baa0a852f 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 @@ -149,17 +149,18 @@ class Mail_Handler{ for ($i = 1; $i <= $message_count; ++$i) { //return task ID - self::incoming_mail_handler($mbox, $i,$group); - $tid = 1; //self::ams_create_email($from, $subject, $txt, $html, $to, $from); + $tid = self::incoming_mail_handler($mbox, $i,$group); if($tid) { - //TODO: base file on Ticket + reply id - /* $file = fopen($MAIL_DIR."/mail/".$tid, 'w'); + //TODO: base file on Ticket + timestamp + $file = fopen($MAIL_DIR."/mail/ticket".$tid.".".time(), 'w'); fwrite($file, $entire_email); - fclose($file); */ + fclose($file); + + //mark message $i of $mbox for deletion! + imap_delete($mbox, $i); } - //mark message $i of $mbox for deletion! - imap_delete($mbox, $i); + } //delete marked messages imap_expunge($mbox); @@ -252,23 +253,30 @@ class Mail_Handler{ if((Ticket_User::isMod($user) or ($ticket->getAuthor() == $user->getTUserId())) and $txt != ""){ Ticket::createReply($txt, $user->getTUserId(), $ticket->getTId(), 0); } + } + print("\n Email found that is a reply to a ticket!\n"); + return $ticket_id; - }else{ + }else if($from != "FALSE"){ //if ticket_id isn't found, create a new ticket! - //if an existing email address mailed the ticket - if($from != "FALSE"){ - - $newTicketId = Ticket::create_Ticket($subject, $txt,1, $from, $from); - - //if not default group, then forward it! - if($group->getSGroupId()){ - Ticket::forwardTicket(0, $newTicketId, $group->getSGroupId()); - } - } + $newTicketId = Ticket::create_Ticket($subject, $txt,1, $from, $from); + + //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"); + 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"); + return 0; } } diff --git a/code/ryzom/tools/server/ryzom_ams/www/config.php b/code/ryzom/tools/server/ryzom_ams/www/config.php index 8cac58fe0..247b2a961 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/config.php +++ b/code/ryzom/tools/server/ryzom_ams/www/config.php @@ -42,7 +42,7 @@ $cfg['db']['ring']['pass'] = ''; // To connect to a remote server replace "localhost" with the name or the IP address of the server you want to connect to. //$cfg['mail']['server'] = '{localhost:110/pop3/novalidate-cert}INBOX'; $cfg['mail']['default_mailserver']= '{imap.gmail.com:993/imap/ssl}INBOX'; -$cfg['mail']['default_groupemail'] = 'support@ryzomcore.com'; +$cfg['mail']['default_groupemail'] = 'amsryzom@gmail.com'; $cfg['mail']['default_groupname'] = 'Ryzomcore Support'; $cfg['mail']['default_username'] = 'amsryzom@gmail.com'; $cfg['mail']['default_password'] = 'lol123bol'; 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 58856a5ce..88c9cc062 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 @@ -81,7 +81,9 @@ class WebUsers extends Users{ $dbw = new DBLayer("web"); $statement = $dbw->execute("SELECT * FROM ams_user WHERE Email=:email", array('email' => $email)); $row = $statement->fetch(); - if($row !== "FALSE"){ + if(!empty($row)){ + print "shouldn't be here!" . $row . "seee"; + return $row['UId']; }else{ return "FALSE";