/** * @see FrontController::initContent() */ public function initContent() { $this->display_column_left = false; parent::initContent(); if (!$this->isTokenValid()) { die($this->module->l($this->module->displayName . ' Error: (invalid token)')); } $cart = $this->context->cart; $address = new Address((int) $cart->id_address_invoice); $customer = new Customer((int) $cart->id_customer); $currency = $this->context->currency; $country = new Country((int) $address->id_country); if (!Configuration::get('SOFORTBANKING_USER_ID')) { die($this->module->l($this->module->displayName . ' Error: (invalid or undefined userId)')); } if (!Configuration::get('SOFORTBANKING_PROJECT_ID')) { die($this->module->l($this->module->displayName . ' Error: (invalid or undefined projectId)')); } if (!Validate::isLoadedObject($address) || !Validate::isLoadedObject($customer) || !Validate::isLoadedObject($currency)) { die($this->module->l($this->module->displayName . ' Error: (invalid address or customer)')); } $parameters = array('user_id' => Configuration::get('SOFORTBANKING_USER_ID'), 'project_id' => Configuration::get('SOFORTBANKING_PROJECT_ID'), 'sender_holder' => '', '', '', 'sender_country_id' => $country->iso_code, 'amount' => number_format($cart->getOrderTotal(), 2, '.', ''), 'currency_id' => $currency->iso_code, 'reason_1' => time() . '-' . (int) $cart->id, 'reason_2' => $customer->firstname . ' ' . Tools::ucfirst(Tools::strtolower($customer->lastname)), 'user_variable_0' => $customer->secure_key, 'user_variable_1' => (int) $cart->id, 'user_variable_2' => '', 'user_variable_3' => '', 'user_variable_4' => '', 'user_variable_5' => '', 'project_password' => Configuration::get('SOFORTBANKING_PROJECT_PW')); $this->context->smarty->assign(array('this_path' => $this->module->getPathUri(), 'nbProducts' => $cart->nbProducts(), 'total' => $cart->getOrderTotal(), 'version' => _PS_VERSION_, 'hash' => sha1(implode('|', $parameters)), 'gateway' => 'https://www.sofortueberweisung.de/payment/start', 'cprotect' => Configuration::get('SOFORTBANKING_CPROTECT'), 'parameters' => $parameters, 'mod_lang' => $this->isSupportedLang())); $this->setTemplate(Configuration::get('SOFORTBANKING_REDIRECT') == 'Y' ? 'payment_redirect.tpl' : 'payment_execution.tpl'); }
public function getFields() { parent::validateFields(); $fields['id_profile'] = (int) $this->id_profile; $fields['id_lang'] = (int) $this->id_lang; $fields['lastname'] = pSQL($this->lastname); $fields['firstname'] = pSQL(Tools::ucfirst($this->firstname)); $fields['email'] = pSQL($this->email); $fields['passwd'] = pSQL($this->passwd); $fields['last_passwd_gen'] = pSQL($this->last_passwd_gen); if (empty($this->stats_date_from)) { $this->stats_date_from = date('Y-m-d 00:00:00'); } $fields['stats_date_from'] = pSQL($this->stats_date_from); if (empty($this->stats_date_to)) { $this->stats_date_to = date('Y-m-d 23:59:59', strtotime('+1 year')); } $fields['stats_date_to'] = pSQL($this->stats_date_to); $fields['bo_color'] = pSQL($this->bo_color); $fields['bo_theme'] = pSQL($this->bo_theme); $fields['bo_uimode'] = pSQL($this->bo_uimode); $fields['bo_show_screencast'] = (int) $this->bo_show_screencast; $fields['active'] = (int) $this->active; return $fields; }
public function hold() { $userId = (int) $this->getParam('user_id'); if ($userId) { $isId = DB::run()->query('select id from users where id = ' . $userId . ' and family = ' . Registry::get('user')->family . ' limit 1')->fetch(); if (!$isId) { exit(json_encode(['result' => 'fail', 'message' => 'Пользователь не находится в данной семье'])); } } else { $userId = Registry::get('user')->id; } $reason = $this->getParam('task_name'); $value = (int) $this->getParam('task_value', 0); $value = $value == 0 ? Registry::get('min_task_value') : ($value < Registry::get('min_task_value') ? Registry::get('min_task_value') : ($value > Registry::get('max_task_value') ? Registry::get('max_task_value') : $value)); if (empty($reason)) { exit(json_encode(['result' => 'fail', 'message' => 'Поле "Причина удержания баллов" должно быть заполнено!'])); } $stmt = DB::run()->prepare('insert into points (user_id, task_id, hold_reason, value, date) values (?, ?, ?, ?, ?)'); try { DB::run()->beginTransaction(); $stmt->execute([$userId, 0, Tools::ucfirst($reason), -$value, date('Y-m-d H:i:s')]); DB::run()->commit(); exit(json_encode(['result' => 'done', 'message' => 'Снятие баллов произведено успешно!', 'type' => 'hold-points'])); } catch (PDOException $e) { DB::run()->rollBack(); exit(json_encode(['result' => 'fail', 'message' => $e->getMessage()])); } }
public function add() { $taskName = Tools::ucfirst($this->getParam('task_name')); $taskValue = (int) $this->getParam('task_value', 0); $taskValue = $taskValue == 0 ? Registry::get('min_task_value') : ($taskValue < Registry::get('min_task_value') ? Registry::get('min_task_value') : ($taskValue > Registry::get('max_task_value') ? Registry::get('max_task_value') : $taskValue)); if (empty($taskName)) { exit(json_encode(['result' => 'fail', 'message' => 'Поле "Название задачи" должно быть заполнено!'])); } $email = $this->getParam('email'); if (empty($email)) { $id = Registry::get('user')->id; } else { $id = DB::run()->query('select id from users where email = ' . DB::run()->quote($email) . ' and family = ' . Registry::get('user')->family)->fetchColumn(); } $resp = DB::run()->query('select name from tasks where user_id = ' . $id . ' and name = ' . DB::run()->quote($taskName))->fetchColumn(); if ($resp) { exit(json_encode(['result' => 'fail', 'message' => 'Задача с таким названием уже существует!'])); } $stmt = DB::run()->prepare('insert into tasks (user_id, family_id, name, value) values (?, ?, ?, ?)'); try { DB::run()->beginTransaction(); $stmt->execute([$id, Registry::get('user')->family, $taskName, $taskValue]); DB::run()->commit(); exit(json_encode(['result' => 'done', 'message' => 'Новая задача успешно добавлена!', 'type' => 'add-task'])); } catch (PDOException $e) { DB::run()->rollBack(); exit(json_encode(['result' => 'fail', 'message' => $e->getMessage()])); } }
public function preProcess() { parent::preProcess(); $customer = new Customer((int) self::$cookie->id_customer); if (isset($_POST['years']) && isset($_POST['months']) && isset($_POST['days'])) { $customer->birthday = (int) $_POST['years'] . '-' . (int) $_POST['months'] . '-' . (int) $_POST['days']; } if (Tools::isSubmit('submitIdentity')) { if (Module::getInstanceByName('blocknewsletter')->active) { if (!isset($_POST['optin'])) { $customer->optin = 0; } if (!isset($_POST['newsletter'])) { $customer->newsletter = 0; } } if (!isset($_POST['id_gender'])) { $_POST['id_gender'] = 9; } if (!@checkdate(Tools::getValue('months'), Tools::getValue('days'), Tools::getValue('years')) && !(Tools::getValue('months') == '' && Tools::getValue('days') == '' && Tools::getValue('years') == '')) { $this->errors[] = Tools::displayError('Invalid date of birth'); } else { $customer->birthday = empty($_POST['years']) ? '' : (int) $_POST['years'] . '-' . (int) $_POST['months'] . '-' . (int) $_POST['days']; $id_customer_exists = (int) Customer::customerExists(Tools::getValue('email'), true, false); if ($id_customer_exists && $id_customer_exists != (int) self::$cookie->id_customer) { $this->errors[] = Tools::displayError('An account is already registered with this e-mail.'); } $_POST['old_passwd'] = trim($_POST['old_passwd']); if (empty($_POST['old_passwd']) || Tools::encrypt($_POST['old_passwd']) != self::$cookie->passwd) { $this->errors[] = Tools::displayError('Your password is incorrect.'); } elseif ($_POST['passwd'] != $_POST['confirmation']) { $this->errors[] = Tools::displayError('Password and confirmation do not match'); } else { $prev_id_default_group = $customer->id_default_group; $this->errors = array_unique(array_merge($this->errors, $customer->validateController(true, true))); } if (!count($this->errors)) { $customer->id_default_group = (int) $prev_id_default_group; $customer->firstname = Tools::ucfirst(Tools::strtolower($customer->firstname)); if (Tools::getValue('passwd')) { self::$cookie->passwd = $customer->passwd; } if ($customer->update()) { self::$cookie->customer_lastname = $customer->lastname; self::$cookie->customer_firstname = $customer->firstname; self::$smarty->assign('confirmation', 1); } else { $this->errors[] = Tools::displayError('Cannot update information'); } } } } else { $_POST = array_map('stripslashes', $customer->getFields()); } $birthday = $customer->birthday ? explode('-', $customer->birthday) : array('-', '-', '-'); /* Generate years, months and days */ self::$smarty->assign(array('years' => Tools::dateYears(), 'sl_year' => $birthday[0], 'months' => Tools::dateMonths(), 'sl_month' => $birthday[1], 'days' => Tools::dateDays(), 'sl_day' => $birthday[2], 'errors' => $this->errors)); self::$smarty->assign('newsletter', (int) Module::getInstanceByName('blocknewsletter')->active); }
public function preProcess() { parent::preProcess(); $customer = new Customer((int) self::$cookie->id_customer); if (sizeof($_POST)) { $exclusion = array('secure_key', 'old_passwd', 'passwd', 'active', 'date_add', 'date_upd', 'last_passwd_gen', 'newsletter_date_add', 'id_default_group'); $fields = $customer->getFields(); foreach ($fields as $key => $value) { if (!in_array($key, $exclusion)) { $customer->{$key} = key_exists($key, $_POST) ? trim($_POST[$key]) : 0; } } } if (isset($_POST['years']) and isset($_POST['months']) and isset($_POST['days'])) { $customer->birthday = (int) $_POST['years'] . '-' . (int) $_POST['months'] . '-' . (int) $_POST['days']; } if (Tools::isSubmit('submitIdentity')) { if (!@checkdate(Tools::getValue('months'), Tools::getValue('days'), Tools::getValue('years')) and !(Tools::getValue('months') == '' and Tools::getValue('days') == '' and Tools::getValue('years') == '')) { $this->errors[] = Tools::displayError('Invalid date of birth'); } else { $customer->birthday = empty($_POST['years']) ? '' : (int) $_POST['years'] . '-' . (int) $_POST['months'] . '-' . (int) $_POST['days']; $_POST['old_passwd'] = trim($_POST['old_passwd']); if (empty($_POST['old_passwd']) or Tools::encrypt($_POST['old_passwd']) != self::$cookie->passwd) { $this->errors[] = Tools::displayError('Your password is incorrect.'); } elseif ($_POST['passwd'] != $_POST['confirmation']) { $this->errors[] = Tools::displayError('Password and confirmation do not match'); } else { $prev_id_default_group = $customer->id_default_group; $this->errors = $customer->validateControler(); } if (!sizeof($this->errors)) { $customer->id_default_group = (int) $prev_id_default_group; $customer->firstname = Tools::ucfirst(Tools::strtolower($customer->firstname)); if (Tools::getValue('passwd')) { self::$cookie->passwd = $customer->passwd; } if ($customer->update()) { self::$cookie->customer_lastname = $customer->lastname; self::$cookie->customer_firstname = $customer->firstname; self::$smarty->assign('confirmation', 1); } else { $this->errors[] = Tools::displayError('Cannot update information'); } } } } else { $_POST = array_map('stripslashes', $customer->getFields()); } if ($customer->birthday) { $birthday = explode('-', $customer->birthday); } else { $birthday = array('-', '-', '-'); } /* Generate years, months and days */ self::$smarty->assign(array('years' => Tools::dateYears(), 'sl_year' => $birthday[0], 'months' => Tools::dateMonths(), 'sl_month' => $birthday[1], 'days' => Tools::dateDays(), 'sl_day' => $birthday[2], 'errors' => $this->errors)); self::$smarty->assign('newsletter', (int) Module::getInstanceByName('blocknewsletter')->active); }
/** * */ public static function getSkins($theme) { $folder = _PS_ALL_THEMES_DIR_ . $theme . '/sass/skins/*.scss'; $dirs = glob($folder); $output = array(); foreach ($dirs as $dir) { $file = str_replace('.scss', '', basename($dir)); $output[] = array('id' => $file, 'name' => Tools::ucfirst($file)); } return $output; }
public function getFields() { parent::validateFields(); $fields['id_profile'] = intval($this->id_profile); $fields['lastname'] = pSQL(Tools::strtoupper($this->lastname)); $fields['firstname'] = pSQL(Tools::ucfirst($this->firstname)); $fields['email'] = pSQL($this->email); $fields['passwd'] = pSQL($this->passwd); $fields['last_passwd_gen'] = pSQL($this->last_passwd_gen); $fields['stats_date_from'] = pSQL($this->stats_date_from); $fields['stats_date_to'] = pSQL($this->stats_date_to); $fields['active'] = intval($this->active); return $fields; }
public function getThemes() { if ($this->themes) { return $this->themes; } $themes = array(); $directories = glob(_PS_ALL_THEMES_DIR_ . $this->theme_name . '/css/themes/*.css'); $themes[] = array('skin' => 'default', 'rehook' => PtsThemeSample::isReHookBySkin($this->theme_name, 'default'), 'name' => $this->l('Default')); if ($directories) { foreach ($directories as $dir) { $skin = str_replace('.css', '', basename($dir)); $rehook = PtsThemeSample::isReHookBySkin($this->theme_name, $skin); $themes[] = array('skin' => $skin, 'rehook' => $rehook, 'name' => $this->l(Tools::ucfirst($skin))); } } return $themes; }
public function getFields() { parent::validateFields(); $fields['id_profile'] = (int) $this->id_profile; $fields['id_lang'] = (int) $this->id_lang; $fields['lastname'] = pSQL($this->lastname); $fields['firstname'] = pSQL(Tools::ucfirst($this->firstname)); $fields['email'] = pSQL($this->email); $fields['passwd'] = pSQL($this->passwd); $fields['last_passwd_gen'] = pSQL($this->last_passwd_gen); $fields['stats_date_from'] = pSQL($this->stats_date_from); $fields['stats_date_to'] = pSQL($this->stats_date_to); $fields['bo_color'] = pSQL($this->bo_color); $fields['bo_theme'] = pSQL($this->bo_theme); $fields['bo_uimode'] = pSQL($this->bo_uimode); $fields['active'] = (int) $this->active; return $fields; }
/** * Install Module Tabs */ private function installModuleTab($title, $class_sfx = '', $parent = '') { $class = 'Admin' . Tools::ucfirst($this->name) . Tools::ucfirst($class_sfx); if ($parent == '') { $position = Tab::getCurrentTabId(); } else { $position = Tab::getIdFromClassName($parent); } $tab = new Tab(); $tab->class_name = $class; $tab->module = $this->name; $tab->id_parent = (int) $position; $langs = Language::getLanguages(false); foreach ($langs as $l) { $tab->name[$l['id_lang']] = $title; } return $tab->add(true, false); }
public function loadEngines() { if (!$this->engines) { $wds = glob(dirname(__FILE__) . '/widget/*.php'); foreach ($wds as $w) { $paths = explode('/', $w); $last = array_pop($paths); if ($last != 'index.php') { require_once $w; $f = str_replace('.php', '', basename($w)); $class = 'PsMegamenuWidget' . Tools::ucfirst($f); if (class_exists($class)) { $this->engines[$f] = new $class(); $this->engines[$f]->id_shop = Context::getContext()->shop->id; $this->engines[$f]->lang_id = Context::getContext()->language->id; $this->engine_types[$f] = $this->engines[$f]->getWidgetInfo(); $this->engine_types[$f]['type'] = $f; } } } } }
public function loadEngines() { if (!$this->engines) { $wds = glob(dirname(__FILE__) . '/widget/*.php'); foreach ($wds as $w) { if (basename($w) == 'index.php') { continue; } require_once $w; $f = str_replace('.php', '', basename($w)); $class = 'LeoWidget' . Tools::ucfirst($f); if (class_exists($class)) { $this->engines[$f] = new $class(); $this->engines[$f]->id_shop = Context::getContext()->shop->id; $this->engines[$f]->langID = Context::getContext()->language->id; $this->engineTypes[$f] = $this->engines[$f]->getWidgetInfo(); $this->engineTypes[$f]['type'] = $f; $this->engineTypes[$f]['for'] = $this->engines[$f]->for_module; } } } }
private function placeOrder() { $mercadopago = $this->module; $response = $mercadopago->execPayment($_POST); $order_status = null; if (array_key_exists('status', $response)) { switch ($response['status']) { case 'in_process': $order_status = 'MERCADOPAGO_STATUS_0'; break; case 'approved': $order_status = 'MERCADOPAGO_STATUS_1'; break; case 'pending': $order_status = 'MERCADOPAGO_STATUS_7'; break; } } if ($order_status != null) { $cart = Context::getContext()->cart; $total = (double) number_format($response['amount'], 2, '.', ''); $extra_vars = array('{bankwire_owner}' => $mercadopago->textshowemail, '{bankwire_details}' => '', '{bankwire_address}' => ''); $mercadopago->validateOrder($cart->id, Configuration::get($order_status), $total, $mercadopago->displayName, null, $extra_vars, $cart->id_currency); $order = new Order($mercadopago->currentOrder); $order_payments = $order->getOrderPayments(); $order_payments[0]->transaction_id = $response['payment_id']; $uri = __PS_BASE_URI__ . 'order-confirmation.php?id_cart=' . $cart->id . '&id_module=' . $mercadopago->id . '&id_order=' . $mercadopago->currentOrder . '&key=' . $order->secure_key . '&payment_id=' . $response['payment_id'] . '&payment_status=' . $response['status']; if (Tools::getIsset('card_token_id')) { // get credit card last 4 digits $four_digits = '**** **** **** ' . Tools::substr(Tools::getValue('cardNumber'), -4); // expiration date $expiration_date = Tools::getValue('cardExpirationMonth') . '/20' . Tools::getValue('cardExpirationYear'); $order_payments[0]->card_number = $four_digits; $order_payments[0]->card_brand = Tools::ucfirst(Tools::getValue('payment_method_id')); $order_payments[0]->card_expiration = $expiration_date; $order_payments[0]->card_holder = Tools::getValue('cardholderName'); $uri .= '&card_token=' . Tools::getValue('card_token_id') . '&card_holder_name=' . Tools::getValue('cardholderName') . '&four_digits=' . $four_digits . '&payment_method_id=' . Tools::getValue('payment_method_id') . '&expiration_date=' . $expiration_date . '&installments=' . $response['installments'] . '&statement_descriptor=' . $response['statement_descriptor'] . '&status_detail=' . $response['status_detail'] . '&amount=' . $response['amount']; } else { $uri .= '&payment_method_id=' . Tools::getValue('payment_method_id') . '&boleto_url=' . urlencode($response['activation_uri']); } $order_payments[0]->save(); Tools::redirectLink($uri); } else { $this->context->controller->addCss((Configuration::get('PS_SSL_ENABLED') ? 'https://' : 'http://') . htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8') . __PS_BASE_URI__ . 'modules/mercadopago/views/css/mercadopago_core.css', 'all'); $data = array('version' => $mercadopago->getPrestashopVersion(), 'one_step' => Configuration::get('PS_ORDER_PROCESS_TYPE')); if (array_key_exists('message', $response) && (strpos($response['message'], 'Invalid users involved') !== false || strpos($response['message'], 'users from different countries') !== false)) { $data['valid_user'] = false; } else { $data['version'] = $mercadopago->getPrestashopVersion(); $data['status_detail'] = $response['status_detail']; $data['card_holder_name'] = Tools::getValue('cardholderName'); $data['four_digits'] = Tools::substr(Tools::getValue('cardNumber'), -4); $data['payment_method_id'] = Tools::getValue('payment_method_id'); $data['expiration_date'] = Tools::getValue('cardExpirationMonth') . '/20' . Tools::getValue('cardExpirationYear'); $data['installments'] = $response['installments']; $data['amount'] = Tools::displayPrice($response['amount'], new Currency(Context::getContext()->cart->id_currency), false); $data['payment_id'] = $response['payment_id']; $data['one_step'] = Configuration::get('PS_ORDER_PROCESS_TYPE'); $data['valid_user'] = true; $data['message'] = $response['message']; } $this->context->smarty->assign($data); $this->setTemplate('error.tpl'); } }
public function renderForm() { if (!is_dir(AdminImportController::getPath())) { return !($this->errors[] = Tools::displayError('The import directory doesn\'t exist. Please check your file path.')); } if (!is_writable(AdminImportController::getPath())) { $this->displayWarning($this->l('The import directory must be writable (CHMOD 755 / 777).')); } $files_to_import = scandir(AdminImportController::getPath()); uasort($files_to_import, array('AdminImportController', 'usortFiles')); foreach ($files_to_import as $k => &$filename) { //exclude . .. .svn and index.php and all hidden files if (preg_match('/^\\..*|index\\.php/i', $filename) || is_dir(AdminImportController::getPath() . $filename)) { unset($files_to_import[$k]); } } unset($filename); $this->fields_form = array(''); $this->toolbar_scroll = false; $this->toolbar_btn = array(); // adds fancybox $this->addJqueryPlugin(array('fancybox')); $entity_selected = 0; if (isset($this->entities[$this->l(Tools::ucfirst(Tools::getValue('import_type')))])) { $entity_selected = $this->entities[$this->l(Tools::ucfirst(Tools::getValue('import_type')))]; $this->context->cookie->entity_selected = (int) $entity_selected; } elseif (isset($this->context->cookie->entity_selected)) { $entity_selected = (int) $this->context->cookie->entity_selected; } $csv_selected = ''; if (isset($this->context->cookie->csv_selected) && @filemtime(AdminImportController::getPath(urldecode($this->context->cookie->csv_selected)))) { $csv_selected = urldecode($this->context->cookie->csv_selected); } else { $this->context->cookie->csv_selected = $csv_selected; } $id_lang_selected = ''; if (isset($this->context->cookie->iso_lang_selected) && $this->context->cookie->iso_lang_selected) { $id_lang_selected = (int) Language::getIdByIso(urldecode($this->context->cookie->iso_lang_selected)); } $separator_selected = $this->separator; if (isset($this->context->cookie->separator_selected) && $this->context->cookie->separator_selected) { $separator_selected = urldecode($this->context->cookie->separator_selected); } $multiple_value_separator_selected = $this->multiple_value_separator; if (isset($this->context->cookie->multiple_value_separator_selected) && $this->context->cookie->multiple_value_separator_selected) { $multiple_value_separator_selected = urldecode($this->context->cookie->multiple_value_separator_selected); } //get post max size $post_max_size = ini_get('post_max_size'); $bytes = trim($post_max_size); $last = strtolower($post_max_size[strlen($post_max_size) - 1]); switch ($last) { case 'g': $bytes *= 1024; // no break to fall-through // no break to fall-through case 'm': $bytes *= 1024; // no break to fall-through // no break to fall-through case 'k': $bytes *= 1024; } if (!isset($bytes) || $bytes == '') { $bytes = 20971520; } // 20Mb $this->tpl_form_vars = array('post_max_size' => (int) $bytes, 'module_confirmation' => Tools::isSubmit('import') && (isset($this->warnings) && !count($this->warnings)), 'path_import' => AdminImportController::getPath(), 'entities' => $this->entities, 'entity_selected' => $entity_selected, 'csv_selected' => $csv_selected, 'separator_selected' => $separator_selected, 'multiple_value_separator_selected' => $multiple_value_separator_selected, 'files_to_import' => $files_to_import, 'languages' => Language::getLanguages(false), 'id_language' => $id_lang_selected ? $id_lang_selected : $this->context->language->id, 'available_fields' => $this->getAvailableFields(), 'truncateAuthorized' => Shop::isFeatureActive() && $this->context->employee->isSuperAdmin() || !Shop::isFeatureActive(), 'PS_ADVANCED_STOCK_MANAGEMENT' => Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')); return parent::renderForm(); }
public function __construct() { $this->bootstrap = true; $this->table = 'employee'; $this->className = 'Employee'; $this->lang = false; $this->context = Context::getContext(); $this->addRowAction('edit'); $this->addRowAction('delete'); $this->addRowActionSkipList('delete', array((int) $this->context->employee->id)); $this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?'), 'icon' => 'icon-trash')); /* check if there are more than one superAdmin if it's the case then we can delete a superAdmin */ $super_admin = Employee::countProfile(_PS_ADMIN_PROFILE_, true); if ($super_admin == 1) { $super_admin_array = Employee::getEmployeesByProfile(_PS_ADMIN_PROFILE_, true); $super_admin_id = array(); foreach ($super_admin_array as $key => $val) { $super_admin_id[] = $val['id_employee']; } $this->addRowActionSkipList('delete', $super_admin_id); } $profiles = Profile::getProfiles($this->context->language->id); if (!$profiles) { $this->errors[] = Tools::displayError('No profile.'); } else { foreach ($profiles as $profile) { $this->profiles_array[$profile['name']] = $profile['name']; } } $this->fields_list = array('id_employee' => array('title' => $this->l('ID'), 'align' => 'center', 'class' => 'fixed-width-xs'), 'firstname' => array('title' => $this->l('First Name')), 'lastname' => array('title' => $this->l('Last Name')), 'email' => array('title' => $this->l('Email address')), 'profile' => array('title' => $this->l('Profile'), 'type' => 'select', 'list' => $this->profiles_array, 'filter_key' => 'pl!name', 'class' => 'fixed-width-lg'), 'active' => array('title' => $this->l('Active'), 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'class' => 'fixed-width-sm')); $this->fields_options = array('general' => array('title' => $this->l('Employee options'), 'fields' => array('PS_PASSWD_TIME_BACK' => array('title' => $this->l('Password regeneration'), 'hint' => $this->l('Security: Minimum time to wait between two password changes.'), 'cast' => 'intval', 'type' => 'text', 'suffix' => ' ' . $this->l('minutes'), 'visibility' => Shop::CONTEXT_ALL), 'PS_BO_ALLOW_EMPLOYEE_FORM_LANG' => array('title' => $this->l('Memorize the language used in Admin panel forms'), 'hint' => $this->l('Allow employees to select a specific language for the Admin panel form.'), 'cast' => 'intval', 'type' => 'select', 'identifier' => 'value', 'list' => array('0' => array('value' => 0, 'name' => $this->l('No')), '1' => array('value' => 1, 'name' => $this->l('Yes'))), 'visibility' => Shop::CONTEXT_ALL)), 'submit' => array('title' => $this->l('Save')))); $rtl = $this->context->language->is_rtl ? '_rtl' : ''; $path = _PS_ADMIN_DIR_ . DIRECTORY_SEPARATOR . 'themes' . DIRECTORY_SEPARATOR; foreach (scandir($path) as $theme) { if ($theme[0] != '.' && is_dir($path . $theme) && @filemtime($path . $theme . DIRECTORY_SEPARATOR . 'css' . DIRECTORY_SEPARATOR . 'admin-theme.css')) { $this->themes[] = array('id' => $theme . '|admin-theme' . $rtl . '.css', 'name' => $theme == 'default' ? $this->l('Default') : ucfirst($theme)); if (file_exists($path . $theme . DIRECTORY_SEPARATOR . 'css' . DIRECTORY_SEPARATOR . 'schemes' . $rtl)) { foreach (scandir($path . $theme . DIRECTORY_SEPARATOR . 'css' . DIRECTORY_SEPARATOR . 'schemes' . $rtl) as $css) { if ($css[0] != '.' && preg_match('/\\.css$/', $css)) { $name = strpos($css, 'admin-theme-') !== false ? Tools::ucfirst(preg_replace('/^admin-theme-(.*)\\.css$/', '$1', $css)) : $css; $this->themes[] = array('id' => $theme . '|schemes' . $rtl . '/' . $css, 'name' => $name); } } } } } $home_tab = Tab::getInstanceFromClassName('AdminDashboard', $this->context->language->id); $this->tabs_list[$home_tab->id] = array('name' => $home_tab->name, 'id_tab' => $home_tab->id, 'children' => array(array('id_tab' => $home_tab->id, 'name' => $home_tab->name))); foreach (Tab::getTabs($this->context->language->id, 0) as $tab) { if (Tab::checkTabRights($tab['id_tab'])) { $this->tabs_list[$tab['id_tab']] = $tab; foreach (Tab::getTabs($this->context->language->id, $tab['id_tab']) as $children) { if (Tab::checkTabRights($children['id_tab'])) { $this->tabs_list[$tab['id_tab']]['children'][] = $children; } } } } parent::__construct(); // An employee can edit its own profile if ($this->context->employee->id == Tools::getValue('id_employee')) { $this->tabAccess['view'] = '1'; $this->restrict_edition = true; $this->tabAccess['edit'] = '1'; } }
/** * PROCESS : configureShop * Set default shop configuration */ public function configureShop(array $data = array()) { //clear image cache in tmp folder if (file_exists(_PS_TMP_IMG_DIR_)) { foreach (scandir(_PS_TMP_IMG_DIR_) as $file) { if ($file[0] != '.' && $file != 'index.php') { Tools::deleteFile(_PS_TMP_IMG_DIR_ . $file); } } } $default_data = array('shop_name' => 'My Shop', 'shop_activity' => '', 'shop_country' => 'us', 'shop_timezone' => 'US/Eastern', 'use_smtp' => false, 'smtp_server' => '', 'smtp_login' => '', 'smtp_password' => '', 'smtp_encryption' => 'off', 'smtp_port' => 25); foreach ($default_data as $k => $v) { if (!isset($data[$k])) { $data[$k] = $v; } } Context::getContext()->shop = new Shop(1); Configuration::loadConfiguration(); // use the old image system if the safe_mod is enabled otherwise the installer will fail with the fixtures installation if (InstallSession::getInstance()->safe_mode) { Configuration::updateGlobalValue('PS_LEGACY_IMAGES', 1); } $id_country = Country::getByIso($data['shop_country']); // Set default configuration Configuration::updateGlobalValue('PS_SHOP_DOMAIN', Tools::getHttpHost()); Configuration::updateGlobalValue('PS_SHOP_DOMAIN_SSL', Tools::getHttpHost()); Configuration::updateGlobalValue('PS_INSTALL_VERSION', _PS_INSTALL_VERSION_); Configuration::updateGlobalValue('PS_LOCALE_LANGUAGE', $this->language->getLanguageIso()); Configuration::updateGlobalValue('PS_SHOP_NAME', $data['shop_name']); Configuration::updateGlobalValue('PS_SHOP_ACTIVITY', $data['shop_activity']); Configuration::updateGlobalValue('PS_COUNTRY_DEFAULT', $id_country); Configuration::updateGlobalValue('PS_LOCALE_COUNTRY', $data['shop_country']); Configuration::updateGlobalValue('PS_TIMEZONE', $data['shop_timezone']); Configuration::updateGlobalValue('PS_CONFIGURATION_AGREMENT', (int) $data['configuration_agrement']); // Set mails configuration Configuration::updateGlobalValue('PS_MAIL_METHOD', $data['use_smtp'] ? 2 : 1); Configuration::updateGlobalValue('PS_MAIL_SERVER', $data['smtp_server']); Configuration::updateGlobalValue('PS_MAIL_USER', $data['smtp_login']); Configuration::updateGlobalValue('PS_MAIL_PASSWD', $data['smtp_password']); Configuration::updateGlobalValue('PS_MAIL_SMTP_ENCRYPTION', $data['smtp_encryption']); Configuration::updateGlobalValue('PS_MAIL_SMTP_PORT', $data['smtp_port']); // Activate rijndael 128 encrypt algorihtm if mcrypt is activated Configuration::updateGlobalValue('PS_CIPHER_ALGORITHM', function_exists('mcrypt_encrypt') ? 1 : 0); // Set logo configuration if (file_exists(_PS_IMG_DIR_ . 'logo.jpg')) { list($width, $height) = getimagesize(_PS_IMG_DIR_ . 'logo.jpg'); Configuration::updateGlobalValue('SHOP_LOGO_WIDTH', round($width)); Configuration::updateGlobalValue('SHOP_LOGO_HEIGHT', round($height)); } // Active only the country selected by the merchant Db::getInstance()->execute('UPDATE ' . _DB_PREFIX_ . 'country SET active = 0 WHERE id_country != ' . (int) $id_country); // Set localization configuration $version = str_replace('.', '', _PS_VERSION_); $version = substr($version, 0, 2); $localization_file_content = @Tools::file_get_contents('http://api.prestashop.com/localization/' . $version . '/' . $data['shop_country'] . '.xml'); if (!@simplexml_load_string($localization_file_content)) { $localization_file_content = false; } if (!$localization_file_content) { $localization_file = _PS_ROOT_DIR_ . '/localization/default.xml'; if (file_exists(_PS_ROOT_DIR_ . '/localization/' . $data['shop_country'] . '.xml')) { $localization_file = _PS_ROOT_DIR_ . '/localization/' . $data['shop_country'] . '.xml'; } $localization_file_content = file_get_contents($localization_file); } $locale = new LocalizationPackCore(); $locale->loadLocalisationPack($localization_file_content, '', true); // Create default employee if (isset($data['admin_firstname']) && isset($data['admin_lastname']) && isset($data['admin_password']) && isset($data['admin_email'])) { $employee = new Employee(); $employee->firstname = Tools::ucfirst($data['admin_firstname']); $employee->lastname = Tools::ucfirst($data['admin_lastname']); $employee->email = $data['admin_email']; $employee->passwd = md5(_COOKIE_KEY_ . $data['admin_password']); $employee->last_passwd_gen = date('Y-m-d h:i:s', strtotime('-360 minutes')); $employee->bo_theme = 'default'; $employee->default_tab = 1; $employee->active = true; $employee->id_profile = 1; $employee->id_lang = Configuration::get('PS_LANG_DEFAULT'); $employee->bo_show_screencast = 1; if (!$employee->add()) { $this->setError($this->language->l('Cannot create admin account')); return false; } } else { $this->setError($this->language->l('Cannot create admin account')); return false; } // Update default contact if (isset($data['admin_email'])) { Configuration::updateGlobalValue('PS_SHOP_EMAIL', $data['admin_email']); $contacts = new Collection('Contact'); foreach ($contacts as $contact) { $contact->email = $data['admin_email']; $contact->update(); } } return true; }
/** * */ public function getWidgetContent($type, $data) { $method = "renderWidget" . Tools::ucfirst($type) . 'Content'; $args = array(); $data = Tools::jsonDecode(call_user_func('base64' . '_decode', $data), true); $data['widget_heading'] = isset($data['widget_title_' . $this->langID]) ? $data['widget_title_' . $this->langID] : ""; //echo $method; if (isset($this->engines[$type])) { $args = array(); return $this->engines[$type]->renderContent($args, $data); } return; }
/** * @see FrontController::initContent() */ public function initContent() { $config = LeoBlogConfig::getInstance(); /* Load Css and JS File */ LeoBlogHelper::loadMedia($this->context, $this); $this->php_self = 'category'; parent::initContent(); $id_category = (int) Tools::getValue('id'); $helper = LeoBlogHelper::getInstance(); $limit_leading_blogs = (int) $config->get('listing_leading_limit_items', 1); $limit_secondary_blogs = (int) $config->get('listing_secondary_limit_items', 6); $limit = (int) $limit_leading_blogs + (int) $limit_secondary_blogs; $n = $limit; $p = abs((int) Tools::getValue('p', 1)); $category = new Leoblogcat($id_category, $this->context->language->id); $template = isset($category->template) && $category->template ? $category->template : $config->get('template', 'default'); if ($category->id_leoblogcat && $category->active) { // $_GET['rewrite'] = $category->link_rewrite; $this->template_path .= $template . '/'; if ($category->image) { # validate module $category->image = _LEOBLOG_BLOG_IMG_URI_ . 'c/' . $category->image; } $blogs = LeoBlogBlog::getListBlogs($id_category, $this->context->language->id, $p, $limit, 'id_leoblog_blog', 'DESC', array(), true); $count = LeoBlogBlog::countBlogs($id_category, $this->context->language->id, true); $authors = array(); $leading_blogs = array(); $secondary_blogs = array(); // $links = array(); if (count($blogs)) { $leading_blogs = array_slice($blogs, 0, $limit_leading_blogs); $secondary_blogs = array_splice($blogs, $limit_leading_blogs, count($blogs)); } $image_w = (int) $config->get('listing_leading_img_width', 690); $image_h = (int) $config->get('listing_leading_img_height', 300); foreach ($leading_blogs as $key => $blog) { $blog = LeoBlogHelper::buildBlog($helper, $blog, $image_w, $image_h, $config); if ($blog['id_employee']) { if (!isset($authors[$blog['id_employee']])) { # validate module $authors[$blog['id_employee']] = new Employee($blog['id_employee']); } $blog['author'] = $authors[$blog['id_employee']]->firstname . ' ' . $authors[$blog['id_employee']]->lastname; $blog['author_link'] = $helper->getBlogAuthorLink($authors[$blog['id_employee']]->id); } else { $blog['author'] = ''; $blog['author_link'] = ''; } $leading_blogs[$key] = $blog; } $image_w = (int) $config->get('listing_secondary_img_width', 390); $image_h = (int) $config->get('listing_secondary_img_height', 200); foreach ($secondary_blogs as $key => $blog) { $blog = LeoBlogHelper::buildBlog($helper, $blog, $image_w, $image_h, $config); if ($blog['id_employee']) { if (!isset($authors[$blog['id_employee']])) { # validate module $authors[$blog['id_employee']] = new Employee($blog['id_employee']); } $blog['author'] = $authors[$blog['id_employee']]->firstname . ' ' . $authors[$blog['id_employee']]->lastname; $blog['author_link'] = $helper->getBlogAuthorLink($authors[$blog['id_employee']]->id); } else { $blog['author'] = ''; $blog['author_link'] = ''; } $secondary_blogs[$key] = $blog; } $nb_blogs = $count; $range = 2; /* how many pages around page selected */ if ($p > $nb_blogs / $n + 1) { Tools::redirect(preg_replace('/[&?]p=\\d+/', '', $_SERVER['REQUEST_URI'])); } $pages_nb = ceil($nb_blogs / (int) $n); $start = (int) ($p - $range); if ($start < 1) { $start = 1; } $stop = (int) ($p + $range); if ($stop > $pages_nb) { $stop = (int) $pages_nb; } $params = array('rewrite' => $category->link_rewrite, 'id' => $category->id_leoblogcat); /* breadcrumb */ $r = $helper->getPaginationLink('module-leoblog-category', 'category', $params, false, true); $path = ''; $all_cats = array(); self::parentCategories($category, $all_cats); foreach ($all_cats as $key => $cat) { if ($cat->id == 1) { # validate module $path .= '<a href="' . $helper->getFontBlogLink() . '">' . htmlentities($config->get('blog_link_title_' . $this->context->language->id, 'Blog'), ENT_NOQUOTES, 'UTF-8') . '</a><span class="navigation-pipe">' . Configuration::get('PS_NAVIGATION_PIPE') . '</span>'; } elseif (count($all_cats) - 1 == $key) { # validate module $path .= $cat->title; } else { $params = array('rewrite' => $cat->link_rewrite, 'id' => $cat->id); $path .= '<a href="' . $helper->getBlogCatLink($params) . '">' . htmlentities($cat->title, ENT_NOQUOTES, 'UTF-8') . '</a><span class="navigation-pipe">' . Configuration::get('PS_NAVIGATION_PIPE') . '</span>'; } } /* sub categories */ $categories = $category->getChild($category->id_leoblogcat, $this->context->language->id); $childrens = array(); if ($categories) { foreach ($categories as $child) { $params = array('rewrite' => $child['link_rewrite'], 'id' => $child['id_leoblogcat']); $child['thumb'] = _LEOBLOG_BLOG_IMG_URI_ . 'c/' . $child['image']; $child['category_link'] = $helper->getBlogCatLink($params); $childrens[] = $child; } } $this->context->smarty->assign(array('leading_blogs' => $leading_blogs, 'secondary_blogs' => $secondary_blogs, 'listing_leading_column' => $config->get('listing_leading_column', 1), 'listing_secondary_column' => $config->get('listing_secondary_column', 3), 'module_tpl' => $this->template_path, 'config' => $config, 'range' => $range, 'category' => $category, 'start' => $start, 'childrens' => $childrens, 'stop' => $stop, 'path' => $path, 'pages_nb' => $pages_nb, 'nb_items' => $count, 'p' => (int) $p, 'n' => (int) $n, 'meta_title' => Tools::ucfirst($category->title) . ' - ' . $this->context->shop->name, 'meta_keywords' => $category->meta_keywords, 'meta_description' => $category->meta_description, 'requestPage' => $r['requestUrl'], 'requestNb' => $r, 'category' => $category)); } else { $path = '<a href="' . $helper->getFontBlogLink() . '">' . htmlentities($config->get('blog_link_title_' . $this->context->language->id, 'Blog'), ENT_NOQUOTES, 'UTF-8') . '</a><span class="navigation-pipe">' . Configuration::get('PS_NAVIGATION_PIPE') . '</span>'; $this->context->smarty->assign(array('active' => '0', 'path' => $path, 'leading_blogs' => array(), 'secondary_blogs' => array(), 'controller' => 'category', 'category' => $category)); } $this->setTemplate($template . '/category.tpl'); }
public function displayForm() { $this->context->smarty->assign('request_uri', Tools::safeOutput($_SERVER['REQUEST_URI'])); $this->context->smarty->assign('path', $this->_path); $this->context->smarty->assign('EXAMPLE_CONF', pSQL(Tools::getValue('EXAMPLE_CONF', Configuration::get('EXAMPLE_CONF')))); $this->context->smarty->assign('submitName', 'submit' . Tools::ucfirst($this->name)); $this->context->smarty->assign('errors', $this->errors); // You can return html, but I prefer this new version: use smarty in admin, :) return $this->display(__FILE__, 'views/templates/admin/configure.tpl'); }
public function displayList() { global $currentIndex; $url = $currentIndex . '&token=' . $this->token; $msg = new GetresponseError(); $updategetresponse_settings = Tools::getValue('updategetresponse_settings'); $exportgetresponse_settings = Tools::getValue('exportgetresponse_settings'); $ordergetresponse_settings = Tools::getValue('ordergetresponse_settings'); $webformgetresponse_settings = Tools::getValue('webformgetresponse_settings'); if (!empty($updategetresponse_settings)) { $api_key = Tools::getValue('api_key'); if (!empty($api_key)) { $c = $this->db->getCampaigns($api_key); if (is_array($c)) { $this->db->updateApikey($api_key); $this->apikey = $api_key; echo $msg->success('API Key update successful'); } else { echo $msg->errorMsg('Wrong API key'); } } else { echo $msg->errorMsg('Api Key field can\'t be empty'); } } else { if (!empty($exportgetresponse_settings)) { $settings = $this->db->getSettings(); if (!empty($settings)) { $this->apikey = $settings['api_key']; } else { echo $msg->errorMsg('Wrong API Key'); } $campaign = Tools::getValue('campaign'); if (!empty($campaign) && $campaign == '0') { echo $msg->errorMsg('No campaign selected'); } else { $newsletter_guests = false; $ng = Tools::getValue('newsletter_guests'); if (!empty($ng)) { $newsletter_guests = true; } $contacts = $this->db->getContacts(null, $newsletter_guests); if (empty($contacts)) { echo $msg->errorMsg('No contacts to export'); } else { $add = $this->db->exportSubscriber($this->apikey, $campaign, $contacts); if ($add['status'] == 1) { echo $msg->success($add['message']); } else { echo $msg->errorMsg($add['message']); } } } } else { if (!empty($ordergetresponse_settings)) { $settings = $this->db->getSettings(); if (!empty($settings)) { $this->apikey = $settings['api_key']; } else { echo $msg->errorMsg('Wrong API Key'); } $order_campaign = Tools::getValue('order_campaign'); $order_status = Tools::getValue('order_status'); $update_address = Tools::getValue('update_address'); if (!empty($order_campaign) && $order_campaign != '0' && !empty($order_status)) { $update_address = empty($update_address) ? 'no' : $update_address; $this->db->updateSettings($order_status, $order_campaign, $update_address); $this->db->updateCustoms($_POST); echo $msg->success('Settings update successful'); } else { if (!empty($order_campaign) && $order_campaign == '0') { echo $msg->errorMsg('No campaign selected'); } } } else { if (!empty($webformgetresponse_settings)) { $webform_id = Tools::getValue('webform_id'); $webform_status = Tools::getValue('webform_status'); $webform_sidebar = Tools::getValue('webform_sidebar'); $webform_style = Tools::getValue('webform_style'); if (!empty($webform_id) && $webform_id <= '0') { echo $msg->errorMsg('No Web Form ID or incorrect value'); } else { $this->db->updateWebformSettings($webform_id, $webform_status, $webform_sidebar, $webform_style); echo $msg->success('Settings update successful'); } } } } } // apikey settings $settings = $this->db->getSettings(); if (!empty($settings)) { $this->apikey = $settings['api_key']; } $custom_fields = $this->db->getCustoms(); if (!empty($custom_fields)) { $new_inputs = ''; $inputs = ''; foreach ($custom_fields as $custom_field) { if ($settings['update_address'] == 'yes') { $value = !empty($custom_field['custom_name']) ? $custom_field['custom_name'] : ''; } else { $value = $custom_field['custom_field']; } if ($custom_field['default'] == 'yes') { $inputs .= '<input style="margin-bottom:5px" id="' . $custom_field['custom_value'] . '" name="export_' . $custom_field['custom_value'] . '"value="' . $custom_field['custom_field'] . '" disabled="disabled"></input><span style="color: #AAAAAA"> ' . Tools::ucfirst($custom_field['custom_field']) . '</span><br/>'; $new_inputs .= '<input style="margin-bottom:5px" id="' . $custom_field['custom_value'] . '" name="' . $custom_field['custom_value'] . '"value="' . $custom_field['custom_field'] . '" disabled="disabled"></input><span style="color: #AAAAAA"> ' . Tools::ucfirst($custom_field['custom_field']) . '</span><br/>'; } else { $inputs .= '<input style="margin-bottom:5px" id="' . $custom_field['custom_value'] . '" name="export_' . $custom_field['custom_value'] . '"value="' . $custom_field['custom_field'] . '"></input> ' . Tools::ucfirst($custom_field['custom_field']) . '<br/>'; $new_inputs .= '<input style="margin-bottom:5px" id="' . $custom_field['custom_value'] . '" name="' . $custom_field['custom_value'] . '"value="' . $value . '"></input> ' . Tools::ucfirst($custom_field['custom_field']) . '<br/>'; } } } echo <<<APIFORM \t\t<div class="toolbarBox toolbarHead"> \t\t<span style="font-size: 2em; text-shadow:0 1px 0 white;line-height:52px;padding-left:10px">GetResponse Settings & Actions</span> \t\t</div> \t\t<form id="form-api" action="{$url}" method="post" class="width2"> \t\t\t<fieldset> \t\t\t\t<legend>{$this->l('API Key Settings')}</legend> \t\t\t\t\t<label>{$this->l('Api Key: ')}</label> \t\t\t\t\t\t<div class="margin-form"> \t\t\t\t\t\t\t<input id="api_key" name="api_key" value="{$this->apikey}" style="width: 150px"></input> \t\t\t\t\t\t\t<sup>*</sup> \t\t\t\t\t<br><br> \t\t\t\t\t<input type="submit" value="{$this->l('Save')}" name="update{$this->table}" class="button" /> \t\t\t\t\t</div><div class="small"> \t\t\t\t\t\t<sup>*</sup>{$this->l('API Key can be found here: https://app.getresponse.com/my_api_key.html')} \t\t\t\t\t</div> \t\t\t</fieldset> \t\t<script> \t\t\twindow.onload = function() \t\t\t{ \t\t\t\tsetTimeout(function () \t\t\t\t{ \t\t\t\t\t\$('.conf').remove(); \t\t\t\t\t\$('.error').remove(); \t\t\t\t}, 7000); \t\t\t\tif (\$('#update_address').is(':checked') == true) \t\t\t\t{ \t\t\t\t\t\$('#update_extra').html('<br/><span style="color:black;font-size: 12px">Name your custom fields:<sup>**</sup><br/>{$new_inputs}</span>'); \t\t\t\t\t\$('#update_sup_extra').html('<sup>**</sup>{$this->l('Empty input fields won\'t be updated.')}'); \t\t\t\t} \t\t\t} \t\t</script> APIFORM; // export data if ($this->apikey) { $campaigns = $this->db->getCampaigns($this->apikey); $options = ''; $options2 = ''; $options3 = ''; if (!empty($campaigns)) { foreach ($campaigns as $campaign) { $options .= '<option value="' . $campaign['id'] . '">' . $campaign['name'] . '</option>'; $seleted = ''; $order_campaign = Tools::getValue('order_campaign'); if ($campaign['id'] == $settings['campaign_id'] || !empty($order_campaign) && $order_campaign == $campaign['id']) { $seleted = 'selected'; } $options2 .= '<option value="' . $campaign['id'] . '"' . $seleted . '>' . $campaign['name'] . '</option>'; $options3 .= '<option value="' . $campaign['id'] . '"' . $seleted . '>' . $campaign['name'] . '</option>'; } echo <<<EXPORTFORM \t\t\t<br/> \t\t\t\t<fieldset> \t\t\t\t\t<legend>{$this->l('Export Customers')}</legend> \t\t\t\t\t\t<label>{$this->l('Select target campaign: ')}</label> \t\t\t\t\t\t\t<div class="margin-form"> \t\t\t\t\t\t\t\t<select id="campaign" name="campaign" style="width: 150px"> \t\t\t\t\t\t\t\t\t{$options} \t\t\t\t\t\t\t\t</select> \t\t\t\t\t\t</div> \t\t\t\t\t\t<label>{$this->l('Guests who subscribed to newsletter: ')}</label> \t\t\t\t\t\t\t<div class="margin-form"> \t\t\t\t\t\t\t\t<input form="form-api" type="checkbox" name="newsletter_guests" id="newsletter_guests" value="yes"/> \t\t\t\t\t\t<br/><br/> \t\t\t\t\t\t<div id="extra"></div> \t\t\t\t\t\t<input type="submit" value="{$this->l('Export')}" name="export{$this->table}" class="button" /> \t\t\t\t\t\t</div> \t\t\t\t\t\t<div class="small"> \t\t\t\t\t\t\t<div id="sup_extra"></div> \t\t\t\t\t\t</div> \t\t\t\t</fieldset> \t\t\t<br/> \t\t\t<script> \t\t\t\$('#campaign').change(function() \t\t\t{ \t\t\t\tif((\$('#campaign').val() != '0')) \t\t\t\t{ \t\t\t\t\t\$('#extra').html('<span style="color:black;font-size: 12px">Name your custom fields:<sup>*</sup><br/>{$inputs}</span>'); \t\t\t\t\t\$('#sup_extra').html('<sup>*</sup>{$this->l('Empty input fields won\'t be added.')}'); \t\t\t\t} \t\t\t\telse \t\t\t\t{ \t\t\t\t\t\$('#extra,#sup_extra').empty(); \t\t\t\t} \t\t\t}); \t\t\t</script> EXPORTFORM; // order form $opt_yes = ''; $opt_no = ''; $opt_update = ''; $order_status = Tools::getValue('order_status'); $update_address = Tools::getValue('update_address'); if ($settings['active_subscription'] == 'yes' || !empty($order_status) && $order_status == 'yes') { $opt_yes = 'selected'; if ($settings['update_address'] == 'yes' || !empty($update_address) && $update_address == 'yes') { $opt_update = 'checked'; } } else { $opt_no = 'selected'; } echo <<<ORDERFORM \t\t\t<br/> \t\t\t<fieldset> \t\t\t\t\t<legend>{$this->l('Subscription via registration page')}</legend> \t\t\t\t\t\t<label>{$this->l('Select target campaign: ')}</label> \t\t\t\t\t\t\t<div class="margin-form"> \t\t\t\t\t\t\t\t<select id="order_campaign" name="order_campaign" style="width: 150px"> \t\t\t\t\t\t\t\t\t{$options2} \t\t\t\t\t\t\t\t</select> \t\t\t\t\t\t<br/> \t\t\t\t\t\t</div> \t\t\t\t\t\t<label>{$this->l('Subscription: ')}</label> \t\t\t\t\t\t\t<div class="margin-form"> \t\t\t\t\t\t\t\t<select id="order_status" name="order_status" style="width: 150px"> \t\t\t\t\t\t\t\t\t<option value="no" {$opt_no}>{$this->l('disabled')}</option> \t\t\t\t\t\t\t\t\t<option value="yes" {$opt_yes}>{$this->l('enabled')}</option> \t\t\t\t\t\t\t\t</select> \t\t\t\t\t\t\t\t<sup>*</sup> \t\t\t\t\t\t<br/> \t\t\t\t\t\t</div> \t\t\t\t\t\t<label>{$this->l('Update contact data on checkout page:')}</label> \t\t\t\t\t\t\t<div class="margin-form"> \t\t\t\t\t\t\t\t<input form="form-api" type="checkbox" name="update_address" id="update_address" value="yes" {$opt_update}/> \t\t\t\t\t\t\t\t<div id="update_extra"></div> \t\t\t\t\t\t<br> \t\t\t\t\t\t<input type="submit" value="{$this->l('Save')}" name="order{$this->table}" class="button" /> \t\t\t\t\t\t</div> \t\t\t\t\t\t<div class="small"> \t\t\t\t\t\t\t<sup>*</sup>{$this->l('If update isn\'t selected, only the following data will be imported: firstname, lastname, email.')} \t\t\t\t\t\t\t<br/> \t\t\t\t\t\t\t<div id="update_sup_extra"></div> \t\t\t\t\t\t</div> \t\t\t\t</fieldset> \t\t\t<br/> \t\t\t<script> \t\t\t\$('#update_address').change(function() \t\t\t{ \t\t\t\tif(\$('#update_address').is(':checked') == true) \t\t\t\t{ \t\t\t\t\t\$('#update_extra').html('<br/><span style="color:black;font-size: 12px">Name your custom fields:<sup>**</sup><br/>{$new_inputs}</span>'); \t\t\t\t\t\$('#update_sup_extra').html('<sup>**</sup>{$this->l('Empty input fields won\'t be updated.')}'); \t\t\t\t} \t\t\t\telse \t\t\t\t{ \t\t\t\t\t\$('#update_extra,#update_sup_extra').empty(); \t\t\t\t} \t\t\t}); \t\t\t\$('#order_status').change(function() \t\t\t{ \t\t\t\tif(\$('#order_status').val() == 'no') \t\t\t\t{ \t\t\t\t\t\$('#update_extra,update_sup_extra').empty(); \t\t\t\t\t\$('#update_address').removeAttr('checked'); \t\t\t\t} \t\t\t}); \t\t\t</script> ORDERFORM; } } $webform_settings = $this->db->getWebformSettings(); // order form $webform_yes = ''; $webform_no = ''; $sidebar_left = ''; $sidebar_right = ''; $webform_style = ''; $presta_style = ''; $webform_status = Tools::getValue('webform_status'); $webform_stylee = Tools::getValue('webform_style'); $webform_sidebar = Tools::getValue('webform_sidebar'); if ($webform_settings['active_subscription'] == 'yes' || !empty($webform_status) && $webform_status == 'yes') { $webform_yes = 'selected'; if ($webform_settings['style'] == 'webform' || !empty($webform_stylee) && $webform_stylee == 'yes') { $webform_style = 'selected'; } else { $presta_style = 'selected'; } if ($webform_settings['sidebar'] == 'right' || !empty($webform_sidebar) && $webform_sidebar == 'yes') { $sidebar_right = 'selected'; } else { $sidebar_left = 'selected'; } } else { $webform_no = 'selected'; } echo <<<ORDERFORM \t\t\t<br/> \t\t\t<fieldset> \t\t\t\t\t<legend>{$this->l('Subscription via Web Form')}</legend> \t\t\t\t\t\t<label>{$this->l('Web Form ID: ')}</label> \t\t\t\t\t\t\t<div class="margin-form"> \t\t\t\t\t\t\t\t<input id="webform_id" name="webform_id" value="{$webform_settings['webform_id']}" style="width: 150px"></input> \t\t\t\t\t\t\t\t<sup>*</sup> \t\t\t\t\t\t<br/> \t\t\t\t\t\t</div> \t\t\t\t\t\t<label>{$this->l('Web Form position: ')}</label> \t\t\t\t\t\t\t<div class="margin-form"> \t\t\t\t\t\t\t\t<select id="webform_sidebar" name="webform_sidebar" style="width: 150px"> \t\t\t\t\t\t\t\t\t<option value="left" {$sidebar_left}>{$this->l('Left sidebar')}</option> \t\t\t\t\t\t\t\t\t<option value="right" {$sidebar_right}>{$this->l('Right sidebar')}</option> \t\t\t\t\t\t\t\t</select> \t\t\t\t\t\t<br/> \t\t\t\t\t\t</div> \t\t\t\t\t\t<label>{$this->l('Style: ')}</label> \t\t\t\t\t\t\t<div class="margin-form"> \t\t\t\t\t\t\t\t<select id="webform_style" name="webform_style" style="width: 150px"> \t\t\t\t\t\t\t\t\t<option value="webform" {$webform_style}>{$this->l('Web Form')}</option> \t\t\t\t\t\t\t\t\t<option value="prestashop" {$presta_style}>{$this->l('PrestaShop')}</option> \t\t\t\t\t\t\t\t</select> \t\t\t\t\t\t<br/> \t\t\t\t\t\t</div> \t\t\t\t\t\t<label>{$this->l('Subscription: ')}</label> \t\t\t\t\t\t\t<div class="margin-form"> \t\t\t\t\t\t\t\t<select id="webform_status" name="webform_status" style="width: 150px"> \t\t\t\t\t\t\t\t\t<option value="no" {$webform_no}>{$this->l('disabled')}</option> \t\t\t\t\t\t\t\t\t<option value="yes" {$webform_yes}>{$this->l('enabled')}</option> \t\t\t\t\t\t\t\t</select> \t\t\t\t\t\t<br/><br/> \t\t\t\t\t\t<input type="submit" value="{$this->l('Save')}" name="webform{$this->table}" class="button" /> \t\t\t\t\t\t</div> \t\t\t\t\t\t<div class="small"> \t\t\t\t\t\t\t<sup>*</sup>{$this->l('You will find your web form ID right in your GetResponse account...')} \t\t\t\t\t\t\t<a href="#webform_info" id="webform_info" style="color:#009DD4"><span id="webform_click">click here to see more</span></a> \t\t\t\t\t\t\t<span id="webform_info2"></span> \t\t\t\t\t\t\t<br/> \t\t\t\t\t\t\t<div id="webform_extra"></div> \t\t\t\t\t\t</div> \t\t\t\t</fieldset> \t\t\t</form> \t\t\t<br/> \t\t\t<script> \t\t\t\$('#webform_info').click(function() \t\t\t{ \t\t\t\tvar info_part1 = '<br/>Go to Web Forms => Web forms list and click on the \\"Source\\" link in the selected web form.'; \t\t\t\tvar info_part2 = 'Your web form ID is the number you\\'ll see right after the \\"?wid=\\" portion of the JavaScript code.'; \t\t\t\t\$('#webform_click').html(''); \t\t\t\t\$('#webform_info2').html(info_part1+info_part2); \t\t\t\t\$('#webform_extra').html('<br/><span style="color:black;font-size: 12px"><img src="{$this->webform_img}"/></span>'); \t\t\t}); \t\t\t\$('#order_status').change(function() \t\t\t{ \t\t\t\tif(\$('#order_status').val() == 'no') \t\t\t\t{ \t\t\t\t\t\$('#update_extra,update_sup_extra').empty(); \t\t\t\t\t\$('#update_address').removeAttr('checked'); \t\t\t\t} \t\t\t}); \t\t\t</script> ORDERFORM; }
/** * Install Module Tabs */ private function installModuleTab($title, $class_sfx = '', $parent = '') { $class = 'Admin' . Tools::ucfirst($this->name) . Tools::ucfirst($class_sfx); @copy(_PS_MODULE_DIR_ . $this->name . '/logo.gif', _PS_IMG_DIR_ . 't/' . $class . '.gif'); if ($parent == '') { $position = Tab::getCurrentTabId(); } else { $position = Tab::getIdFromClassName($parent); } $tab1 = new Tab(); $tab1->class_name = $class; $tab1->module = $this->name; $tab1->id_parent = (int) $position; $langs = Language::getLanguages(false); foreach ($langs as $l) { $tab1->name[$l['id_lang']] = $title; } if ($parent == -1) { $tab1->id_parent = -1; $id_tab1 = $tab1->add(); } else { $id_tab1 = $tab1->add(true, false); } }
/** * PROCESS : configureShop * Set default shop configuration */ public function configureShop(array $data = array()) { //clear image cache in tmp folder if (file_exists(_PS_TMP_IMG_DIR_)) { foreach (scandir(_PS_TMP_IMG_DIR_) as $file) { if ($file[0] != '.' && $file != 'index.php') { Tools::deleteFile(_PS_TMP_IMG_DIR_ . $file); } } } $default_data = array('shop_name' => 'My Shop', 'shop_activity' => '', 'shop_country' => 'us', 'shop_timezone' => 'US/Eastern', 'use_smtp' => false, 'smtp_encryption' => 'off', 'smtp_port' => 25, 'rewrite_engine' => false); foreach ($default_data as $k => $v) { if (!isset($data[$k])) { $data[$k] = $v; } } Context::getContext()->shop = new Shop(1); Configuration::loadConfiguration(); // use the old image system if the safe_mod is enabled otherwise the installer will fail with the fixtures installation if (InstallSession::getInstance()->safe_mode) { Configuration::updateGlobalValue('PS_LEGACY_IMAGES', 1); } $id_country = Country::getByIso($data['shop_country']); // Set default configuration Configuration::updateGlobalValue('PS_SHOP_DOMAIN', Tools::getHttpHost()); Configuration::updateGlobalValue('PS_SHOP_DOMAIN_SSL', Tools::getHttpHost()); Configuration::updateGlobalValue('PS_INSTALL_VERSION', _PS_INSTALL_VERSION_); Configuration::updateGlobalValue('PS_LOCALE_LANGUAGE', $this->language->getLanguageIso()); Configuration::updateGlobalValue('PS_SHOP_NAME', $data['shop_name']); Configuration::updateGlobalValue('PS_SHOP_ACTIVITY', $data['shop_activity']); Configuration::updateGlobalValue('PS_COUNTRY_DEFAULT', $id_country); Configuration::updateGlobalValue('PS_LOCALE_COUNTRY', $data['shop_country']); Configuration::updateGlobalValue('PS_TIMEZONE', $data['shop_timezone']); Configuration::updateGlobalValue('PS_CONFIGURATION_AGREMENT', (int) $data['configuration_agrement']); // Set mails configuration Configuration::updateGlobalValue('PS_MAIL_METHOD', $data['use_smtp'] ? 2 : 1); Configuration::updateGlobalValue('PS_MAIL_SMTP_ENCRYPTION', $data['smtp_encryption']); Configuration::updateGlobalValue('PS_MAIL_SMTP_PORT', $data['smtp_port']); // Set default rewriting settings Configuration::updateGlobalValue('PS_REWRITING_SETTINGS', $data['rewrite_engine']); // Activate rijndael 128 encrypt algorihtm if mcrypt is activated Configuration::updateGlobalValue('PS_CIPHER_ALGORITHM', function_exists('mcrypt_encrypt') ? 1 : 0); $groups = Group::getGroups((int) Configuration::get('PS_LANG_DEFAULT')); $groups_default = Db::getInstance()->executeS('SELECT `name` FROM ' . _DB_PREFIX_ . 'configuration WHERE `name` LIKE "PS_%_GROUP" ORDER BY `id_configuration`'); foreach ($groups_default as &$group_default) { if (is_array($group_default) && isset($group_default['name'])) { $group_default = $group_default['name']; } } if (is_array($groups) && count($groups)) { foreach ($groups as $key => $group) { if (Configuration::get($groups_default[$key]) != $groups[$key]['id_group']) { Configuration::updateGlobalValue($groups_default[$key], (int) $groups[$key]['id_group']); } } } $states = Db::getInstance()->executeS('SELECT `id_order_state` FROM ' . _DB_PREFIX_ . 'order_state ORDER by `id_order_state`'); $states_default = Db::getInstance()->executeS('SELECT MIN(`id_configuration`), `name` FROM ' . _DB_PREFIX_ . 'configuration WHERE `name` LIKE "PS_OS_%" GROUP BY `value` ORDER BY`id_configuration`'); foreach ($states_default as &$state_default) { if (is_array($state_default) && isset($state_default['name'])) { $state_default = $state_default['name']; } } if (is_array($states) && count($states)) { foreach ($states as $key => $state) { if (Configuration::get($states_default[$key]) != $states[$key]['id_order_state']) { Configuration::updateGlobalValue($states_default[$key], (int) $states[$key]['id_order_state']); } } /* deprecated order state */ Configuration::updateGlobalValue('PS_OS_OUTOFSTOCK_PAID', (int) Configuration::get('PS_OS_OUTOFSTOCK')); } // Set logo configuration if (file_exists(_PS_IMG_DIR_ . 'logo.jpg')) { list($width, $height) = getimagesize(_PS_IMG_DIR_ . 'logo.jpg'); Configuration::updateGlobalValue('SHOP_LOGO_WIDTH', round($width)); Configuration::updateGlobalValue('SHOP_LOGO_HEIGHT', round($height)); } // Disable cache for debug mode if (_PS_MODE_DEV_) { Configuration::updateGlobalValue('PS_SMARTY_CACHE', 1); } // Active only the country selected by the merchant Db::getInstance()->execute('UPDATE ' . _DB_PREFIX_ . 'country SET active = 0 WHERE id_country != ' . (int) $id_country); // Set localization configuration $version = str_replace('.', '', _PS_VERSION_); $version = substr($version, 0, 2); $localization_file_content = $this->getLocalizationPackContent($version, $data['shop_country']); $locale = new LocalizationPackCore(); $locale->loadLocalisationPack($localization_file_content, '', true); // Create default employee if (isset($data['admin_firstname']) && isset($data['admin_lastname']) && isset($data['admin_password']) && isset($data['admin_email'])) { $employee = new Employee(); $employee->firstname = Tools::ucfirst($data['admin_firstname']); $employee->lastname = Tools::ucfirst($data['admin_lastname']); $employee->email = $data['admin_email']; $employee->passwd = md5(_COOKIE_KEY_ . $data['admin_password']); $employee->last_passwd_gen = date('Y-m-d h:i:s', strtotime('-360 minutes')); $employee->bo_theme = 'default'; $employee->default_tab = 1; $employee->active = true; $employee->optin = (bool) $data['send_informations']; $employee->id_profile = 1; $employee->id_lang = Configuration::get('PS_LANG_DEFAULT'); $employee->bo_menu = 1; if (!$employee->add()) { $this->setError($this->language->l('Cannot create admin account')); return false; } } else { $this->setError($this->language->l('Cannot create admin account')); return false; } // Update default contact if (isset($data['admin_email'])) { Configuration::updateGlobalValue('PS_SHOP_EMAIL', $data['admin_email']); $contacts = new PrestaShopCollection('Contact'); foreach ($contacts as $contact) { $contact->email = $data['admin_email']; $contact->update(); } } if (!@Tools::generateHtaccess(null, $data['rewrite_engine'])) { Configuration::updateGlobalValue('PS_REWRITING_SETTINGS', 0); } return true; }
/** * @see FrontController::initContent() */ public function initContent() { $link = $this->context->link; $realex = new RealexRedirect(); $this->display_column_left = false; parent::initContent(); if (!$this->context->customer->isLogged() && !$this->context->customer->is_guest) { Tools::redirect('index.php?controller=order'); } $infos = $this->getInfosForm(); $currency = $this->context->currency; extract($infos, EXTR_OVERWRITE); if (!$this->module->checkCurrency($cart)) { Tools::redirect('index.php?controller=order'); } // ---------------- REALVAULT $inputs_payer = "<input type='hidden' name='PAYER_EXIST' value='" . $payer_exists . "' />"; $inputs_payer .= "<input type='hidden' name='PAYER_REF' value='" . $ref_payer . "' />"; $inputs_pmt_registered = ''; if ($payer_exists) { $sql = 'SELECT `refpayment_realex`, `paymentname_realex`, `type_card_realex`, rs.`name_realex_subaccount`, `threeds_realex_subaccount`, `dcc_realex_subaccount`, `dcc_choice_realex_subaccount` FROM `' . _DB_PREFIX_ . 'realex_paymentref` JOIN `' . _DB_PREFIX_ . 'realex_rel_card` rc ON `type_card_realex`=`realex_card_name` JOIN `' . _DB_PREFIX_ . 'realex_subaccount` rs ON rs.`id_realex_subaccount`=rc.`id_realex_subaccount` WHERE `id_realex_payerref` = "' . pSQL($id_realex_payerref) . '"'; $pmt_refs = Db::getInstance()->ExecuteS($sql); if (count($pmt_refs) > 0) { foreach ($pmt_refs as $pmt_ref) { $inputs_pmt_registered .= "<form method='post' action='" . $link->getModuleLink('realexredirect', 'validation', array(), true) . "'>"; $inputs_pmt_registered .= "<input type='hidden' name='PMT_REF' value='{$pmt_ref['refpayment_realex']}' />"; //SHA1 $tmp = $timestamp . '.' . $realex->merchant_id . '.' . $order_id; $tmp .= '.' . $realex->getAmountFormat($cart->getOrderTotal(true, Cart::BOTH)) . '.' . $iso_currency . '.' . $ref_payer; $sha1_temp = sha1($tmp); $sha1 = sha1($sha1_temp . '.' . $realex->shared_secret); $inputs_pmt_registered .= "<input type='HIDDEN' name='SHA1HASH' value='{$sha1}'/>"; $inputs_pmt_registered .= "<input type='HIDDEN' name='CURRENCY' value='" . $iso_currency . "' />"; $inputs_pmt_registered .= "<input type='HIDDEN' name='MERCHANT_ID' value='" . $realex->merchant_id . "' />"; $inputs_pmt_registered .= "<input type='HIDDEN' name='ACCOUNT' value='" . $pmt_ref['name_realex_subaccount'] . "' />"; $inputs_pmt_registered .= "<input type='HIDDEN' name='ORDER_ID' value='" . $order_id . "' />"; $inputs_pmt_registered .= "<input type='HIDDEN' name='AMOUNT' value='" . $realex->getAmountFormat($cart->getOrderTotal(true, Cart::BOTH)) . "' />"; $inputs_pmt_registered .= "<input type='HIDDEN' name='TIMESTAMP' value='" . $timestamp . "' />"; $inputs_pmt_registered .= "<input type='HIDDEN' name='AUTO_SETTLE_FLAG' value='" . $settlement . "' />"; $inputs_pmt_registered .= "<input type='HIDDEN' name='BILLING_ZIP' value='" . $billing_postcode . "' />"; $inputs_pmt_registered .= "<input type='HIDDEN' name='BILLING_STREETNUMBER' value='" . $billing_streetumber . "' />"; $inputs_pmt_registered .= "<input type='HIDDEN' name='BILLING_CO' value='" . $billing_co . "' />"; $inputs_pmt_registered .= "<input type='HIDDEN' name='SHIPPING_ZIP' value='" . $shipping_postcode . "' />"; $inputs_pmt_registered .= "<input type='HIDDEN' name='SHIPPING_STREETNUMBER' value='" . $shipping_streetumber . "' />"; $inputs_pmt_registered .= "<input type='HIDDEN' name='SHIPPING_CO' value='" . $shipping_co . "' />"; $inputs_pmt_registered .= "<input type='HIDDEN' name='RETURN_TSS' value='1' />"; $inputs_pmt_registered .= "<input type='HIDDEN' name='DCC' value='{$pmt_ref['dcc_realex_subaccount']}' />"; $inputs_pmt_registered .= "<input type='HIDDEN' name='DCC_CHOICE' value='{$pmt_ref['dcc_choice_realex_subaccount']}' />"; $inputs_pmt_registered .= "<input type='HIDDEN' name='THREEDS' value='{$pmt_ref['threeds_realex_subaccount']}' />"; $inputs_pmt_registered .= "<input type='HIDDEN' name='TYPE_CARD' value='{$pmt_ref['type_card_realex']}' />"; $inputs_pmt_registered .= $inputs_payer; if ($pmt_ref['type_card_realex'] == 'MC') { $type_card = 'MasterCard'; } elseif ($pmt_ref['type_card_realex'] == 'AMEX') { $type_card = 'American Express'; } else { $type_card = Tools::ucfirst(Tools::strtolower($pmt_ref['type_card_realex'])); } $inputs_pmt_registered .= "<div class='fleft'>{$pmt_ref['paymentname_realex']} / {$type_card}<br/>"; if ($realex->cvn) { $inputs_pmt_registered .= $realex->l('Security Code', 'payment') . " : <input type='text' style='width:40px' name='cvn' />"; } $secure_link = $link->getModuleLink('realexredirect', "payment?reg={$pmt_ref['refpayment_realex']}&token=" . $this->context->cart->secure_key, array(), true); $inputs_pmt_registered .= "<br/><a href='" . $secure_link . "' class='delete' onclick='return(confirm(\"" . $realex->bout_suppr . "\"))'>"; $inputs_pmt_registered .= 'x ' . $realex->l('Delete') . '</a></div>'; $inputs_pmt_registered .= "<p class='cart_navigation'>"; $inputs_pmt_registered .= "<input type='submit' name='submit_registered' value='" . $realex->bout_valide . "' class='exclusive_large' />"; $inputs_pmt_registered .= "</p><div class='clear'><br/></div>"; $inputs_pmt_registered .= '</form>'; } } } $inputs_pmt_new = "<p class='cart_navigation'><input type='submit' name='submit' value='" . $realex->bout_valide . "' class='exclusive_large' /></p>"; // ---------------- VARIABLES TPL $this->context->smarty->assign(array('nbProducts' => $cart->nbProducts(), 'cust_currency' => $cart->id_currency, 'order_id' => $order_id, 'currencies' => $this->module->getCurrency((int) $cart->id_currency), 'curr' => $currency->iso_code, 'total' => $cart->getOrderTotal(true, Cart::BOTH), 'amount' => $realex->getAmountFormat($cart->getOrderTotal(true, Cart::BOTH)), 'this_path' => $this->module->getPathUri(), 'this_path_ssl' => Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'modules/' . $this->module->name . '/', 'selectAccount' => $realex->getSelectAccount(), 'payer_exists' => $payer_exists, 'realvault' => $realex->realvault, 'input_registered' => $inputs_pmt_registered, 'input_new' => $inputs_pmt_new, 'submit_new' => $this->context->link->getModuleLink('realexredirect', 'payment', array('token' => $this->context->cart->secure_key), true))); $this->setTemplate('payment_execution.tpl'); }
public function postProcess() { if ((Tools::isSubmit('saveleotempcp') || Tools::isSubmit('saveandstayleotempcp')) && Tools::isSubmit('widgets')) { if (!Tools::getValue('widget_name')) { $this->errors[] = Tools::displayError('Widget Name Empty !'); } if (!count($this->errors)) { if (Tools::getValue('id_leowidgets')) { $model = new LeoTempcpWidget((int) Tools::getValue('id_leowidgets')); } else { $model = $this->widget; } $model->loadEngines(); $model->id_shop = Context::getContext()->shop->id; // $id_lang_default = (int)Configuration::get('PS_LANG_DEFAULT'); $languages = Language::getLanguages(false); $tmp = array(); $post = LeomanagewidgetsHelper::getPost(); $widget_type = Tools::getValue('widget_type'); # GET POST - BEGIN $widget_type = Tools::getValue('widget_type'); $file_name = _PS_MODULE_DIR_ . 'leomanagewidgets/classes/widget/' . $widget_type . '.php'; require_once $file_name; $class_name = 'LeoWidget' . Tools::ucfirst($widget_type); $widget = new $class_name(); $keys = array('addleowidgets', 'id_leowidgets', 'widget_name', 'widget_type', 'saveandstayleotempcp'); $post = LeomanagewidgetsHelper::getPost($keys, 0); $keys = array('widget_title'); $post += LeomanagewidgetsHelper::getPost($keys, 1); $keys = $widget->getConfigKey(0); $post += LeomanagewidgetsHelper::getPost($keys, 0); $keys = $widget->getConfigKey(1); $post += LeomanagewidgetsHelper::getPost($keys, 1); $keys = $widget->getConfigKey(2); $post += LeomanagewidgetsHelper::getPost($keys, 2); # GET POST - END foreach ($post as $key => $value) { $tmp[$key] = str_replace(array('\'', '\\"'), array("'", '"'), $value); foreach ($this->_langField as $fVal) { if (strpos($key, $fVal) !== false) { foreach ($languages as $language) { if (Tools::getIsset($fVal . '_' . $language['id_lang'])) { $valueLang = Tools::getValue($fVal . '_' . $language['id_lang']); if (empty($valueLang)) { $tmp[$fVal . '_' . $language['id_lang']] = $value; } } } } } } $data = array('id' => Tools::getValue('id_leowidgets'), 'params' => call_user_func('base64' . '_encode', Tools::jsonEncode($tmp)), 'type' => Tools::getValue('widget_type'), 'name' => Tools::getValue('widget_name')); foreach ($data as $k => $v) { $model->{$k} = $v; } if ($model->id) { if (!$model->update()) { $this->errors[] = Tools::displayError('Can not update new widget'); } else { if (Tools::isSubmit('saveandstayleotempcp')) { $this->confirmations[] = $this->l('Update successful'); $model->clearCaches(); Tools::redirectAdmin(self::$currentIndex . '&id_leowidgets=' . $model->id . '&updateleowidgets&token=' . $this->token . '&conf=4'); } else { Tools::redirectAdmin(self::$currentIndex . '&token=' . $this->token . '&conf=4'); } } } else { $model->key_widget = time(); if (!$model->add()) { $this->errors[] = Tools::displayError('Can not add new widget'); } else { if (Tools::isSubmit('saveandstayleotempcp')) { $this->confirmations[] = $this->l('Update successful'); $model->clearCaches(); Tools::redirectAdmin(self::$currentIndex . '&id_leowidgets=' . $model->id . '&updateleowidgets&token=' . $this->token . '&conf=4'); } else { Tools::redirectAdmin(self::$currentIndex . '&token=' . $this->token . '&conf=4'); } } } } } if (Tools::isSubmit('submitBulkcorrectlinkleowidgets')) { $leowidgetsBox = Tools::getValue('leowidgetsBox'); if ($leowidgetsBox) { foreach ($leowidgetsBox as $widgetID) { $model = new LeoTempcpWidget($widgetID); $params = Tools::jsonDecode(call_user_func('base64' . '_decode', $model->params), true); $tmp = array(); foreach ($params as $widKey => $widValue) { foreach ($this->_imageField as $fVal) { if (strpos($widKey, $fVal) !== false && strpos($widValue, 'img') !== false) { // $widValue = str_replace('src="' . __PS_BASE_URI__ . 'modules/', 'src="' . __PS_BASE_URI__ . 'themes/'.$this->_theme_dir.'/img/modules/', $widValue); // $patterns = array('/\/leomanagewidgets\/data\//','/\/leobootstrapmenu\/img\//','/\/leobootstrapmenu\/images\//' // ,'/\/leomanagewidgets\/images\//','/\/leomenusidebar\/images\//'); // $replacements = array('/leomanagewidgets/','/leobootstrapmenu/','/leobootstrapmenu/','/leomanagewidgets/','/leomenusidebar/'); // $widValue = preg_replace($patterns, $replacements, $widValue); $widValue = preg_replace('/\\/themes\\/(\\w+)\\/img/', '/themes/' . $this->_theme_dir . '/img', $widValue); break; } } $tmp[$widKey] = $widValue; } $model->params = call_user_func('base64' . '_encode', Tools::jsonEncode($tmp)); $model->save(); } } } if (Tools::isSubmit('submitBulkinsertLangleowidgets')) { $leowidgetsBox = Tools::getValue('leowidgetsBox'); $id_currentLang = $this->context->language->id; $languages = Language::getLanguages(false); if ($leowidgetsBox) { foreach ($leowidgetsBox as $widgetID) { $model = new LeoTempcpWidget($widgetID); $tmp = Tools::jsonDecode(call_user_func('base64' . '_decode', $model->params), true); $defauleVal = array(); if ($tmp) { foreach ($tmp as $widKey => $widValue) { $defaulArray = explode('_', $widKey); if (strpos($widKey, '_' . $id_currentLang) !== false && $defaulArray[count($defaulArray) - 1] == $id_currentLang) { $defauleVal[$widKey] = $widValue; } } } if ($defauleVal) { foreach ($languages as $lang) { if ($lang['id_lang'] == $id_currentLang) { continue; } foreach ($defauleVal as $widKey => $widValue) { $keyRemove = Tools::substr($widKey, 0, -Tools::strlen('_' . $id_currentLang)); $keyReal = $keyRemove . '_' . $lang['id_lang']; if (!isset($tmp[$keyReal]) || trim($tmp[$keyReal]) == '') { $tmp[$keyReal] = $widValue; } } } } if ($defauleVal) { $model->params = call_user_func('base64' . '_encode', Tools::jsonEncode($tmp)); $model->save(); } } } } if (Tools::isSubmit('submitBulkcorrectContentleowidgets')) { $leowidgetsBox = Tools::getValue('leowidgetsBox'); $id_currentLang = $this->context->language->id; $languages = Language::getLanguages(false); if ($leowidgetsBox) { foreach ($leowidgetsBox as $widgetID) { $model = new LeoTempcpWidget($widgetID); $tmp = @unserialize($model->params); if (!$tmp) { $tmp = Tools::json_decode($model->params, true); } if ($tmp) { $model->params = call_user_func('base64' . '_encode', Tools::jsonEncode($tmp)); $model->save(); } } } } parent::postProcess(); }
} else { $customer->birthday = empty($_POST['years']) ? '' : intval($_POST['years']) . '-' . intval($_POST['months']) . '-' . intval($_POST['days']); $_POST['old_passwd'] = trim($_POST['old_passwd']); if (empty($_POST['old_passwd']) or Tools::encrypt($_POST['old_passwd']) != $cookie->passwd) { $errors[] = Tools::displayError('your current password is not that one'); } elseif ($_POST['passwd'] != $_POST['confirmation']) { $errors[] = Tools::displayError('password and confirmation do not match'); } elseif ($need_identification_number and Tools::getValue('dni') != NULL and !Validate::isDni(Tools::getValue('dni'))) { $errors[] = Tools::displayError('identification number is incorrect or already used'); } else { $prev_id_default_group = $customer->id_default_group; $errors = $customer->validateControler(); } if (!sizeof($errors)) { $customer->id_default_group = intval($prev_id_default_group); $customer->firstname = Tools::ucfirst(Tools::strtolower($customer->firstname)); if (Tools::getValue('passwd')) { $cookie->passwd = $customer->passwd; } if ($customer->update()) { $cookie->customer_lastname = $customer->lastname; $cookie->customer_firstname = $customer->firstname; $smarty->assign('confirmation', 1); } else { $errors[] = Tools::displayError('impossible to update information'); } } } } else { $_POST = array_map('stripslashes', $customer->getFields()); }
public function postProcess() { if (Tools::isSubmit('submitSmsStep1')) { // Date verification // ----------------- $date_send = DateTime::createFromFormat('Y-m-d H:i:s', (string) Tools::getValue('campaign_date_send')); $campaign_date_send = $date_send->getTimestamp(); $campaign_date_send = date('Y-m-d H:i:s', $campaign_date_send); $campaign_name = Tools::ucfirst((string) Tools::getValue('campaign_name')); $campaign_text = Tools::ucfirst((string) Tools::getValue('campaign_text')); $limit_dayoftheweek = ''; if (Tools::getValue('week_day_limit_L')) { $limit_dayoftheweek .= 'L'; } if (Tools::getValue('week_day_limit_M')) { $limit_dayoftheweek .= 'M'; } if (Tools::getValue('week_day_limit_C')) { $limit_dayoftheweek .= 'C'; } if (Tools::getValue('week_day_limit_J')) { $limit_dayoftheweek .= 'J'; } if (Tools::getValue('week_day_limit_V')) { $limit_dayoftheweek .= 'V'; } if (Tools::getValue('week_day_limit_S')) { $limit_dayoftheweek .= 'S'; } if (Tools::getValue('week_day_limit_D')) { $limit_dayoftheweek .= 'D'; } if (empty($this->campaign_id) || empty($campaign_name) || empty($campaign_date_send) || empty($campaign_text) || Tools::strlen($campaign_text) < 5) { $this->errors[] = $this->module->l('Please verify the required fields', 'adminmarketingsstep1'); return false; } else { // On mémorise els info, même si la date n'est pas bonne // ----------------------------------------------------- Db::getInstance()->update('expressmailing_sms', array('campaign_state' => 1, 'campaign_date_update' => date('Y-m-d H:i:s'), 'campaign_date_send' => $campaign_date_send, 'campaign_sms_text' => pSQL($campaign_text), 'campaign_name' => pSQL($campaign_name), 'campaign_week_limit' => $limit_dayoftheweek, 'campaign_start_hour' => (int) Tools::getValue('start_hour_hidden'), 'campaign_end_hour' => (int) Tools::getValue('end_hour_hidden')), 'campaign_id = ' . $this->campaign_id); if ($campaign_date_send > mktime(0, 0, 0, date('m') + 3, date('d'), date('Y'))) { $this->errors[] = $this->module->l('Invalid date (max 3 months)', 'adminmarketingsstep1'); return false; } Tools::redirectAdmin('index.php?controller=AdminMarketingSStep2&campaign_id=' . $this->campaign_id . '&token=' . Tools::getAdminTokenLite('AdminMarketingSStep2')); exit; } } }
public function renderForm($field, $data) { if ($data) { $data = unserialize($data); } // echo '<pre>'.print_r( $data, 1 );die; $sengine = isset($data['engine']) ? $data['engine'] : ""; $selectors = isset($data['selectors']) ? $data['selectors'] : ""; $output = '<div class="margin-form form-fonts">'; $output .= '<div class="group-fields">'; $output .= '<div class="g-fields"><label>Font Engine</label>'; $output .= '<select id="' . $field . '" name="' . $field . '[engine]" class="font-engine">'; $output .= '<option value="">No Use</option>'; foreach ($this->engines as $engine => $text) { $selected = ''; if ($sengine == $engine) { $selected = 'selected="selected"'; } $output .= '<option ' . $selected . ' value="' . $engine . '">' . $text . '</option>'; } $output .= '</select></div>'; foreach ($this->engines as $engine => $text) { $output .= '<div id="' . $field . '_' . $engine . '" class="font-engine-setting">'; $fonts = $this->getFontsByEngine($engine); $sfont = isset($data[$engine]['font']) ? $data[$engine]['font'] : ""; $sfontlink = isset($data[$engine]['link']) ? $data[$engine]['link'] : ""; if (is_array($fonts) && !empty($fonts)) { $output .= '<div class="g-fields"><label>Select Font</label>'; $output .= '<select name="' . $field . '[' . $engine . '][font]">'; foreach ($fonts as $font) { $selected = ''; if (htmlspecialchars($font[0]) == htmlspecialchars($sfont)) { $selected = 'selected="selected"'; } $output .= '<option ' . $selected . ' value="' . htmlspecialchars($font[0]) . '">' . $font[1] . '</option>'; } $output .= '</select></div>'; } else { $output .= '<div class="g-fields"><label>' . Tools::ucfirst($engine) . ' Font Link</label>'; $output .= '<input name="' . $field . '[' . $engine . '][link]" value="' . $sfontlink . '" style="width:400px; margin-bottom:12px"> <p><i>Example: <b>http://fonts.googleapis.com/css?family=Cantora+One</b></i></p> </div>'; $output .= '<div class="g-fields"><label>Font Family</label>'; $output .= '<input name="' . $field . '[' . $engine . '][font]" value="' . $sfont . '" style="width:400px; margin-bottom:12px"> <p><i>Example: <b>\'Cantora One\', sans-serif</b></i></p> </div>'; } $output .= '</div>'; } $output .= '<div class="g-fields"><label>Selectors</label>'; $output .= '<textarea name="' . $field . '[selectors]" cols="50" rows="5">' . $selectors . '</textarea> <p><i>Example: <b>body, h1,h2,h3, #yourstyle, .myrule div</b></i></p> </div>'; $output .= '</div>'; $output .= '</div>'; return $output; }
/** * Translates a string with underscores into camel case (e.g. first_name -> firstName) * @prototype string public static function toCamelCase(string $str[, bool $capitalise_first_char = false]) */ public static function toCamelCase($str, $catapitalise_first_char = false) { $str = Tools::strtolower($str); if ($catapitalise_first_char) { $str = Tools::ucfirst($str); } return preg_replace_callback('/_+([a-z])/', create_function('$c', 'return strtoupper($c[1]);'), $str); }
/** * Start forms process * @see FrontController::postProcess() */ public function postProcess() { $origin_newsletter = (bool) $this->customer->newsletter; if (isset($_POST['years']) && isset($_POST['months']) && isset($_POST['days'])) { $this->customer->birthday = (int) $_POST['years'] . '-' . (int) $_POST['months'] . '-' . (int) $_POST['days']; } if (Tools::isSubmit('submitIdentity')) { if (!@checkdate(Tools::getValue('months'), Tools::getValue('days'), Tools::getValue('years')) && !(Tools::getValue('months') == '' && Tools::getValue('days') == '' && Tools::getValue('years') == '')) { $this->errors[] = Tools::displayError('Invalid date of birth.'); } else { $email = trim(Tools::getValue('email')); $this->customer->birthday = empty($_POST['years']) ? '' : (int) $_POST['years'] . '-' . (int) $_POST['months'] . '-' . (int) $_POST['days']; if (isset($_POST['old_passwd'])) { $_POST['old_passwd'] = trim($_POST['old_passwd']); } if (!Validate::isEmail($email)) { $this->errors[] = Tools::displayError('This email address is not valid'); } elseif ($this->customer->email != $email && Customer::customerExists($email, true)) { $this->errors[] = Tools::displayError('An account using this email address has already been registered.'); } elseif (!isset($_POST['old_passwd']) || empty($_POST['old_passwd']) || Tools::encrypt($_POST['old_passwd']) != $this->context->cookie->passwd) { $this->errors[] = Tools::displayError('The password you entered is incorrect.'); } elseif ($_POST['passwd'] != $_POST['confirmation']) { $this->errors[] = Tools::displayError('The password and confirmation do not match.'); } else { $prev_id_default_group = $this->customer->id_default_group; // Merge all errors of this file and of the Object Model $this->errors = array_merge($this->errors, $this->customer->validateController()); } if (!count($this->errors)) { $this->customer->id_default_group = (int) $prev_id_default_group; $this->customer->firstname = Tools::ucfirst(Tools::strtolower($this->customer->firstname)); if (!isset($_POST['newsletter'])) { $this->customer->newsletter = 0; } elseif (!$origin_newsletter && isset($_POST['newsletter'])) { if ($module_newsletter = Module::getInstanceByName('blocknewsletter')) { if ($module_newsletter->active) { $module_newsletter->confirmSubscription($this->customer->email); } } } if (!isset($_POST['optin'])) { $this->customer->optin = 0; } if (Tools::getValue('passwd')) { $this->context->cookie->passwd = $this->customer->passwd; } if ($this->customer->update()) { $this->context->cookie->customer_lastname = $this->customer->lastname; $this->context->cookie->customer_firstname = $this->customer->firstname; $this->context->smarty->assign('confirmation', 1); } else { $this->errors[] = Tools::displayError('The information cannot be updated.'); } } } } else { $_POST = array_map('stripslashes', $this->customer->getFields()); } return $this->customer; }