Exemplo n.º 1
0
 public function save()
 {
     $this->load();
     $this->userAddress->get()->load();
     $this->userAddress->get()->save();
     return parent::save();
 }
Exemplo n.º 2
0
 public function save()
 {
     if (!$this->orderedItem->get()->customerOrder->get()->isFinalized->get()) {
         $this->updatePriceDiff();
     }
     return parent::save();
 }
 protected function save(ActiveRecordModel $listGroup)
 {
     $validator = $this->buildValidator();
     if ($validator->isValid()) {
         $listGroup->loadRequestData($this->request);
         $listGroup->save();
         return new JSONResponse(array('ID' => $listGroup->getID(), 'data' => $listGroup->toArray()), 'success');
     } else {
         return new JSONResponse(array('errors' => $validator->getErrorList()), 'failure');
     }
 }
Exemplo n.º 4
0
Arquivo: User.php Projeto: saiber/www
 /**
  * Save user in the database
  */
 public function save($forceOperation = null)
 {
     // auto-generate password if not set
     if (!$this->password->get()) {
         $this->setPassword($this->getAutoGeneratedPassword());
     }
     return parent::save($forceOperation);
 }
Exemplo n.º 5
0
 public function save()
 {
     if ($this->isModified()) {
         @unlink($this->userGroup->get()->getRoleCacheFile());
     }
     return parent::save();
 }
Exemplo n.º 6
0
 public function save($forceOperation = 0)
 {
     // do not allow 0 rates
     if (!$this->rate->get()) {
         $this->rate->set(1);
     }
     self::deleteCache();
     return parent::save($forceOperation);
 }
Exemplo n.º 7
0
 protected function saveRecord(ActiveRecordModel $record)
 {
     $record->save();
 }
Exemplo n.º 8
0
 public function save($forceOperation = null)
 {
     if (!$this->currency->get()) {
         $this->currency->set($this->realCurrency->get());
         $this->amount->set($this->realAmount->get());
     }
     // encrypt card number
     if ($this->ccLastDigits->isModified()) {
         $this->ccLastDigits->set($this->encrypt($this->ccLastDigits->get()));
     }
     return parent::save($forceOperation);
 }
Exemplo n.º 9
0
 public function save()
 {
     BusinessRuleController::clearCache();
     return parent::save();
 }
Exemplo n.º 10
0
 public function save($allowEmpty = false)
 {
     if (!$this->orderedItems) {
         $this->loadItems();
     }
     // remove zero-count items
     foreach ($this->orderedItems as $item) {
         if (!$item->count->get()) {
             $this->removeItem($item);
         }
     }
     $isModified = false;
     foreach ($this->orderedItems as $item) {
         if ($item->isDeleted()) {
             $this->removeItem($item);
         }
     }
     // delete removed items
     if ($this->removedItems) {
         foreach ($this->removedItems as $item) {
             $item->delete();
             $isModified = true;
         }
         $this->removedItems = array();
         $this->resetShipments();
     }
     if ($this->orderedItems) {
         $this->getCurrency();
         foreach ($this->orderedItems as $item) {
             if ($item->isModified()) {
                 if (!$this->isExistingRecord()) {
                     parent::save();
                 }
                 if ($item->save()) {
                     $isModified = true;
                 }
             }
             $item->markAsLoaded();
         }
     }
     // If shipment is modified
     if ($this->isFinalized->get()) {
         if ($this->shipments) {
             foreach ($this->shipments as $shipment) {
                 if ($shipment->isModified()) {
                     $isModified = true;
                     break;
                 }
             }
         }
     }
     if ($isModified) {
         $this->getCurrency();
         // reorder shipments when cart items are modified
         $this->resetShipments();
         $this->totalAmount->set($this->getTotal(true));
     } else {
         if (!$this->isShippingRequired()) {
             //$this->shippingAddress->setNull();
         }
     }
     if ($this->isModified() || $isModified) {
         $this->serializeShipments();
     }
     if (!$this->isFinalized->get() && !$this->orderedItems && !$allowEmpty && !self::$isEmptyAllowed) {
         $this->delete();
         return false;
     }
     if ($this->user->get()) {
         $this->user->get()->invalidateSessionCache();
     }
     return parent::save();
 }
