Ejemplo n.º 1
0
 public function tearDown()
 {
     parent::tearDown();
     @unlink(ClassLoader::getRealPath('cache.') . 'currencies.php');
     $this->setUpCurrency();
     ActiveRecordModel::rollback();
 }
Ejemplo n.º 2
0
 public function tearDown()
 {
     ActiveRecordModel::rollback();
     foreach ($this->getUsedSchemas() as $table) {
         ActiveRecord::removeClassFromPool($table);
         $this->db->executeUpdate("ALTER TABLE {$table} AUTO_INCREMENT=" . $this->autoincrements[$table]);
     }
     self::getApplication()->setRequest(clone $this->originalRequest);
 }
Ejemplo n.º 3
0
 /**
  * Removes a product from a database
  *
  * @param int $recordID
  * @return bool
  * @throws Exception
  */
 public static function deleteByID($recordID)
 {
     ActiveRecordModel::beginTransaction();
     try {
         $product = Product::getInstanceByID($recordID, Product::LOAD_DATA);
         $filter = $product->getCountUpdateFilter(true);
         if ($product->category->get()) {
             $product->updateCategoryCounters($filter, $product->category->get());
         }
         foreach ($product->getAdditionalCategories() as $category) {
             $product->updateCategoryCounters($filter, $category);
         }
         parent::deleteByID(__CLASS__, $recordID);
         ActiveRecordModel::commit();
         return true;
     } catch (Exception $e) {
         ActiveRecordModel::rollback();
         throw $e;
     }
 }
Ejemplo n.º 4
0
 /**
  * Removes category by ID and fixes data in parent categories
  * (updates activeProductCount and totalProductCount)
  *
  * @param int $recordID
  */
 public function delete()
 {
     ActiveRecordModel::beginTransaction();
     try {
         $activeProductCount = $this->activeProductCount->get();
         $totalProductCount = $this->totalProductCount->get();
         $availableProductCount = $this->availableProductCount->get();
         foreach ($this->getPathNodeSet(true) as $node) {
             $node->setFieldValue("activeProductCount", "activeProductCount - " . $activeProductCount);
             $node->setFieldValue("totalProductCount", "totalProductCount - " . $totalProductCount);
             $node->setFieldValue("availableProductCount", "availableProductCount - " . $availableProductCount);
             $node->save();
         }
         ActiveRecordModel::commit();
         parent::delete();
     } catch (Exception $e) {
         ActiveRecordModel::rollback();
         throw $e;
     }
 }
Ejemplo n.º 5
0
 function test_SuiteTearDown()
 {
     ActiveRecordModel::rollback();
 }
Ejemplo n.º 6
0
 protected function postProcessResponse(Response $response)
 {
     if ($response instanceof ActionRedirectResponse) {
         $response = new ActionResponse();
     }
     if (empty($GLOBALS['stepData'])) {
         $stepData = array();
         $stepData['steps'] = $this->getCheckoutSteps($this->order);
         $stepData['editableSteps'] = $this->getStepStatus($this->order);
         $stepData['completedSteps'] = $this->getStepStatus($this->order, true);
         $GLOBALS['stepData'] = $stepData;
     } else {
         $stepData = $GLOBALS['stepData'];
     }
     foreach ($stepData as $key => $data) {
         $response->set($key, $data);
     }
     if ($this->anonTransactionInitiated) {
         ActiveRecordModel::rollback();
     }
     return $response;
 }
Ejemplo n.º 7
0
 protected function postProcessResponse(Response $response)
 {
     if ($response instanceof ActionRedirectResponse) {
         $response = new ActionResponse();
     }
     $response->set('steps', $this->getCheckoutSteps($this->order));
     $response->set('editableSteps', $this->getStepStatus($this->order));
     $response->set('completedSteps', $this->getStepStatus($this->order, true));
     if ($this->anonTransactionInitiated) {
         ActiveRecordModel::rollback();
         $this->anonTransactionInitiated = false;
     }
     return $response;
 }
