コード例 #1
0
ファイル: Url.php プロジェクト: rajarshc/Rooja
 public function getUrl(Mage_Customer_Model_Customer $customer)
 {
     switch (Mage::helper('rewardsref')->getReferralUrlStyle()) {
         case TBT_RewardsReferral_Helper_Data::REWARDSREF_URL_STYLE_EMAIL:
             $url_data = array('email' => urlencode($customer->getEmail()));
             break;
         case TBT_RewardsReferral_Helper_Data::REWARDSREF_URL_STYLE_CODE:
             $url_data = array('code' => urlencode(Mage::helper('rewardsref/code')->getCode($customer->getEmail())));
             break;
         default:
             $url_data = array('id' => $customer->getId());
     }
     $url = Mage::getUrl('rewardsref/index/refer', $url_data);
     return $url;
 }
コード例 #2
0
ファイル: Signup.php プロジェクト: rajarshc/Rooja
 /**
  * Referral Signup trigger
  * 
  * @param Mage_Customer_Model_Customer $customer
  * @return TBT_RewardsReferral_Model_Referral_Abstract 
  */
 public function triggerEvent(Mage_Customer_Model_Customer $customer)
 {
     $this->loadByEmail($customer->getEmail());
     if (!$this->getReferralParentId()) {
         Mage::helper('rewardsref')->initateSessionReferral($customer);
         $this->loadByEmail($customer->getEmail());
         if (!$this->getReferralParentId()) {
             return $this;
         }
     }
     // update referral status
     $this->setReferralChildId($customer->getId());
     $this->setReferralStatus($this->getReferralStatusId());
     $this->save();
     $points = $this->getTotalReferralPoints();
     if ($points->isEmpty()) {
         return $this;
     }
     try {
         foreach ($points->getPoints() as $currencyId => $points_amount) {
             $transfer = Mage::getModel('rewardsref/transfer');
             $transferStatus = Mage::getStoreConfig('rewards/InitialTransferStatus/ReferralSignup');
             $transfer->create($points_amount, $currencyId, $this->getReferralParentId(), $customer->getId(), $this->getReferralTransferMessage($customer), $this->getTransferReasonId(), $transferStatus);
         }
         // send affiliate an email of the transaction
         $affiliate = $this->getParentCustomer();
         if ($affiliate->getRewardsrefNotifyOnReferral()) {
             $msg = $this->getReferralTransferMessage($customer);
             $this->sendConfirmation($affiliate, $customer->getEmail(), $customer->getName(), $msg, (string) $points);
         }
     } catch (Exception $e) {
         Mage::logException($e);
     }
     return $this;
 }
コード例 #3
0
ファイル: Customer.php プロジェクト: aplazame/magento
 public static function createFromCustomer(Mage_Customer_Model_Customer $customer)
 {
     /** @var Mage_Log_Model_Customer $logCustomer */
     $logCustomer = Mage::getModel('log/customer')->loadByCustomer($customer->getId());
     switch ($customer->getGender()) {
         case '1':
             $gender = 1;
             break;
         case '2':
             $gender = 2;
             break;
         default:
             $gender = 0;
     }
     $aCustomer = new self();
     $aCustomer->email = $customer->getEmail();
     $aCustomer->type = 'e';
     $aCustomer->gender = $gender;
     $aCustomer->id = $customer->getId();
     $aCustomer->first_name = $customer->getFirstname();
     $aCustomer->last_name = $customer->getLastname();
     if (($birthday = $customer->getDob()) !== null) {
         $aCustomer->birthday = Aplazame_Sdk_Serializer_Date::fromDateTime(new DateTime($birthday));
     }
     if (($document_id = $customer->getTaxvat()) !== null) {
         $aCustomer->document_id = $document_id;
     }
     $aCustomer->date_joined = Aplazame_Sdk_Serializer_Date::fromDateTime(new DateTime('@' . $customer->getCreatedAtTimestamp()));
     if (($lastLogin = $logCustomer->getLoginAtTimestamp()) != null) {
         $aCustomer->last_login = Aplazame_Sdk_Serializer_Date::fromDateTime(new DateTime('@' . $lastLogin));
     }
     return $aCustomer;
 }
コード例 #4
0
ファイル: Referral.php プロジェクト: xiaoguizhidao/devfashion
 public function sendSubscription(Mage_Customer_Model_Customer $parent, $destination, $destination_name)
 {
     $translate = Mage::getSingleton('core/translate');
     /* @var $translate Mage_Core_Model_Translate */
     $translate->setTranslateInline(false);
     //$template = Mage::getStoreConfig(self::XML_PATH_SUBSCRIPTION_EMAIL_TEMPLATE, $this->getStoreId());
     $email = Mage::getModel('core/email_template');
     /* @var $email Mage_Core_Model_Email_Template */
     //$email->setDesignConfig(array('area'=>'frontend', 'store'=>$this->getStoreId()));
     $template = Mage::getStoreConfig(self::XML_PATH_SUBSCRIPTION_EMAIL_TEMPLATE, Mage::app()->getStore()->getId());
     $recipient = array('email' => $destination, 'name' => $destination_name);
     if (Mage::helper('core')->isModuleEnabled('Aschroder_SMTPPro')) {
         $sender = Mage::getStoreConfig(self::XML_PATH_CONFIRMATION_EMAIL_IDENTITY);
     } else {
         $sender = array('name' => strip_tags($parent->getFirstname() . ' ' . $parent->getLastname()), 'email' => strip_tags($parent->getEmail()));
     }
     /*        $sender  = array(
                 'name' => strip_tags($parent->getFirstname().' '.$parent->getLastname()),
                 'email' => strip_tags($parent->getEmail())
             );
     */
     $real_url = Mage::getUrl('rewardpoints/index/goReferral', array("referrer" => $parent->getId()));
     $used_url = Mage::getUrl('', array("referral-program" => str_replace('/', '-', base64_encode($parent->getId() . 'j2t'))));
     $email->setDesignConfig(array('area' => 'frontend', 'store' => Mage::app()->getStore()->getId()))->sendTransactional($template, $sender, $recipient['email'], $recipient['name'], array('parent' => $parent, 'referral' => $this, 'store_name' => Mage::getModel('core/store')->load(Mage::app()->getStore()->getCode())->getName(), 'referral_url' => $used_url));
     $translate->setTranslateInline(true);
     return $email->getSentSuccess();
 }
