示例#1
0
 public function postProcess(Axis_Sales_Model_Order_Row $order)
 {
     $number = $this->getCreditCard()->getCcNumber();
     switch (Axis::config("payment/{$order->payment_method_code}/saveCCAction")) {
         case 'last_four':
             $number = str_repeat('X', strlen($number) - 4) . substr($number, -4);
             break;
         case 'first_last_four':
             $number = substr($number, 0, 4) . str_repeat('X', strlen($number) - 8) . substr($number, -4);
             break;
         case 'partial_email':
             $number = substr($number, 0, 4) . str_repeat('X', strlen($number) - 8) . substr($number, -4);
             try {
                 $mail = new Axis_Mail();
                 $mail->setLocale(Axis::config('locale/main/language_admin'));
                 $mail->setConfig(array('subject' => Axis::translate('sales')->__('Order #%s. Credit card number'), 'data' => array('text' => Axis::translate('sales')->__('Order #%s, Credit card middle digits: %s', $order->number, substr($number, 4, strlen($number) - 8))), 'to' => Axis_Collect_MailBoxes::getName(Axis::config('sales/order/email'))));
                 $mail->send();
             } catch (Zend_Mail_Transport_Exception $e) {
             }
             break;
         case 'complete':
             $number = $number;
             break;
         default:
             return true;
     }
     $crypt = Axis_Crypt::factory();
     $data = array('order_id' => $order->id, 'cc_type' => $crypt->encrypt($card->getCcType()), 'cc_owner' => $crypt->encrypt($card->getCcOwner()), 'cc_number' => $crypt->encrypt($number), 'cc_expires_year' => $crypt->encrypt($card->getCcExpiresYear()), 'cc_expires_month' => $crypt->encrypt($card->getCcExpiresMonth()), 'cc_cvv' => Axis::config()->payment->{$order->payment_method_code}->saveCvv ? $crypt->encrypt($card->getCcCvv()) : '', 'cc_issue_year' => $crypt->encrypt($card->getCcIssueYear()), 'cc_issue_month' => $crypt->encrypt($card->getCcIssueMonth()));
     Axis::single('sales/order_creditcard')->save($data);
 }
示例#2
0
 public function listMailAction()
 {
     $templates = Axis_Collect_MailBoxes::collect();
     $data = array();
     $i = 0;
     foreach ($templates as $templateKey => $template) {
         $data[$i] = array('name' => $template, 'id' => $templateKey);
         $i++;
     }
     return $this->_helper->json->setData($data)->sendSuccess();
 }
示例#3
0
 /**
  *
  * @param Axis_Sales_Model_Order_Row $order
  * @return bool
  */
 public function notifyAdminNewOrder(Axis_Sales_Model_Order_Row $order)
 {
     try {
         $mail = new Axis_Mail();
         $mail->setLocale(Axis::config('locale/main/language_admin'));
         $mail->setConfig(array('event' => 'order_new-owner', 'subject' => Axis::translate('sales')->__('Order created'), 'data' => array('order' => $order), 'to' => Axis_Collect_MailBoxes::getName(Axis::config('sales/order/email'))));
         $mail->send();
         return true;
     } catch (Zend_Mail_Exception $e) {
         return false;
     }
 }
示例#4
0
 /**
  * Send notification emails to registered cutomer, store owner
  *
  * @param array $data
  * Array(
  *  'customer' => Axis_Account_Model_Customer_Row
  *  'password' => string
  * )
  * @return void
  */
 public function notifyCustomerRegistration($data)
 {
     try {
         $mail = new Axis_Mail();
         $mail->setLocale($data['customer']->locale);
         $configResult = $mail->setConfig(array('event' => 'account_new-customer', 'subject' => Axis::translate('account')->__("Welcome, %s %s", $data['customer']->firstname, $data['customer']->lastname), 'data' => array('customer' => $data['customer'], 'password' => $data['password']), 'to' => $data['customer']->email));
         $mail->send();
         //            if ($configResult) {
         //                Axis::message()->addSuccess(
         //                    Axis::translate('core')->__('Mail was sended successfully')
         //                );
         //            }
     } catch (Zend_Mail_Transport_Exception $e) {
         Axis::message()->addError(Axis::translate('core')->__('Mail sending was failed.'));
     }
     try {
         $mailNotice = new Axis_Mail();
         $mailNotice->setLocale(Axis::config('locale/main/language_admin'));
         $mailNotice->setConfig(array('event' => 'account_new-owner', 'subject' => Axis::translate('account')->__('New Account Created'), 'data' => array('customer' => $data['customer']), 'to' => Axis_Collect_MailBoxes::getName(Axis::config('core/company/administratorEmail'))));
         $mailNotice->send();
     } catch (Zend_Mail_Transport_Exception $e) {
     }
 }
