Ejemplo n.º 1
0
 public function build($dispatch_rt)
 {
     $dispatch = '';
     $this->recursion_limit = 0;
     foreach ($this->pre_dispatch as $pre_dispatch) {
         $result = $pre_dispatch->dispatch();
         if ($result) {
             //Something happened. Need to run different page
             $dispatch_rt = $result;
             break;
         }
     }
     //Process disparcher in while in case we have new dispatch back
     while ($dispatch_rt) {
         //Process main level controller
         // load page layout
         if ($this->layout) {
             //filter in case we have pages set already
             $dispatch_rt = preg_replace('/^(pages)\\//', '', $dispatch_rt);
             $dispatch_rt = 'pages/' . $dispatch_rt;
             //get controller only part. Layout needs only controller path
             $controller = $this->router->getController();
             $this->pade_id = $this->layout->buildPageData($controller);
             //add controller and a child to parent page controller
             $this->layout->addChildFirst(0, $dispatch_rt, 'content', $dispatch_rt . '.tpl');
             $dispatch_rt = "common/page";
         }
         //Do the magic
         $dispatch = new ADispatcher($dispatch_rt, array("instance_id" => "0"));
         $dispatch_rt = $dispatch->dispatch();
     }
     unset($dispatch);
 }
Ejemplo n.º 2
0
 /**
  * update only one field
  *
  * @return void
  */
 public function update_field()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     if (!$this->user->canModify('listing_grid/store')) {
         $error = new AError('');
         return $error->toJSONResponse('NO_PERMISSIONS_402', array('error_text' => sprintf($this->language->get('error_permission_modify'), 'listing_grid/store'), 'reset_value' => true));
     }
     $this->loadLanguage('setting/store');
     $this->loadModel('setting/store');
     if (isset($this->request->get['id'])) {
         //request sent from edit form. ID in url
         foreach ($this->request->post as $key => $value) {
             $err = $this->_validateField($key, $value);
             if (!empty($err)) {
                 $dd = new ADispatcher('responses/error/ajaxerror/validation', array('error_text' => $err));
                 return $dd->dispatch();
             }
             $data = array($key => $value);
             $this->model_setting_store->editStore($this->request->get['id'], $data);
         }
         return;
     }
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }
Ejemplo n.º 3
0
 /**
  * @param string $dispatch_rt
  */
 public function build($dispatch_rt)
 {
     $dispatch = '';
     $this->recursion_limit = 0;
     foreach ($this->pre_dispatch as $pre_dispatch) {
         /**
          * @var ADispatcher $pre_dispatch
          */
         $result = $pre_dispatch->dispatch();
         if ($result) {
             //Something happened. Need to run different page
             $dispatch_rt = $result;
             break;
         }
     }
     //Process disparcher in while if we have new dispatch back
     while ($dispatch_rt) {
         //Process main level controller
         //filter in case we have responses set already
         $dispatch_rt = preg_replace('/^(responses)\\//', '', $dispatch_rt);
         $dispatch = new ADispatcher('responses/' . $dispatch_rt, array("instance_id" => "0"));
         $dispatch_rt = $dispatch->dispatch();
     }
     unset($dispatch);
 }