コード例 #5
0
ファイル: Notify.php プロジェクト: rajarshc/Rooja
 /**
  *
  * @param Mage_Customer_Model_Customer $customer
  * @param string $pointsString
  * @param type $date
  */
 public function systemLog($customer, $pointsString, $date)
 {
     $storeId = $customer->getStoreId();
     if ($this->_getHelper()->isLogBirthdayEnabled($storeId)) {
         $name = $customer->getName();
         $email = $customer->getEmail();
         $msg = $this->_getHelper()->__("Customer %s with the e-mail %s has a birthday on %s and been rewarded %s.", $name, $email, $date, $pointsString);
         Mage::log($msg, null, $this->getLogFileName());
     }
 }
コード例 #6
0
ファイル: Card.php プロジェクト: billadams/forever-frame
 /**
  * Set the customer account (if any) for the card.
  */
 public function setCustomer(Mage_Customer_Model_Customer $customer, Mage_Payment_Model_Info $payment = null)
 {
     if ($customer->getEmail() != '') {
         $this->setCustomerEmail($customer->getEmail());
         /**
          * Make an ID if we don't have one (and hope this doesn't break anything)
          */
         if ($customer->getId() < 1) {
             $customer->save();
         }
         $this->setCustomerId($customer->getId());
         parent::setCustomer($customer);
     } elseif (!is_null($payment)) {
         $model = null;
         /**
          * If we have no email, try to find it from current scope data.
          */
         if ($payment->getQuote() != null && $payment->getQuote()->getBillingAddress() != null && $payment->getQuote()->getBillingAddress()->getCustomerEmail() != '') {
             $model = $payment->getQuote();
         } elseif ($payment->getOrder() != null && ($payment->getOrder()->getCustomerEmail() != '' || $payment->getOrder()->getBillingAddress() != null && $payment->getOrder()->getBillingAddress()->getCustomerEmail() != '')) {
             $model = $payment->getOrder();
         } else {
             /**
              * This will fall back to checkout/session if onepage has no quote loaded.
              * Should work for all checkouts that use normal Magento processes.
              */
             $model = Mage::getSingleton('checkout/type_onepage')->getQuote();
         }
         if (!is_null($model)) {
             if ($model->getCustomerEmail() == '' && $model->getBillingAddress() instanceof Varien_Object && $model->getBillingAddress()->getEmail() != '') {
                 $model->setCustomerEmail($model->getBillingAddress()->getEmail());
             }
             if ($model->hasEmail()) {
                 $this->setCustomerEmail($model->getEmail());
             } elseif ($model->hasCustomerEmail()) {
                 $this->setCustomerEmail($model->getCustomerEmail());
             }
             $this->setCustomerId(intval($model->getCustomerId()));
         }
     }
     return $this;
 }
コード例 #7
0
 /**
  * Send customer email
  *
  * @return bool
  */
 public function send()
 {
     if (is_null($this->_website) || is_null($this->_customer)) {
         return false;
     }
     if ($this->_type == 'price' && count($this->_priceProducts) == 0 || $this->_type == 'stock' && count($this->_stockProducts) == 0) {
         return false;
     }
     if (!$this->_website->getDefaultGroup() || !$this->_website->getDefaultGroup()->getDefaultStore()) {
         return false;
     }
     $store = $this->_website->getDefaultStore();
     $storeId = $store->getId();
     if ($this->_type == 'price' && !Mage::getStoreConfig(self::XML_PATH_EMAIL_PRICE_TEMPLATE, $storeId)) {
         return false;
     } elseif ($this->_type == 'stock' && !Mage::getStoreConfig(self::XML_PATH_EMAIL_STOCK_TEMPLATE, $storeId)) {
         return false;
     }
     // set design parameters, required for email (remember current)
     $currentDesign = Mage::getDesign()->setAllGetOld(array('store' => $storeId, 'area' => 'frontend', 'package' => Mage::getStoreConfig('design/package/name', $storeId)));
     Mage::app()->getLocale()->emulate($storeId);
     $translate = Mage::getSingleton('core/translate');
     /* @var $translate Mage_Core_Model_Translate */
     $translate->setTranslateInline(false);
     if ($this->_type == 'price') {
         $this->_getPriceBlock()->setStore($store)->reset();
         foreach ($this->_priceProducts as $product) {
             $product->setCustomerGroupId($this->_customer->getGroupId());
             $this->_getPriceBlock()->addProduct($product);
         }
         $block = $this->_getPriceBlock()->toHtml();
         $templateId = Mage::getStoreConfig(self::XML_PATH_EMAIL_PRICE_TEMPLATE, $storeId);
     } elseif ($this->_type == 'stock') {
         $this->_getStockBlock()->setStore($store)->reset();
         foreach ($this->_stockProducts as $product) {
             $product->setCustomerGroupId($this->_customer->getGroupId());
             $this->_getStockBlock()->addProduct($product);
         }
         $block = $this->_getStockBlock()->toHtml();
         $templateId = Mage::getStoreConfig(self::XML_PATH_EMAIL_STOCK_TEMPLATE, $storeId);
     } else {
         Mage::app()->getLocale()->revert();
         return false;
     }
     Mage::getModel('core/email_template')->setDesignConfig(array('area' => 'frontend', 'store' => $storeId))->sendTransactional($templateId, Mage::getStoreConfig(self::XML_PATH_EMAIL_IDENTITY, $storeId), $this->_customer->getEmail(), $this->_customer->getName(), array('customerName' => $this->_customer->getName(), 'alertGrid' => $block));
     $translate->setTranslateInline(true);
     // revert current design
     Mage::getDesign()->setAllGetOld($currentDesign);
     Mage::app()->getLocale()->revert();
     return true;
 }
