Skip to content
Snippets Groups Projects
Commit 85aada1f authored by Peter Rotich's avatar Peter Rotich
Browse files

Merge remote-tracking branch 'origin/develop' into develop

parents 24b9264e be043dd4
No related branches found
No related tags found
No related merge requests found
......@@ -313,7 +313,7 @@ class Config {
}
function canFetchMail() {
return ($this->config['enable_mail_fetch']);
return ($this->config['enable_mail_polling']);
}
function enableStaffIPBinding() {
......
......@@ -346,7 +346,7 @@ class MailFetcher {
}
function fetchTickets($emailid,$max=20,$deletemsgs=false){
function fetchTickets($emailid,$max=20,$deletemsgs=false,$archivefolder){
$nummsgs=imap_num_msg($this->mbox);
//echo "New Emails: $nummsgs\n";
......@@ -354,7 +354,7 @@ class MailFetcher {
for($i=$nummsgs; $i>0; $i--){ //process messages in reverse. Latest first. FILO.
if($this->createTicket($i,$emailid)){
imap_setflag_full($this->mbox, imap_uid($this->mbox,$i), "\\Seen", ST_UID); //IMAP only??
if($deletemsgs)
if((!$archivefolder || !imap_mail_move($this->mbox,$i,$archivefolder)) && $deletemsgs)
imap_delete($this->mbox,$i);
$msgs++;
$errors=0; //We are only interested in consecutive errors.
......@@ -384,7 +384,7 @@ class MailFetcher {
$MAX_ERRORS=5; //Max errors before we start delayed fetch attempts - hardcoded for now.
$sql=' SELECT email_id,mail_host,mail_port,mail_protocol,mail_encryption,mail_delete,mail_errors,userid,userpass FROM '.EMAIL_TABLE.
$sql=' SELECT email_id,mail_host,mail_port,mail_protocol,mail_encryption,mail_delete,mail_archivefolder,mail_errors,userid,userpass FROM '.EMAIL_TABLE.
' WHERE mail_active=1 AND (mail_errors<='.$MAX_ERRORS.' OR (TIME_TO_SEC(TIMEDIFF(NOW(),mail_lasterror))>5*60) )'.
' AND (mail_lastfetch IS NULL OR TIME_TO_SEC(TIMEDIFF(NOW(),mail_lastfetch))>mail_fetchfreq*60) ';
//echo $sql;
......@@ -396,7 +396,7 @@ class MailFetcher {
$fetcher = new MailFetcher($row['userid'],Misc::decrypt($row['userpass'],SECRET_SALT),
$row['mail_host'],$row['mail_port'],$row['mail_protocol'],$row['mail_encryption']);
if($fetcher->connect()){
$fetcher->fetchTickets($row['email_id'],$row['mail_fetchmax'],$row['mail_delete']?true:false);
$fetcher->fetchTickets($row['email_id'],$row['mail_fetchmax'],$row['mail_delete']?true:false,$row['mail_archivefolder']);
$fetcher->close();
db_query('UPDATE '.EMAIL_TABLE.' SET mail_errors=0, mail_lastfetch=NOW() WHERE email_id='.db_input($row['email_id']));
}else{
......
......@@ -1310,7 +1310,7 @@ class Ticket{
if ($emsgid !== null) {
$sql='INSERT INTO '.TICKET_EMAIL_INFO_TABLE
.' SET msg_id='.db_input($msgid)
.' SET message_id='.db_input($msgid)
.', email_mid='.db_input($emsgid)
.', headers='.db_input($headers);
......@@ -1719,7 +1719,7 @@ class Ticket{
return 0;
$sql='SELECT ticket.ticket_id FROM '.TICKET_TABLE. ' ticket '.
' LEFT JOIN '.TICKE_THREAD_TABLE.' msg USING(ticket_id) '.
' LEFT JOIN '.TICKET_THREAD_TABLE.' msg USING(ticket_id) '.
' INNER JOIN '.TICKET_EMAIL_INFO_TABLE.' emsg ON (msg.id = emsg.message_id) '.
' WHERE email_mid='.db_input($mid).' AND email='.db_input($email);
$id=0;
......
......@@ -141,6 +141,7 @@
define('PRIORITY_TABLE',TICKET_PRIORITY_TABLE);
define('TICKET_LOCK_TABLE',TABLE_PREFIX.'ticket_lock');
define('TICKET_EVENT_TABLE',TABLE_PREFIX.'ticket_event');
define('TICKET_EMAIL_INFO_TABLE',TABLE_PREFIX.'ticket_email_info');
define('EMAIL_TABLE',TABLE_PREFIX.'email');
define('EMAIL_TEMPLATE_TABLE',TABLE_PREFIX.'email_template');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment