/** * @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); } }
function onSubscriptionChanged(Am_Event_SubscriptionChanged $event) { $this->getDi()->newsletterUserSubscriptionTable->checkSubscriptions($event->getUser()); }