コード例 #8
0
ファイル: User.php プロジェクト: freshdesk/magento_extension
 public function syncCustomer(Mage_Customer_Model_Customer $customer)
 {
     if (!($email = $customer->getEmail())) {
         return false;
     }
     $this->load($email);
     if (!$this->getId()) {
         $this->setEmail($email);
     }
     $this->setName($customer->getName());
     $this->save();
     $this->cleanCache();
     return true;
 }
コード例 #9
0
 /**
  * Load subscriber by customer
  *
  * @param Mage_Customer_Model_Customer $customer
  * @return array
  */
 public function loadByCustomer(Mage_Customer_Model_Customer $customer)
 {
     $select = $this->_read->select()->from($this->getMainTable())->where('customer_id=:customer_id');
     Mage::fireLog($customer->getId(), "loadByCustomer");
     $result = $this->_read->fetchRow($select, array('customer_id' => $customer->getId()));
     if ($result) {
         return $result;
     }
     $select = $this->_read->select()->from($this->getMainTable())->where('subscriber_email=:subscriber_email');
     $result = $this->_read->fetchRow($select, array('subscriber_email' => $customer->getEmail()));
     if ($result) {
         return $result;
     }
     return array();
 }
コード例 #10
0
 public function sendCustomerNotification(Mage_Customer_Model_Customer $customer, $store_id, $points, $point_model, $sender, $email_template = null)
 {
     $translate = Mage::getSingleton('core/translate');
     /* @var $translate Mage_Core_Model_Translate */
     $translate->setTranslateInline(false);
     $email = Mage::getModel('core/email_template');
     $template = Mage::getStoreConfig(self::XML_PATH_CUSTOMER_NOTIFICATION_EMAIL_TEMPLATE, $store_id);
     if ($email_template != null) {
         $template = $email_template;
     }
     $recipient = array('email' => $customer->getEmail(), 'name' => $customer->getName());
     //$sender  = Mage::getStoreConfig(self::XML_PATH_NOTIFICATION_EMAIL_IDENTITY, $store_id);
     $email->setDesignConfig(array('area' => 'frontend', 'store' => $store_id))->sendTransactional($template, $sender, $recipient['email'], $recipient['name'], array('points' => $points, 'customer' => $customer, 'point_model' => $point_model, 'store_name' => Mage::getModel('core/store')->load(Mage::app()->getStore($store_id)->getCode())->getName()));
     $translate->setTranslateInline(true);
     return $email->getSentSuccess();
 }
コード例 #11
0
ファイル: Referral.php プロジェクト: ntnhan220488/ggm
 public function sendSubscription(Mage_Customer_Model_Customer $parent, $destination, $destination_name)
 {
     $translate = Mage::getSingleton('core/translate');
     /* @var $translate Mage_Core_Model_Translate */
     $translate->setTranslateInline(false);
     //$template = Mage::getStoreConfig(self::XML_PATH_SUBSCRIPTION_EMAIL_TEMPLATE, $this->getStoreId());
     $email = Mage::getModel('core/email_template');
     /* @var $email Mage_Core_Model_Email_Template */
     //$email->setDesignConfig(array('area'=>'frontend', 'store'=>$this->getStoreId()));
     $template = Mage::getStoreConfig(self::XML_PATH_SUBSCRIPTION_EMAIL_TEMPLATE, Mage::app()->getStore()->getId());
     $recipient = array('email' => $destination, 'name' => $destination_name);
     $sender = array('name' => strip_tags($parent->getFirstname() . ' ' . $parent->getLastname()), 'email' => strip_tags($parent->getEmail()));
     $email->setDesignConfig(array('area' => 'frontend', 'store' => Mage::app()->getStore()->getId()))->sendTransactional($template, $sender, $recipient['email'], $recipient['name'], array('parent' => $parent, 'referral' => $this, 'store_name' => Mage::getModel('core/store')->load(Mage::app()->getStore()->getCode())->getName()));
     $translate->setTranslateInline(true);
     return $email->getSentSuccess();
 }
コード例 #12
0
ファイル: Email.php プロジェクト: HelioFreitas/magento-pt_br
 /**
  * Send customer email
  *
  * @return bool
  */
 public function send()
 {
     if (is_null($this->_website) || is_null($this->_customer)) {
         return false;
     }
     if ($this->_type == 'price' && count($this->_priceProducts) == 0 || $this->_type == 'stock' && count($this->_stockProducts) == 0) {
         return false;
     }
     if (!$this->_website->getDefaultGroup() || !$this->_website->getDefaultGroup()->getDefaultStore()) {
         return false;
     }
     $storeId = $this->_website->getDefaultGroup()->getDefaultStore()->getId();
     $storeCode = $this->_website->getDefaultGroup()->getDefaultStore()->getCode();
     if ($this->_type == 'price' && !Mage::getStoreConfig(self::XML_PATH_EMAIL_PRICE_TEMPLATE, $storeId)) {
         return false;
     } elseif ($this->_type == 'stock' && !Mage::getStoreConfig(self::XML_PATH_EMAIL_STOCK_TEMPLATE, $storeId)) {
         return false;
     }
     Mage::getDesign()->setStore($storeId);
     Mage::getDesign()->setArea('frontend');
     $translate = Mage::getSingleton('core/translate');
     /* @var $translate Mage_Core_Model_Translate */
     $translate->setTranslateInline(false);
     if ($this->_type == 'price') {
         $this->_getPriceBlock()->setStoreCode($storeCode);
         foreach ($this->_priceProducts as $product) {
             $product->setCustomerGroupId($this->_customer->getGroupId());
             $this->_getPriceBlock()->addProduct($product);
         }
         $block = $this->_getPriceBlock()->toHtml();
         $templateId = Mage::getStoreConfig(self::XML_PATH_EMAIL_PRICE_TEMPLATE, $storeId);
     } elseif ($this->_type == 'stock') {
         $this->_getStockBlock()->setStoreCode($storeCode);
         foreach ($this->_stockProducts as $product) {
             $product->setCustomerGroupId($this->_customer->getGroupId());
             $this->_getStockBlock()->addProduct($product);
         }
         $block = $this->_getStockBlock()->toHtml();
         $templateId = Mage::getStoreConfig(self::XML_PATH_EMAIL_STOCK_TEMPLATE, $storeId);
     } else {
         return false;
     }
     Mage::getModel('core/email_template')->setDesignConfig(array('area' => 'frontend', 'store' => $storeId))->sendTransactional($templateId, Mage::getStoreConfig(self::XML_PATH_EMAIL_IDENTITY, $storeId), $this->_customer->getEmail(), $this->_customer->getName(), array('customerName' => $this->_customer->getName(), 'alertGrid' => $block));
     $translate->setTranslateInline(true);
     return true;
 }