Ejemplo n.º 4
0
 public function update()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->loadModel('localisation/tax_class');
     $this->loadLanguage('localisation/tax_class');
     if (!$this->user->canModify('listing_grid/tax_class')) {
         $error = new AError('');
         return $error->toJSONResponse('NO_PERMISSIONS_402', array('error_text' => sprintf($this->language->get('error_permission_modify'), 'listing_grid/tax_class'), 'reset_value' => true));
     }
     switch ($this->request->post['oper']) {
         case 'del':
             $ids = explode(',', $this->request->post['id']);
             if (!empty($ids)) {
                 foreach ($ids as $id) {
                     $err = $this->_validateDelete($id);
                     if (!empty($err)) {
                         $dd = new ADispatcher('responses/error/ajaxerror/validation', array('error_text' => $err));
                         return $dd->dispatch();
                     }
                     $this->model_localisation_tax_class->deleteTaxClass($id);
                 }
             }
             break;
         case 'save':
             $ids = explode(',', $this->request->post['id']);
             if (!empty($ids)) {
                 foreach ($ids as $id) {
                     if (isset($this->request->post['tax_class'][$id])) {
                         foreach ($this->request->post['tax_class'][$id] as $lang => $value) {
                             if (isset($value['title'])) {
                                 $err = $this->_validateField('title', $value['title']);
                                 if (!empty($err)) {
                                     $this->response->setOutput($err);
                                     return;
                                 }
                             }
                         }
                         $this->model_localisation_tax_class->editTaxClass($id, array('tax_class' => $this->request->post['tax_class'][$id]));
                     }
                 }
             }
             break;
         default:
     }
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }
Ejemplo n.º 5
0
 public function __construct(array $values = array())
 {
     parent::__construct($values);
     // Application service
     if (!isset($this['application'])) {
         $this['application'] = function (AContainer $c) {
             return AApplication::getTmpInstance($c->application_name, array(), 'Angie', $c);
         };
     }
     // Input Access service
     if (!isset($this['input'])) {
         $this['input'] = function (AContainer $c) {
             return new AInput();
         };
     }
     // Application Dispatcher service
     if (!isset($this['dispatcher'])) {
         $this['dispatcher'] = function (AContainer $c) {
             return ADispatcher::getTmpInstance(null, null, array(), $c);
         };
     }
     if (!isset($this['session'])) {
         $this['session'] = function (AContainer $c) {
             return ASession::getInstance();
         };
     }
 }