示例#5
0
 /**
  *
  * @todo refactoring http://www.zendcasts.com/painless-html-emails-with-zend_mail/2010/06/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+ZendScreencastsVideoTutorialsAboutTheZendPhpFrameworkForDesktop+%28Zend+Screencasts%3A+Video+Tutorials+about+the+Zend+PHP+Framework++%28desktop%29%29&utm_content=Google+Reader
  *
  * @param array
  * <pre>
  * array(
  *      'event'      => string                   [optional]
  *      'subject'    => string,
  *      'data'       => array(
  *          'text'   =>
  *          'blabla' =>
  *          ....
  *      ),
  *      'to'         => email,
  *      'from'       => mixed (string|array('email' => '', 'name' => '')), [optional]
  *      'type'       => string 'txt'|'html',     [optional]
  *      'charset'    => string                   [optional],
  *      'attachments' => array()
  *  )
  * </pre>
  *  @return bool
  */
 public function setConfig(array $config)
 {
     $from = array();
     if (isset($config['from']) && is_string($config['from'])) {
         $from = $config['from'];
     } else {
         if (isset($config['from']['email'])) {
             $from['email'] = $config['from']['email'];
         }
         if (isset($config['from']['name'])) {
             $from['name'] = $config['from']['name'];
         }
     }
     if (isset($config['event'])) {
         $mailTemplate = Axis::model('core/template_mail')->select('*')->where('ctm.event = ?', $config['event'])->fetchRow();
         if (!$mailTemplate || !$mailTemplate->status) {
             $this->_disabled = true;
             return false;
         }
         $siteIds = explode(',', $mailTemplate->site);
         if (isset($config['siteId'])) {
             if (!in_array($config['siteId'], $siteIds)) {
                 $this->_disabled = true;
                 return false;
             }
         } elseif (!in_array(Axis::getSiteId(), $siteIds)) {
             $this->_disabled = true;
             return false;
         }
         $type = isset($config['type']) ? $config['type'] : $mailTemplate->type;
         if (is_array($from)) {
             if (!isset($from['email'])) {
                 $from['email'] = Axis_Collect_MailBoxes::getName($mailTemplate->from);
             }
         }
     }
     $this->setSubject($config['subject']);
     $this->addTo($config['to']);
     $this->view->to = $config['to'];
     $siteName = $this->view->site;
     if (isset($config['siteId']) && $config['siteId'] != Axis::getSiteId()) {
         $siteName = Axis::model('core/site')->find($config['siteId'])->current()->name;
     }
     $this->view->siteName = $siteName;
     if (is_array($from)) {
         if (!isset($from['name'])) {
             $from['name'] = $siteName;
         }
         if (empty($from['email'])) {
             $from['email'] = Axis_Collect_MailBoxes::getName(Axis::config('mail/main/mtcFrom'));
         }
         $this->setFrom($from['email'], $from['name']);
         $this->view->from = $from['email'];
     } else {
         $this->setFrom($from);
         $this->view->from = $from;
     }
     $this->view->assign($config['data']);
     if (isset($config['event'])) {
         if ('html' == $type) {
             $this->renderHtml($mailTemplate->template);
         } else {
             $this->renderText($mailTemplate->template);
         }
     } else {
         $this->setBodyText($config['data']['text']);
     }
     if (isset($config['attachments'])) {
         foreach ($config['attachments'] as $name => $file) {
             $attachment = $this->createAttachment($this->view->render($file));
             $attachment->filename = $name;
         }
     }
     return true;
 }
示例#6
0
 /**
  * @param mixed (int|bool) $siteId[optional]
  * @return array
  */
 public function getCompanyInfo($siteId = null)
 {
     $company = Axis::config('core/company', $siteId)->toArray();
     //@todo Use Axis_Object
     return array('email' => Axis_Collect_MailBoxes::getName($company['administratorEmail']), 'city' => $company['city'], 'country' => Axis_Collect_Country::getName($company['country']), 'fax' => $company['fax'], 'name' => $company['name'], 'phone' => $company['phone'], 'postcode' => $company['zip'], 'site' => $company['site'], 'zone' => Axis_Collect_Zone::getName($company['zone']), 'street_address' => $company['street'], 'customer_relation_email' => Axis_Collect_MailBoxes::getName($company['customerRelationEmail']), 'sales_email' => Axis_Collect_MailBoxes::getName($company['salesDepartmentEmail']), 'support_email' => Axis_Collect_MailBoxes::getName($company['supportEmail']));
 }