コード例 #13
0
 /**
  * Send customer email
  *
  * @return bool
  */
 public function send()
 {
     if (is_null($this->_website) || is_null($this->_customer)) {
         return false;
     }
     if ($this->_type == 'price' && count($this->_priceProducts) == 0 || $this->_type == 'stock' && count($this->_stockProducts) == 0) {
         return false;
     }
     if (!$this->_website->getDefaultGroup() || !$this->_website->getDefaultGroup()->getDefaultStore()) {
         return false;
     }
     $store = Mage::getModel('core/store')->load($this->_customer->getStoreId());
     $storeId = $store->getId();
     if ($this->_type == 'price' && !Mage::getStoreConfig(self::XML_PATH_EMAIL_PRICE_TEMPLATE, $storeId)) {
         return false;
     } elseif ($this->_type == 'stock' && !Mage::getStoreConfig(self::XML_PATH_EMAIL_STOCK_TEMPLATE, $storeId)) {
         return false;
     }
     if ($this->_type != 'price' && $this->_type != 'stock') {
         return false;
     }
     $appEmulation = Mage::getSingleton('core/app_emulation');
     $initialEnvironmentInfo = $appEmulation->startEnvironmentEmulation($storeId);
     Mage::app()->getTranslator()->init('frontend', true);
     if ($this->_type == 'price') {
         $this->_getPriceBlock()->setStore($store)->reset();
         foreach ($this->_priceProducts as $product) {
             $product->setCustomerGroupId($this->_customer->getGroupId());
             $this->_getPriceBlock()->addProduct($product);
         }
         $block = $this->_getPriceBlock()->toHtml();
         $templateId = Mage::getStoreConfig(self::XML_PATH_EMAIL_PRICE_TEMPLATE, $storeId);
     } else {
         $this->_getStockBlock()->setStore($store)->reset();
         foreach ($this->_stockProducts as $product) {
             $product->setCustomerGroupId($this->_customer->getGroupId());
             $this->_getStockBlock()->addProduct($product);
         }
         $block = $this->_getStockBlock()->toHtml();
         $templateId = Mage::getStoreConfig(self::XML_PATH_EMAIL_STOCK_TEMPLATE, $storeId);
     }
     $appEmulation->stopEnvironmentEmulation($initialEnvironmentInfo);
     Mage::getModel('core/email_template')->setDesignConfig(array('area' => 'frontend', 'store' => $storeId))->sendTransactional($templateId, Mage::getStoreConfig(self::XML_PATH_EMAIL_IDENTITY, $storeId), $this->_customer->getEmail(), $this->_customer->getName(), array('customerName' => $this->_customer->getName(), 'alertGrid' => $block));
     return true;
 }
コード例 #14
0
ファイル: Action.php プロジェクト: kanotest15/cbmagento
 /**
  * Add transaction that change customer reward point balance
  * 
  * @param string $actionCode
  * @param Mage_Customer_Model_Customer $customer
  * @param type $object
  * @param array $extraContent
  * @return Magestore_RewardPoints_Model_Transaction
  */
 public function addTransaction($actionCode, $customer, $object = null, $extraContent = array())
 {
     Varien_Profiler::start('REWARDPOINTS_HELPER_ACTION::addTransaction');
     if (!$customer->getId()) {
         throw new Exception($this->__('Customer must be existed.'));
     }
     $actionModel = $this->getActionModel($actionCode);
     /** @var $actionModel Magestore_RewardPoints_Model_Action_Interface */
     $actionModel->setData(array('customer' => $customer, 'action_object' => $object, 'extra_content' => $extraContent))->prepareTransaction();
     $transaction = Mage::getModel('rewardpoints/transaction');
     if (is_array($actionModel->getData('transaction_data'))) {
         $transaction->setData($actionModel->getData('transaction_data'));
     }
     $transaction->setData('point_amount', (int) $actionModel->getPointAmount());
     if (!$transaction->hasData('store_id')) {
         $transaction->setData('store_id', Mage::app()->getStore()->getId());
     }
     $transaction->createTransaction(array('customer_id' => $customer->getId(), 'customer' => $customer, 'customer_email' => $customer->getEmail(), 'title' => $actionModel->getTitle(), 'action' => $actionCode, 'action_type' => $actionModel->getActionType(), 'created_time' => now(), 'updated_time' => now()));
     Varien_Profiler::stop('REWARDPOINTS_HELPER_ACTION::addTransaction');
     return $transaction;
 }
コード例 #15
0
ファイル: Subscriber.php プロジェクト: arslbbt/mangentovies
 /**
  * Load subscriber by customer
  *
  * @param 	Mage_Customer_Model_Customer $customer
  * @return 	array
  */
 public function loadByCustomer(Mage_Customer_Model_Customer $customer)
 {
     $select = $this->_read->select()->from($this->_subscriberTable)->where('customer_id=?', $customer->getId());
     $result = $this->_read->fetchRow($select);
     if ($result) {
         return $result;
     }
     $select = $this->_read->select()->from($this->_subscriberTable)->where('subscriber_email=?', $customer->getEmail());
     $result = $this->_read->fetchRow($select);
     if ($result) {
         return $result;
     }
     return array();
 }
