public function main() { $this->loadLanguage('default_banktransfer/default_banktransfer'); $this->view->assign('text_instructions', $this->language->get('text_instructions')); $this->view->assign('text_payment', $this->language->get('text_payment')); $this->view->batchAssign($this->language->getASet()); $lang_id = $this->language->getLanguageID(); $instructions = $this->config->get('default_banktransfer_instructions_' . $lang_id); if (!$instructions) { $this->messages->saveError('default_banktransfer error', 'Please, set instructions for all languages!'); $lang_id = $this->language->getDefaultLanguageID(); $instructions = $this->config->get('default_banktransfer_instructions_' . $lang_id); } if (!$instructions) { $this->messages->saveError('default_banktransfer error', 'Please, set instructions for all languages!'); } $this->view->assign('instructions', nl2br($instructions)); $this->view->assign('continue', $this->html->getSecureURL('checkout/success')); if ($this->request->get['rt'] != 'checkout/guest_step_3') { $this->view->assign('back', $this->html->getSecureURL('checkout/payment', '', true)); } else { $this->view->assign('back', $this->html->getSecureURL('checkout/guest_step_2', '', true)); } //check total for to meat min requirement if (has_value($this->config->get('default_banktransfer_order_min'))) { if ($this->cart->getTotal() < $this->config->get('default_banktransfer_order_min')) { $this->view->assign('minimum_notmet', $this->language->get('text_minimum_notmet')); } } $this->processTemplate('responses/default_banktransfer.tpl'); }
public function main() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->document->setTitle($this->language->get('heading_title')); $this->form = new AForm('ContactUsFrm'); $this->form->loadFromDb('ContactUsFrm'); $form = $this->form->getForm(); if ($this->request->is_POST() && $this->_validate()) { // move all uploaded files to their directories $file_pathes = $this->form->processFileUploads($this->request->files); $mail = new AMail($this->config); $mail->setTo($this->config->get('store_main_email')); $mail->setFrom($this->request->post['email']); $mail->setSender($this->request->post['first_name']); $mail->setSubject(sprintf($this->language->get('email_subject'), $this->request->post['name'])); $msg = $this->request->post['enquiry'] . "\r\n"; $form_fields = $this->form->getFields(); foreach ($form_fields as $field_name => $field_info) { if (has_value($this->request->post[$field_name]) && !in_array($field_name, array('first_name', 'email', 'enquiry', 'captcha'))) { $field_details = $this->form->getField($field_name); $msg .= "\r\n" . rtrim($field_details['name'], ':') . ":\t" . $this->request->post[$field_name]; } } if ($file_pathes) { $msg .= "\r\n" . $this->language->get('entry_attached') . ": \r\n"; foreach ($file_pathes as $file_info) { $basename = pathinfo(str_replace(' ', '_', $file_info['path']), PATHINFO_BASENAME); $msg .= "\t" . $file_info['display_name'] . ': ' . $basename . " (" . round(filesize($file_info['path']) / 1024, 2) . "Kb)\r\n"; $mail->addAttachment($file_info['path'], $basename); } } $mail->setText(strip_tags(html_entity_decode($msg, ENT_QUOTES, 'UTF-8'))); $mail->send(); //get success_page if ($form['success_page']) { $success_url = $this->html->getSecureURL($form['success_page']); } else { $success_url = $this->html->getSecureURL('content/contact/success'); } $this->redirect($success_url); } if ($this->request->is_POST()) { foreach ($this->request->post as $name => $value) { $this->form->assign($name, $value); } } $this->document->resetBreadcrumbs(); $this->document->addBreadcrumb(array('href' => $this->html->getURL('index/home'), 'text' => $this->language->get('text_home'), 'separator' => FALSE)); $this->document->addBreadcrumb(array('href' => $this->html->getURL('content/contact'), 'text' => $this->language->get('heading_title'), 'separator' => $this->language->get('text_separator'))); $this->view->assign('form_output', $this->form->getFormHtml()); $this->view->assign('action', $this->html->getURL('content/contact')); $this->view->assign('store', $this->config->get('store_name')); $this->view->assign('address', nl2br($this->config->get('config_address'))); $this->view->assign('telephone', $this->config->get('config_telephone')); $this->view->assign('fax', $this->config->get('config_fax')); $this->processTemplate('pages/content/contact.tpl'); //init controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); }
public function complete() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $task_id = (int) $this->request->post['task_id']; if (!$task_id) { return null; } //check task result $tm = new ATaskManager(); $task_info = $tm->getTaskById($task_id); $task_result = $task_info['last_result']; if ($task_result) { $tm->deleteTask($task_id); $result_text = sprintf($this->language->get('text_success_sent'), $task_info['settings']['sent']); if (has_value($this->session->data['sale_contact_presave'])) { unset($this->session->data['sale_contact_presave']); } } else { $result_text = $this->language->get('text_task_failed'); } //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); $this->load->library('json'); $this->response->addJSONHeader(); $this->response->setOutput(AJson::encode(array('result' => $task_result, 'result_text' => $result_text))); }
public function dumpTables() { if ($this->request->get['eta'] > 30) { set_time_limit((int) $this->request->get['eta'] * 2); } $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); if (has_value($this->request->get['sql_dump_mode'])) { $bkp->sql_dump_mode = $this->request->get['sql_dump_mode']; } if (has_value($this->request->get['table_list'])) { $table_list = $this->request->get['table_list']; } if (!$table_list) { $this->loadModel('tool/backup'); $table_list = $this->model_tool_backup->getTables(); } $result = $bkp->dumpTables($table_list); if ($result) { $this->load->library('json'); $this->response->addJSONHeader(); $output = array('result' => true); $this->response->setOutput(AJson::encode($output)); } else { $error = new AError('dump tables error'); return $error->toJSONResponse('APP_ERROR_402', array('error_text' => $bkp->error, 'reset_value' => true)); } }
private function _get_refund_form($data = array(), $payment_method_data = array(), $not_refunded = 0) { $refunded_amount = has_value($payment_method_data['refunded_amount']) ? (double) $payment_method_data['refunded_amount'] : 0; if ($not_refunded) { $data['add_to_capture'] = true; $not_refunded = (double) $not_refunded; } else { $data['add_to_capture'] = false; $not_refunded = (double) $payment_method_data['AMT']; } $data['payment_status'] = $this->baseObject->language->get('text_processing'); if ((double) $refunded_amount > 0) { $data['payment_status'] = $this->baseObject->language->get('text_partially_refunded'); $data['refunded_amount'] = $this->baseObject->currency->format($refunded_amount, $this->baseObject->data['currency']['code'], $this->baseObject->data['order_info']['value']); } if ((double) $refunded_amount < $not_refunded) { $data['pp_refund_amount'] = $this->baseObject->html->buildInput(array('name' => 'pp_refund_amount', 'value' => $not_refunded - $refunded_amount, 'style' => 'no-save')); $data['text_do_paypal_refund'] = $this->baseObject->language->get('text_do_paypal_refund'); $data['pp_refund_submit'] = $this->baseObject->html->buildButton(array('text' => $this->baseObject->language->get('text_refund'), 'name' => 'pp_refund_submit', 'style' => 'button3')); $params = '&order_id=' . (int) $this->baseObject->data['order_info']['order_id'] . '¤cy=' . $this->baseObject->data['currency']['code']; if ($data['add_to_capture']) { $params .= '&refund_captured=1'; } $data['pp_refund_action'] = $this->baseObject->html->getSecureURL('r/extension/default_pp_pro/refund', $params); } else { $data['payment_status'] = $this->baseObject->language->get('text_refunded'); } $data['text_already_refunded'] = $this->baseObject->language->get('text_already_refunded'); $data['error_wrong_amount'] = $this->baseObject->language->get('error_wrong_amount'); $view = new AView(Registry::getInstance(), 0); $view->batchAssign($data); $this->baseObject->view->addHookVar('order_details', $view->fetch('pages/extension/paypal_refund.tpl')); }
public function names() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $stdout = ''; if (has_value($this->request->get['country_name'])) { $country_name = $this->request->get['country_name']; $stdout = '<option value="FALSE">' . $this->language->get('text_select') . '</option>'; $this->loadModel('localisation/zone'); $country_id = $this->model_localisation_zone->getCountryIdByName($country_name); $results = $this->model_localisation_zone->getZonesByCountryId($country_id); foreach ($results as $result) { $stdout .= '<option value="' . $result['name'] . '"'; if (isset($this->request->get['zone_name']) && $this->request->get['zone_name'] == $result['name']) { $stdout .= ' selected="selected"'; } $stdout .= '>' . $result['name'] . '</option>'; } if (!$results) { if (!$this->request->get['zone_name']) { $stdout .= '<option value="0" selected="selected">' . $this->language->get('text_none') . '</option>'; } else { $stdout .= '<option value="0">' . $this->language->get('text_none') . '</option>'; } } } //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->response->setOutput($stdout, $this->config->get('config_compression')); }
public function main() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); if (has_value($this->request->get['customer_id']) && (int) $this->request->get['customer_id'] > 0 && has_value($this->request->get['email'])) { $this->loadModel('account/customer'); $customer = $this->model_account_customer->getCustomer((int) $this->request->get['customer_id']); //check is customer_id exists and compare his email with given if ($customer && $customer['email'] == $this->request->get['email']) { $this->model_account_customer->editNewsletter(0, (int) $this->request->get['customer_id']); } else { //othewise - redirect to index page $this->html->redirect($this->html->getSecureURL('index/home')); } } else { $this->html->redirect($this->html->getSecureURL('index/home')); } $this->document->setTitle($this->language->get('heading_title')); $this->document->resetBreadcrumbs(); $this->document->addBreadcrumb(array('href' => $this->html->getURL('index/home'), 'text' => $this->language->get('text_home'), 'separator' => FALSE)); $this->data['heading_title'] = $this->language->get('heading_title'); $this->data['text_message'] = $this->language->get('text_message'); $this->data['button_continue'] = $this->language->get('button_continue'); $this->data['continue'] = $this->html->getURL('index/home'); $continue = HtmlElementFactory::create(array('type' => 'button', 'name' => 'continue_button', 'text' => $this->language->get('button_continue'), 'style' => 'button')); $this->data['continue_button'] = $continue; $this->view->batchAssign($this->data); $this->processTemplate('common/unsubscribe.tpl'); //init controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); unset($this->session->data['success']); }
public function get() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->loadLanguage('sale/order'); $this->loadModel('sale/order'); $request = $this->rest->getRequestParams(); if (!has_value($request['customer_id'])) { $this->rest->setResponseData(array('Error' => 'Customer ID is missing')); $this->rest->sendResponse(200); return null; } $filter = array('filter_customer_id' => $request['customer_id'], 'sort' => 'o.date_added', 'order' => 'DESC', 'start' => 0, 'limit' => 20); if ($request['start']) { $filter['start'] = (int) $request['start']; } if ($request['limit']) { $filter['limit'] = (int) $request['limit']; } $orders = $this->model_sale_order->getOrders($filter); if (!count($orders)) { $this->rest->setResponseData(array('Message' => 'No order records found for the customer')); $this->rest->sendResponse(200); return null; } $this->extensions->hk_UpdateData($this, __FUNCTION__); $this->rest->setResponseData($orders); $this->rest->sendResponse(200); }
public function get() { $customer_details = array(); $customer_addresses = array(); //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->loadModel('sale/customer'); $this->loadModel('sale/customer_group'); $request = $this->rest->getRequestParams(); if (!has_value($request['customer_id'])) { $this->rest->setResponseData(array('Error' => 'Customer ID is missing')); $this->rest->sendResponse(200); return; } $customer_details = $this->model_sale_customer->getCustomer($request['customer_id']); if (!count($customer_details)) { $this->rest->setResponseData(array('Error' => 'Incorrect Customer ID or missing customer data')); $this->rest->sendResponse(200); return; } //clean up data before display unset($customer_details['password']); unset($customer_details['cart']); $cst_grp = $this->model_sale_customer_group->getCustomerGroup($customer_details['customer_group_id']); $customer_details['customer_group'] = $cst_grp['name']; $customer_addresses = $this->model_sale_customer->getAddressesByCustomerId($request['customer_id']); $customer_details['addresses'] = $customer_addresses; $this->extensions->hk_UpdateData($this, __FUNCTION__); $this->rest->setResponseData($customer_details); $this->rest->sendResponse(200); }
public function main() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->loadLanguage('sale/customer'); $this->loadModel('sale/customer'); $this->load->library('json'); $approved = array(1 => $this->language->get('text_yes'), 0 => $this->language->get('text_no')); $page = $this->request->post['page']; // get the requested page $limit = $this->request->post['rows']; // get how many rows we want to have into the grid $sidx = $this->request->post['sidx']; // get index row - i.e. user click to sort $sord = $this->request->post['sord']; // get the direction $data = array('sort' => $sidx, 'order' => $sord, 'start' => ($page - 1) * $limit, 'limit' => $limit); if (has_value($this->request->get['customer_group'])) { $data['filter']['customer_group_id'] = $this->request->get['customer_group']; } if (has_value($this->request->get['status'])) { $data['filter']['status'] = $this->request->get['status']; } if (has_value($this->request->get['approved'])) { $data['filter']['approved'] = $this->request->get['approved']; } $allowedFields = array('name', 'email'); if (isset($this->request->post['_search']) && $this->request->post['_search'] == 'true') { $searchData = AJson::decode(htmlspecialchars_decode($this->request->post['filters']), true); foreach ($searchData['rules'] as $rule) { if (!in_array($rule['field'], $allowedFields)) { continue; } $data['filter'][$rule['field']] = $rule['data']; } } $total = $this->model_sale_customer->getTotalCustomers($data); if ($total > 0) { $total_pages = ceil($total / $limit); } else { $total_pages = 0; } $response = new stdClass(); $response->page = $page; $response->total = $total_pages; $response->records = $total; $results = $this->model_sale_customer->getCustomers($data); $i = 0; foreach ($results as $result) { $response->rows[$i]['id'] = $result['customer_id']; $response->rows[$i]['cell'] = array($result['name'], '<a href="' . $this->html->getSecureURL('sale/contact', '&email[]=' . $result['email']) . '">' . $result['email'] . '</a>', $result['customer_group'], $this->html->buildCheckbox(array('name' => 'status[' . $result['customer_id'] . ']', 'value' => $result['status'], 'style' => 'btn_switch')), $this->html->buildSelectbox(array('name' => 'approved[' . $result['customer_id'] . ']', 'value' => $result['approved'], 'options' => $approved)), $result['orders_count'] > 0 ? $this->html->buildButton(array('name' => 'view orders', 'text' => $result['orders_count'], 'style' => 'button2', 'href' => $this->html->getSecureURL('sale/order', '&customer_id=' . $result['customer_id']), 'title' => $this->language->get('text_view') . ' ' . $this->language->get('tab_history'), 'target' => '_blank')) : 0); $i++; } //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); $this->response->setOutput(AJson::encode($response)); }
public function product() { if (!has_value($this->request->get['product_id'])) { return null; } //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $form = new AForm('ST'); $form->setForm(array('form_name' => 'getEmbedFrm')); $this->data['form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'getEmbedFrm', 'attr' => 'class="aform form-horizontal"')); $this->data['fields'][] = $form->getFieldHtml(array('type' => 'checkbox', 'name' => 'image', 'value' => 1, 'style' => 'btn_switch btn-group-xs')); $this->data['fields'][] = $form->getFieldHtml(array('type' => 'checkbox', 'name' => 'name', 'value' => 1, 'style' => 'btn_switch btn-group-xs')); $this->data['fields'][] = $form->getFieldHtml(array('type' => 'checkbox', 'name' => 'blurb', 'value' => 1, 'style' => 'btn_switch btn-group-xs')); $this->data['fields'][] = $form->getFieldHtml(array('type' => 'checkbox', 'name' => 'price', 'value' => 1, 'style' => 'btn_switch btn-group-xs')); $this->data['fields'][] = $form->getFieldHtml(array('type' => 'checkbox', 'name' => 'rating', 'value' => 1, 'style' => 'btn_switch btn-group-xs')); $this->data['fields'][] = $form->getFieldHtml(array('type' => 'checkbox', 'name' => 'quantity', 'value' => 1, 'style' => 'btn_switch btn-group-xs')); $this->data['fields'][] = $form->getFieldHtml(array('type' => 'checkbox', 'name' => 'addtocart', 'value' => 1, 'style' => 'btn_switch btn-group-xs')); $results = $this->language->getAvailableLanguages(); $languages = $language_codes = array(); foreach ($results as $v) { $languages[$v['code']] = $v['name']; $lng_code = $this->language->getLanguageCodeByLocale($v['locale']); $language_codes[$lng_code] = $v['name']; } $this->data['fields'][] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'language', 'value' => $this->config->get('config_storefront_language'), 'options' => $language_codes)); $this->load->model('localisation/currency'); $results = $this->model_localisation_currency->getCurrencies(); $currencies = array(); foreach ($results as $v) { $currencies[$v['code']] = $v['title']; } $this->data['fields'][] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'currency', 'value' => $this->config->get('config_currency'), 'options' => $currencies)); $this->data['text_area'] = $form->getFieldHtml(array('type' => 'textarea', 'name' => 'code_area', 'attr' => 'rows="10"', 'style' => 'ml_field')); $this->loadModel('catalog/product'); $this->loadModel('setting/store'); //if loaded not default store - hide store switcher $current_store_settings = $this->model_setting_store->getStore($this->config->get('config_store_id')); $remote_store_url = $current_store_settings['config_url']; $product_id = $this->request->get['product_id']; $this->data['product_id'] = $product_id; $product_stores = $this->model_catalog_product->getProductStoresInfo($product_id); if (sizeof($product_stores) == 1) { $remote_store_url = $product_stores[0]['store_url']; } $this->data['sf_js_embed_url'] = $remote_store_url . INDEX_FILE . '?rt=r/embed/js'; $this->data['sf_base_url'] = $remote_store_url; $this->data['help_url'] = $this->gen_help_url('embed'); $this->data['sf_css_embed_url'] = $remote_store_url . 'storefront/view/' . $this->config->get('config_storefront_template') . '/stylesheet/embed.css'; //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); $this->loadlanguage('common/do_embed'); $this->view->batchAssign($this->language->getASet('common/do_embed')); $this->view->batchAssign($this->data); $this->processTemplate('responses/embed/do_embed_product_modal.tpl'); }
/** * @param int $field_id * @return array */ public function getField($field_id) { $result = $this->db->query('SELECT * FROM ' . $this->db->table('fields') . ' WHERE field_id = "' . (int) $field_id . '"'); if ($result->num_rows) { if (has_value($result->row['settings'])) { $result->row['settings'] = unserialize($result->row['settings']); } return $result->row; } return array(); }
private function _validate_ip() { if (!has_value($this->config->get('config_admin_access_ip_list'))) { return true; } $ips = array_map('trim', explode(",", $this->config->get('config_admin_access_ip_list'))); if (in_array($_SERVER['REMOTE_ADDR'], $ips)) { return true; } return false; }
public function getCustomerTransactions($data = array(), $mode = '') { // get decrypted customer name first $this->load->model('sale/customer'); $customer_info = $this->model_sale_customer->getCustomer((int) $data['customer_id']); $sql = "SELECT *, t.date_added, t.date_modified,\n\t\t\t\tCASE\n\t\t\t\t\tWHEN t.section=1\n\t\t\t\t\t\tTHEN CONCAT(u.firstname,' ',u.lastname, ' (',u.username,')')\n\t\t\t\t\tELSE\n\t\t\t\t\t\t'" . $customer_info['firstname'] . ' ' . $customer_info['lastname'] . "'\n\t\t\t\t\t END as user\n\t\t\t\tFROM " . $this->db->table("customer_transactions") . " t\n\t\t\t\tLEFT JOIN " . $this->db->table("users") . " u ON u.user_id = t.created_by\n\t\t\t\tWHERE t.customer_id = '" . (int) $data['customer_id'] . "'"; $filter = isset($data['filter']) ? $data['filter'] : array(); $implode = array(); if (has_value($filter['date_start']) && has_value($filter['date_end'])) { $implode[] = "DATE(t.date_added) BETWEEN DATE('" . $this->db->escape($filter['date_start']) . "') AND DATE('" . $this->db->escape($filter['date_end']) . "')"; } if (has_value($filter['debit'])) { $implode[] = "ROUND(t.debit,2) = '" . round((double) $filter['debit'], 2) . "'"; } if (has_value($filter['credit'])) { $implode[] = "ROUND(t.credit,2) = '" . round((double) $filter['credit'], 2) . "'"; } if (has_value($filter['transaction_type'])) { $implode[] = "t.transaction_type like '%" . $this->db->escape($filter['transaction_type']) . "%'"; } if (has_value($filter['user'])) { $implode[] = "LOWER(CASE\n\t\t\t\t\t\t\t\tWHEN t.section=1\n\t\t\t\t\t\t\t\t\tTHEN CONCAT(u.firstname,' ',u.lastname, ' (',u.username,')')\n\t\t\t\t\t\t\t\tELSE\n\t\t\t\t\t\t\t\t\t'" . $customer_info['firstname'] . ' ' . $customer_info['lastname'] . "'\n\t\t\t\t\t\t\t\t END) like '%" . mb_strtolower($this->db->escape($filter['user'])) . "%'"; } if ($implode) { $sql .= " AND " . implode(" AND ", $implode); } //If for total, we done bulding the query if ($mode == 'total_only') { $query = $this->db->query($sql); return $query->num_rows; } $sort_data = array('t.date_added', 'user', 'debit', 'credit', 'transaction_type'); if (isset($data['sort']) && in_array($data['sort'], $sort_data)) { $sql .= " ORDER BY " . $data['sort']; } else { $sql .= " ORDER BY t.date_added"; } if (isset($data['order']) && strtoupper($data['order']) == 'DESC') { $sql .= " DESC"; } else { $sql .= " ASC"; } if (isset($data['start']) || isset($data['limit'])) { if ($data['start'] < 0) { $data['start'] = 0; } if ($data['limit'] < 1) { $data['limit'] = 20; } $sql .= " LIMIT " . (int) $data['start'] . "," . (int) $data['limit']; } $query = $this->db->query($sql); return $query->rows; }
public function main() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->loadLanguage('blocks/manufacturer'); $this->view->assign('heading_title', $this->language->get('heading_title')); $this->view->assign('text_select', $this->language->get('text_select')); //For product page show only brand icon if (isset($this->request->get['product_id']) && is_int($this->request->get['product_id'])) { $product_id = $this->request->get['product_id']; $this->view->assign('product_id', $product_id); $result = $this->model_catalog_manufacturer->getManufacturerByProductId($product_id); $manuf_detls = $result[0]; $resource = new AResource('image'); $thumbnail = $resource->getMainThumb('manufacturers', $manuf_detls['manufacturer_id'], (int) $this->config->get('config_image_grid_width'), (int) $this->config->get('config_image_grid_height'), true); $manufacturer = array('manufacturer_id' => $manuf_detls['manufacturer_id'], 'name' => $manuf_detls['name'], 'href' => $this->html->getSEOURL('product/manufacturer', '&manufacturer_id=' . $manuf_detls['manufacturer_id'], '&encode'), 'icon' => $thumbnail['thumb_url']); $this->view->assign('manufacturer', $manufacturer); } else { if (isset($this->request->get['manufacturer_id']) && is_int($this->request->get['manufacturer_id'])) { $manufacturer_id = $this->request->get['manufacturer_id']; } else { $manufacturer_id = 0; } $this->view->assign('manufacturer_id', $manufacturer_id); $this->loadModel('catalog/manufacturer'); $manufacturers = array(); $results = $this->model_catalog_manufacturer->getManufacturers(); $thumbnail_list = $this->cache->get('manufacturer.block.thumbnals', '', (int) $this->config->get('config_store_id')); $is_cache_exists = $this->cache->exists('manufacturer.block.thumbnals', '', (int) $this->config->get('config_store_id')); $resource = new AResource('image'); foreach ($results as $result) { if (!$is_cache_exists) { $thumbnail = $resource->getMainThumb('manufacturers', $result['manufacturer_id'], (int) $this->config->get('config_image_grid_width'), (int) $this->config->get('config_image_grid_height'), true); $thumbnails_cache[$result['manufacturer_id']] = $thumbnail; } else { if (has_value($thumbnail_list[$result['manufacturer_id']])) { $thumbnail = $thumbnail_list[$result['manufacturer_id']]; } } $manufacturers[] = array('manufacturer_id' => $result['manufacturer_id'], 'name' => $result['name'], 'href' => $this->html->getSEOURL('product/manufacturer', '&manufacturer_id=' . $result['manufacturer_id'], '&encode'), 'icon' => $thumbnail); } if (!$is_cache_exists) { $this->cache->set('manufacturer.block.thumbnals', $thumbnails_cache, '', (int) $this->config->get('config_store_id')); } $this->view->assign('manufacturers', $manufacturers); } // framed needs to show frames for generic block. //If tpl used by listing block framed was set by listing block settings $this->view->assign('block_framed', true); $this->processTemplate('blocks/manufacturer.tpl'); //init controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); }
public function error() { unset($this->session->data['pp_express_checkout']); // remove session data with paypal token $this->loadLanguage('default_pp_express/default_pp_express'); $this->data['heading_title'] = $this->language->get('text_paypal_error'); $this->data['continue'] = $this->html->getSecureURL('index/home'); $this->data['message'] = has_value($this->session->data['pp_express_checkout_error']) ? $this->session->data['pp_express_checkout_error'] : $this->language->get('service_error'); $this->data['button_continue'] = $this->html->buildElement(array('type' => 'button', 'name' => 'button_continue', 'text' => $this->language->get('button_continue'), 'href' => $this->data['continue'])); $this->view->batchAssign($this->data); $this->processTemplate('responses/default_pp_express_error.tpl'); }
/** * @param string $key * @param object $object * @param string|null $objectKey */ protected function addObject($key, $object, $objectKey = null) { if (false == has_value($key, $this->values)) { set_value($key, [], $this->values, $this->changedValues); } if (false == has_value($key, $this->objects)) { set_value($key, [], $this->objects); } if (null === $objectKey) { $objectKey = count(get_value($key, [], $this->values)); } $this->setObject("{$key}.{$objectKey}", $object); }
public function main() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $this->loadLanguage('localisation/order_status'); $this->loadModel('localisation/order_status'); $page = $this->request->post['page']; // get the requested page $limit = $this->request->post['rows']; // get how many rows we want to have into the grid $sidx = $this->request->post['sidx']; // get index row - i.e. user click to sort $sord = $this->request->post['sord']; // get the direction // process jGrid search parameter $allowedDirection = array('asc', 'desc'); if (!in_array($sord, $allowedDirection)) { $sord = $allowedDirection[0]; } $data = array('order' => strtoupper($sord), 'start' => ($page - 1) * $limit, 'limit' => $limit, 'content_language_id' => $this->session->data['content_language_id']); $total = $this->model_localisation_order_status->getTotalOrderStatuses(); if ($total > 0) { $total_pages = ceil($total / $limit); } else { $total_pages = 0; } if ($page > $total_pages) { $page = $total_pages; $data['start'] = ($page - 1) * $limit; } $response = new stdClass(); $response->page = $page; $response->total = $total_pages; $response->records = $total; $results = $this->model_localisation_order_status->getOrderStatuses($data); $i = 0; $base_order_statuses = $this->order_status->getBaseStatuses(); foreach ($results as $result) { $id = $result['order_status_id']; $response->rows[$i]['id'] = $id; if (has_value($base_order_statuses[$id])) { $response->userdata->classes[$id] = 'disable-delete'; } $response->rows[$i]['cell'] = array($this->html->buildInput(array('name' => 'order_status[' . $id . '][name]', 'value' => $result['name'])), $result['status_text_id']); $i++; } //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); $this->load->library('json'); $this->response->setOutput(AJson::encode($response)); }
/** * function to mark ANT message read */ public function antMessageRead() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $message_id = $this->request->get['message_id']; $result = array(); if (has_value($message_id) && $this->messages->markViewedANT($message_id, '*')) { $result['success'] = true; } //update controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); $this->load->library('json'); $this->response->setOutput(AJson::encode($result)); }
public function download() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); if ($this->user->canAccess('tool/files')) { $filename = str_replace(array('../', '..\\', '\\', '/'), '', $this->request->get['filename']); if ($this->request->get['attribute_type'] == 'field') { $this->loadModel('tool/file_uploads'); $attribute_data = $this->model_tool_file_uploads->getField($this->request->get['attribute_id']); } elseif (strpos($this->request->get['attribute_type'], 'AForm:') === 0) { // for aform fields $form_info = explode(':', $this->request->get['attribute_type']); $aform = new AForm('ST'); $aform->loadFromDb($form_info[1]); $attribute_data = $aform->getField($form_info[2]); } elseif ($this->request->get['order_option_id']) { $this->loadModel('sale/order'); $attribute_data = $this->model_sale_order->getOrderOption($this->request->get['order_option_id']); $attribute_data['settings'] = unserialize($attribute_data['settings']); } else { $am = new AAttribute($this->request->get['attribute_type']); $attribute_data = $am->getAttribute($this->request->get['attribute_id']); } if (has_value($attribute_data['settings']['directory'])) { $file = DIR_APP_SECTION . 'system/uploads/' . $attribute_data['settings']['directory'] . '/' . $filename; } else { $file = DIR_APP_SECTION . 'system/uploads/' . $filename; } if (file_exists($file)) { header('Content-Description: File Transfer'); header('Content-Type: application/x-gzip'); header('Content-Disposition: attachment; filename=' . $filename); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); header('Content-Length: ' . filesize($file)); ob_end_clean(); flush(); readfile($file); exit; } else { echo 'Error: File ' . $file . ' does not exists!'; exit; } } else { return $this->dispatch('error/permission'); } }
public function getSettingImage($rl_image) { $image_data = array(); if (!has_value($rl_image)) { return array(); } $resource = new AResource('image'); if (is_numeric($rl_image)) { // consider this is a pure image resource ID $image_data = $resource->getResource($rl_image); } else { $image_data = $resource->getResource($resource->getIdFromHexPath(str_replace('image/', '', $rl_image))); } return $image_data; }
public function __construct($registry, $order_id = '') { $this->registry = $registry; $this->load->model('checkout/order', 'storefront'); $this->load->model('account/order', 'storefront'); //if nothing is passed use session array. Customer session, can function on storefrnt only if (!has_value($order_id)) { $this->order_id = (int) $this->session->data['order_id']; } else { $this->order_id = (int) $order_id; } if (class_exists($this->registry->customer)) { $this->customer_id = $this->registry->customer->getId(); } else { $this->customer = new ACustomer($registry); } }
/** * @param int $coupon_id * @param array $data */ public function editCoupon($coupon_id, $data) { if (has_value($data['date_start'])) { $data['date_start'] = "DATE('" . $data['date_start'] . "')"; } else { if (isset($data['date_start'])) { $data['date_start'] = 'NULL'; } } if (has_value($data['date_end'])) { $data['date_end'] = "DATE('" . $data['date_end'] . "')"; } else { if (isset($data['date_end'])) { $data['date_end'] = 'NULL'; } } $coupon_table_fields = array('code', 'discount', 'type', 'total', 'logged', 'shipping', 'date_start', 'date_end', 'uses_total', 'uses_customer', 'status'); $update = array(); foreach ($coupon_table_fields as $f) { if (isset($data[$f])) { if (!in_array($f, array('date_start', 'date_end'))) { $update[] = $f . " = '" . $this->db->escape($data[$f]) . "'"; } else { $update[] = $f . " = " . $data[$f] . ""; } } } if (!empty($update)) { $this->db->query("UPDATE " . $this->db->table("coupons") . " \n\t\t\t\t\t\t\t\t\t\t\t\tSET " . implode(',', $update) . "\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE coupon_id = '" . (int) $coupon_id . "'"); } if (!empty($data['coupon_description'])) { foreach ($data['coupon_description'] as $language_id => $value) { $update = array(); if (isset($value['name'])) { $update["name"] = $value['name']; } if (isset($value['description'])) { $update["description"] = $value['description']; } if (!empty($update)) { $this->language->replaceDescriptions('coupon_descriptions', array('coupon_id' => (int) $coupon_id), array($language_id => array('name' => $value['name'], 'description' => $value['description']))); } } } }
public function main() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); $min = $this->config->get("default_pp_express_payment_minimum_total"); $max = $this->config->get("default_pp_express_payment_maximum_total"); $amount = $this->cart->getFinalTotal(); if (has_value($min) && $amount < $min || has_value($max) && $amount > $max) { return null; } if (!$this->config->get('default_pp_express_billmelater')) { return null; } $this->view->assign('pp_publisher_id', $this->config->get('default_pp_express_billmelater_publisher_id')); $this->processTemplate(); //init controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); }
public function getFields($form_id) { $fields = array(); $query = $this->db->query("\n SELECT f.*, fd.name, fd.description\n FROM " . $this->db->table("fields") . " f\n LEFT JOIN " . $this->db->table("field_descriptions") . " fd ON ( f.field_id = fd.field_id AND fd.language_id = '" . (int) $this->config->get('storefront_language_id') . "' )\n WHERE f.form_id = '" . (int) $form_id . "'\n AND f.status = 1\n ORDER BY f.sort_order"); if ($query->num_rows) { foreach ($query->rows as $row) { if (has_value($row['settings'])) { $row['settings'] = unserialize($row['settings']); } $fields[$row['field_id']] = $row; $query = $this->db->query("\n\t\t\t\t\tSELECT *\n\t\t\t\t\tFROM " . $this->db->table("field_values") . "\n\t\t\t\t\tWHERE field_id = '" . $row['field_id'] . "'\n\t\t\t\t\t\tAND language_id = '" . (int) $this->config->get('storefront_language_id') . "'"); if ($query->num_rows) { $fields[$row['field_id']]['values'] = $query->rows; } } } return $fields; }
/** * @param string $ses_name */ public function __construct($ses_name = '') { if (!session_id() || has_value($ses_name)) { $this->ses_name = $ses_name; $this->init($this->ses_name); } $registry = Registry::getInstance(); if ($registry->get('config')) { $session_ttl = $registry->get('config')->get('config_session_ttl'); if ((isset($_SESSION['user_id']) || isset($_SESSION['customer_id'])) && isset($_SESSION['LAST_ACTIVITY']) && (time() - $_SESSION['LAST_ACTIVITY']) / 60 > $session_ttl) { // last request was more than 30 minutes ago $this->clear(); header('Location: ' . $registry->get('html')->currentURL(array('token'))); } } $_SESSION['LAST_ACTIVITY'] = time(); // update last activity time stamp $this->data =& $_SESSION; }
public function getTask() { //init controller data $this->extensions->hk_InitData($this, __FUNCTION__); if (!has_value($this->request->get['task_name'])) { $this->data['output'] = array('error' => true, 'error_text' => 'Error: Do not know what to run.'); } else { $task_obj = new ATaskManager(); $this->data['output'] = $task_obj->getTaskByName($this->request->get['task_name']); } //init controller data $this->extensions->hk_UpdateData($this, __FUNCTION__); $this->load->library('json'); if ($this->data['output']) { $output = AJson::encode($this->data['output']); } else { $output = array('error' => true, 'error_text' => 'Error: Cannot find task "' . $this->request->get['task_name'] . '".'); } $this->response->setOutput($output); }
public function main() { $this->loadLanguage('default_banktransfer/default_banktransfer'); $this->view->assign('text_instructions', $this->language->get('text_instructions')); $this->view->assign('text_payment', $this->language->get('text_payment')); $this->view->batchAssign($this->language->getASet()); $this->view->assign('instructions', nl2br($this->config->get('default_banktransfer_instructions'))); $this->view->assign('continue', $this->html->getSecureURL('checkout/success')); if ($this->request->get['rt'] != 'checkout/guest_step_3') { $this->view->assign('back', $this->html->getSecureURL('checkout/payment')); } else { $this->view->assign('back', $this->html->getSecureURL('checkout/guest_step_2')); } //check total for to meat min requirement if (has_value($this->config->get('default_banktransfer_order_min'))) { if ($this->cart->getTotal() < $this->config->get('default_banktransfer_order_min')) { $this->view->assign('minimum_notmet', $this->language->get('text_minimum_notmet')); } } $this->processTemplate('responses/default_banktransfer.tpl'); }
public function addShippingAddress($data) { //encrypt customer data $key_sql = ''; if ($this->dcrypt->active) { $data = $this->dcrypt->encrypt_data($data, 'addresses'); $key_sql = ", key_id = '" . (int) $data['key_id'] . "'"; } if (!has_value($data['country_id'])) { $data['country_id'] = $this->getCountryIdByCode2($data['iso_code_2']); } if (!has_value($data['zone_id'])) { $data['zone_id'] = $this->getZoneId($data['country_id'], $data['zone_code']); } $this->db->query("INSERT INTO " . $this->db->table("addresses") . "\n\t\t\tSET\n\t\t\t\tcustomer_id = '" . (int) $this->customer->getId() . "',\n\t\t\t\tcompany = '" . (has_value($data['company']) ? $this->db->escape($data['company']) : '') . "',\n\t\t\t\tfirstname = '" . $this->db->escape($data['firstname']) . "',\n\t\t\t\tlastname = '" . $this->db->escape($data['lastname']) . "',\n\t\t\t\taddress_1 = '" . $this->db->escape($data['address_1']) . "',\n\t\t\t\taddress_2 = '" . (has_value($data['address_2']) ? $this->db->escape($data['address_2']) : '') . "',\n\t\t\t\tpostcode = '" . $this->db->escape($data['postcode']) . "',\n\t\t\t\tcity = '" . $this->db->escape($data['city']) . "',\n\t\t\t\tzone_id = '" . (int) $data['zone_id'] . "',\n\t\t\t\tcountry_id = '" . (int) $data['country_id'] . "'" . $key_sql); $address_id = $this->db->getLastId(); if (isset($data['default']) && $data['default'] == '1') { $this->db->query("UPDATE " . $this->db->table("customers") . "\n\t\t\tSET address_id = '" . (int) $address_id . "'\n\t\t\tWHERE customer_id = '" . (int) $this->customer->getId() . "'"); } return $address_id; }
public function __construct() { $_GET = $this->clean($_GET); $_POST = $this->clean($_POST); $_COOKIE = $this->clean($_COOKIE); $_FILES = $this->clean($_FILES); $_SERVER = $this->clean($_SERVER); $this->get = $_GET; $this->post = $_POST; $this->cookie = $_COOKIE; $this->files = $_FILES; $this->server = $_SERVER; //check if there is any encrypted data if (has_value($this->get['__e'])) { $this->get = array_replace_recursive($this->get, $this->decodeURI($this->get['__e'])); } if (has_value($this->post['__e'])) { $this->post = array_replace_recursive($this->post, $this->decodeURI($this->post['__e'])); } $this->_detectBrowser(); }