Ejemplo n.º 6
0
 /**
  * update only one field
  *
  * @return void
  */
 public function update_field()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->loadLanguage('catalog/category');
     if (!$this->user->canModify('listing_grid/category')) {
         $error = new AError('');
         return $error->toJSONResponse('NO_PERMISSIONS_402', array('error_text' => sprintf($this->language->get('error_permission_modify'), 'listing_grid/category'), 'reset_value' => true));
     }
     $this->loadModel('catalog/category');
     if (isset($this->request->get['id'])) {
         //request sent from edit form. ID in url
         foreach ($this->request->post as $field => $value) {
             if ($field == 'keyword') {
                 if ($err = $this->html->isSEOkeywordExists('category_id=' . $this->request->get['id'], $value)) {
                     $dd = new ADispatcher('responses/error/ajaxerror/validation', array('error_text' => $err));
                     return $dd->dispatch();
                 }
             }
             $this->model_catalog_category->editCategory($this->request->get['id'], array($field => $value));
         }
         return null;
     }
     $language_id = $this->session->data['content_language_id'];
     //request sent from jGrid. ID is key of array
     foreach ($this->request->post as $field => $value) {
         foreach ($value as $k => $v) {
             if ($field == 'category_description') {
                 if (strlen(utf8_decode($v[$language_id]['name'])) < 2 || strlen(utf8_decode($v[$language_id]['name'])) > 32) {
                     $err = $this->language->get('error_name');
                     $dd = new ADispatcher('responses/error/ajaxerror/validation', array('error_text' => $err));
                     return $dd->dispatch();
                 }
             }
             $this->model_catalog_category->editCategory($k, array($field => $v));
         }
     }
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }
Ejemplo n.º 7
0
 /**
  * update only one field
  *
  * @return void
  */
 public function update_field()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->loadLanguage('design/content');
     $this->acm = new AContentManager();
     if (!$this->user->canModify('listing_grid/content')) {
         $error = new AError('');
         return $error->toJSONResponse('NO_PERMISSIONS_402', array('error_text' => sprintf($this->language->get('error_permission_modify'), 'listing_grid/content'), 'reset_value' => true));
     }
     $allowedFields = array('title', 'description', 'keyword', 'store_id', 'sort_order', 'status', 'parent_content_id');
     if (isset($this->request->get['id'])) {
         //request sent from edit form. ID in url
         foreach ($this->request->post as $field => $value) {
             if (!in_array($field, $allowedFields)) {
                 continue;
             }
             if ($field == 'keyword') {
                 if ($err = $this->html->isSEOkeywordExists('content_id=' . $this->request->get['id'], $value)) {
                     $dd = new ADispatcher('responses/error/ajaxerror/validation', array('error_text' => $err));
                     return $dd->dispatch();
                 }
             }
             if ($field == 'sort_order') {
                 // NOTE: grid quicksave ids are not the same as id from form quick save request!
                 list($void, $parent_content_id) = explode('_', key($value));
                 $value = current($value);
             }
             $this->acm->editContentField($this->request->get['id'], $field, $value, $parent_content_id);
         }
         return null;
     }
     //request sent from jGrid. ID is key of array
     foreach ($this->request->post as $field => $value) {
         if (!in_array($field, $allowedFields)) {
             continue;
         }
         // NOTE: grid quicksave ids are not the same as id from form quick save request!
         list($parent_content_id, $content_id) = explode('_', key($value));
         $this->acm->editContentField($content_id, $field, current($value), $parent_content_id);
     }
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }
 private function _run_steps($task_id, $task_settings)
 {
     $task_id = (int) $task_id;
     if (!$task_id) {
         return false;
     }
     $this->_update_task_state($task_id, array('status' => 2));
     //change status of task to "active" while it run
     //get steps
     $steps = $this->getScheduledTaskSteps($task_id);
     $task_result = 0;
     $steps_count = sizeof($steps);
     // total count of steps to calculate percentage (for future)
     $k = 0;
     foreach ($steps as $step) {
         $this->toLog('Tried to run step #' . $step['step_id'] . ' of task #' . $task_id);
         //change status to active
         $this->_update_step_state($step['step_id'], array('result' => 1, 'last_time_run' => date('Y-m-d H:i:s'), 'status' => 2));
         //change status of step to active while it run
         try {
             $dd = new ADispatcher($step['controller'], $step_settings['params']);
             $response = $dd->dispatchGetOutput($step['controller']);
         } catch (AException $e) {
         }
         $result = $response['result'] == true ? 0 : 1;
         $this->_update_step_state($step['step_id'], array('result' => $result, 'last_time_run' => date('Y-m-d H:i:s'), 'status' => 1));
         if (!$result) {
             $this->log->write('Sheduled step #' . $step['step_id'] . ' of task #' . $task_id . ' failed during process');
             //interrupt task if need
             if ($task_settings['interrupt_on_step_fault'] === true) {
                 $this->_update_task_state($task_id, array('result' => 1, 'last_time_run' => date('Y-m-d H:i:s'), 'status' => 1));
                 return false;
             }
             $task_result = 1;
             $this->toLog('Step #' . $step['step_id'] . ' of task #' . $task_id . ' failed.');
         }
         $this->toLog('Step #' . $step['step_id'] . ' of task #' . $task_id . ' finished.');
         $this->_update_task_state($task_id, array('progress' => ceil($k * 100 / $steps_count)));
     }
     $this->_update_task_state($task_id, array('result' => $task_result, 'last_time_run' => date('Y-m-d H:i:s'), 'status' => 1));
     return true;
 }
Ejemplo n.º 9
0
 public function getCacheKeyValues($controller)
 {
     //check if requested controller allows HTML caching
     //use dispatcher to get class and details
     $ds = new ADispatcher($controller, array("instance_id" => "0"));
     $rt_class = $ds->getClass();
     $rt_file = $ds->getFile();
     $rt_method = $ds->getMethod();
     if (!empty($rt_file) && !empty($rt_class) && !empty($rt_method)) {
         /** @noinspection PhpIncludeInspection */
         require_once $rt_file;
         if (class_exists($rt_class)) {
             $static_method = $rt_method . '_cache_keys';
             if (method_exists($rt_class, $static_method)) {
                 //finally get keys and build a cache key
                 $cache_keys = call_user_func($rt_class . '::' . $static_method);
                 return $cache_keys;
             }
         }
     }
     return false;
 }
