예제 #1
0
 /**
  * Encode JSON response and immediately send
  *
  * @param  mixed   $data
  * @param  boolean|array $keepLayouts
  * NOTE:   if boolean, establish $keepLayouts to true|false
  *         if array, admit params for Zend_Json::encode as enableJsonExprFinder=>true|false
  *         if $keepLayouts and parmas for Zend_Json::encode are required
  *         then, the array can contains a 'keepLayout'=>true|false
  *         that will not be passed to Zend_Json::encode method but will be passed
  *         to Zend_View_Helper_Json
  * @param  bool $wrap
  * @return string|void
  */
 public function sendJson($data, $keepLayouts = false, $wrap = true)
 {
     if (!is_array($data)) {
         return parent::sendJson($data, $keepLayouts);
     }
     if (isset($data['success']) && !is_bool($data['success'])) {
         $data['success'] = (bool) $data['success'];
     }
     if ($wrap) {
         $messages = Axis::message()->getAll();
         //            if (isset(false === $data['success']) && $data['success']) {
         //                unset($messages['success']);
         //            }
         $data = array_merge(array('messages' => $messages), $data);
     }
     if ($this->_data) {
         $data = array_merge_recursive($this->_data, $data);
     }
     $data = $this->encodeJson($data, $keepLayouts);
     $response = $this->getResponse();
     $response->setBody($data);
     if (!$this->suppressExit) {
         Zend_Wildfire_Channel_HttpHeaders::getInstance()->flush();
         //Axis_FirePhp
         $response->sendResponse();
         exit;
     }
     return $data;
 }
 /**
  *
  * @param mixed $value
  * @return mixed
  */
 public static function getSaveValue($value)
 {
     if (!is_array($value)) {
         return $value;
     }
     function remove_quotes(&$str)
     {
         $str = str_replace(array('"', "'"), '', $str);
     }
     $filename = Axis::config()->system->path . '/var/export/' . current($value);
     if (@(!($fp = fopen($filename, 'r')))) {
         Axis::message()->addError(Axis::translate('core')->__("Can't open file : %s", $filename));
         return current($value);
     }
     $titles = fgetcsv($fp, 2048, ',', "'");
     array_walk($titles, 'remove_quotes');
     $rowSize = count($titles);
     Axis::table('shippingtable_rate')->delete("site_id = " . $value['siteId']);
     while (!feof($fp)) {
         $data = fgetcsv($fp, 2048, ',', "'");
         if (!is_array($data)) {
             continue;
         }
         $data = array_pad($data, $rowSize, '');
         array_walk($data, 'remove_quotes');
         $data = array_combine($titles, $data);
         Axis::table('shippingtable_rate')->insert(array('site_id' => $value['siteId'], 'country_id' => Axis::single('location/country')->getIdByIsoCode3($data['Country']), 'zone_id' => Axis::single('location/zone')->getIdByCode($data['Region/State']), 'zip' => $data['Zip'], 'value' => $data['Value'], 'price' => $data['Price']));
     }
     return current($value);
 }
예제 #3
0
 /**
  * Customer add new tag on product
  * @return void
  */
 public function addAction()
 {
     $tags = array_filter(explode(',', $this->_getParam('tags')));
     $productId = $this->_getParam('productId');
     $modelCustomer = Axis::model('tag/customer');
     $modelProduct = Axis::model('tag/product');
     $defaultStatus = $modelCustomer->getDefaultStatus();
     $customerId = Axis::getCustomerId();
     $siteId = Axis::getSiteId();
     $_row = array('customer_id' => $customerId, 'site_id' => $siteId, 'status' => $modelCustomer->getDefaultStatus());
     foreach ($tags as $tag) {
         $row = $modelCustomer->select()->where('name = ?', $tag)->where('customer_id = ?', $customerId)->where('site_id = ?', $siteId)->fetchRow();
         if (!$row) {
             $_row['name'] = $tag;
             $row = $modelCustomer->createRow($_row);
             $row->save();
             Axis::message()->addSuccess(Axis::translate('tag')->__("Tag '%s' was successfully added to product", $tag));
         } else {
             Axis::message()->addNotice(Axis::translate('tag')->__("Your tag '%s' is already added to this product", $tag));
         }
         // add to product relation
         $isExist = (bool) $modelProduct->select('id')->where('customer_tag_id = ?', $row->id)->where('product_id = ?', $productId)->fetchOne();
         if (!$isExist) {
             $modelProduct->createRow(array('customer_tag_id' => $row->id, 'product_id' => $productId))->save();
         }
         Axis::dispatch('tag_product_add_success', array('tag' => $tag, 'product_id' => $productId));
     }
     $this->_redirect($this->getRequest()->getServer('HTTP_REFERER'));
 }
예제 #4
0
 public function removeAction()
 {
     $customerGroupIds = Zend_Json::decode($this->_getParam('data'));
     $isValid = true;
     if (in_array(Axis_Account_Model_Customer_Group::GROUP_GUEST_ID, $customerGroupIds)) {
         $isValid = false;
         Axis::message()->addError(Axis::translate('admin')->__("Your can't delete default Guest group id: %s ", Axis_Account_Model_Customer_Group));
     }
     if (in_array(Axis_Account_Model_Customer_Group::GROUP_ALL_ID, $customerGroupIds)) {
         $isValid = false;
         Axis::message()->addError(Axis::translate('admin')->__("Your can't delete default All group id: %s ", Axis_Account_Model_Customer_Group::GROUP_ALL_ID));
     }
     if (true === in_array(Axis::config()->account->main->defaultCustomerGroup, $customerGroupIds)) {
         $isValid = false;
         Axis::message()->addError(Axis::translate('admin')->__("Your can't delete default customer group id: %s ", $id));
     }
     if (!sizeof($customerGroupIds)) {
         $isValid = false;
         Axis::message()->addError(Axis::translate('admin')->__('No data to delete'));
     }
     if ($isValid) {
         Axis::single('account/customer_group')->delete($this->db->quoteInto('id IN(?)', $customerGroupIds));
         Axis::message()->addSuccess(Axis::translate('admin')->__('Group was deleted successfully'));
     }
     $this->_helper->json->sendJson(array('success' => $isValid));
 }
예제 #5
0
 /**
  * Loging
  *
  * @param mixed $message
  */
 public function log($message)
 {
     if ($this->_config->showErrors) {
         Axis::message()->addError($this->_code . ': ' . $message);
     }
     $this->_logger->info($this->_code . ' ' . $message);
 }
예제 #6
0
 public function postProcess(Axis_Sales_Model_Order_Row $order)
 {
     $this->saveCreditCard($order);
     $cc = $this->getCreditCard();
     $options = $this->getLineItemDetails();
     $billing = $order->getBilling();
     $optionsAll = array_merge($options, array('STREET' => $billing->getStreetAddress(), 'ZIP' => $billing->getPostcode(), 'BUTTONSOURCE' => $this->_buttonSourceDP, 'CURRENCY' => $this->getBaseCurrencyCode(), 'IPADDRESS' => $_SERVER['REMOTE_ADDR']));
     if ($cc->getCcIssueMonth() && $cc->getCcIssueYear()) {
         $optionsAll['CARDSTART'] = $cc->getCcIssueMonth() . substr($cc->getCcIssueYear(), -2);
     }
     $optionsNVP = array('CITY' => $billing->getCity(), 'STATE' => $billing->getZone()->getCode() ? $billing->getZone()->getCode() : $billing->getCity(), 'COUNTRYCODE' => $billing->getCountry()->getIsoCode2(), 'EXPDATE' => $cc->getCcExpiresMonth() . $cc->getCcExpiresYear(), 'PAYMENTACTION' => $this->_config->paymentAction == 'Authorization' ? 'Authorization' : 'Sale');
     $delivery = $order->getDelivery();
     $optionsShip = array('SHIPTONAME' => $delivery->getFirstname() . ' ' . $delivery->getLastname(), 'SHIPTOSTREET' => $delivery->getStreetAddress(), 'SHIPTOSTREET2' => $delivery->getSuburb(), 'SHIPTOCITY' => $delivery->getCity(), 'SHIPTOZIP' => $delivery->getPostcode(), 'SHIPTOSTATE' => $delivery->getZone()->getCode() ? $delivery->getZone()->getCode() : $delivery->getCity(), 'SHIPTOCOUNTRYCODE' => $delivery->getCountry()->getIsoCode2());
     // if these optional parameters are blank, remove them from transaction
     if (isset($optionsShip['SHIPTOSTREET2']) && empty($optionsShip['SHIPTOSTREET2'])) {
         unset($optionsShip['SHIPTOSTREET2']);
     }
     $response = $this->getApi()->DoDirectPayment(sprintf('%.2f', $this->getAmountInBaseCurrency($order->order_total)), $cc->getCcNumber(), $cc->getCcCvv(), $cc->getCcExpiresMonth() . $cc->getCcExpiresYear(), $billing->getFirstname(), $billing->getLastname(), $cc->getCcType(), $optionsAll, array_merge($optionsNVP, $optionsShip));
     if ($response['ACK'] != 'Success') {
         $this->log("Response : " . Zend_Debug::dump($response, null, false));
         foreach ($this->getMessages($response) as $severity => $messages) {
             Axis::message()->batchAdd($messages, $severity);
         }
         throw new Axis_Exception('DoDirectPayment Failure');
     }
 }
