[-] BO : Customer Service options/sync mailbox not working - #PSFV-539
This commit is contained in:
+26
-7
@@ -637,16 +637,35 @@ if (Tools::isSubmit('updateElementEmployee') && Tools::getValue('updateElementEm
|
|||||||
|
|
||||||
if (Tools::isSubmit('syncImapMail'))
|
if (Tools::isSubmit('syncImapMail'))
|
||||||
{
|
{
|
||||||
if (!$url = Configuration::get('PS_SAV_IMAP_URL')
|
if (!($url = Configuration::get('PS_SAV_IMAP_URL'))
|
||||||
|| !$port = Configuration::get('PS_SAV_IMAP_PORT')
|
|| !($port = Configuration::get('PS_SAV_IMAP_PORT'))
|
||||||
|| !$user = Configuration::get('PS_SAV_IMAP_USER')
|
|| !($user = Configuration::get('PS_SAV_IMAP_USER'))
|
||||||
|| !$password = Configuration::get('PS_SAV_IMAP_PWD'))
|
|| !($password = Configuration::get('PS_SAV_IMAP_PWD')))
|
||||||
die('{"hasError" : true, "errors" : ["Configuration is not correct"]}');
|
die('{"hasError" : true, "errors" : ["Configuration is not correct"]}');
|
||||||
|
|
||||||
|
$conf = Configuration::getMultiple(array(
|
||||||
|
'PS_SAV_IMAP_OPT_NORSH', 'PS_SAV_IMAP_OPT_SSL',
|
||||||
|
'PS_SAV_IMAP_OPT_VALIDATE-CERT', 'PS_SAV_IMAP_OPT_NOVALIDATE-CERT',
|
||||||
|
'PS_SAV_IMAP_OPT_TLS', 'PS_SAV_IMAP_OPT_NOTLS'));
|
||||||
|
|
||||||
|
$conf_str = '';
|
||||||
|
if ($conf['PS_SAV_IMAP_OPT_NORSH'])
|
||||||
|
$conf_str .= '/norsh';
|
||||||
|
if ($conf['PS_SAV_IMAP_OPT_SSL'])
|
||||||
|
$conf_str .= '/ssl';
|
||||||
|
if ($conf['PS_SAV_IMAP_OPT_VALIDATE-CERT'])
|
||||||
|
$conf_str .= '/validate-cert';
|
||||||
|
if ($conf['PS_SAV_IMAP_OPT_NOVALIDATE-CERT'])
|
||||||
|
$conf_str .= '/novalidate-cert';
|
||||||
|
if ($conf['PS_SAV_IMAP_OPT_TLS'])
|
||||||
|
$conf_str .= '/tls';
|
||||||
|
if ($conf['PS_SAV_IMAP_OPT_NOTLS'])
|
||||||
|
$conf_str .= '/notls';
|
||||||
|
|
||||||
if (!function_exists('imap_open'))
|
if (!function_exists('imap_open'))
|
||||||
die('{"hasError" : true, "errors" : ["imap is not installed on this server"]}');
|
die('{"hasError" : true, "errors" : ["imap is not installed on this server"]}');
|
||||||
|
|
||||||
$mbox = @imap_open('{'.$url.':'.$port.(Configuration::get('PS_SAV_IMAP_OPT') ? Configuration::get('PS_SAV_IMAP_OPT') : '').'}', $user, $password);
|
$mbox = @imap_open('{'.$url.':'.$port.$conf_str.'}', $user, $password);
|
||||||
|
|
||||||
//checks if there is no error when connecting imap server
|
//checks if there is no error when connecting imap server
|
||||||
$errors = imap_errors();
|
$errors = imap_errors();
|
||||||
@@ -666,7 +685,7 @@ if (Tools::isSubmit('syncImapMail'))
|
|||||||
|
|
||||||
//Returns information about the current mailbox. Returns FALSE on failure.
|
//Returns information about the current mailbox. Returns FALSE on failure.
|
||||||
$check = imap_check($mbox);
|
$check = imap_check($mbox);
|
||||||
if ($check)
|
if (!$check)
|
||||||
die('{"hasError" : true, "errors" : ["Fail to get information about the current mailbox"]}');
|
die('{"hasError" : true, "errors" : ["Fail to get information about the current mailbox"]}');
|
||||||
|
|
||||||
if ($check->Nmsgs == 0)
|
if ($check->Nmsgs == 0)
|
||||||
@@ -717,7 +736,7 @@ if (Tools::isSubmit('syncImapMail'))
|
|||||||
}
|
}
|
||||||
imap_expunge($mbox);
|
imap_expunge($mbox);
|
||||||
imap_close($mbox);
|
imap_close($mbox);
|
||||||
die('{"hasError" : false, "errors" : '.$str_errors.$str_errors_delete.'"]}');
|
die('{"hasError" : false, "errors" : ["'.$str_errors.$str_error_delete.'"]}');
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Modify attribute position */
|
/* Modify attribute position */
|
||||||
|
|||||||
@@ -161,28 +161,48 @@ class AdminCustomerThreadsControllerCore extends AdminController
|
|||||||
'size' => 40,
|
'size' => 40,
|
||||||
'visibility' => Shop::CONTEXT_ALL,
|
'visibility' => Shop::CONTEXT_ALL,
|
||||||
),
|
),
|
||||||
'PS_SAV_IMAP_OPT' => array(
|
|
||||||
'title' => $this->l('Imap option'),
|
|
||||||
'type' => 'select',
|
|
||||||
'select_multiple' => true,
|
|
||||||
'size' => 6,
|
|
||||||
'visibility' => Shop::CONTEXT_ALL,
|
|
||||||
'identifier' => 'value',
|
|
||||||
'list' => array(
|
|
||||||
'0' => array('value' => '/norsh', 'name' => $this->l('Do not use rsh or ssh to establish a preauthenticated IMAP session').' /norsh'),
|
|
||||||
'1' => array('value' => '/ssl', 'name' => $this->l('Use the Secure Socket Layer to encrypt the session').' /ssl '),
|
|
||||||
'2' => array('value' => '/validate-cert', 'name' => $this->l('Validate certificates from TLS/SSL server').' /validate-cert'),
|
|
||||||
'3' => array('value' => '/novalidate-cert', 'name' => $this->l('Do not validate certificates from TLS/SSL server, needed if server uses self-signed certificates').' /novalidate-cert'),
|
|
||||||
'4' => array('value' => '/tls', 'name' => $this->l('Force use of start-TLS to encrypt the session, and reject connection to servers that do not support it').' /tls'),
|
|
||||||
'5' => array('value' => '/notls', 'name' => $this->l('do not do start-TLS to encrypt the session, even with servers that support it').' /notls')
|
|
||||||
),
|
|
||||||
),
|
|
||||||
'PS_SAV_IMAP_DELETE_MSG' => array(
|
'PS_SAV_IMAP_DELETE_MSG' => array(
|
||||||
'title' => $this->l('Deletes messages'),
|
'title' => $this->l('Deletes messages'),
|
||||||
'desc' => $this->l('Deletes message after sync. If you do not active this option, the sync will be longer'),
|
'desc' => $this->l('Deletes message after sync. If you do not active this option, the sync will be longer'),
|
||||||
'type' => 'bool',
|
'type' => 'bool',
|
||||||
'visibility' => Shop::CONTEXT_ALL,
|
'visibility' => Shop::CONTEXT_ALL,
|
||||||
)
|
),
|
||||||
|
'PS_SAV_IMAP_OPT_NORSH' => array(
|
||||||
|
'title' => $this->l('Imap option').' (/norsh)',
|
||||||
|
'type' => 'bool',
|
||||||
|
'desc' => $this->l('Do not use rsh or ssh to establish a preauthenticated IMAP session'),
|
||||||
|
'visibility' => Shop::CONTEXT_ALL,
|
||||||
|
),
|
||||||
|
'PS_SAV_IMAP_OPT_SSL' => array(
|
||||||
|
'title' => $this->l('Imap option').' (/ssl)',
|
||||||
|
'type' => 'bool',
|
||||||
|
'desc' => $this->l('Use the Secure Socket Layer to encrypt the session'),
|
||||||
|
'visibility' => Shop::CONTEXT_ALL,
|
||||||
|
),
|
||||||
|
'PS_SAV_IMAP_OPT_VALIDATE-CERT' => array(
|
||||||
|
'title' => $this->l('Imap option').' (/validate-cert)',
|
||||||
|
'type' => 'bool',
|
||||||
|
'desc' => $this->l('Validate certificates from TLS/SSL server'),
|
||||||
|
'visibility' => Shop::CONTEXT_ALL,
|
||||||
|
),
|
||||||
|
'PS_SAV_IMAP_OPT_NOVALIDATE-CERT' => array(
|
||||||
|
'title' => $this->l('Imap option').' (/novalidate-cert)',
|
||||||
|
'type' => 'bool',
|
||||||
|
'desc' => $this->l('Do not validate certificates from TLS/SSL server, needed if server uses self-signed certificates'),
|
||||||
|
'visibility' => Shop::CONTEXT_ALL,
|
||||||
|
),
|
||||||
|
'PS_SAV_IMAP_OPT_TLS' => array(
|
||||||
|
'title' => $this->l('Imap option').' (/tls)',
|
||||||
|
'type' => 'bool',
|
||||||
|
'desc' => $this->l('Force use of start-TLS to encrypt the session, and reject connection to servers that do not support it'),
|
||||||
|
'visibility' => Shop::CONTEXT_ALL,
|
||||||
|
),
|
||||||
|
'PS_SAV_IMAP_OPT_NOTLS' => array(
|
||||||
|
'title' => $this->l('Imap option').' (/notls)',
|
||||||
|
'type' => 'bool',
|
||||||
|
'desc' => $this->l('do not do start-TLS to encrypt the session, even with servers that support it'),
|
||||||
|
'visibility' => Shop::CONTEXT_ALL,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
'submit' => array('title' => $this->l('Save'), 'class' => 'button'),
|
'submit' => array('title' => $this->l('Save'), 'class' => 'button'),
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user