Ejemplo n.º 10
0
 public function update()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->loadModel('localisation/stock_status');
     $this->loadModel('setting/store');
     $this->loadModel('catalog/product');
     $this->loadLanguage('localisation/stock_status');
     if (!$this->user->canModify('listing_grid/stock_status')) {
         $error = new AError('');
         return $error->toJSONResponse('NO_PERMISSIONS_402', array('error_text' => sprintf($this->language->get('error_permission_modify'), 'listing_grid/stock_status'), 'reset_value' => true));
     }
     switch ($this->request->post['oper']) {
         case 'del':
             $ids = explode(',', $this->request->post['id']);
             if (!empty($ids)) {
                 foreach ($ids as $id) {
                     $err = $this->_validateDelete($id);
                     if (!empty($err)) {
                         $dd = new ADispatcher('responses/error/ajaxerror/validation', array('error_text' => $err));
                         return $dd->dispatch();
                     }
                     $this->model_localisation_stock_status->deleteStockStatus($id);
                 }
             }
             break;
         case 'save':
             $ids = explode(',', $this->request->post['id']);
             if (!empty($ids)) {
                 foreach ($ids as $id) {
                     if (isset($this->request->post['stock_status'][$id])) {
                         foreach ($this->request->post['stock_status'][$id] as $value) {
                             if (strlen(utf8_decode($value['name'])) < 2 || strlen(utf8_decode($value['name'])) > 32) {
                                 $this->response->setOutput($this->language->get('error_name'));
                                 return;
                             }
                         }
                         $this->model_localisation_stock_status->editStockStatus($id, array('stock_status' => $this->request->post['stock_status'][$id]));
                     }
                 }
             }
             break;
         default:
     }
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }
Ejemplo n.º 11
0
 /**
  * @param string $parent_controller
  * @return null|string
  */
 public function dispatch($parent_controller = '')
 {
     ADebug::checkpoint('' . $this->class . '/' . $this->method . ' dispatch START');
     //Process the controller, layout and children
     //check if we have missing class or everithing
     if (empty($this->class) && has_value($this->file)) {
         #Build back trace of calling functions to provide more details
         $backtrace = debug_backtrace();
         $function_stack = '';
         if (is_object($parent_controller) && strlen($parent_controller->rt()) > 1) {
             $function_stack = 'Parent Controller: ' . $parent_controller->rt() . ' | ';
         }
         for ($i = 1; $i < count($backtrace); $i++) {
             $function_stack .= ' < ' . $backtrace[$i]['function'];
         }
         $url = $this->request->server['REQUEST_URI'];
         $error = new AError('Error: URL: ' . $url . ' Could not load controller ' . $this->controller . '! Call stack: ' . $function_stack . '', AC_ERR_CLASS_CLASS_NOT_EXIST);
         $error->toLog()->toDebug();
         $error->toMessages();
         return null;
     } else {
         if (empty($this->file) && empty($this->class) || empty($this->method)) {
             $warning_txt = 'ADispatch: skipping unavailable controller …';
             $warning = new AWarning($warning_txt);
             $warning->toDebug();
             return null;
         }
     }
     //check for controller.pre
     $output_pre = $this->dispatchPrePost($this->controller . POSTFIX_PRE);
     /** @noinspection PhpIncludeInspection */
     require_once $this->file;
     /**
      * @var $controller AController
      */
     $controller = null;
     if (class_exists($this->class)) {
         $controller = new $this->class($this->registry, $this->args["instance_id"], $this->controller, $parent_controller);
         $controller->dispatcher = $this;
     } else {
         $error = new AError('Error: controller class not exist ' . $this->class . '!', AC_ERR_CLASS_CLASS_NOT_EXIST);
         $error->toLog()->toDebug();
     }
     if (is_callable(array($controller, $this->method))) {
         /**
          * @var $dispatch ADispatcher
          */
         $dispatch = call_user_func_array(array($controller, $this->method), $this->args);
         //Check if return is a dispatch and need to call new page
         if ($dispatch && is_object($dispatch)) {
             if ($this->args["instance_id"] == 0) {
                 //If main controller come back for new dispatch
                 return $dispatch->getController() . '/' . $dispatch->getMethod();
             } else {
                 // Call new dispatch for new controller and exit
                 //???? need to put limit for recursion to prevent overflow
                 $dispatch->dispatch();
                 return null;
             }
         }
         /**
          * Load layout and process children controllers
          * @method AController getChildren()
          */
         $children = $controller->getChildren();
         ADebug::variable('Processing children of ' . $this->controller, $children);
         $block_uids = array();
         //Process each child controller
         foreach ($children as $child) {
             //???? Add highest Debug level here with backtrace to review this
             ADebug::checkpoint($child['controller'] . ' ( child of ' . $this->controller . ', instance_id: ' . $child['instance_id'] . ' ) dispatch START');
             //Process each child and create dispatch to call recurcive
             $dispatch = new ADispatcher($child['controller'], array("instance_id" => $child['instance_id']));
             $dispatch->dispatch($controller);
             // Append output of child controller to current controller
             if ($child['position']) {
                 // maden for recognizing few custom_blocks in the same placeholder
                 $controller->view->assign($child['block_txt_id'] . '_' . $child['instance_id'], $this->response->getOutput());
             } else {
                 $controller->view->assign($child['block_txt_id'], $this->response->getOutput());
             }
             //clean up and remove output
             $this->response->setOutput('');
             ADebug::checkpoint($child['controller'] . ' ( child of ' . $this->controller . ' ) dispatch END');
         }
         //Request controller to generate output
         $controller->finalize();
         //check for controller.pre
         $output_post = $this->dispatchPrePost($this->controller . POSTFIX_POST);
         //add pre and post controllers output
         $this->response->setOutput($output_pre . $this->response->getOutput() . $output_post);
         //clean up and destroy the object
         unset($controller);
         unset($dispatch);
     } else {
         $err = new AError('Error: controller method not exist ' . $this->class . '::' . $this->method . '!', AC_ERR_CLASS_METHOD_NOT_EXIST);
         $err->toLog()->toDebug();
     }
     ADebug::checkpoint('' . $this->class . '/' . $this->method . ' dispatch END');
     return null;
 }
