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); }
public function load() { $userLevel = $this->sessionManager->getUser()->getLevel(); $serviceCompaniesPriceListManager = ServiceCompaniesPriceListManager::getInstance($this->config, $this->args); $serviceCompanyManager = ServiceCompanyManager::getInstance($this->config, $this->args); if ($userLevel === UserGroups::$SERVICE_COMPANY) { $serviceCompanyId = $this->getUserId(); $selectedCompanyId = $serviceCompanyId; $serviceCompanyExtendedProfileManager = ServiceCompanyExtendedProfileManager::getInstance($this->config, $this->args); $dto = $serviceCompanyExtendedProfileManager->getByCompanyId($serviceCompanyId); if (!isset($dto)) { $serviceCompanyExtendedProfileManager->createDefaultExCompanyProfile($serviceCompanyId); } $dto = $serviceCompanyExtendedProfileManager->getByCompanyId($serviceCompanyId); 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 . "/service_companies/" . $serviceCompanyId . "/*")); } else { if ($userLevel === UserGroups::$ADMIN) { $allCompanies = $serviceCompanyManager->selectAll(); $companiesIds = $serviceCompanyManager->getCompaniesIdsArray($allCompanies); $companiesNames = $serviceCompanyManager->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 = $serviceCompaniesPriceListManager->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() { $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(); }