Exemplo n.º 11
0
 protected function importAttributes(ActiveRecordModel $instance, $record, $fields, $attrIdentifier = 'eavField')
 {
     if (isset($fields[$attrIdentifier])) {
         $impReq = new Request();
         $fieldClass = ucfirst($attrIdentifier);
         $valueClass = 'eavField' == $attrIdentifier ? 'EavValue' : $fieldClass . 'Value';
         foreach ($fields[$attrIdentifier] as $specFieldID => $csvIndex) {
             if (empty($record[$csvIndex])) {
                 continue;
             }
             $attr = ActiveRecordModel::getInstanceByID($fieldClass, $specFieldID, ActiveRecord::LOAD_DATA);
             if ($attr->isSimpleNumbers()) {
                 $impReq->set($attr->getFormFieldName(), (double) $record[$csvIndex]);
             } else {
                 if ($attr->isSelector()) {
                     if ($attr->isMultiValue->get()) {
                         $values = explode(',', $record[$csvIndex]);
                     } else {
                         $values = array($record[$csvIndex]);
                     }
                     foreach ($values as $fieldValue) {
                         $fieldValue = trim($fieldValue);
                         $f = new ARSelectFilter(new LikeCond(MultilingualObject::getLangSearchHandle(new ARFieldHandle($valueClass, 'value'), $this->application->getDefaultLanguageCode()), $fieldValue . '%'));
                         $f->setLimit(1);
                         if (!($value = $attr->getRelatedRecordSet($valueClass, $f)->shift())) {
                             $value = call_user_func_array(array($valueClass, 'getNewInstance'), array($attr));
                             if ($attr->type->get() == EavFieldCommon::TYPE_NUMBERS_SELECTOR) {
                                 $value->value->set($fieldValue);
                             } else {
                                 $value->setValueByLang('value', $this->application->getDefaultLanguageCode(), $fieldValue);
                             }
                             $value->save();
                         }
                         if (!$attr->isMultiValue->get()) {
                             $impReq->set($attr->getFormFieldName(), $value->getID());
                         } else {
                             $impReq->set($value->getFormFieldName(), true);
                         }
                     }
                 } else {
                     $impReq->set($attr->getFormFieldName(), $record[$csvIndex]);
                 }
             }
         }
         $instance->loadRequestData($impReq);
         $instance->save();
     }
 }
Exemplo n.º 12
0
 public function save($downloadable = false)
 {
     $this->removeDeletedItems();
     // make sure the shipment doesn't consist of downloadable files only
     if (!$this->isShippable() && !$this->order->get()->isFinalized->get()) {
         //return false;
     }
     // reset amounts...
     //		$this->amount->set(0);
     //		$this->shippingAmount->set(0);
     //		$this->taxAmount->set(0);
     // ... and recalculated them
     $this->recalculateAmounts();
     // set shipping data
     $rate = $this->getSelectedRate();
     if ($rate) {
         $serviceId = $rate->getServiceID();
         if (is_numeric($serviceId)) {
             $this->shippingService->set(ShippingService::getInstanceByID($serviceId));
         } else {
             $this->shippingService->set(null);
             $this->shippingServiceData->set(serialize($rate));
         }
     }
     // Update order status if to reflect it's shipments statuses
     if (!$downloadable && $this->isShippable() && $this->order->get()->isFinalized->get()) {
         $this->order->get()->updateStatusFromShipments(!$this->isExistingRecord());
     }
     parent::save();
     // save ordered items
     foreach ($this->items as $item) {
         if (!$item->isDeleted()) {
             $item->shipment->set($this);
             $item->customerOrder->set($this->order->get());
             $item->save();
         }
     }
     // save taxes
     foreach ($this->getTaxes() as $tax) {
         if ($tax->amount->get()) {
             $tax->save();
         } else {
             $tax->delete();
         }
     }
 }
Exemplo n.º 13
0
 public function save()
 {
     parent::save();
     $this->order->get()->registerFixedDiscount($this);
 }
Exemplo n.º 14
0
 public function save($forceOperation = 0)
 {
     self::deleteCache();
     return parent::save($forceOperation);
 }
Exemplo n.º 15
0
 public function save($forceOperation = 0)
 {
     parent::save($forceOperation);
     $this->updateRoles();
 }