Ejemplo n.º 12
0
 /**
  * update only one field
  *
  * @return void
  */
 public function update_field()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->loadLanguage('sale/coupon');
     $this->loadModel('sale/coupon');
     if (!$this->user->canModify('listing_grid/coupon')) {
         $error = new AError('');
         return $error->toJSONResponse('NO_PERMISSIONS_402', array('error_text' => sprintf($this->language->get('error_permission_modify'), 'listing_grid/coupon'), 'reset_value' => true));
     }
     if (isset($this->request->get['id'])) {
         foreach ($this->request->post as $field => $value) {
             if ($field == 'uses_total' && $value == '' || $field == 'uses_customer' && $value == '') {
                 $value = -1;
             }
             $err = $this->_validateForm($field, $value);
             if (in_array($field, array('date_start', 'date_end'))) {
                 $value = dateDisplay2ISO($value);
             }
             if (!$err) {
                 $this->model_sale_coupon->editCoupon($this->request->get['id'], array($field => $value));
             } else {
                 $dd = new ADispatcher('responses/error/ajaxerror/validation', array('error_text' => $err));
                 return $dd->dispatch();
             }
         }
         return;
     }
     //request sent from jGrid. ID is key of array
     foreach ($this->request->post as $field => $value) {
         foreach ($value as $k => $v) {
             $err = $this->_validateForm($field, $v);
             if (!$err) {
                 $this->model_sale_coupon->editCoupon($k, array($field => $v));
             } else {
                 $dd = new ADispatcher('responses/error/ajaxerror/validation', array('error_text' => $err));
                 return $dd->dispatch();
             }
         }
     }
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }
Ejemplo n.º 13
0
 public function build($dispatch_rt)
 {
     $dispatch = '';
     $this->recursion_limit = 0;
     foreach ($this->pre_dispatch as $pre_dispatch) {
         /**
          * @var ADispatcher $pre_dispatch
          */
         $result = $pre_dispatch->dispatch();
         //Processing has finished, Example: we have cache generated.
         if ($result == 'completed') {
             return;
         } else {
             if ($result) {
                 //Something happened. Need to run different dispatcher
                 $dispatch_rt = $result;
                 //Rule exception for SEO_URL. DO not break with pre_dispatch for SEO_URL
                 if ($pre_dispatch->getController() != 'common/seo_url') {
                     break;
                 }
             }
         }
     }
     //Process dispatcher in while in case we have new dispatch back
     while ($dispatch_rt) {
         //Process main level controller
         // load page layout
         if ($this->layout) {
             //filter in case we have pages set already
             $dispatch_rt = preg_replace('/^(pages)\\//', '', $dispatch_rt);
             $dispatch_rt = 'pages/' . $dispatch_rt;
             //get controller only part. Layout needs only controller path
             $controller = $this->router->getController();
             $this->pade_id = $this->layout->buildPageData($controller);
             //add controller and a child to parent page controller
             $this->layout->addChildFirst(0, $dispatch_rt, 'content', $dispatch_rt . '.tpl');
             $dispatch_rt = "common/page";
         }
         //Do the magic
         $dispatch = new ADispatcher($dispatch_rt, array("instance_id" => "0"));
         $dispatch_rt = $dispatch->dispatch();
     }
     unset($dispatch);
 }