예제 #7
0
 public function removeAction()
 {
     $id = $this->_getParam('id');
     Axis::model('admin/acl_role')->delete($this->db->quoteInto('id = ?', $id));
     Axis::message()->addSuccess(Axis::translate('admin')->__('Role was deleted successfully'));
     return $this->_helper->json->sendSuccess();
 }
예제 #8
0
 public function removeAction()
 {
     $data = Zend_Json::decode($this->_getParam('data'));
     Axis::model('account/customer_valueSet')->delete($this->db->quoteInto('id IN (?)', $data));
     Axis::message()->addSuccess(Axis::translate('admin')->__('Group was deleted successfully'));
     return $this->_helper->json->sendSuccess();
 }
예제 #9
0
 /**
  * @param int $quantity [optional]
  * @param int $variationId [optional]
  * @param boolean $isBackOrdered [optional]
  * @return boolean
  */
 protected function _available($quantity = 1, $variationId = null, $isBackOrdered = false)
 {
     if (!$this->in_stock) {
         Axis::message()->addError(Axis::translate('catalog')->__('Product is out of stock'));
         return false;
     }
     if ($quantity < $this->min_qty_allowed || $quantity <= 0) {
         Axis::message()->addError(Axis::translate('catalog')->__('Minimum allowed quantity is %d', $this->min_qty_allowed > 0 ? $this->min_qty_allowed : 1));
         return false;
     }
     if ($quantity > $this->max_qty_allowed && $this->max_qty_allowed > 0) {
         Axis::message()->addError(Axis::translate('catalog')->__('Maximum allowed quantity is %d', $this->max_qty_allowed));
         return false;
     }
     $stockQuantity = $this->getQuantity($variationId);
     $availableQuantity = $stockQuantity - $this->min_qty;
     if ($isBackOrdered && $quantity > $availableQuantity && !$this->backorder) {
         Axis::message()->addError(Axis::translate('catalog')->__('Only %d item(s) are available', $availableQuantity));
         return false;
     }
     if (!$isBackOrdered && $quantity > $availableQuantity) {
         Axis::message()->addError(Axis::translate('catalog')->__('Only %d item(s) are available', $availableQuantity));
         return false;
     }
     return true;
 }
 public function removeAction()
 {
     $data = Zend_Json::decode($this->_getParam('data'));
     Axis::single('catalog/product_option')->delete($this->db->quoteInto('id IN (?)', $data));
     Axis::message()->addSuccess(Axis::translate('catalog')->__('Option was deleted successfully'));
     return $this->_helper->json->sendSuccess();
 }
예제 #11
0
 /**
  * Execute multiqueries
  *
  * @param string $sql
  * @return Axis_Install_Model_Installer provides fluent interface
  * @throws Exception
  */
 public function run($sql)
 {
     $tries = 0;
     $stmts = $this->_splitMultiQuery($sql);
     foreach ($stmts as $stmt) {
         do {
             $retry = false;
             try {
                 // skip commented queries
                 if (0 === strpos($stmt, '--') || 0 === strpos($stmt, '/*')) {
                     continue;
                 }
                 Axis::db()->getConnection()->exec($stmt);
             } catch (Exception $e) {
                 if ($e->getMessage() == 'SQLSTATE[HY000]: General error: 2013 Lost connection to MySQL server during query' && $tries < 10) {
                     $retry = true;
                     $tries++;
                 } else {
                     //                        Axis::message()->addError($e->getTraceAsString());
                     Axis::message()->addError($e->getMessage());
                     throw $e;
                 }
             }
         } while ($retry);
     }
     return $this;
 }
