コード例 #1
0
 /**
  * @test
  * @loadFixture data
  *
  * @doNotIndex catalog_product_price
  */
 public function basicTest()
 {
     $this->assertEquals('Sales', $this->_model->getDepartment());
     $this->assertEquals('Open', $this->_model->getStatus());
     $this->assertEquals('High', $this->_model->getPriority());
     $this->assertEquals('John Doe', $this->_model->getCustomerName());
     $this->assertEquals('*****@*****.**', $this->_model->getCustomerEmail());
     $this->assertEquals('Mike Peterson', $this->_model->getUserName());
 }
コード例 #2
0
 /**
  * @param Mirasvit_Helpdesk_Model_Ticket       $ticket
  * @param Mage_Customer_Model_Customer|false   $customer
  * @param Mage_Admin_Model_User|false          $user
  * @param $recipientEmail
  * @param $recipientName
  * @param $templateName
  * @param Mirasvit_Helpdesk_Model_Attachment[] $attachments
  * @param array                                $variables
  * @param bool                                 $emailFlag
  *
  * @return bool
  *
  * @throws Exception
  * @throws Zend_Mail_Exception
  */
 public function mail($ticket, $customer, $user, $recipientEmail, $recipientName, $templateName, $attachments = array(), $variables = array(), $emailFlag = false)
 {
     if ($templateName == 'none') {
         return false;
     }
     $storeId = $ticket->getStoreId();
     $config = Mage::getSingleton('helpdesk/config');
     if ($config->getDeveloperIsActive($storeId)) {
         if ($sandboxEmail = $config->getDeveloperSandboxEmail($storeId)) {
             $recipientEmail = $sandboxEmail;
         }
     }
     $department = $ticket->getDepartment();
     $store = $ticket->getStore();
     if (!$customer) {
         $customer = $ticket->getCustomer();
     }
     if (!$user) {
         $user = $ticket->getUser();
     }
     // save current design settings
     $currentDesignConfig = clone $this->_getDesignConfig();
     $this->_setDesignConfig(array('area' => 'frontend', 'store' => $store->getId()));
     $this->_applyDesignConfig();
     $variables = array_merge($variables, array('ticket' => $ticket, 'customer' => $customer, 'user' => $user, 'department' => $department, 'store' => $store, 'hidden_separator' => Mage::helper('helpdesk/email')->getHiddenSeparator(), 'logo_url' => $this->_getLogoUrl($store), 'logo_alt' => $this->_getLogoAlt($store)));
     if (isset($variables['email_subject'])) {
         $variables['email_subject'] = $this->processVariable($variables['email_subject'], $variables);
     }
     if (isset($variables['email_body'])) {
         $variables['email_body'] = $this->processVariable($variables['email_body'], $variables);
     }
     $senderName = Mage::getStoreConfig("trans_email/ident_{$department->getSenderEmail()}/name", $storeId);
     $senderEmail = Mage::getStoreConfig("trans_email/ident_{$department->getSenderEmail()}/email", $storeId);
     if (!$senderEmail) {
         return;
     }
     if (!$recipientEmail) {
         return;
     }
     $template = Mage::getModel('core/email_template');
     foreach ($attachments as $attachment) {
         /* @noinspection PhpUndefinedClassInspection */
         $template->getMail()->createAttachment($attachment->getBody(), $attachment->getType(), Zend_Mime::DISPOSITION_ATTACHMENT, Zend_Mime::ENCODING_BASE64, $attachment->getName());
     }
     $translate = Mage::getSingleton('core/translate');
     $translate->setTranslateInline(false);
     if ($emailFlag) {
         $template->getMail()->addHeader('Auto-Submitted', $emailFlag);
     }
     // Mandrill NOT ABLE to send CC - so we need an overwork
     if (method_exists($template->getMail(), 'addCc')) {
         if (count($ticket->getCc())) {
             $template->getMail()->addCc($ticket->getCc());
         }
     } else {
         $recipientEmail = array_unique(array_merge((array) $recipientEmail, $ticket->getCc()));
     }
     $bcc = array_unique(array_merge($this->getConfig()->getGeneralBccEmail($storeId), $ticket->getBcc()));
     if (count($bcc)) {
         $template->getMail()->addBcc($bcc);
     }
     $template->setDesignConfig(array('area' => 'frontend', 'store' => $storeId));
     $template->sendTransactional($templateName, array('name' => $senderName, 'email' => $senderEmail), $recipientEmail, $recipientName, $variables, $storeId);
     $text = $template->getProcessedTemplate($variables, true);
     $this->emails[] = $text;
     $translate->setTranslateInline(true);
     // restore previous design settings
     $this->_setDesignConfig($currentDesignConfig->getData());
     $this->_applyDesignConfig();
 }