Ejemplo n.º 14
0
 /**
  * update only one field
  *
  * @return void
  */
 public function update_field()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     if (!$this->user->canModify('listing_grid/attribute')) {
         $error = new AError('');
         return $error->toJSONResponse('NO_PERMISSIONS_402', array('error_text' => sprintf($this->language->get('error_permission_modify'), 'listing_grid/attribute'), 'reset_value' => true));
     }
     if (isset($this->request->get['id'])) {
         //request sent from edit form. ID in url
         foreach ($this->request->post as $key => $value) {
             $err = $this->_validateField($key, $value);
             if (!empty($err)) {
                 $dd = new ADispatcher('responses/error/ajaxerror/validation', array('error_text' => $err));
                 return $dd->dispatch();
             }
             $data = array($key => $value);
             $this->attribute_manager->updateAttribute($this->request->get['id'], $data);
         }
         return null;
     }
     //request sent from jGrid. ID is key of array
     $fields = array('sort_order', 'status');
     foreach ($fields as $f) {
         if (isset($this->request->post[$f])) {
             foreach ($this->request->post[$f] as $k => $v) {
                 $err = $this->_validateField($f, $v);
                 if (!empty($err)) {
                     $dd = new ADispatcher('responses/error/ajaxerror/validation', array('error_text' => $err));
                     return $dd->dispatch();
                 }
                 $this->attribute_manager->updateAttribute($k, array($f => $v));
             }
         }
     }
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }
Ejemplo n.º 15
0
 /**
  * update only one field
  *
  * @return void
  */
 public function update_field()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->loadLanguage('localisation/currency');
     if (!$this->user->canModify('listing_grid/currency')) {
         $error = new AError('');
         return $error->toJSONResponse('NO_PERMISSIONS_402', array('error_text' => sprintf($this->language->get('error_permission_modify'), 'listing_grid/currency'), 'reset_value' => true));
     }
     $this->loadModel('localisation/currency');
     if (isset($this->request->get['id'])) {
         //request sent from edit form. ID in url
         foreach ($this->request->post as $key => $value) {
             $err = $this->_validateField($key, $value);
             if (!empty($err)) {
                 $dd = new ADispatcher('responses/error/ajaxerror/validation', array('error_text' => $err));
                 return $dd->dispatch();
             }
             $data = array($key => $value);
             $this->model_localisation_currency->editCurrency($this->request->get['id'], $data);
         }
         return;
     }
     //request sent from jGrid. ID is key of array
     $fields = array('title', 'code', 'value', 'status');
     foreach ($fields as $f) {
         if (isset($this->request->post[$f])) {
             foreach ($this->request->post[$f] as $k => $v) {
                 $err = $this->_validateField($f, $v);
                 if (!empty($err)) {
                     $dd = new ADispatcher('responses/error/ajaxerror/validation', array('error_text' => $err));
                     return $dd->dispatch();
                 }
                 $result = $this->model_localisation_currency->editCurrency($k, array($f => $v));
                 if (!$result) {
                     if ($f == 'status') {
                         $this->messages->saveNotice('Currency warning', 'Warning: You tried to disable the only enabled currency of cart!');
                     }
                     $this->response->setOutput('error!');
                     return;
                 }
             }
         }
     }
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }
Ejemplo n.º 16
0
 /**
  * update only one field
  *
  * @return null
  */
 public function update_field()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->loadLanguage('sale/customer');
     $this->loadModel('sale/customer');
     if (!$this->user->canModify('listing_grid/customer')) {
         $error = new AError('');
         return $error->toJSONResponse('NO_PERMISSIONS_402', array('error_text' => sprintf($this->language->get('error_permission_modify'), 'listing_grid/customer'), 'reset_value' => true));
     }
     if (isset($this->request->get['id'])) {
         foreach ($this->request->post as $field => $value) {
             $err = $this->_validateForm($field, $value, $this->request->get['id']);
             if (!$err) {
                 if ($field == 'approved') {
                     $this->_sendMail($this->request->get['id'], $value);
                 }
                 $this->model_sale_customer->editCustomerField($this->request->get['id'], $field, $value);
             } else {
                 $dd = new ADispatcher('responses/error/ajaxerror/validation', array('error_text' => $err));
                 return $dd->dispatch();
             }
         }
         //update controller data
         $this->extensions->hk_UpdateData($this, __FUNCTION__);
         return null;
     }
     //request sent from jGrid. ID is key of array
     foreach ($this->request->post as $field => $value) {
         foreach ($value as $k => $v) {
             $err = $this->_validateForm($field, $v);
             if (!$err) {
                 if ($field == 'approved') {
                     $this->_sendMail(key($value), current($value));
                 }
                 $this->model_sale_customer->editCustomerField($k, $field, $v);
             } else {
                 $dd = new ADispatcher('responses/error/ajaxerror/validation', array('error_text' => $err));
                 return $dd->dispatch();
             }
         }
     }
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }
Ejemplo n.º 17
0
 /**
  * update only one field
  *
  */
 public function update_field()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     if (!$this->user->canModify('listing_grid/download')) {
         $error = new AError('');
         return $error->toJSONResponse('NO_PERMISSIONS_402', array('error_text' => sprintf($this->language->get('error_permission_modify'), 'listing_grid/download'), 'reset_value' => true));
     }
     $this->loadLanguage('catalog/download');
     $this->loadModel('catalog/download');
     $allowedFields = array('name', 'filename', 'mask', 'max_downloads', 'shared', 'expire_days', 'sort_order', 'activate_order_status_id', 'status', 'attributes');
     if (isset($this->request->get['id'])) {
         $download_id = (int) $this->request->get['id'];
         //request sent from edit form. ID in url
         foreach ($this->request->post as $key => $value) {
             if (!in_array($key, $allowedFields)) {
                 continue;
             }
             // check first
             if ($key == 'name' && (mb_strlen($value) < 2 || mb_strlen($value) > 64)) {
                 $error = $this->language->get('error_download_name');
             } elseif ($key == 'activate' && !in_array($data['activate'], array('before_order', 'immediately', 'order_status', 'manually'))) {
                 $error = $this->language->get('error_activate');
             } elseif ($key == 'attributes') {
                 $attr_mngr = new AAttribute_Manager('download_attribute');
                 $attr_errors = $attr_mngr->validateAttributeData($value[$download_id]);
                 if ($attr_errors) {
                     $error = $this->language->get('error_download_attributes') . '<br>&nbsp;&nbsp;&nbsp;' . implode('<br>&nbsp;&nbsp;&nbsp;', $attr_errors);
                 }
             }
             if (!$error) {
                 $data = array($key => $value);
                 $this->model_catalog_download->editDownload($download_id, $data);
             } else {
                 $dd = new ADispatcher('responses/error/ajaxerror/validation', array('error_text' => $error));
                 return $dd->dispatch();
             }
         }
         return null;
     } else {
         //request sent from jGrid. ID is key of array
         foreach ($this->request->post as $field => $value) {
             foreach ($value as $k => $v) {
                 if ($field == 'name') {
                     if (mb_strlen($v) < 2 || mb_strlen($v) > 64) {
                         $err = $this->language->get('error_name');
                         $dd = new ADispatcher('responses/error/ajaxerror/validation', array('error_text' => $err));
                         return $dd->dispatch();
                     }
                 }
                 $this->model_catalog_download->editDownload($k, array($field => $v));
             }
         }
     }
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
     return null;
 }
