예제 #1
0
 /**
  * @param Am_Event_SubscriptionChanged $event 
  * @param User $oldUser presents if called from onUserLoginChanged
  */
 function onSubscriptionChanged(Am_Event_SubscriptionChanged $event, User $oldUser = null)
 {
     if ($oldUser === null) {
         $oldUser = $event->getUser();
     }
     $user = $event->getUser();
     $found = $this->getTable()->findByAmember($oldUser);
     if ($found) {
         if ($this->canUpdate($found)) {
             $this->getTable()->updateFromAmember($found, $user, $this->calculateGroups($user, true));
             $pass = $this->findPassword($user, true);
             if ($pass) {
                 $this->getTable()->updatePassword($found, $pass);
             }
         }
     } elseif ($groups = $this->calculateGroups($user, false)) {
         // we will only insert record if it makes sense - there are groups
         $this->getTable()->insertFromAmember($user, $this->findPassword($user, true), $groups);
     }
 }
예제 #2
0
 function onSubscriptionChanged(Am_Event_SubscriptionChanged $event)
 {
     $this->getDi()->newsletterUserSubscriptionTable->checkSubscriptions($event->getUser());
 }