本文整理汇总了PHP中Ticket_User::get_id_from_email方法的典型用法代码示例。如果您正苦于以下问题:PHP Ticket_User::get_id_from_email方法的具体用法?PHP Ticket_User::get_id_from_email怎么用?PHP Ticket_User::get_id_from_email使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ticket_User
的用法示例。
在下文中一共展示了Ticket_User::get_id_from_email方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: incoming_mail_handler
/**
* Handles an incomming email
* Read the content of one email by using imap's functionality. If a ticket id is found inside the message_id or else in the subject line, then a reply will be added
* (if the email is not being sent from the authors email address it won't be added though and a warning will be sent to both parties). If no ticket id is found, then a new
* ticket will be created.
* @param $mbox a mailbox object
* @param $i the email's id in the mailbox (integer)
* @param $group the group object that owns the inbox.
* @return a string based on the found ticket i and timestamp (will be used to store a copy of the email locally)
*/
function incoming_mail_handler($mbox, $i, $group)
{
global $MAIL_LOG_PATH;
$header = imap_header($mbox, $i);
$subject = self::decode_utf8($header->subject);
$entire_email = imap_fetchheader($mbox, $i) . imap_body($mbox, $i);
$subject = self::decode_utf8($header->subject);
$to = $header->to[0]->mailbox;
$from = $header->from[0]->mailbox . '@' . $header->from[0]->host;
$fromEmail = $header->from[0]->mailbox . '@' . $header->from[0]->host;
$txt = self::get_part($mbox, $i, "TEXT/PLAIN");
//$html = self::get_part($mbox, $i, "TEXT/HTML");
//get the id out of the email address of the person sending the email.
if ($from !== NULL && !is_numeric($from)) {
$from = Ticket_User::get_id_from_email($from);
}
//get ticket_id out of the message-id or else out of the subject line
$ticket_id = 0;
if (isset($header->references)) {
$pieces = explode(".", $header->references);
if ($pieces[0] == "<ams") {
$ticket_id = $pieces[2];
} else {
$ticket_id = self::get_ticket_id_from_subject($subject);
}
} else {
$ticket_id = self::get_ticket_id_from_subject($subject);
}
//if ticket id is found, that means it is a reply on an existing ticket
if ($ticket_id && is_numeric($ticket_id) && $ticket_id > 0) {
$ticket = new Ticket();
$ticket->load_With_TId($ticket_id);
//if email is sent from an existing email address in the db (else it will give an error while loading the user object)
if ($from != "FALSE") {
$user = new Ticket_User();
$user->load_With_TUserId($from);
//if user has access to it!
if ((Ticket_User::isMod($user) or $ticket->getAuthor() == $user->getTUserId()) and $txt != "") {
Ticket::createReply($txt, $user->getTUserId(), $ticket->getTId(), 0);
error_log("Email found that is a reply to a ticket at:" . $group->getGroupEmail() . "\n", 3, $MAIL_LOG_PATH);
} else {
//if user has no access to it
//Warn real ticket owner + person that send the mail
Mail_Handler::send_ticketing_mail($ticket->getAuthor(), $ticket, NULL, "WARNAUTHOR", $from);
Mail_Handler::send_ticketing_mail($from, $ticket, NULL, "WARNSENDER", NULL);
error_log("Email found that was a reply to a ticket, though send by another user to " . $group->getGroupEmail() . "\n", 3, $MAIL_LOG_PATH);
}
} else {
//if a reply to a ticket is being sent by a non-user!
//Warn real ticket owner + person that send the mail
Mail_Handler::send_ticketing_mail($ticket->getAuthor(), $ticket, NULL, "WARNAUTHOR", $fromEmail);
Mail_Handler::send_ticketing_mail($fromEmail, $ticket, NULL, "WARNUNKNOWNSENDER", NULL);
error_log("Email found that was a reply to a ticket, though send by an unknown email address to " . $group->getGroupEmail() . "\n", 3, $MAIL_LOG_PATH);
}
return $ticket_id . "." . time();
} else {
if ($from != "FALSE") {
//if ticket_id isn't found, create a new ticket!
//if an existing email address mailed the ticket
//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());
error_log("Email regarding new ticket found at:" . $group->getGroupEmail() . "\n", 3, $MAIL_LOG_PATH);
return $newTicketId . "." . time();
} else {
//if it's a email that has nothing to do with ticketing, return 0;
error_log("Email found that isn't a reply or new ticket, at:" . $group->getGroupEmail() . "\n", 3, $MAIL_LOG_PATH);
return 0;
}
}
}