* Portions created by vtiger are Copyright (C) vtiger.
 * All Rights Reserved.
 *
 ********************************************************************************/
require_once 'modules/Settings/MailScanner/core/MailScannerInfo.php';
require_once 'modules/Settings/MailScanner/core/MailBox.php';
$scannername = vtlib_purify(trim($_REQUEST['mailboxinfo_scannername']));
if (!empty($scannername) && !validateAlphanumericInput($scannername)) {
    $scannername = '';
}
$server = vtlib_purify(trim($_REQUEST['mailboxinfo_server']));
if (!empty($server) && !validateServerName($server)) {
    $server = '';
}
$username = vtlib_purify(trim($_REQUEST['mailboxinfo_username']));
if (!empty($username) && !validateEmailId($username) && !validateAlphanumericInput($username)) {
    $username = '';
}
$newscannerinfo = new Vtiger_MailScannerInfo(false, false);
$newscannerinfo->scannername = $scannername;
$newscannerinfo->server = $server;
$newscannerinfo->protocol = vtlib_purify(trim($_REQUEST['mailboxinfo_protocol']));
$newscannerinfo->username = $username;
$newscannerinfo->password = vtlib_purify(trim($_REQUEST['mailboxinfo_password']));
$newscannerinfo->ssltype = vtlib_purify(trim($_REQUEST['mailboxinfo_ssltype']));
$newscannerinfo->sslmethod = vtlib_purify(trim($_REQUEST['mailboxinfo_sslmethod']));
$newscannerinfo->searchfor = vtlib_purify(trim($_REQUEST['mailboxinfo_searchfor']));
$newscannerinfo->markas = vtlib_purify(trim($_REQUEST['mailboxinfo_markas']));
$newscannerinfo->isvalid = $_REQUEST['mailboxinfo_enable'] == 'true' ? true : false;
// Rescan all folders on next run?
$rescanfolder = $_REQUEST['mailboxinfo_rescan_folders'] == 'true' ? true : false;
Beispiel #2
0
 /**
  * Function to save this record
  * @return <Boolean> true/false (Saved/Not Saved)
  */
 public function save()
 {
     vimport('~~modules/Settings/MailConverter/handlers/MailScannerInfo.php');
     $scannerLatestInfo = new Vtiger_MailScannerInfo(false, false);
     $fieldsList = $this->getModule()->getFields();
     foreach ($fieldsList as $fieldName => $fieldModel) {
         $scannerLatestInfo->{$fieldName} = $this->get($fieldName);
     }
     $scannerId = $this->getId();
     if (!empty($scannerId)) {
         $scannerLatestInfo->scannerid = $this->getId();
     }
     //Checking Scanner Name
     $scannerName = $this->getName();
     if ($scannerName && !validateAlphanumericInput($scannerName)) {
         return false;
     }
     //Checking Server
     $server = $this->get('server');
     if ($server && !validateServerName($server)) {
         return false;
     }
     $isConnected = true;
     $scannerOldInfo = new Vtiger_MailScannerInfo($this->get('scannerOldName'));
     if (!$scannerOldInfo->compare($scannerLatestInfo)) {
         vimport('~~modules/Settings/MailConverter/handlers/MailBox.php');
         $mailBox = new Vtiger_MailBox($scannerLatestInfo);
         $isConnected = $mailBox->connect();
     }
     if ($isConnected) {
         $scannerLatestInfo->connecturl = $mailBox->_imapurl;
         //$scannerLatestInfo->isvalid = $scannerOldInfo->isvalid = $isConnected;
         if (!empty($scannerId)) {
             $scannerOldInfo->scannerid = $scannerId;
         }
         $mailServerChanged = $scannerOldInfo->update($scannerLatestInfo);
         if (empty($scannerId)) {
             $this->set('scannerid', $scannerOldInfo->scannerid);
         }
         $rescanFolder = false;
         if ($this->get('searchfor') === 'all') {
             $rescanFolder = true;
         }
         $scannerOldInfo->updateAllFolderRescan($rescanFolder);
     }
     return $isConnected;
 }