Ejemplo n.º 18
0
 /**
  * update only one field
  *
  * @return void
  */
 public function update_field()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     if (!$this->user->canModify('listing_grid/product')) {
         $error = new AError('');
         return $error->toJSONResponse('NO_PERMISSIONS_402', array('error_text' => sprintf($this->language->get('error_permission_modify'), 'listing_grid/product'), 'reset_value' => true));
     }
     $this->loadLanguage('catalog/product');
     $this->loadModel('catalog/product');
     if (isset($this->request->get['id'])) {
         //request sent from edit form. ID in url
         foreach ($this->request->post as $key => $value) {
             $err = $this->_validateField($key, $value);
             if (!empty($err)) {
                 $dd = new ADispatcher('responses/error/ajaxerror/validation', array('error_text' => $err));
                 return $dd->dispatch();
             }
             if ($key == 'date_available') {
                 $value = dateDisplay2ISO($value);
             }
             $data = array($key => $value);
             $this->model_catalog_product->updateProduct($this->request->get['id'], $data);
             $this->model_catalog_product->updateProductLinks($this->request->get['id'], $data);
         }
         return null;
     }
     //request sent from jGrid. ID is key of array
     $fields = array('product_description', 'model', 'price', 'call_to_order', 'quantity', 'status');
     foreach ($fields as $f) {
         if (isset($this->request->post[$f])) {
             foreach ($this->request->post[$f] as $k => $v) {
                 $err = $this->_validateField($f, $v);
                 if (!empty($err)) {
                     $dd = new ADispatcher('responses/error/ajaxerror/validation', array('error_text' => $err));
                     return $dd->dispatch();
                 }
                 $this->model_catalog_product->updateProduct($k, array($f => $v));
             }
         }
     }
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }
Ejemplo n.º 19
0
 /**
  * Dispatches the application
  */
 public function dispatch()
 {
     @ob_start();
     $dispatcher = ADispatcher::getAnInstance();
     $dispatcher->dispatch();
     $result = @ob_get_clean();
     $document = $this->getDocument();
     $document->setBuffer($result);
 }