예제 #12
0
 public function removeAction()
 {
     $data = Zend_Json::decode($this->_getParam('data'));
     Axis::model('core/site')->delete($this->db->quoteInto('id IN(?)', $data));
     Axis::dispatch('core_site_delete_success', array('site_ids' => $data));
     Axis::message()->addSuccess(Axis::translate('admin')->__('Site was deleted successfully'));
     return $this->_helper->json->sendSuccess();
 }
예제 #13
0
 /**
  * Loging
  *
  * @param mixed $message
  */
 public function log($message)
 {
     if ($this->_config->showErrors) {
         Axis::message()->addError($this->_code . ': ' . $message);
     }
     if ($this->_logger instanceof Zend_Log) {
         $this->_logger->info($this->_code . ' ' . $message);
     }
 }
예제 #14
0
 public function batchSaveAction()
 {
     $_rowset = Zend_Json::decode($this->_getParam('data'));
     $model = Axis::model('cms/page_comment');
     foreach ($_rowset as $id => $_row) {
         $model->find($id)->current()->setFromArray($_row)->save();
     }
     Axis::message()->addSuccess(Axis::translate('core')->__('Data was saved successfully'));
     return $this->_helper->json->sendSuccess();
 }
예제 #15
0
 public function saveAction()
 {
     $data = $this->_getAllParams();
     $row = Axis::model('community/review')->save($data);
     Axis::message()->addSuccess(Axis::translate('community')->__('Review was successfully saved'));
     if (count($data['rating'])) {
         $row->setRating($data['rating']);
     }
     return $this->_helper->json->sendSuccess();
 }
예제 #16
0
 /**
  *
  * @static
  * @param string $value
  * @return string
  */
 public static function getSaveValue($value)
 {
     $row = Axis::single('locale/currency')->select()->where('code = ?', $value)->fetchRow();
     if ($row instanceof Axis_Db_Table_Row && 1 !== $row->rate) {
         $row->rate = 1;
         $row->save();
         Axis::message()->addNotice(Axis::translate('locale')->__('Currency rate was changed to 1.00'));
     }
     return $value;
 }
예제 #17
0
 public function removeAction()
 {
     $data = Zend_Json::decode($this->_getParam('data'));
     if (!sizeof($data)) {
         Axis::message()->addError(Axis::translate('admin')->__('No data to delete'));
         return $this->_helper->json->sendFailure();
     }
     Axis::single('locale/currency')->delete($this->db->quoteInto('id IN(?)', $data));
     Axis::message()->addSuccess(Axis::translate('locale')->__('Currency was deleted successfully'));
     return $this->_helper->json->sendSuccess();
 }
예제 #18
0
 public function saveAction()
 {
     $data = $this->_getAllParams();
     if (empty($data['path'])) {
         Axis::message()->addError(Axis::translate('core')->__('Incorrect field path'));
         return $this->_helper->json->sendFailure();
     }
     Axis::model('core/config_field')->save($data);
     Axis::message()->addSuccess(Axis::translate('core')->__('Data was saved successfully'));
     return $this->_helper->json->sendSuccess();
 }
예제 #19
0
 public function deleteByIds(array $ids)
 {
     if (!count($ids)) {
         return false;
     }
     $where = $this->getAdapter()->quoteInto('id IN(?)', $ids);
     if ($result = parent::delete($where)) {
         Axis::message()->addSuccess(Axis::translate('admin')->__('Profile was deleted successfully'));
     }
     return $result;
 }
예제 #20
0
 /**
  *
  * @param string $value
  * @return string
  */
 public function encode($value)
 {
     //@todo move to specific event
     $row = Axis::model('locale/currency')->select()->where('code = ?', $value)->fetchRow();
     if ($row instanceof Axis_Db_Table_Row && 1 !== $row->rate) {
         $row->rate = 1;
         $row->save();
         Axis::message()->addNotice(Axis::translate('locale')->__('Currency rate was changed to 1.00'));
     }
     return $value;
 }