コード例 #16
0
ファイル: Customer.php プロジェクト: javik223/Evron-Magento
 public function getCustomerHtml(Mage_Customer_Model_Customer $customer)
 {
     $html = "<li onclick=\"addCustomerToCart(" . $customer->getId() . ")\" style='width:100%; float:left; cursor: pointer' class='email-customer col-lg-6 col-md-6'><span style='float:left;'>" . $customer->getFirstname() . " " . $customer->getLastname() . "</span><span style='float:right'><a href='mailto:" . $customer->getEmail() . "'>" . $customer->getEmail() . "</a></span><br/><span style='float:right'>" . $customer->getTelephone() . "</span></li>";
     return $html;
 }
コード例 #17
0
 /**
  * Success Registration
  *
  * @param Mage_Customer_Model_Customer $customer
  * @return Mage_Customer_AccountController
  */
 protected function _successProcessRegistration(Mage_Customer_Model_Customer $customer)
 {
     $session = $this->_getSession();
     if ($customer->isConfirmationRequired()) {
         /** @var $app Mage_Core_Model_App */
         $app = $this->_getApp();
         /** @var $store  Mage_Core_Model_Store*/
         $store = $app->getStore();
         $customer->sendNewAccountEmail('confirmation', $session->getBeforeAuthUrl(), $store->getId());
         $customerHelper = $this->_getHelper('customer');
         $session->addSuccess($this->__('Account confirmation is required. Please, check your email for the confirmation link. To resend the confirmation email please <a href="%s">click here</a>.', $customerHelper->getEmailConfirmationUrl($customer->getEmail())));
         $url = $this->_getUrl('*/*/index', array('_secure' => true));
     } else {
         $session->setCustomerAsLoggedIn($customer);
         $url = $this->_welcomeCustomer($customer);
     }
     $this->_redirectSuccess($url);
     return $this;
 }
コード例 #18
0
 /**
  * Validate customer attributes
  *
  * @param Mage_Customer_Model_Customer $customer
  * @return bool
  */
 public function validateCustomerAttributes(Mage_Customer_Model_Customer $customer)
 {
     $errors = array();
     $customerHelper = Mage::helper('customer');
     if (!Zend_Validate::is(trim($customer->getFirstname()), 'NotEmpty')) {
         $errors[] = $customerHelper->__('The first name cannot be empty.');
     }
     /*
             if (!Zend_Validate::is( trim($customer->getLastname()) , 'NotEmpty')) {
                 $errors[] = $customerHelper->__('The last name cannot be empty.');
             }
     */
     if (!Zend_Validate::is($customer->getEmail(), 'EmailAddress')) {
         $errors[] = $customerHelper->__('Invalid email address "%s".', $customer->getEmail());
     }
     $password = $customer->getPassword();
     if (!$customer->getId() && !Zend_Validate::is($password, 'NotEmpty')) {
         $errors[] = $customerHelper->__('The password cannot be empty.');
     }
     if (strlen($password) && !Zend_Validate::is($password, 'StringLength', array(6))) {
         $errors[] = $customerHelper->__('The minimum password length is %s', 6);
     }
     $confirmation = $customer->getConfirmation();
     if ($password != $confirmation) {
         $errors[] = $customerHelper->__('Please make sure your passwords match.');
     }
     $entityType = Mage::getSingleton('eav/config')->getEntityType('customer');
     $attribute = Mage::getModel('customer/attribute')->loadByCode($entityType, 'dob');
     if ($attribute->getIsRequired() && '' == trim($customer->getDob())) {
         $errors[] = $customerHelper->__('The Date of Birth is required.');
     }
     $attribute = Mage::getModel('customer/attribute')->loadByCode($entityType, 'taxvat');
     if ($attribute->getIsRequired() && '' == trim($customer->getTaxvat())) {
         $errors[] = $customerHelper->__('The TAX/VAT number is required.');
     }
     $attribute = Mage::getModel('customer/attribute')->loadByCode($entityType, 'gender');
     if ($attribute->getIsRequired() && '' == trim($customer->getGender())) {
         $errors[] = $customerHelper->__('Gender is required.');
     }
     return empty($errors) ? true : $errors;
 }
コード例 #19
0
ファイル: Data.php プロジェクト: jokusafet/MagentoSource
 /**
  * Handle additional lists subscription on form posts like Customer Create Account
  *
  * @param Mage_Customer_Model_Customer $customer
  */
 public function additionalListsSubscription($customer = null, $post = null)
 {
     $request = Mage::app()->getRequest();
     if (!$request->isPost() && is_null($post)) {
         return false;
     }
     $allowedPost = array('/customer/account/createpost/');
     $requestString = $request->getRequestString();
     if (in_array($requestString, $allowedPost) or !is_null($post)) {
         if (!is_null($post)) {
             $request = $post;
         }
         $this->handlePost($request, $customer->getEmail());
     }
 }
コード例 #20
0
ファイル: Data.php プロジェクト: shebin512/Magento_Zoff
 public function getLinkAjax(Mage_Customer_Model_Customer $customer, $link)
 {
     return trim($link) . "?mw_reward=" . md5($customer->getEmail());
 }
コード例 #21
0
ファイル: Referral.php プロジェクト: rajarshc/Rooja
 /**
  * @param $affiliate TBT_Rewards_Model_Customer the person who's making the referral and will earn the points
  * @param $child TBT_Rewards_Model_Customer the person being referred to the site
  * @param $destinationEmail
  * 
  * @return send result          
  */
 public function sendConfirmation(Mage_Customer_Model_Customer $affiliate, $destinationEmail, $destinationName, $message = "", $pointsSummary = "")
 {
     $translate = Mage::getSingleton('core/translate');
     /* @var $translate Mage_Core_Model_Translate */
     $translate->setTranslateInline(false);
     $store_id = $this->getStoreId();
     $store_id = empty($store_id) ? Mage::app()->getStore()->getId() : $store_id;
     $email = Mage::getModel('core/email_template');
     $email->setDesignConfig(array('area' => 'frontend', 'store' => $store_id));
     /* @var $email Mage_Core_Model_Email_Template */
     $template = Mage::getStoreConfig(self::XML_PATH_CONFIRMATION_EMAIL_TEMPLATE, $store_id);
     $recipient = array('email' => $affiliate->getEmail(), 'name' => $affiliate->getName());
     $sender = array('name' => strip_tags($this->getSubscSenderName($store_id)), 'email' => strip_tags($this->getSubscSenderEmail($store_id)));
     $store_name = Mage::getModel('core/store')->load(Mage::app()->getStore()->getCode())->getName();
     // save theme settings because sendTransactional might not restore them
     $initial_layout = Mage::getDesign()->getTheme('layout');
     $initial_template = Mage::getDesign()->getTheme('template');
     $initial_skin = Mage::getDesign()->getTheme('skin');
     $initial_locale = Mage::getDesign()->getTheme('locale');
     $customerId = $this->getReferralChildId();
     $customer = Mage::getModel('rewards/customer')->load($customerId);
     $email->sendTransactional($template, $sender, $recipient['email'], $recipient['name'], array('parent' => $affiliate, 'affiliate' => $affiliate, 'referral' => $this, 'store_name' => $store_name, 'msg' => $message, 'referral_customer' => $customer, 'points_earned' => $pointsSummary, 'affiliate_url' => (string) Mage::helper('rewardsref/url')->getUrl($affiliate), 'referral_code' => (string) Mage::helper('rewardsref/code')->getCode($affiliate->getEmail()), 'referral_shortcode' => (string) Mage::helper('rewardsref/shortcode')->getCode($affiliate->getEmail())));
     $translate->setTranslateInline(true);
     if (!$email->getProcessedTemplate()) {
         throw new Exception(Mage::helper('rewards')->__("The referral e-mail template was not properly loaded. This might be due to locale issues with characters that could be read, or tempalte variables that could not be parsed properly. The template being loaded was %s", $template));
     }
     $return_value = $email->getSentSuccess();
     // restore theme restore
     Mage::getDesign()->setTheme('layout', $initial_layout);
     Mage::getDesign()->setTheme('template', $initial_template);
     Mage::getDesign()->setTheme('skin', $initial_skin);
     Mage::getDesign()->setTheme('locale', $initial_locale);
     return $return_value;
 }
コード例 #22
0
 /**
  * Send email id payment is in Fraud status
  * @param Mage_Customer_Model_Customer $receiver
  * @param Mage_Sales_Model_Order $order
  * @param string $message
  * @return Mage_Checkout_Helper_Data
  */
 public function sendFraudPaymentEmail($receiver, $order, $message, $email_key = 'fraud_payment')
 {
     $translate = Mage::getSingleton('core/translate');
     /* @var $translate Mage_Core_Model_Translate */
     $translate->setTranslateInline(false);
     $mailTemplate = Mage::getModel('core/email_template');
     /* @var $mailTemplate Mage_Core_Model_Email_Template */
     $template = Mage::getStoreConfig('hipay/' . $email_key . '/template', $order->getStoreId());
     $copyTo = $this->_getEmails('hipay/' . $email_key . '/copy_to', $order->getStoreId());
     $copyMethod = Mage::getStoreConfig('hipay/' . $email_key . '/copy_method', $order->getStoreId());
     if ($copyTo && $copyMethod == 'bcc') {
         $mailTemplate->addBcc($copyTo);
     }
     $sendTo = array(array('email' => $receiver->getEmail(), 'name' => $receiver->getName()));
     if ($copyTo && $copyMethod == 'copy') {
         foreach ($copyTo as $email) {
             $sendTo[] = array('email' => $email, 'name' => null);
         }
     }
     $shippingMethod = '';
     if ($shippingInfo = $order->getShippingAddress()->getShippingMethod()) {
         $data = explode('_', $shippingInfo);
         $shippingMethod = $data[0];
     }
     $paymentMethod = '';
     if ($paymentInfo = $order->getPayment()) {
         $paymentMethod = $paymentInfo->getMethod();
     }
     $items = '';
     foreach ($order->getAllVisibleItems() as $_item) {
         /* @var $_item Mage_Sales_Model_Quote_Item */
         $items .= $_item->getProduct()->getName() . '  x ' . $_item->getQty() . '  ' . $order->getStoreCurrencyCode() . ' ' . $_item->getProduct()->getFinalPrice($_item->getQty()) . "\n";
     }
     $total = $order->getStoreCurrencyCode() . ' ' . $order->getGrandTotal();
     foreach ($sendTo as $recipient) {
         $mailTemplate->setDesignConfig(array('area' => 'frontend', 'store' => $order->getStoreId()))->sendTransactional($template, Mage::getStoreConfig('hipay/' . $email_key . '/identity', $order->getStoreId()), $recipient['email'], $recipient['name'], array('reason' => $message, 'dateAndTime' => Mage::app()->getLocale()->date(), 'customer' => $order->getCustomerFirstname() . ' ' . $order->getCustomerLastname(), 'customerEmail' => $order->getCustomerEmail(), 'billingAddress' => $order->getBillingAddress(), 'shippingAddress' => $order->getShippingAddress(), 'shippingMethod' => Mage::getStoreConfig('carriers/' . $shippingMethod . '/title'), 'paymentMethod' => Mage::getStoreConfig('payment/' . $paymentMethod . '/title'), 'items' => nl2br($items), 'total' => $total));
     }
     $translate->setTranslateInline(true);
     return $this;
 }
コード例 #23
0
 public function sendCustomerDeActivationEmail(Mage_Customer_Model_Customer $customer)
 {
     if (Mage::helper('actions')->notify_customer()) {
         $name = Mage::getStoreConfig('trans_email/ident_support/name');
         $email = Mage::getStoreConfig('trans_email/ident_support/email');
         if ($customer->getEmail() != "") {
             $store_id = $this->getCustomerStoreId($customer);
             $local = Mage::getStoreConfig('general/locale/code', $store_id);
             $emailTemplate = Mage::getModel('core/email_template')->loadDefault('action_notify_customer_deactivate_email_template', $local);
             $emailTemplate->setSenderName($name)->setSenderEmail($email);
             $deactivate_subject = "";
             $deactivate_subject = Mage::getStoreConfig('zeo_actions_setting/customer_activation/email_deactivate_subject', $store_id);
             if ($deactivate_subject == "") {
                 $deactivate_subject = Mage::helper('core')->__("Your account has been deactivated");
             }
             $emailTemplate->setTemplateSubject($deactivate_subject);
             $emailTemplateVariables = array();
             $emailTemplateVariables['customer'] = $customer;
             $emailTemplateVariables['store'] = Mage::getModel('core/store')->load($store_id);
             $processedTemplate = $emailTemplate->getProcessedTemplate($emailTemplateVariables);
             $result = $emailTemplate->send($customer->getEmail(), $customer->getEmail(), $emailTemplateVariables);
         }
     }
 }
コード例 #24
0
ファイル: Filter.php プロジェクト: bevello/bevello
 /**
  * @param Mage_Customer_Model_Customer $customer
  *
  * @return Bronto_Common_Model_Email_Template_Filter
  */
 protected function _filterCustomer(Mage_Customer_Model_Customer $customer)
 {
     if (!in_array('customer', $this->_filteredObjects)) {
         // Handle Defaults from settings
         $customerName = trim($customer->getName()) == '' ? Mage::helper('bronto_common')->getDefaultGreeting('full', 'store', $this->getStoreId()) : $customer->getName();
         $customerPrefix = trim($customer->getPrefix()) == '' ? Mage::helper('bronto_common')->getDefaultGreeting('prefix', 'store', $this->getStoreId()) : $customer->getPrefix();
         $customerFirstName = trim($customer->getFirstname()) == '' ? Mage::helper('bronto_common')->getDefaultGreeting('firstname', 'store', $this->getStoreId()) : $customer->getFirstname();
         $customerLastName = trim($customer->getLastname()) == '' ? Mage::helper('bronto_common')->getDefaultGreeting('lastname', 'store', $this->getStoreId()) : $customer->getLastname();
         $this->setField('customerName', $customerName);
         $this->setField('firstName', $customerFirstName);
         $this->setField('prefix', $customerPrefix);
         $this->setField('lastName', $customerLastName);
         $this->setField('customerEmail', $customer->getEmail());
         $this->setField('customerPassword', $customer->getPassword());
         if ($store = $customer->getStore()) {
             $this->setField('confirmationLink', $store->getUrl('customer/account/confirm', array('_query' => array('id' => $customer->getId(), 'key' => $customer->getConfirmation()))));
             if (Mage::helper('bronto_common')->isVersionMatch(Mage::getVersionInfo(), 1, array(array('>=', '6')))) {
                 $this->setField('passwordResetLink', $store->getUrl('customer/account/resetpassword', array('_query' => array('id' => $customer->getId(), 'token' => $customer->getRpToken()))));
             }
         } else {
             $this->setField('confirmationLink', Mage::getUrl('customer/account/confirm', array('_query' => array('id' => $customer->getId(), 'key' => $customer->getConfirmation()))));
             if (Mage::helper('bronto_common')->isVersionMatch(Mage::getVersionInfo(), 1, array(array('>=', '6')))) {
                 $this->setField('passwordResetLink', Mage::getUrl('customer/account/resetpassword', array('_query' => array('id' => $customer->getId(), 'token' => $customer->getRpToken()))));
             }
         }
         $this->_filteredObjects[] = 'customer';
     }
     return $this;
 }
コード例 #25
0
ファイル: DeleteCommand.php プロジェクト: lslab/n98-magerun
 /**
  * @param \Mage_Customer_Model_Customer $customer
  * @return bool|\Exception
  */
 protected function deleteCustomer(\Mage_Customer_Model_Customer $customer)
 {
     try {
         $customer->delete();
         $this->output->writeln(sprintf('<info>%s (%s) was successfully deleted</info>', $customer->getName(), $customer->getEmail()));
         return true;
     } catch (\Exception $e) {
         $this->output->writeln('<error>' . $e->getMessage() . '</error>');
         return $e;
     }
 }
コード例 #26
0
ファイル: Quote.php プロジェクト: arslbbt/mangentovies
 /**
  * Define customer object
  *
  * @param   Mage_Customer_Model_Customer $customer
  * @return  Mage_Sales_Model_Quote
  */
 public function setCustomer(Mage_Customer_Model_Customer $customer)
 {
     $this->_customer = $customer;
     $this->setCustomerId($customer->getId());
     $this->setCustomerEmail($customer->getEmail());
     $this->setCustomerFirstname($customer->getFirstname());
     $this->setCustomerLastname($customer->getLastname());
     $this->setCustomerGroupId($customer->getGroupId());
     $this->setCustomerTaxClassId($customer->getTaxClassId());
     return $this;
 }
 /**
  * Synchronise a Magento customer with WordPress
  *
  * @param Mage_Customer_Model_Customer $customer
  * @return bool
  */
 public function synchroniseCustomer(Mage_Customer_Model_Customer $customer)
 {
     $email = $customer->getEmail();
     if ($customer->getCsData() && $customer->getCsData()->getEmail()) {
         $email = $customer->getCsData()->getEmail();
     }
     $user = Mage::getModel('wordpress/user')->loadByEmail($email);
     if (!$user->getId() && !$customer->getPassword()) {
         return false;
     }
     $user->setUserEmail($customer->getEmail())->setUserRegistered($customer->getCreatedAt())->setUserNicename($customer->getName())->setDisplayName($customer->getFirstname())->setFirstName($customer->getFirstname())->setLastName($customer->getLastname())->setNickname($customer->getFirstname());
     if (!$user->getUserLogin() || strpos($user->getUserLogin(), '@') !== false) {
         $user->setUserLogin($customer->getEmail());
     }
     try {
         if ($customer->hasPassword()) {
             if ($customer->validatePassword($customer->getPassword())) {
                 $wpHash = $this->hashPasswordForWordPress($customer->getPassword());
                 if ($this->isValidWordPressPassword($customer->getPassword(), $wpHash)) {
                     $user->setUserPass($wpHash);
                 }
             }
         }
         $user->save();
         $customer->setWordpressUser($user);
     } catch (Exception $e) {
         Mage::helper('wordpress')->log($e);
     }
 }
コード例 #28
0
ファイル: Observer.php プロジェクト: xiaoguizhidao/magento
 /**
  * Change customers segments after changing them at customer edit > newsletter section
  * @param Mage_Customer_Model_Customer $customer 
  */
 protected function updateSegmentsFromAdmin($customer)
 {
     if (Mage::app()->getRequest()->getParam('an_segments_changed')) {
         $segments = $this->getRequest()->getParam('segments_codes') ? $this->getRequest()->getParam('segments_codes') : array();
         $subscriber = Mage::getModel('advancednewsletter/subscriber')->loadByEmail($customer->getEmail());
         if ($subscriber->getId()) {
             if (empty($segments)) {
                 $subscriber->unsubscribeFromAll();
             } else {
                 $subscriber->forceWrite(array('segments_codes' => $segments, 'status' => AW_Advancednewsletter_Model_Subscriber::STATUS_SUBSCRIBED));
             }
         } else {
             if (!empty($segments)) {
                 $subscriber->setCustomer($customer)->subscribe($customer->getEmail(), $segments);
             }
         }
     }
 }
コード例 #29
0
ファイル: Email.php プロジェクト: ridhoq/mxpi-twitter
 /**
  * @param Mage_Customer_Model_Customer $customer
  * @return array
  */
 protected function _createEmailAddress(Mage_Customer_Model_Customer $customer)
 {
     $data = array('emailAddress' => $customer->getEmail());
     return $data;
 }
コード例 #30
0
 /**
  * @param string                                           $text
  * @param Mage_Customer_Model_Customer|Varien_Object|false $customer
  * @param Mage_Admin_Model_User|false                      $user
  * @param string                                           $triggeredBy
  * @param string                                           $messageType
  * @param bool|Mirasvit_Helpdesk_Model_Email               $email
  * @param bool|string                                      $bodyFormat
  *
  * @return Mirasvit_Helpdesk_Model_Message
  *
  * @throws Exception
  */
 public function addMessage($text, $customer, $user, $triggeredBy, $messageType = Mirasvit_Helpdesk_Model_Config::MESSAGE_PUBLIC, $email = false, $bodyFormat = false)
 {
     $message = Mage::getModel('helpdesk/message')->setTicketId($this->getId())->setType($messageType)->setBody($text)->setBodyFormat($bodyFormat)->setTriggeredBy($triggeredBy);
     if ($triggeredBy == Mirasvit_Helpdesk_Model_Config::CUSTOMER) {
         $message->setCustomerId($customer->getId());
         $message->setCustomerName($customer->getName());
         $message->setCustomerEmail($customer->getEmail());
         $message->setIsRead(true);
         $this->setLastReplyName($customer->getName());
     } elseif ($triggeredBy == Mirasvit_Helpdesk_Model_Config::USER) {
         $message->setUserId($user->getId());
         if ($this->getOrigData('user_id') == $this->getData('user_id')) {
             if ($messageType != Mirasvit_Helpdesk_Model_Config::MESSAGE_INTERNAL) {
                 $this->setUserId($user->getId());
                 // In case of different departments of ticket and owner, correct department id
                 $departments = Mage::getModel('helpdesk/department')->getCollection();
                 $departments->addUserFilter($user->getId())->addFieldToFilter('is_active', true);
                 if ($departments->count()) {
                     $this->_department = null;
                     $this->setDepartmentId($departments->getFirstItem()->getId());
                 }
             }
         }
         $this->setLastReplyName($user->getName());
         if ($message->isThirdParty()) {
             $message->setThirdPartyEmail($this->getThirdPartyEmail());
         }
     } elseif ($triggeredBy == Mirasvit_Helpdesk_Model_Config::THIRD) {
         $message->setThirdPartyEmail($this->getThirdPartyEmail());
         if ($email) {
             $this->setLastReplyName($email->getSenderNameOrEmail());
             $message->setThirdPartyName($email->getSenderName());
         }
     }
     if ($email) {
         $message->setEmailId($email->getId());
     }
     //если тикет был закрыт, затем поступило сообщение от пользователя - мы его открываем
     if ($triggeredBy != Mirasvit_Helpdesk_Model_Config::USER) {
         if ($this->isClosed()) {
             $status = Mage::getModel('helpdesk/status')->loadByCode(Mirasvit_Helpdesk_Model_Config::STATUS_OPEN);
             $this->setStatusId($status->getId());
         }
         $this->setIsArchived(false);
     }
     $message->save();
     if ($email) {
         $email->setIsProcessed(true)->setAttachmentMessageId($message->getId())->save();
     } else {
         Mage::helper('helpdesk')->saveAttachments($message);
     }
     if (!$this->getIsSpam()) {
         if ($this->getReplyCnt() == 0) {
             Mage::helper('helpdesk/notification')->newTicket($this, $customer, $user, $triggeredBy, $messageType);
         } else {
             Mage::helper('helpdesk/notification')->newMessage($this, $customer, $user, $triggeredBy, $messageType);
         }
     }
     $this->setReplyCnt($this->getReplyCnt() + 1);
     if (!$this->getFirstReplyAt() && $user) {
         $this->setFirstReplyAt(Mage::getSingleton('core/date')->gmtDate());
     }
     $this->setLastReplyAt(Mage::getSingleton('core/date')->gmtDate());
     $this->save();
     Mage::helper('helpdesk/history')->addMessage($this, $text, $triggeredBy, array('customer' => $customer, 'user' => $user, 'email' => $email), $messageType);
     return $message;
 }