Example #1
0
 public function update()
 {
     $hm = $this->getDi()->hook;
     if ($hm->have(Am_Event::ACCESS_AFTER_UPDATE)) {
         $old = $this->getTable()->load($this->pk());
     }
     parent::update();
     $this->runHooks();
     if ($hm->have(Am_Event::ACCESS_AFTER_UPDATE)) {
         $this->getDi()->hook->call(Am_Event::ACCESS_AFTER_UPDATE, array('access' => $this, 'old' => $old));
     }
     return $this;
 }
Example #2
0
 function update()
 {
     $oldU = new stdclass();
     $oldU->user_id = null;
     if ($this->getDi()->hook->have(array('userBeforeUpdate', 'userAfterUpdate', 'subscriptionUpdated')) || $this->getDi()->config->get('manually_approve')) {
         // do loading only if hooks are set
         $oldU = $this->getTable()->load($this->user_id, false);
         if (!$oldU) {
             $oldU = new self();
         }
         // avoid errors here
         $this->getDi()->hook->call(new Am_Event_UserBeforeUpdate($this, $oldU));
     }
     $ret = parent::update();
     if ($this->_passwordChanged) {
         $this->data()->set(self::NEED_SESSION_REFRESH, true)->update();
         $event = new Am_Event_SetPassword($this, $this->getPlaintextPass());
         $this->getDi()->savedPassTable->setPass($event);
         $this->getDi()->hook->call($event);
         $this->sendChangepassEmail();
     }
     if ($oldU->user_id) {
         if ($this->is_approved && !$oldU->is_approved) {
             $this->approve();
         }
         $this->getDi()->hook->call(new Am_Event_UserAfterUpdate($this, $oldU));
     }
     if ($this->status && $oldU->user_id) {
         $this->getDi()->hook->call(new Am_Event_SubscriptionUpdated($this, $oldU));
     }
     $this->_passwordChanged = false;
     return $ret;
 }
Example #3
0
 function update()
 {
     $oldU = new stdclass();
     $oldU->user_id = null;
     if ($this->getDi()->hook->have(array('userBeforeUpdate', 'userAfterUpdate', 'subscriptionUpdated'))) {
         // do loading only if hooks are set
         $oldU = $this->getTable()->load($this->user_id, false);
         if (!$oldU) {
             $oldU = new self();
         }
         // avoid errors here
         $this->getDi()->hook->call(new Am_Event_UserBeforeUpdate($this, $oldU));
     }
     $ret = parent::update();
     if ($this->_passwordChanged) {
         $event = new Am_Event_SetPassword($this, $this->getPlaintextPass());
         $this->getDi()->savedPassTable->setPass($event);
         $event->run();
     }
     if ($oldU->user_id) {
         if ($this->is_approved && !$oldU->is_approved) {
             $this->sendSignupEmailIfNecessary();
         }
         $this->getDi()->hook->call(new Am_Event_UserAfterUpdate($this, $oldU));
     }
     if ($this->status && $oldU->user_id) {
         $this->getDi()->hook->call(new Am_Event_SubscriptionUpdated($this, $oldU));
     }
     $this->_passwordChanged = false;
     return $ret;
 }
Example #4
0
 function update()
 {
     $ret = parent::update();
     $ids = array();
     foreach ($this->_items as $item) {
         $item->set('invoice_id', $this->invoice_id)->save();
     }
     return $ret;
 }
Example #5
0
 public function update()
 {
     $hm = $this->getDi()->hook;
     if ($hm->have(Am_Event::COUPON_BEFORE_UPDATE)) {
         $old = $this->getTable()->load($this->pk());
         $old->toggleFrozen(true);
         $hm->call(Am_Event::COUPON_BEFORE_UPDATE, array('coupon' => $this, 'old' => $old));
     }
     if (!$this->user_id) {
         $this->user_id = null;
     }
     if (!is_numeric($this->user_id)) {
         $user = $this->getDi()->userTable->findFirstByLogin($this->user_id);
         $this->user_id = $user ? $user->pk() : null;
     }
     parent::update();
     return $this;
 }