예제 #21
0
 public function removeAction()
 {
     $ids = Zend_Json::decode($this->_getParam('data'));
     if (!count($ids)) {
         Axis::message()->addError(Axis::translate('admin')->__('No data to delete'));
         return $this->_helper->json->sendFailure();
     }
     Axis::single('core/page')->delete($this->db->quoteInto('id IN(?)', $ids));
     Axis::message()->addSuccess(Axis::translate('admin')->__('Data was deleted successfully'));
     return $this->_helper->json->sendSuccess();
 }
 public function removeAction()
 {
     $data = Zend_Json::decode($this->_getParam('data'));
     if (!count($data)) {
         Axis::message()->addError(Axis::translate('admin')->__('No data to delete'));
         return $this->_helper->json->sendFailure();
     }
     Axis::single('catalog/product_option_ValueSet')->delete($this->db->quoteInto('id IN(?)', $data));
     Axis::message()->addSuccess(Axis::translate('catalog')->__('Value Set was deleted sucessfully'));
     return $this->_helper->json->sendSuccess();
 }
예제 #23
0
 public function removeAction()
 {
     $data = Zend_Json::decode($this->_getParam('data'));
     if (!count($data)) {
         Axis::message()->addError(Axis::translate('core')->__('No data to save'));
         return $this->_helper->json->sendFailure();
     }
     Axis::model('shippingTable/rate')->delete($this->db->quoteInto('id IN(?)', $data));
     Axis::message()->addSuccess(Axis::translate('location')->__('Data was deleted successfully'));
     return $this->_helper->json->sendSuccess();
 }
예제 #24
0
 public function removeAction()
 {
     $data = Zend_Json::decode($this->_getParam('data'));
     if (!count($data)) {
         Axis::message()->addError(Axis::translate('location')->__('No zone found to delete'));
         return $this->_helper->json->sendFailure();
     }
     Axis::single('location/zone')->delete($this->db->quoteInto('id IN(?)', $data));
     Axis::message()->addSuccess(Axis::translate('location')->__('Zone was deleted successfully'));
     return $this->_helper->json->sendSuccess();
 }
예제 #25
0
 public function up()
 {
     $installer = $this->getInstaller();
     if (@preg_match('/\\pL/u', 'a') != 1) {
         Axis::message()->addNotice("Axis_Search module :PCRE unicode support is turned off.\n");
     }
     if (!function_exists("mb_strstr")) {
         Axis::message()->addNotice("For current work Axis_Search module need http://php.net/manual/en/mbstring.installation.php");
     }
     $installer->run("\n\n        -- DROP TABLE IF EXISTS `{$installer->getTable('search_log')}`;\n        CREATE TABLE IF NOT EXISTS `{$installer->getTable('search_log')}` (\n            `id` int(10) unsigned NOT NULL auto_increment,\n            `visitor_id` int(10) unsigned NOT NULL,\n            `query_id` int(10) unsigned NOT NULL,\n            `num_results` mediumint(8) unsigned NOT NULL default '0',\n            `created_at` datetime NOT NULL,\n            `site_id` smallint(9) NOT NULL,\n            `customer_id` int(10) unsigned default NULL,\n            PRIMARY KEY  (`id`)\n        ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED;\n\n        -- DROP TABLE IF EXISTS `{$installer->getTable('search_log_query')}`;\n        CREATE TABLE IF NOT EXISTS `{$installer->getTable('search_log_query')}` (\n            `id` int(11) NOT NULL auto_increment,\n            `query` varchar(255) NOT NULL,\n            `hit` int(11) NOT NULL default '0',\n            PRIMARY KEY  (`id`)\n        ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;\n\n        ");
     Axis::single('core/page')->add('search/*/*')->add('search/index/*')->add('search/index/index')->add('search/index/result');
 }
예제 #26
0
 public function removeAction()
 {
     $id = $this->_getParam('id', 0);
     if (!$id) {
         Axis::message()->addError(Axis::translate('admin')->__('No data to delete'));
         return $this->_helper->json->sendFailure();
     }
     $model = Axis::single('contacts/department');
     $model->delete($this->db->quoteInto('id = ?', $id));
     Axis::message()->addSuccess(Axis::translate('contacts')->__('Department was deleted successfully'));
     return $this->_helper->json->sendSuccess();
 }
