/**
  * Returns an singleton instance of this class
  *
  * @param object $config
  * @param object $args
  * @return
  */
 public static function getInstance($config, $args)
 {
     if (self::$instance == null) {
         self::$instance = new EmailServersManager($config, $args);
     }
     return self::$instance;
 }
예제 #2
0
 private function initPHPMailer($server)
 {
     $this->mail = new PHPMailer(true);
     $this->mail->IsSMTP();
     try {
         // enables SMTP debug information (for testing)
         $this->mail->SMTPAuth = true;
         // enable SMTP authentication
         // sets the prefix to the servier
         $emailServersManager = EmailServersManager::getInstance(null, null);
         $emailServerDto = $emailServersManager->getByName($server);
         if (isset($emailServerDto)) {
             $this->mail->SMTPSecure = $emailServerDto->getSmtpAuth();
             $this->mail->Host = $emailServerDto->getSmtpHost();
             $this->mail->Port = intval($emailServerDto->getSmtpPort());
             $this->dayMaxSendingLimit = intval($emailServerDto->getDayMaxSendingLimit());
         }
         $this->mail->IsHTML(true);
         $this->mail->CharSet = 'UTF-8';
     } catch (phpmailerException $e) {
         return $e->errorMessage();
     } catch (Exception $e) {
         return $e->getMessage();
     }
     return true;
 }
예제 #3
0
 public function load()
 {
     $userLevel = $this->sessionManager->getUser()->getLevel();
     $companiesPriceListManager = CompaniesPriceListManager::getInstance($this->config, $this->args);
     $companyManager = CompanyManager::getInstance($this->config, $this->args);
     if ($userLevel === UserGroups::$COMPANY) {
         $companyId = $this->getUserId();
         $selectedCompanyId = $companyId;
         $companyExtendedProfileManager = CompanyExtendedProfileManager::getInstance($this->config, $this->args);
         $dto = $companyExtendedProfileManager->getByCompanyId($companyId);
         if (!isset($dto)) {
             $companyExtendedProfileManager->createDefaultExCompanyProfile($companyId);
         }
         $dto = $companyExtendedProfileManager->getByCompanyId($companyId);
         list($companyEmailServerLogins, $companyEmailServersEmailsCount) = $this->getCompanyEmailServerLogins($dto);
         $this->addParam("companyEmailServerLogins", $companyEmailServerLogins);
         $this->addParam("companyEmailServersEmailsCount", $companyEmailServersEmailsCount);
         $this->addParam("companyExProfileDto", $dto);
         $dealerEmails = trim($dto->getDealerEmails());
         $this->addParam("total_price_email_recipients_count", empty($dealerEmails) ? 0 : count(explode(';', $dealerEmails)));
         array_map('unlink', glob(HTDOCS_TMP_DIR_ATTACHMENTS . "/companies/" . $companyId . "/*"));
     } else {
         if ($userLevel === UserGroups::$ADMIN) {
             $allCompanies = $companyManager->getAllCompanies(true, true);
             $companiesIds = $companyManager->getCompaniesIdsArray($allCompanies);
             $companiesNames = $companyManager->getCompaniesNamesArray($allCompanies);
             if (isset($_REQUEST['selected_company'])) {
                 $selectedCompanyId = $this->secure($_REQUEST['selected_company']);
             } else {
                 $selectedCompanyId = $allCompanies[0]->getId();
             }
             $this->addParam("companiesIds", $companiesIds);
             $this->addParam("companiesNames", $companiesNames);
         }
     }
     $companyPrices = $companiesPriceListManager->getCompanyHistoryPricesOrderByDate($selectedCompanyId, 0, 50);
     $this->addParam("company_prices", $companyPrices);
     $this->addParam("selectedCompanyId", $selectedCompanyId);
     if (isset($_REQUEST['show_send_email_to_dealers']) && $_REQUEST['show_send_email_to_dealers'] == 1) {
         $this->addParam("show_send_email_to_dealers", 1);
     }
     $emailServersManager = EmailServersManager::getInstance($this->config, $this->args);
     $allEmailServers = $emailServersManager->selectAll();
     $this->addParam("allEmailServers", $allEmailServers);
 }