Beispiel #1
0
 public function insert($reload = true)
 {
     parent::insert($reload);
     $this->runHooks();
     $this->getDi()->hook->call(Am_Event::ACCESS_AFTER_INSERT, array('access' => $this));
     return $this;
 }
Beispiel #2
0
 public function insert($reload = true)
 {
     if ($this->currency == Am_Currency::getDefault()) {
         $this->base_currency_multi = 1.0;
     } else {
         $this->base_currency_multi = $this->getDi()->currencyExchangeTable->getRate($this->currency, sqlDate($this->dattm));
     }
     $ret = parent::insert($reload);
     $this->setDisplayInvoiceId();
     $this->getDi()->hook->call('refundAfterInsert', array('invoice' => $this->getInvoice(), 'refund' => $this, 'user' => $this->getInvoice()->getUser()));
     return $ret;
 }
Beispiel #3
0
 function insert($reload = true)
 {
     if (!isset($this->is_approved)) {
         $this->is_approved = !$this->getDi()->config->get('manually_approve');
     }
     if (empty($this->remote_addr)) {
         $this->remote_addr = htmlentities(@$_SERVER['REMOTE_ADDR']);
     }
     if (empty($this->added)) {
         $this->added = $this->getDi()->sqlDateTime;
     }
     $this->getDi()->hook->call(new Am_Event_UserBeforeInsert($this));
     $ret = parent::insert($reload);
     if ($this->_passwordChanged) {
         $event = new Am_Event_SetPassword($this, $this->getPlaintextPass());
         $this->getDi()->savedPassTable->setPass($event);
         $event->run();
     }
     $this->getDi()->hook->call(new Am_Event_UserAfterInsert($this));
     $this->_passwordChanged = false;
     return $ret;
 }
Beispiel #4
0
 function insert($reload = true)
 {
     $this->uploaded = $this->getDi()->time;
     return parent::insert($reload);
 }
Beispiel #5
0
 function insert($reload = true)
 {
     if (!isset($this->is_approved)) {
         $this->is_approved = !$this->getDi()->config->get('manually_approve');
     }
     if (empty($this->remote_addr)) {
         $this->remote_addr = htmlentities(@$_SERVER['REMOTE_ADDR']);
     }
     if (empty($this->user_agent)) {
         $this->user_agent = @$_SERVER['HTTP_USER_AGENT'];
     }
     if (empty($this->added)) {
         $this->added = $this->getDi()->sqlDateTime;
     }
     $this->getDi()->hook->call(new Am_Event_UserBeforeInsert($this));
     $ret = parent::insert($reload);
     if ($this->_passwordChanged) {
         $event = new Am_Event_SetPassword($this, $this->getPlaintextPass());
         $this->getDi()->savedPassTable->setPass($event);
         $this->getDi()->hook->call($event);
     }
     if ($this->_passwordGenerated) {
         $crypt = new Crypt_Blowfish($this->getDi()->app->getSiteKey());
         $pg = $crypt->encrypt($this->getPlaintextPass());
         $this->getDi()->store->set('pass-generated-' . $this->pk(), base64_encode($pg), '+6 hours');
     }
     $this->getDi()->hook->call(new Am_Event_UserAfterInsert($this));
     $this->_passwordChanged = false;
     return $ret;
 }
Beispiel #6
0
 public function insert($reload = true)
 {
     $table_name = $this->getTable()->getName();
     $max = $this->getAdapter()->selectCell("SELECT MAX(sort_order) FROM {$table_name}");
     $this->sort_order = $max + 1;
     return parent::insert($reload);
 }
Beispiel #7
0
 function insert($reload = true)
 {
     if (empty($this->tm_added)) {
         $this->tm_added = sqlTime('now');
     }
     $this->_getInvoiceKey();
     $maxAttempts = 20;
     for ($i = 0; $i <= $maxAttempts; $i++) {
         try {
             $this->_getPublicId();
             $ret = parent::insert($reload = true);
             break;
         } catch (Am_Exception_Db_NotUnique $e) {
             if ($i >= $maxAttempts) {
                 throw $e;
             }
             $this->public_id = null;
         }
     }
     foreach ($this->_items as $item) {
         $item->set('invoice_id', $this->invoice_id)->insert();
     }
     return $ret;
 }
 public function insert($reload = true)
 {
     if ($this->currency == Am_Currency::getDefault()) {
         $this->base_currency_multi = 1.0;
     } else {
         $this->base_currency_multi = $this->getDi()->currencyExchangeTable->getRate($this->currency, sqlDate($this->dattm));
     }
     $this->getDi()->hook->call(new Am_Event(Am_Event::PAYMENT_BEFORE_INSERT, array('payment' => $this, 'invoice' => $this->getInvoice(), 'user' => $this->getInvoice()->getUser())));
     parent::insert($reload);
     $this->setDisplayInvoiceId();
     $this->getDi()->hook->call(new Am_Event_PaymentAfterInsert(null, array('payment' => $this, 'invoice' => $this->getInvoice(), 'user' => $this->getInvoice()->getUser())));
     return $this;
 }
Beispiel #9
0
 function insert($reload = true)
 {
     // Set is confirmed value if it wasn't set yet;
     if (!isset($this->is_confirmed)) {
         // If user is not approved, invoice shouldn't be approved too.
         if ($this->getUser() && !$this->getUser()->isApproved()) {
             $this->is_confirmed = self::IS_CONFIRMED_WAIT_FOR_USER;
         }
         if ($this->getDi()->config->get('manually_approve_invoice')) {
             // Now check is manually_approve_invoice_products is set.
             if ($products = $this->getManuallyApproveInvoiceProducts()) {
                 foreach ($this->getProducts() as $p) {
                     if (in_array($p->product_id, $products)) {
                         $this->is_confirmed = self::IS_CONFIRMED_NOT_CONFIRMED;
                     }
                 }
             } else {
                 $this->is_confirmed = self::IS_CONFIRMED_NOT_CONFIRMED;
             }
         }
         // If above checks, didn't change is_confirmed status, then invoice is confirmed;
         if (!isset($this->is_confirmed)) {
             $this->is_confirmed = self::IS_CONFIRMED_CONFIRMED;
         }
     }
     $this->getDi()->hook->call(Am_Event::INVOICE_BEFORE_INSERT, array('invoice' => $this));
     if (empty($this->tm_added)) {
         $this->tm_added = sqlTime('now');
     }
     $this->_getInvoiceKey();
     $maxAttempts = 20;
     for ($i = 0; $i <= $maxAttempts; $i++) {
         try {
             $this->_getPublicId();
             $ret = parent::insert($reload = true);
             break;
         } catch (Am_Exception_Db_NotUnique $e) {
             if ($i >= $maxAttempts) {
                 throw $e;
             }
             $this->public_id = null;
         }
     }
     foreach ($this->_items as $item) {
         $item->set('invoice_id', $this->invoice_id)->set('invoice_public_id', $this->public_id)->insert();
     }
     $this->getDi()->hook->call(Am_Event::INVOICE_AFTER_INSERT, array('invoice' => $this));
     return $ret;
 }