Ejemplo n.º 20
0
 public function update()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->loadModel('localisation/country');
     $this->loadLanguage('localisation/country');
     if (!$this->user->canModify('listing_grid/country')) {
         $error = new AError('');
         return $error->toJSONResponse('NO_PERMISSIONS_402', array('error_text' => sprintf($this->language->get('error_permission_modify'), 'listing_grid/country'), 'reset_value' => true));
     }
     switch ($this->request->post['oper']) {
         case 'del':
             $this->loadModel('setting/store');
             $this->loadModel('sale/order');
             $ids = explode(',', $this->request->post['id']);
             if (!empty($ids)) {
                 foreach ($ids as $id) {
                     $err = $this->_validateDelete($id);
                     if (!empty($err)) {
                         $dd = new ADispatcher('responses/error/ajaxerror/validation', array('error_text' => $err));
                         return $dd->dispatch();
                     }
                     $this->model_localisation_country->deleteCountry($id);
                 }
             }
             break;
         case 'save':
             $fields = array('iso_code_2', 'iso_code_3', 'status');
             $ids = explode(',', $this->request->post['id']);
             if (!empty($ids)) {
                 foreach ($ids as $id) {
                     foreach ($fields as $f) {
                         if ($f == 'status' && !isset($this->request->post['status'][$id])) {
                             $this->request->post['status'][$id] = 0;
                         }
                         if (isset($this->request->post[$f][$id])) {
                             $err = $this->_validateField($f, $this->request->post[$f][$id]);
                             if (!empty($err)) {
                                 $this->response->setOutput($err);
                                 return;
                             }
                             $this->model_localisation_country->editCountry($id, array($f => $this->request->post[$f][$id]));
                         }
                     }
                     if (isset($this->request->post['country_name'][$id])) {
                         foreach ($this->request->post['country_name'][$id] as $lang => $value) {
                             $err = $this->_validateField('name', $value['name']);
                             if (!empty($err)) {
                                 $this->response->setOutput($err);
                                 return;
                             }
                         }
                         $this->model_localisation_country->editCountry($id, array('country_name' => $this->request->post['country_name'][$id]));
                     }
                 }
             }
             break;
         default:
             //print_r($this->request->post);
     }
     //update controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }