public function load() { if (!isset($this->args[0])) { exit; } if (!isset($this->args[1])) { exit; } if (!isset($_REQUEST['md_email'])) { exit; } $companyId = intval($this->args[1]); $serviceCompanyParam = $this->secure($this->args[0]); switch ($serviceCompanyParam) { case 'sc': $isServiceCompany = true; break; case 's': $isServiceCompany = false; break; default: exit; } if ($isServiceCompany) { $companyExtendedProfileManager = ServiceCompanyExtendedProfileManager::getInstance($this->config, $this->args); } else { $companyExtendedProfileManager = CompanyExtendedProfileManager::getInstance($this->config, $this->args); } $md_email = $this->secure($_REQUEST['md_email']); $companyExtendedProfileManager->addUnsubscribeEmailForCompany($companyId, $md_email); }
/** * 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 CompanyExtendedProfileManager($config, $args); } return self::$instance; }
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); }
public function service() { $toEmails = strtolower(trim($_REQUEST['to_emails'])); $valid_addresses = EmailSenderManager::getEmailsFromText($toEmails); $uninterestingEmailsManager = UninterestingEmailsManager::getInstance($this->config, $this->args); $valid_addresses = $uninterestingEmailsManager->removeUninterestingEmailsFromList($valid_addresses); //saving valis recipients $companyDto = $this->getCustomer(); if (!$companyDto) { return false; } $companyExtendedProfileManager = CompanyExtendedProfileManager::getInstance($this->config, $this->args); $dto = $companyExtendedProfileManager->getByCompanyId($companyDto->getId()); $dto->setDealerEmails(implode(';', $valid_addresses)); $companyExtendedProfileManager->updateByPK($dto); $jsonArr = array('status' => "ok", "valid_email_addresses" => implode(';', $valid_addresses)); echo json_encode($jsonArr); return true; }
public function service() { $saveOnly = $_REQUEST['save_only']; $subject = $_REQUEST['subject']; $body = $_REQUEST['body']; $fromEmail = $_REQUEST['from_email']; $to = strtolower(trim($_REQUEST['to'])); $isServiceCompany = $this->getUserLevel() == UserGroups::$SERVICE_COMPANY; if ($isServiceCompany) { $this->extendedProfileManager = ServiceCompanyExtendedProfileManager::getInstance($this->config, $this->args); } else { $this->extendedProfileManager = CompanyExtendedProfileManager::getInstance($this->config, $this->args); } $companyId = $this->getUserId(); $dto = $this->extendedProfileManager->getByCompanyId($companyId); if (!isset($dto)) { $this->error(array('message' => 'System Error!!!')); } $dto->setPriceEmailSubject($subject); $dto->setPriceEmailBody(addslashes($body)); $dto->setFromEmail($fromEmail); $valid_addresses = EmailSenderManager::getEmailsFromText($to); $dto->setDealerEmails(implode(';', $valid_addresses)); $this->extendedProfileManager->updateByPK($dto, false); if ($saveOnly != 1) { $company_price_email_interval_hours = intval($this->getCmsVar('company_price_email_interval_hours')); $allowSend = $this->canCompanySendPriceEmail($companyId, $isServiceCompany ? "service_company" : "company", $company_price_email_interval_hours, $valid_addresses); if ($allowSend) { $res = $this->sendEmailToDealersEmails($dto); if ($res !== true) { $this->error(array('message' => $res)); } } else { $this->error(array('message' => '`645` ' . $company_price_email_interval_hours . ' `646`')); } } $this->ok(); }