Ejemplo n.º 8
0
 /**
  *	@role login
  */
 public function payCreditCard()
 {
     if ($id = $this->request->get('id')) {
         $this->request->set('order', $id);
     }
     $order = $this->getPaymentOrder();
     if ($redirect = $this->validateOrder($order, self::STEP_PAYMENT)) {
         return $redirect;
     }
     // already paid?
     if ($order->isPaid->get()) {
         return new ActionRedirectResponse('checkout', 'completed');
     }
     ActiveRecordModel::beginTransaction();
     $this->order->setCheckoutStep(CustomerOrder::CHECKOUT_PAY);
     $this->order->setPaymentMethod($this->config->get('CC_HANDLER'));
     // process payment
     $transaction = $this->getTransaction();
     $names = explode(' ', $this->request->get('ccName'), 2);
     $transaction->firstName->set(array_shift($names));
     $transaction->lastName->set(array_shift($names));
     $handler = $this->application->getCreditCardHandler($transaction);
     if ($this->request->isValueSet('ccType')) {
         $handler->setCardType($this->request->get('ccType'));
     }
     $handler->setCardData($this->request->get('ccNum'), $this->request->get('ccExpiryMonth'), $this->request->get('ccExpiryYear'), $this->request->get('ccCVV'));
     if (!$this->buildCreditCardValidator($handler)->isValid()) {
         ActiveRecordModel::rollback();
         return $this->getPaymentPageRedirect();
     }
     if ($this->config->get('CC_AUTHONLY')) {
         $result = $handler->authorize();
     } else {
         $result = $handler->authorizeAndCapture();
     }
     if ($result instanceof TransactionResult) {
         $response = $this->registerPayment($result, $handler);
         $trans = $this->order->getTransactions()->get(0);
         $eavObject = EavObject::getInstance($trans);
         $eavObject->setStringIdentifier('creditcard');
         $eavObject->save();
         $trans->getSpecification()->loadRequestData($this->request);
         $trans->save();
     } elseif ($result instanceof TransactionError) {
         // set error message for credit card form
         $validator = $this->buildCreditCardValidator($handler);
         $validator->triggerError('creditCardError', $this->translate('_err_processing_cc'));
         $validator->saveState();
         $response = $this->getPaymentPageRedirect();
     } else {
         var_dump($result);
         throw new Exception('Unknown transaction result type: ' . get_class($result));
     }
     ActiveRecordModel::commit();
     return $response;
 }
Ejemplo n.º 9
0
 /**
  * Delete this node with subtree
  *
  * @return bool
  *
  * @throws Exception If failed to commit the transaction
  */
 public function delete()
 {
     $className = get_class($this);
     $this->load();
     $t_r = $this->getFieldValue(self::RIGHT_NODE_FIELD_NAME);
     $t_l = $this->getFieldValue(self::LEFT_NODE_FIELD_NAME);
     $width = $this->getWidth();
     ActiveRecordModel::beginTransaction();
     try {
         $updates[] = "UPDATE {$className} SET " . self::RIGHT_NODE_FIELD_NAME . " = " . self::RIGHT_NODE_FIELD_NAME . " - {$width}  WHERE " . self::RIGHT_NODE_FIELD_NAME . " >= {$t_r}";
         $updates[] = "UPDATE {$className} SET " . self::LEFT_NODE_FIELD_NAME . " = " . self::LEFT_NODE_FIELD_NAME . " - {$width} WHERE " . self::LEFT_NODE_FIELD_NAME . " >= {$t_l}";
         foreach ($updates as $update) {
             self::getLogger()->logQuery($update);
             self::getDBConnection()->executeUpdate($update);
         }
         $result = parent::delete();
         ActiveRecordModel::commit();
         foreach (ActiveRecord::retrieveFromPool(get_class($this)) as $instance) {
             if ($instance->getFieldValue(self::RIGHT_NODE_FIELD_NAME) >= $t_r) {
                 $instance->setFieldValue(self::RIGHT_NODE_FIELD_NAME, $instance->getFieldValue(self::RIGHT_NODE_FIELD_NAME) - $width);
             }
             if ($instance->getFieldValue(self::LEFT_NODE_FIELD_NAME) >= $t_l) {
                 $instance->setFieldValue(self::LEFT_NODE_FIELD_NAME, $instance->getFieldValue(self::LEFT_NODE_FIELD_NAME) - $width);
             }
         }
     } catch (Exception $e) {
         ActiveRecordModel::rollback();
         throw $e;
     }
     $this->setID(false);
     $this->markAsNotLoaded();
     return $result;
 }