Пример #1
0
 /**
  * Set current object non-blacklisted
  * User and subscriptions will be set to confirmed
  * @return void
  */
 public function setNonBlacklisted()
 {
     CjwNewsletterLog::writeDebug('CjwNewsletterUser::setNonBlacklisted', 'user', 'blacklist', array('nl_user' => $this->attribute('id')));
     // we determine the actual status by checking the various timestamps
     if ($this->attribute('confirmed') != 0) {
         if ($this->attribute('bounced') != 0 || $this->attribute('removed') != 0) {
             if ($this->attribute('removed') > $this->attribute('bounced')) {
                 $this->setRemoved();
             } else {
                 $this->setBounced();
             }
         } else {
             $this->setAttribute('status', self::STATUS_CONFIRMED);
         }
     } else {
         // might have been removed by admin
         if ($this->attribute('removed') != 0) {
             $this->setRemoved(true);
         } else {
             $this->setAttribute('status', self::STATUS_PENDING);
         }
     }
     $this->setAttribute('blacklisted', 0);
     // set all subscriptions and all open senditems to blacklisted
     foreach (CjwNewsletterSubscription::fetchSubscriptionListByNewsletterUserId($this->attribute('id')) as $subscription) {
         $subscription->setNonBlacklisted();
     }
     $this->store();
 }