Blame view

src/lib/MyMailer/EventOnlineSubscribe.php 1.13 KB
f7818cdf   Administrator   change request to...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
  <?php
  
  namespace MyMailer;
  
  class EventOnlineSubscribe extends EventOnline{
  
      public $is_new = false;
      public $customer;
  
      /**
       * @param $post array()
       */
      public function subscribeNewCustomer($post){
          $user['email']       = $post['email'];
          $user['name']        = isset($post['name']) ? $post['name']:'';
          $user['project_id']  = $post['project_id'];
  
          $customers_model = new \customersEmailList;
  
          if(!$this->checkCustomer($customers_model, $post)){
              $customers_model->save($user);
              $this->addLettersList($post['project_id'],$customers_model->id);
              return $customers_model;
          }
  
  
      }
  
      public function checkCustomer($customers_model, $post){
  
          $this->customer = $customers_model->findFirst("email = '{$post['email']}'");
  
          if($this->customer instanceof \customersEmailList){
              return true;
          } else {
              return false;
          }
      }
  
      public function addLatterListToNewCustomer($post,$customer){
          if($this->is_new){
              $this->addLettersList($post['project_id'],$this->customer->id);
          }
      }
  }