コード例 #1
0
 /**
  * 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 UninterestingEmailsManager($config, $args);
     }
     return self::$instance;
 }
コード例 #2
0
 public function service()
 {
     $mandrillEmailSenderManager = new MandrillEmailSenderManager($this->getCmsVar("mandrill_api_key_news"));
     $email_body_html = $_REQUEST['email_body_html'];
     if (empty($email_body_html)) {
         $this->error(array('errText' => 'email body is empty!'));
     }
     $fromEmail = $this->getCmsVar('pcstore_news_email');
     $fromName = 'Pcstore.am Newsletter!';
     $includeUsers = $_REQUEST['include_all_active_users'];
     $subject = 'Newsletter from PcStore.am!!!';
     $test = $_REQUEST['test'];
     if ($test == 1) {
         $testEmail = $_REQUEST['test_email'];
         $res = $mandrillEmailSenderManager->sendHtmlEmail($testEmail, $subject, $email_body_html, $fromEmail, $fromName);
         $this->ok(array('count' => 1));
     }
     $uninterestingEmailsManager = UninterestingEmailsManager::getInstance($this->config, $this->args);
     $newsletterSubscribersManager = NewsletterSubscribersManager::getInstance($this->config, $this->args);
     $emailsArray = $newsletterSubscribersManager->getAllSubscribers();
     $filteredEmailsArray = $uninterestingEmailsManager->removeUninterestingEmailsFromList($emailsArray);
     if ($includeUsers == 1) {
         $userManager = UserManager::getInstance($this->config, $this->args);
         $allUsers = $userManager->selectAll();
         foreach ($allUsers as $userDto) {
             if ($userDto->getAvtive() == 0) {
                 continue;
             }
             $userRealEmailAddress = strtolower($userManager->getRealEmailAddressByUserDto($userDto));
             if (filter_var($userRealEmailAddress, FILTER_VALIDATE_EMAIL)) {
                 $filteredEmailsArray[] = $userRealEmailAddress;
             }
         }
     }
     //for FB, Google and TWITTER users emails may be duplicated!!!! so used array_unique
     $recipients = array_unique($filteredEmailsArray);
     if (count($recipients) === 0) {
         $this->error(array('errText' => 'There is no any recipient!'));
     }
     $email_body_html .= '<p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p>';
     $email_body_html .= '<p style="font-size:10px"><a href="*|UNSUB:http://pcstore.am/unsubscriber|*">Click here to unsubscribe.</a></p>';
     $res = $mandrillEmailSenderManager->sendHtmlEmail($recipients, $subject, $email_body_html, $fromEmail, $fromName);
     $this->ok(array('count' => count($recipients)));
 }
コード例 #3
0
 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;
 }
コード例 #4
0
 public function service()
 {
     $action = $_REQUEST['action'];
     $params = array();
     switch ($action) {
         case 'delete_user':
             $this->deleteUser($_REQUEST['user_id']);
             break;
         case 'delete_all_unnecessary_items_pictures':
             $ret = $this->deleteAllUnnecessaryItemsPictures();
             $params = array('removed_items_ids' => implode(',', $ret));
             break;
         case 'set_item_spec':
             $itemId = $_REQUEST['item_id'];
             $shortSpec = $_REQUEST['short_spec'];
             $fullSpec = $_REQUEST['full_spec'];
             require_once CLASSES_PATH . "/managers/ItemManager.class.php";
             $itemManager = ItemManager::getInstance($this->config, $this->args);
             $itemManager->updateTextField($itemId, 'short_description', $shortSpec);
             $itemManager->updateTextField($itemId, 'full_description', $fullSpec);
             break;
         case 'get_item_spec':
             $itemId = $_REQUEST['item_id'];
             require_once CLASSES_PATH . "/managers/ItemManager.class.php";
             $itemManager = ItemManager::getInstance($this->config, $this->args);
             $itemDto = $itemManager->selectByPK($itemId);
             $params['short_spec'] = $itemDto->getShortDescription();
             $params['full_spec'] = $itemDto->getFullDescription();
             break;
         case 'get_camera_1_snap':
             $url = $this->getCmsVar('pcstore_camera_1_url');
             $login = $this->getCmsVar('pcstore_camera_1_login');
             $pass = $this->getCmsVar('pcstore_camera_1_pass');
             $ch = curl_init($url);
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
             curl_setopt($ch, CURLOPT_USERPWD, $login . ':' . $pass);
             $img = curl_exec($ch);
             header("Content-Type: image/jpeg");
             echo $img;
             exit;
         case 'filter_emails':
             require_once CLASSES_PATH . "/managers/EmailSenderManager.class.php";
             require_once CLASSES_PATH . "/managers/UninterestingEmailsManager.class.php";
             $emails = $_REQUEST['emails'];
             $emailsArray = EmailSenderManager::getEmailsFromText($emails);
             $uninterestingEmailsManager = UninterestingEmailsManager::getInstance($this->config, $this->args);
             $filteredEmailsArray = $uninterestingEmailsManager->removeUninterestingEmailsFromList($emailsArray);
             $params['count'] = count($filteredEmailsArray);
             $params['emails'] = implode(';', $filteredEmailsArray);
             break;
         case 'is_price_values_ready':
             $companyId = intval($_REQUEST['company_id']);
             require_once CLASSES_PATH . "/managers/PriceTextsManager.class.php";
             $priceTextsManager = PriceTextsManager::getInstance($this->config, $this->args);
             $companyPriceValuesReady = $priceTextsManager->isCompanyPriceValuesReady($companyId);
             $params['ready'] = $companyPriceValuesReady ? '1' : '0';
             break;
         case 'delete_price_values_column':
             $companyId = intval($_REQUEST['company_id']);
             $sheetIndex = intval($_REQUEST['sheet_index']);
             $priceIndex = intval($_REQUEST['price_index']);
             $columnLetter = $this->secure($_REQUEST['column_letter']);
             require_once CLASSES_PATH . "/managers/PriceValuesManager.class.php";
             $priceValuesManager = PriceValuesManager::getInstance($this->config, $this->args);
             $priceValuesManager->moveColumnValuesToLastColumn($companyId, $priceIndex, $sheetIndex, $columnLetter);
             break;
         case 'delete_customer_amessage_after_login':
             $pk = intval($_REQUEST['id']);
             require_once CLASSES_PATH . "/managers/CustomerMessagesAfterLoginManager.class.php";
             $customerMessagesAfterLoginManager = CustomerMessagesAfterLoginManager::getInstance($this->config, $this->args);
             $customerMessagesAfterLoginManager->deleteByPK($pk);
             break;
         case 'preview_customer_message':
             $pk = intval($_REQUEST['id']);
             require_once CLASSES_PATH . "/managers/CustomerMessagesAfterLoginManager.class.php";
             $customerMessagesAfterLoginManager = CustomerMessagesAfterLoginManager::getInstance($this->config, $this->args);
             $dto = $customerMessagesAfterLoginManager->selectByPK($pk);
             $params = AbstractDto::dtoToArray($dto);
             break;
         case 'delete_old_hidden_items':
             $monthsNumber = intval($_REQUEST['months_number']);
             require_once CLASSES_PATH . "/managers/ItemManager.class.php";
             $itemManager = ItemManager::getInstance($this->config, $this->args);
             $params['count'] = $itemManager->deleteOldHiddenItemsByMonthsNumber($monthsNumber);
             break;
         case 'update_companies_price_text':
             $company_id = intval($_REQUEST['company_id']);
             $companyManager = CompanyManager::getInstance($this->config, $this->args);
             if ($company_id == 0) {
                 $allCompanies = $companyManager->getAllCompanies(true, true);
             } else {
                 $allCompanies[] = $companyManager->selectByPK($company_id);
             }
             $cidsArray = array();
             foreach ($allCompanies as $c) {
                 $cidsArray[] = $c->getId();
             }
             $this->updateCompanyPriceText(implode(',', $cidsArray));
             break;
         case 'deploy_latest_pcstore_changes':
             $protocol = "http://";
             if (isset($_SERVER["HTTPS"])) {
                 $protocol = "https://";
             }
             $content = file_get_contents($protocol . HTTP_HOST . '/8350e5a3e24c153df2275c9f80692773.php');
             $params['message'] = $content;
             break;
     }
     $this->ok($params);
 }