예제 #27
0
 public function changeAction()
 {
     $this->setTitle(Axis::translate('account')->__('Change Info'));
     $form = Axis::single('account/Form_ChangeInfo');
     if ($this->_request->isPost()) {
         $data = $this->_request->getPost();
         if ($data['change_password_toggle'] == 0) {
             $form->getElement('password_current')->clearValidators();
             // removeValidator('NotEmpty');
             $form->getElement('password')->clearValidators();
             //removeValidator('NotEmpty');
             $form->getElement('password_confirm')->clearValidators();
             //removeValidator('NotEmpty');
         }
         if ($form->isValid($data)) {
             $model = Axis::single('account/customer');
             $row = $model->find(Axis::getCustomerId())->current();
             if (empty($data['password'])) {
                 unset($data['password']);
             } else {
                 $data['password'] = md5($data['password']);
             }
             $row->setFromArray($data);
             $row->modified_at = Axis_Date::now()->toSQLString();
             $row->save();
             $row->setDetails($data);
             Axis::message()->addSuccess(Axis::translate('Axis_Core')->__('Data was saved successfully'));
         }
     } else {
         $data = array();
         $customer = Axis::getCustomer();
         $extraInfo = $customer->findDependentRowset('Axis_Account_Model_Customer_Detail');
         $data = $customer->toArray();
         foreach ($extraInfo as $row) {
             $value = empty($row->data) ? $row->customer_valueset_value_id : $row->data;
             $isMulti = isset($data['field_' . $row->customer_field_id]);
             if ($isMulti && is_array($data['field_' . $row->customer_field_id])) {
                 $data['field_' . $row->customer_field_id][] = $value;
             } elseif ($isMulti) {
                 $data['field_' . $row->customer_field_id] = array($data['field_' . $row->customer_field_id], $value);
             } else {
                 $data['field_' . $row->customer_field_id] = $value;
             }
         }
     }
     $form->populate($data);
     $this->view->form = $form;
     $this->render();
 }
예제 #28
0
 public function removeAction()
 {
     $model = Axis_Core_Model_Cache::getCache();
     if ($this->_hasParam('data')) {
         $tags = Zend_Json::decode($this->_getParam('data'));
         $success = $model->clean('matchingAnyTag', $tags);
     } else {
         $success = $model->clean();
     }
     if (!$success) {
         return $this->_helper->json->sendFailure();
     }
     Axis::message()->addSuccess(Axis::translate('admin')->__('Cache was cleared successfully'));
     return $this->_helper->json->sendSuccess();
 }
예제 #29
0
 public function removeAction()
 {
     $themeId = $this->_getParam('templateId');
     if (!$themeId) {
         return $this->_helper->json->sendFailure();
     }
     $model = Axis::model('core/template');
     if ($model->isUsed($themeId)) {
         Axis::message()->addError(Axis::translate('admin')->__("Template is used already and can't be deleted"));
         return $this->_helper->json->sendFailure();
     }
     $model->delete($this->db->quoteInto('id = ? ', $themeId));
     Axis::message()->addSuccess(Axis::translate('admin')->__('Template was deleted successfully'));
     return $this->_helper->json->sendSuccess();
 }
예제 #30
0
 public function addAction()
 {
     $this->_helper->layout->disableLayout();
     $customerId = Axis::getCustomerId();
     $productId = $this->_getParam('id');
     $hasDuplicate = (bool) Axis::single('account/wishlist')->select('id')->where('customer_id = ?', $customerId)->where('product_id = ?', $productId)->fetchOne();
     if (!$hasDuplicate) {
         $data = array('customer_id' => $customerId, 'product_id' => $productId);
         Axis::single('account/wishlist')->insert($data);
         Axis::dispatch('account_whishlist_add_product_success', $data);
         $this->_redirect('/account/wishlist');
     }
     Axis::message()->addError(Axis::translate('account')->__('Selected product is already in your wishlist'));
     $this->_redirect($this->getRequest()->getServer('HTTP_REFERER'));
 }