public function update() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); if (!$this->user->canModify('listing_grid/location_zones')) { $error = new AError(''); return $error->toJSONResponse('NO_PERMISSIONS_402', array('error_text' => sprintf($this->language->get('error_permission_modify'), 'listing_grid/location_zones'), 'reset_value' => true)); } $this->loadModel('localisation/zone'); $this->loadLanguage('localisation/zone'); switch ($this->request->post['oper']) { case 'del': $this->loadModel('localisation/location'); $ids = explode(',', $this->request->post['id']); if (!empty($ids)) { foreach ($ids as $id) { $this->model_localisation_location->deleteLocationZone($id); } } break; default: } //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); }
public function save() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $output = array(); $this->loadLanguage('tool/rl_manager'); $this->document->setTitle($this->language->get('heading_title')); if ($this->request->is_POST() && $this->_validateRLTypeForm($this->request->post)) { $post_data = $this->request->post; $rm = new AResourceManager(); if ($rm->updateResourceType($post_data)) { $output['result_text'] = $this->language->get('text_success'); $this->load->library('json'); $this->response->addJSONHeader(); $this->response->setOutput(AJson::encode($output)); } else { $error = new AError(''); $err_data = array('error_text' => 'Unable to save resource type'); return $error->toJSONResponse('VALIDATION_ERROR_406', $err_data); } } else { $error = new AError(''); $err_data = array('error_text' => $this->error); return $error->toJSONResponse('VALIDATION_ERROR_406', $err_data); } //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); }
/** * 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__); }
public function update() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); if (!$this->user->canModify($this->rt)) { $error = new AError(''); return $error->toJSONResponse('NO_PERMISSIONS_402', array('error_text' => sprintf($this->language->get('error_permission_modify'), $this->rt), 'reset_value' => true)); } $this->loadModel('localisation/language_definitions'); $this->loadLanguage('localisation/language_definitions'); $this->view->assign('success', $this->session->data['success']); if (isset($this->session->data['success'])) { unset($this->session->data['success']); } $this->document->setTitle($this->language->get('heading_title')); if ($this->request->server['REQUEST_METHOD'] == 'POST' && $this->_validateForm()) { foreach ($this->request->post['language_definition_id'] as $lang_id => $id) { $data = array('language_id' => $lang_id, 'section' => $this->request->post['section'], 'block' => $this->request->post['block'], 'language_key' => $this->request->post['language_key'], 'language_value' => $this->request->post['language_value'][$lang_id]); if ($id) { $this->model_localisation_language_definitions->editLanguageDefinition($id, $data); } else { $this->model_localisation_language_definitions->addLanguageDefinition($data); } } $this->view->assign('success', $this->language->get('text_success')); } $this->_getForm(); //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); }
public function not_found() { //build not_found responce $this->loadLanguage('error/not_found'); $error = new AError(''); $err_data = array('error_title' => $this->language->get('heading_title'), 'error_text' => $this->language->get('text_not_found')); return $error->toJSONResponse('NOT_FOUND_404', $err_data); }
public function updateField() { $this->loadLanguage('forms_manager/forms_manager'); $this->loadModel('tool/forms_manager'); if (!$this->_validateFieldForm($this->request->post) || !$this->request->get['form_id']) { $error = new AError(''); return $error->toJSONResponse('VALIDATION_ERROR_406', array('error_text' => $this->error)); } $data = $this->request->post; $data['form_id'] = $this->request->get['form_id']; $this->model_tool_forms_manager->updateFormFieldData($data); $this->response->setOutput(''); }
public function update() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); if (!$this->user->canModify($this->rt)) { $error = new AError(''); return $error->toJSONResponse('NO_PERMISSIONS_402', array('error_text' => sprintf($this->language->get('error_permission_modify'), $this->rt), 'reset_value' => true)); } $this->loadModel('localisation/language_definitions'); $this->loadLanguage('localisation/language_definitions'); if ($this->request->is_POST()) { $output = array('error_text' => '', 'result_text' => ''); if ($this->_validateForm()) { foreach ($this->request->post['language_definition_id'] as $lang_id => $id) { $data = array('language_id' => $lang_id, 'section' => $this->request->post['section'], 'block' => $this->request->post['block'], 'language_key' => $this->request->post['language_key'], 'language_value' => $this->request->post['language_value'][$lang_id]); if ($id) { $this->model_localisation_language_definitions->editLanguageDefinition($id, $data); } else { $this->model_localisation_language_definitions->addLanguageDefinition($data); } } $output['result_text'] = $this->language->get('text_success'); } else { foreach ($this->error as $err) { if (is_array($err)) { $error_text[] = implode('<br>', $err); } else { $error_text[] = $err; } } $error = new AError(''); return $error->toJSONResponse('NO_PERMISSIONS_406', array('error_text' => $error_text, 'reset_value' => true)); } $this->load->library('json'); $this->response->addJSONHeader(); $this->response->setOutput(AJson::encode($output)); } else { $this->view->assign('success', $this->session->data['success']); if (isset($this->session->data['success'])) { unset($this->session->data['success']); } $this->document->setTitle($this->language->get('heading_title')); $this->_getForm(); } //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); }
public function main() { if (!$this->user->canModify('setting/setting_quick_form')) { $this->error['warning'] = $this->language->get('error_permission'); } //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $output = array('result_text' => ''); $this->loadModel('setting/setting'); $this->loadLanguage('setting/setting'); $this->loadLanguage('common/header'); $this->view->assign('success', $this->session->data['success']); if (isset($this->session->data['success'])) { unset($this->session->data['success']); } $setting = explode('-', $this->request->get['active']); $this->data['group'] = $setting[0]; $this->data['setting_key'] = $setting[1]; $this->data['store_id'] = !isset($this->session->data['current_store_id']) ? $setting[2] : $this->session->data['current_store_id']; if (is_int(strpos($this->data['setting_key'], 'config_description'))) { $this->data['setting_key'] = substr($this->data['setting_key'], 0, strrpos($this->data['setting_key'], '_')); $this->request->get['active'] = $this->data['group'] . '-' . $setting[1] . '-' . $this->data['store_id']; } else { $this->request->get['active'] = $this->data['group'] . '-' . $this->data['setting_key'] . '-' . $this->data['store_id']; } $this->document->setTitle($this->language->get('heading_title')); if ($this->request->is_POST()) { if ($this->_validateForm($this->data['group'])) { $this->model_setting_setting->editSetting($this->data['group'], $this->request->post, $this->data['store_id']); $output['result_text'] = $this->language->get('text_success'); $this->load->library('json'); $this->response->addJSONHeader(); $this->response->setOutput(AJson::encode($output)); } else { $error = new AError(''); return $error->toJSONResponse('NO_PERMISSIONS_406', array('error_text' => $this->error, 'reset_value' => true)); } } else { $this->_getForm(); } //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); }
public function onControllerResponsesListingGridExtension_InitData() { if ($this->baseObject_method != 'update') { return null; } $that = $this->baseObject; if ($that->request->get['id'] != 'default_pp_express') { return false; } if (!has_value($that->request->post['default_pp_express_custom_bg_color'])) { return false; } $that->request->post['default_pp_express_custom_bg_color'] = ltrim($that->request->post['default_pp_express_custom_bg_color'], '#'); $is_valid = $this->_check_valid_colorhex($that->request->post['default_pp_express_custom_bg_color']); if (!$is_valid) { $that->loadLanguage('default_pp_express/default_pp_express'); $error = new AError(''); return $error->toJSONResponse('NO_PERMISSIONS_402', array('error_text' => $that->language->get('default_pp_express_error_bg_color'), 'reset_value' => false)); } }
public function buildTask() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->data['output'] = array(); if ($this->request->is_POST() && $this->_validate()) { $this->loadModel('tool/backup'); $task_details = $this->model_tool_backup->createBackupTask('manual_backup', $this->request->post); if (!$task_details) { $this->errors = array_merge($this->errors, $this->model_tool_backup->errors); $error = new AError('files backup error'); return $error->toJSONResponse('APP_ERROR_402', array('error_text' => implode(' ', $this->errors), 'reset_value' => true)); } else { $this->data['output']['task_details'] = $task_details; } } //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); $this->load->library('json'); $this->response->addJSONHeader(); $this->response->setOutput(AJson::encode($this->data['output'])); }
public function update() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); if (!$this->user->canModify('listing_grid/extension')) { $error = new AError(''); return $error->toJSONResponse('NO_PERMISSIONS_402', array('error_text' => sprintf($this->language->get('error_permission_modify'), 'listing_grid/extension'), 'reset_value' => true)); } $this->loadLanguage('extension/extensions'); $store_id = $this->request->post_or_get('store_id'); if (empty($this->request->get['id'])) { foreach ($this->request->post as $ext => $val) { $val['store_id'] = $store_id; $this->extension_manager->editSetting($ext, $val); } } else { $val = $this->request->post; $val['store_id'] = $store_id; $val['one_field'] = true; // sign that we change only one setting $this->extension_manager->editSetting($this->request->get['id'], $val); } //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); $this->load->library('json'); if ($this->extension_manager->errors) { $error = new AError(''); return $error->toJSONResponse('VALIDATION_ERROR_406', array('error_text' => '<br>' . implode('<br>', $this->extension_manager->errors), 'reset_value' => true)); } }
/** * 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)) { $error = new AError(''); return $error->toJSONResponse('VALIDATION_ERROR_406', array('error_text' => $err)); } } 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__); }
/** * update only one field * * @return void */ public function update_field() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $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)); } $this->loadModel('localisation/stock_status'); if (isset($this->request->get['id']) && !empty($this->request->post['stock_status'])) { //request sent from edit form. ID in url foreach ($this->request->post['stock_status'] as $value) { if (mb_strlen($value['name']) < 2 || mb_strlen($value['name']) > 32) { $this->response->setOutput($this->language->get('error_name')); return null; } } $this->model_localisation_stock_status->editStockStatus($this->request->get['id'], $this->request->post); return null; } //request sent from jGrid. ID is key of array if (isset($this->request->post['stock_status'])) { foreach ($this->request->post['stock_status'] as $id => $v) { foreach ($v as $value) { if (mb_strlen($value['name']) < 2 || mb_strlen($value['name']) > 32) { $this->response->setOutput($this->language->get('error_name')); return null; } } $this->model_localisation_stock_status->editStockStatus($id, array('stock_status' => $v)); } } //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); }
public function CompressBackup() { if ($this->request->get['eta'] > 30) { set_time_limit((int) $this->request->get['eta'] + 30); } $backup_name = preg_replace('[^0-9A-z_\\.]', '', $this->request->get['backup_name']); $backup_name = !$backup_name ? 'manual_backup' : $backup_name; $bkp = new ABackup($backup_name); $arc_basename = DIR_BACKUP . $bkp->getBackupName(); if (is_file($arc_basename . '.tar')) { unlink($arc_basename . '.tar'); } if (is_file($arc_basename . '.tar.gz')) { unlink($arc_basename . '.tar.gz'); } $result = $bkp->archive($arc_basename . '.tar.gz', DIR_BACKUP, $bkp->getBackupName()); if ($result) { $this->load->library('json'); $this->response->addJSONHeader(); $output = array('result' => true, 'filename' => $bkp->getBackupName()); $this->response->setOutput(AJson::encode($output)); } else { $error = new AError('compress backup error'); return $error->toJSONResponse('APP_ERROR_402', array('error_text' => $bkp->error, 'reset_value' => true)); } }
public function get_resource_details() { if (!$this->user->canModify('common/resource_library')) { $error = new AError(''); return $error->toJSONResponse('NO_PERMISSIONS_402', array('error_text' => sprintf($this->language->get('error_permission_modify'), 'common/resource_library'), 'reset_value' => true)); } //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $resource_id = (int) $this->request->get['resource_id']; $language_id = $this->language->getContentLanguageID(); $rm = new AResourceManager(); $info = $rm->getResource($resource_id, $language_id); if (!$info) { $info = null; } else { $rm->setType($info['type_name']); $info['thumbnail_url'] = $rm->getResourceThumb($resource_id, $this->thumb_sizes['width'], $this->thumb_sizes['height'], $language_id); } $this->load->library('json'); $this->response->addJSONHeader(); $this->response->setOutput(AJson::encode($info)); }
public function update_field() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); if (!$this->user->canModify('listing_grid/blocks_grid')) { $error = new AError(''); return $error->toJSONResponse('NO_PERMISSIONS_402', array('error_text' => sprintf($this->language->get('error_permission_modify'), 'listing_grid/blocks_grid'), 'reset_value' => true)); } $this->loadLanguage('design/blocks'); $custom_block_id = (int) $this->request->get['custom_block_id']; $layout = new ALayoutManager(); if ($this->request->server['REQUEST_METHOD'] == 'POST') { $tmp = array(); if (isset($this->request->post['block_status'])) { $tmp['status'] = (int) $this->request->post['block_status']; } if (isset($this->request->post['block_name'])) { $tmp['name'] = $this->request->post['block_name']; } if (isset($this->request->post['block_title'])) { $tmp['title'] = $this->request->post['block_title']; } if (isset($this->request->post['block_description'])) { $tmp['description'] = $this->request->post['block_description']; } if (isset($this->request->post['block_content'])) { $tmp['content'] = $this->request->post['block_content']; } if (isset($this->request->post['block_wrapper'])) { $tmp['block_wrapper'] = $this->request->post['block_wrapper']; } if (isset($this->request->post['block_framed'])) { $tmp['block_framed'] = (int) $this->request->post['block_framed']; } $tmp['language_id'] = $this->language->getContentLanguageID(); $layout->saveBlockDescription((int) $this->request->post['block_id'], $custom_block_id, $tmp); $info = $layout->getBlockDescriptions($custom_block_id); if (isset($tmp['status'])) { if ($info[$tmp['language_id']]['status'] != $tmp['status']) { $error = new AError(''); return $error->toJSONResponse('NO_PERMISSIONS_406', array('error_text' => $this->language->get('error_text_status'), 'reset_value' => true)); } } } //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); }
/** * update only one field * * @return void */ public function update_location_field() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->loadLanguage('localisation/location'); if (!$this->user->canModify('listing_grid/location')) { $error = new AError(''); return $error->toJSONResponse('NO_PERMISSIONS_402', array('error_text' => sprintf($this->language->get('error_permission_modify'), 'listing_grid/location'), 'reset_value' => true)); } $this->loadModel('localisation/location'); 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)) { $error = new AError(''); return $error->toJSONResponse('VALIDATION_ERROR_406', array('error_text' => $err)); } $data = array($key => $value); $this->model_localisation_location->editLocationZone($this->request->get['id'], $data); } return null; } //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); }
/** * 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__); }
/** * update only one field * * @return void */ public function update_field() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->loadLanguage('localisation/language'); if (!$this->user->canModify('listing_grid/menu')) { $error = new AError(''); return $error->toJSONResponse('NO_PERMISSIONS_402', array('error_text' => sprintf($this->language->get('error_permission_modify'), 'listing_grid/menu'), 'reset_value' => true)); } $menu = new AMenu_Storefront(); $allowedFields = array('item_icon', 'item_text', 'item_url', 'parent_id', 'sort_order'); if (isset($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; } $data = array($key => $value); $menu->updateMenuItem($this->request->get['id'], $data); } return null; } //request sent from jGrid. ID is key of array foreach ($this->request->post as $key => $value) { if (!in_array($key, $allowedFields)) { continue; } foreach ($value as $k => $v) { $data = array($key => $v); $menu->updateMenuItem($k, $data); } } //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); }
/** * 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)) { $error = new AError(''); return $error->toJSONResponse('VALIDATION_ERROR_406', array('error_text' => $err)); } $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)) { $error = new AError(''); return $error->toJSONResponse('VALIDATION_ERROR_406', array('error_text' => $err)); } $this->attribute_manager->updateAttribute($k, array($f => $v)); } } } //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); }
/** * update only one field * * @return void */ public function update_field() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->loadLanguage('localisation/language_definitions'); if (!$this->user->canModify('listing_grid/language_definitions')) { $error = new AError(''); return $error->toJSONResponse('NO_PERMISSIONS_402', array('error_text' => sprintf($this->language->get('error_permission_modify'), 'listing_grid/language_definitions'), 'reset_value' => true)); } $this->loadModel('localisation/language_definitions'); $allowedFields = array('block', 'language_key', 'language_value', 'section'); $save_id = $this->request->get['id']; if (isset($save_id)) { //request sent from edit form. ID in url foreach ($this->request->post as $key => $value) { if (!in_array($key, $allowedFields)) { continue; } $data = array($key => $value); if ($key == 'language_value') { //load definition values. $def = $this->model_localisation_language_definitions->getLanguageDefinition($save_id); //if defintion does not match lagnuage this means we create new one if ($def['language_id'] != key($value)) { //save new $def['language_id'] = key($value); $def['language_definition_id'] = ''; $def['language_value'] = current($value); $this->model_localisation_language_definitions->addLanguageDefinition($def); } else { //edit $def['language_value'] = current($value); $this->model_localisation_language_definitions->editLanguageDefinition($save_id, $def); } } if (in_array($key, array('block', 'section', 'language_key'))) { $def = $this->model_localisation_language_definitions->getLanguageDefinition($save_id); $def_ids = $this->model_localisation_language_definitions->getAllLanguageDefinitionsIdByKey($def['language_key'], $def['block'], $def['section']); if ($def_ids) { foreach ($def_ids as $item) { $this->model_localisation_language_definitions->editLanguageDefinition($item['language_definition_id'], array($key => $value)); } } } } return null; } //request sent from jGrid. ID is key of array foreach ($this->request->post as $key => $value) { if (!in_array($key, array('language_value'))) { continue; } foreach ($value as $k => $v) { $data = array($key => $v); $this->model_localisation_language_definitions->editLanguageDefinition($k, $data); } } //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); }
/** * update only one field * * @return void */ public function update_field() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $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)); } $this->loadModel('localisation/country'); if (isset($this->request->get['id'])) { //request sent from edit form. ID in url foreach ($this->request->post as $key => $value) { $err = ''; if ($key == 'country_name') { foreach ($value as $lang => $dvalue) { $err .= $this->_validateField('name', $dvalue['name']); } } else { $err = $this->_validateField($key, $value); } if (!empty($err)) { $error = new AError(''); return $error->toJSONResponse('VALIDATION_ERROR_406', array('error_text' => $err)); } $data = array($key => $value); $this->model_localisation_country->editCountry($this->request->get['id'], $data); } return null; } //request sent from jGrid. ID is key of array $fields = array('iso_code_2', 'iso_code_3', '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)) { $error = new AError(''); return $error->toJSONResponse('VALIDATION_ERROR_406', array('error_text' => $err)); } $this->model_localisation_country->editCountry($k, array($f => $v)); } } } if (isset($this->request->post['country_name'])) { foreach ($this->request->post['country_name'] as $id => $v) { foreach ($v as $lang => $value) { $err = $this->_validateField('name', $value['name']); if (!empty($err)) { $error = new AError(''); return $error->toJSONResponse('VALIDATION_ERROR_406', array('error_text' => $err)); } } $this->model_localisation_country->editCountry($id, array('country_name' => $v)); } } //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); }
public function transaction() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->load->library('json'); $this->loadLanguage('sale/customer'); $this->loadModel('sale/customer_transaction'); if (!$this->user->canAccess('listing_grid/customer_transaction')) { $error = new AError(''); return $error->toJSONResponse('NO_PERMISSIONS_402', array('error_text' => sprintf($this->language->get('error_permission_access'), 'listing_grid/customer_transaction'), 'reset_value' => true)); } $transaction_id = (int) $this->request->get['customer_transaction_id']; $this->data['customer_transaction_id'] = $transaction_id; if ($transaction_id) { $info = $this->model_sale_customer_transaction->getCustomerTransaction($this->request->get['customer_transaction_id']); $this->data['text_title'] = $this->language->get('popup_title_info'); $readonly = true; } else { $this->data['text_title'] = $this->language->get('popup_title_insert'); $readonly = false; } $form = new AForm(); $form->setForm(array('form_name' => 'transaction_form')); $this->data['form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'tFrm', 'action' => $this->html->getSecureURL('listing_grid/customer_transaction/addtransaction', '&customer_id=' . $this->request->get['customer_id']), 'attr' => 'data-confirm-exit="true" class="form-horizontal"')); $this->data['form']['submit'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'submit', 'text' => $this->language->get('button_save'))); $this->data['form']['cancel'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'cancel', 'text' => $this->language->get('button_cancel'))); $this->data['form']['fields']['credit'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'credit', 'value' => $info['credit'], 'attr' => $readonly ? 'disabled="disabled"' : '')); $this->data['form']['fields']['debit'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'debit', 'value' => $info['debit'], 'attr' => $readonly ? 'disabled="disabled"' : '')); $types = $this->model_sale_customer_transaction->getTransactionTypes(); $types[''] = $this->language->get('text_option_other_type'); reset($types); $this->data['form']['fields']['transaction_type'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'transaction_type[0]', 'options' => $types, 'value' => $info['transaction_type'] == '' ? current($types) : $info['transaction_type'], 'attr' => $readonly ? 'disabled="disabled"' : '')); $this->data['form']['fields']['other_type'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'transaction_type[1]', 'value' => !in_array($info['transaction_type'], $types) ? $info['transaction_type'] : '', 'attr' => $readonly ? 'disabled="disabled"' : '')); $this->data['form']['fields']['transaction_comment'] = $form->getFieldHtml(array('type' => 'textarea', 'name' => 'comment', 'value' => $info['comment'], 'attr' => $readonly ? 'disabled="disabled"' : '')); $this->data['form']['fields']['transaction_description'] = $form->getFieldHtml(array('type' => 'textarea', 'name' => 'description', 'value' => $info['description'], 'attr' => $readonly ? 'disabled="disabled"' : '')); if ($readonly) { $this->data['form']['fields']['date_added'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'date_added', 'value' => dateISO2Display($info['date_added'], $this->language->get('date_format_short') . ' ' . $this->language->get('time_format')), 'attr' => 'disabled="disabled"')); $this->data['form']['fields']['date_modified'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'date_modified', 'value' => dateISO2Display($info['date_modified'], $this->language->get('date_format_short') . ' ' . $this->language->get('time_format')), 'attr' => 'disabled="disabled"')); } //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); $this->view->assign('help_url', $this->gen_help_url('customer_transaction_edit')); $this->view->batchAssign($this->data); $this->processTemplate('responses/sale/customer_transaction_form.tpl'); }
/** * 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)) { $error = new AError(''); return $error->toJSONResponse('VALIDATION_ERROR_406', array('error_text' => $err)); } $data = array($key => $value); $this->model_localisation_currency->editCurrency($this->request->get['id'], $data); } return null; } //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)) { $error = new AError(''); return $error->toJSONResponse('VALIDATION_ERROR_406', array('error_text' => $err)); } $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 null; } } } } //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); }
private function _return_error($error_text) { $error = new AError($error_text); $error->toLog()->toDebug(); return $error->toJSONResponse('APP_ERROR_402', array('error_text' => $error_text, 'reset_value' => true)); }
/** * update only one field * * @return void */ public function update_field() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->loadLanguage('user/user_group'); if (!$this->user->canModify('listing_grid/user_permission')) { $error = new AError(''); return $error->toJSONResponse('NO_PERMISSIONS_402', array('error_text' => sprintf($this->language->get('error_permission_modify'), 'listing_grid/user_permission'), 'reset_value' => true)); } $this->loadModel('user/user_group'); // update user group name // request sent from jGrid. ID is key of array $fields = array('name'); 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)) { $error = new AError(''); return $error->toJSONResponse('VALIDATION_ERROR_406', array('error_text' => $err)); } $this->model_user_user_group->editUserGroup($k, array($f => $v)); } } } // update user group permissions if (has_value($this->request->post['permission']) && has_value($this->request->get['user_group_id'])) { $this->model_user_user_group->editUserGroup($this->request->get['user_group_id'], $this->request->post); } //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); }
/** * 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/setting')) { $error = new AError(''); return $error->toJSONResponse('NO_PERMISSIONS_402', array('error_text' => sprintf($this->language->get('error_permission_modify'), 'listing_grid/setting'), 'reset_value' => true)); } $this->loadLanguage('setting/setting'); $this->loadModel('setting/setting'); if (isset($this->request->get['group'])) { $group = $this->request->get['group']; //for appearance settings per template if ($this->request->get['group'] == 'appearance' && has_value($this->request->get['tmpl_id']) && $this->request->get['tmpl_id'] != 'default') { $group = $this->request->get['tmpl_id']; } //request sent from edit form. ID in url foreach ($this->request->post as $key => $value) { $err = $this->_validateField($group, $key, $value); if (!empty($err)) { $error = new AError(''); return $error->toJSONResponse('VALIDATION_ERROR_406', array('error_text' => $err)); } $data = array($key => $value); //html decode store name if (has_value($data['store_name'])) { $data['store_name'] = html_entity_decode($data['store_name'], ENT_COMPAT, 'UTF-8'); } $this->model_setting_setting->editSetting($group, $data, $this->request->get['store_id']); startStorefrontSession($this->user->getId()); } return null; } //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); }
/** * 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/order_status')) { $error = new AError(''); return $error->toJSONResponse('NO_PERMISSIONS_402', array('error_text' => sprintf($this->language->get('error_permission_modify'), 'listing_grid/order_status'), 'reset_value' => true)); } $this->loadLanguage('localisation/order_status'); $this->loadModel('localisation/order_status'); if (isset($this->request->get['id']) && !empty($this->request->post)) { //request sent from edit form. ID in url $fields = array('name', 'status_text_id'); foreach ($fields as $field_name) { if (isset($this->request->post[$field_name])) { if (!$this->_validate_field($this->request->post[$field_name])) { $error = new AError(''); return $error->toJSONResponse('VALIDATION_ERROR_406', array('error_text' => $this->language->get('error_' . $field_name))); } } } $this->model_localisation_order_status->editOrderStatus($this->request->get['id'], $this->request->post); return null; } //request sent from jGrid. ID is key of array if (isset($this->request->post['order_status'])) { foreach ($this->request->post['order_status'] as $id => $value) { if (!$this->_validate_field($value['name'])) { $error = new AError(''); return $error->toJSONResponse('VALIDATION_ERROR_406', array('error_text' => $this->language->get('error_name'))); } $this->model_localisation_order_status->editOrderStatus($id, array('name' => $value['name'])); } } //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); }
public function processDownloadForm() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); if (!$this->user->canModify('product/product')) { $error = new AError(''); return $error->toJSONResponse('NO_PERMISSIONS_402', array('error_text' => sprintf($this->language->get('error_permission_modify'), 'product/product'), 'reset_value' => true)); } if (!$this->request->is_POST()) { return null; } $this->loadModel('catalog/download'); if ($this->_validateDownloadForm($this->request->post)) { $post_data = $this->request->post; //disable download if file not set if (!$post_data['filename']) { $post_data['status'] = 0; } // for shared downloads if (!isset($post_data['shared']) && !$this->request->get['product_id']) { $post_data['shared'] = 1; } if ((int) $this->request->get['download_id']) { $this->model_catalog_download->editDownload($this->request->get['download_id'], $post_data); $download_id = (int) $this->request->get['download_id']; } else { $post_data['product_id'] = (int) $this->request->get['product_id']; $download_id = $this->model_catalog_download->addDownload($post_data); $this->session->data['success'] = $this->language->get('text_success_download_save'); } $this->data['output'] = array('download_id' => $download_id, 'success' => true, 'result_text' => $this->language->get('text_success')); } else { $error = new AError(''); $err_data = array('error_text' => $this->error); return $error->toJSONResponse('VALIDATION_ERROR_406', $err_data); } //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); $this->response->addJSONHeader(); $this->load->library('json'); $this->response->setOutput(AJson::encode($this->data['output'])); }
/** * update only one field * * @return void */ public function update_field() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->loadLanguage('sale/order'); $this->loadModel('sale/order'); if (!$this->user->canModify('listing_grid/order')) { $error = new AError(''); return $error->toJSONResponse('NO_PERMISSIONS_402', array('error_text' => sprintf($this->language->get('error_permission_modify'), 'listing_grid/order'), 'reset_value' => true)); } if (has_value($this->request->post['downloads'])) { $data = $this->request->post['downloads']; $this->loadModel('catalog/download'); foreach ($data as $order_download_id => $item) { if (isset($item['expire_date'])) { $item['expire_date'] = $item['expire_date'] ? dateDisplay2ISO($item['expire_date'], $this->language->get('date_format_short')) : ''; } $this->model_catalog_download->editOrderDownload($order_download_id, $item); } return null; } if (isset($this->request->get['id'])) { $this->model_sale_order->editOrder($this->request->get['id'], $this->request->post); return null; } //request sent from jGrid. ID is key of array foreach ($this->request->post as $field => $value) { foreach ($value as $k => $v) { $this->model_sale_order->editOrder($k, array($field => $v)); } } //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); }