예제 #1
0
 public function confirm()
 {
     $instance = NewsletterSubscriber::getInstanceByEmail($this->request->get('email'));
     if ($instance && $instance->confirmationCode->get() == $this->request->get('code')) {
         $instance->isEnabled->set(true);
         $instance->save();
     }
     return new ActionResponse('subscriber', $instance->toArray());
 }
 public function isApplicable()
 {
     $user = $this->getContext()->getUser();
     if (!$user) {
         return;
     }
     if (is_null($user->_isSubscriber)) {
         $user->load();
         $subscriber = NewsletterSubscriber::getInstanceByEmail($user->email->get());
         if ($subscriber && !$subscriber->isEnabled->get()) {
             $user->_isSubscriber = false;
         } else {
             $user->_isSubscriber = true;
         }
     }
     return $user->_isSubscriber;
 }
 protected function getInstance($record, CsvImportProfile $profile)
 {
     $fields = $profile->getSortedFields();
     if (isset($fields['NewsletterSubscriber']['ID'])) {
         $instance = ActiveRecordModel::getInstanceByID('NewsletterSubscriber', $record[$fields['NewsletterSubscriber']['ID']], true);
     } else {
         if (isset($fields['NewsletterSubscriber']['email'])) {
             $instance = NewsletterSubscriber::getInstanceByEmail($record[$fields['NewsletterSubscriber']['email']]);
         } else {
             return;
         }
     }
     if (empty($instance)) {
         $instance = NewsletterSubscriber::getNewInstanceByEmail($record[$fields['NewsletterSubscriber']['email']]);
     }
     $this->setLastImportedRecordName($instance->email->get());
     return $instance;
 }
예제 #4
0
파일: User.php 프로젝트: saiber/livecart
 protected function insert()
 {
     $res = parent::insert();
     if ($subscriber = NewsletterSubscriber::getInstanceByEmail($this->email->get())) {
         $subscriber->user->set($this);
     } else {
         $subscriber = NewsletterSubscriber::getNewInstanceByUser($this);
         $subscriber->isEnabled->set(false);
         $subscriber->save();
     }
     $subscriber->confirmationCode->set('');
     $subscriber->save();
     return $res;
 }