public function postProcess() { parent::postProcess(); // Déconnexion if (Tools::getIsset('logout')) { Auth::disconnect(); Flash::add('Vous êtes bien déconnécté'); Tools::redirect($this->context->link->getPageLink('auth')); } elseif (Tools::isSubmit('submitLogin')) { $user = (new User())->getByEmail(Tools::getValue('username'), Tools::getValue('password')); if (!Validate::isLoadedObject($user)) { $this->errors[] = 'Identifiant ou mot de passe incorrect'; } else { Auth::setUser($user); Tools::redirect($this->context->link->getPageLink('comments')); } } elseif (Tools::isSubmit('submitSubscribe')) { /** * - Vérification des champs * - Verification non-existant * - Inscription * - Login */ if (!Validate::isEmail($email = Tools::getValue('username'))) { return $this->errors[] = 'Veuillez saisir une adresse e-mail correcte'; } if (!Validate::isPasswd($password = Tools::getValue('password'))) { /// @todo être plus spécifique sur les règles de mot de passes valides return $this->errors[] = 'Veuillez saisir un mot de passe correct'; } $user = new User(); if (Validate::isLoadedObject($user->getByEmail($email))) { $this->errors[] = 'Un compte avec cet identifiant existe déjà '; } else { $user->login = $email; $user->password = Tools::encrypt($password); if (!$user->save()) { $this->errors[] = 'Impossible de vous enregistrer, veuillez réessayer ultérieurement (' . Db::getInstance()->getMsgError() . ')'; } else { Auth::setUser($user); Flash::success('Bienvenue! Votre compte a bien été créé'); Tools::redirect($this->context->link->getPageLink('comments')); } } } elseif (Auth::getUser()) { Tools::redirect($this->context->link->getPageLink('comments')); } }
/** * Assign template vars related to page content * @see FrontController::initContent() */ public function initContent() { parent::initContent(); $this->productSort(); // Override default configuration values: cause the new products page must display latest products first. if (!Tools::getIsset('orderway') || !Tools::getIsset('orderby')) { $this->orderBy = 'date_add'; $this->orderWay = 'DESC'; } $nbProducts = (int) Product::getNewProducts($this->context->language->id, null, null, true); $this->pagination($nbProducts); $products = Product::getNewProducts($this->context->language->id, (int) $this->p - 1, (int) $this->n, false, $this->orderBy, $this->orderWay); $this->addColorsToProductList($products); $this->context->smarty->assign(array('HOOK_LEFT_COLUMN' => Hook::exec('displayLeftColumn'), 'products' => $products, 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'nbProducts' => (int) $nbProducts, 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), 'comparator_max_item' => Configuration::get('PS_COMPARATOR_MAX_ITEM'))); if ($this->ajax) { $product_list = $this->context->smarty->fetch(_PS_THEME_DIR_ . 'product-list.tpl'); $pagination = $this->context->smarty->fetch(_PS_THEME_DIR_ . 'pagination.tpl'); $nbLeftProducts = $nbProducts - ($this->n * ($this->p - 1) + count($products)); $nbLeftProductsPercentage = ($nbProducts - $nbLeftProducts) / $nbProducts * 100; echo Tools::jsonEncode(array('productList' => utf8_encode($product_list), 'pagination' => $pagination, 'nbRenderedProducts' => $nbProducts, 'nbLeftProducts' => $nbLeftProducts, 'nbLeftProductsPercentage' => $nbLeftProductsPercentage)); die; } else { $this->setTemplate(_PS_THEME_DIR_ . 'new-products.tpl'); } }
public function renderForm($args, $data) { # validate module unset($args); $this->checkFolderImage(); $helper = $this->getFormHelper(); $items = ''; $slide_edit = ''; if ($data['params'] && isset($data['params']['leoslide']) && $data['params']['leoslide']) { $slides = $data['params']['leoslide']; $items = $this->getSlide($slides); if (Tools::getValue('id_slide')) { $id_slide = Tools::getValue('id_slide'); $slide_edit = $items[$id_slide] ? $items[$id_slide] : ''; } } $this->fields_form[1]['form'] = array('legend' => array('title' => $this->l('Carousel Form.')), 'input' => array(array('type' => 'text', 'label' => $this->l('Image Size Width'), 'name' => 'img_width', 'default' => 1170), array('type' => 'text', 'label' => $this->l('Image size Height'), 'name' => 'img_height', 'default' => 400), array('type' => 'text', 'label' => $this->l('Thumb Size Width'), 'name' => 'thumb_width', 'default' => 100), array('type' => 'text', 'label' => $this->l('Thumb size Height'), 'name' => 'thumb_height', 'default' => 100), array('type' => 'text', 'label' => $this->l('Interval'), 'name' => 'interval', 'default' => 8000)), 'buttons' => array(array('title' => $this->l('Save And Stay'), 'icon' => 'process-icon-save', 'class' => 'pull-right', 'type' => 'submit', 'name' => 'saveandstayleotempcp'), array('title' => $this->l('Save'), 'icon' => 'process-icon-save', 'class' => 'pull-right', 'type' => 'submit', 'name' => 'saveleotempcp'))); if (Tools::getIsset('addleowidgets')) { $this->fields_form[1]['form']['input'][] = array('type' => 'html', 'name' => 'html', 'default' => '', 'html_content' => '<div class="alert alert-info">' . $this->l('Please Click save to input image') . '</div>'); } else { $this->fields_form[1]['form']['input'][] = array('type' => 'slide', 'name' => 'slide', 'lang' => true, 'selectImg' => Context::getContext()->link->getAdminLink('AdminLeomanagewidgetsImages'), 'tree' => '', 'default' => ''); } $theme_dir = Context::getContext()->shop->theme_directory; $images = array(); $thums = array(); $images = LeoWidgetBase::getImageList(_PS_ROOT_DIR_ . '/themes/' . $theme_dir . '/img/modules/' . $this->name . '/image'); $thums = LeoWidgetBase::getImageList(_PS_ROOT_DIR_ . '/themes/' . $theme_dir . '/img/modules/' . $this->name . '/thum'); $iso = Context::getContext()->language->iso_code; $helper->tpl_vars = array('fields_value' => $this->getConfigFieldsValues($data), 'languages' => Context::getContext()->controller->getLanguages(), 'id_lang_default' => Configuration::get('PS_LANG_DEFAULT'), 'iso_code' => Context::getContext()->language->iso_code, 'iso' => file_exists(_PS_CORE_DIR_ . '/js/tiny_mce/langs/' . $iso . '.js') ? $iso : 'en', 'path_css' => _THEME_CSS_DIR_, 'ad' => __PS_BASE_URI__ . basename(_PS_ADMIN_DIR_), 'images' => $images, 'thums' => $thums, 'items' => $items, 'slide_edit' => $slide_edit, 'url' => AdminController::$currentIndex . '&id_leowidgets=' . Tools::getValue('id_leowidgets') . '&updateleowidgets&token=' . Tools::getValue('token') . '&conf=4', 'pathimg' => __PS_BASE_URI__ . 'themes/' . $theme_dir . '/img/modules/' . $this->name . '/image/', 'paththum' => __PS_BASE_URI__ . 'themes/' . $theme_dir . '/img/modules/' . $this->name . '/thum/'); return $helper->generateForm($this->fields_form); }
public function __construct() { $notificationCode = Tools::getValue('notificationCode'); $this->transaction_code = Tools::getIsset($notificationCode) && trim(Tools::getValue('notificationCode')) !== '' ? trim(Tools::getValue('notificationCode')) : null; $this->createCredential(); $this->createTransaction(); }
public function process() { if (Tools::getIsset('DOCUMENT')) { $data = Tools::getValue('DOCUMENT'); $result = OpenPayU_Order::consumeMessage($data, false); if ($result->getMessage() == 'ShippingCostRetrieveRequest') { $id_payu_session = $result->getSessionId(); $iso_country_code = $result->getCountryCode(); $payu = new PayU(); $order_payment = $payu->getOrderPaymentBySessionId($id_payu_session); $id_cart = $order_payment['id_cart']; if (!empty($id_cart)) { $payu->id_cart = $id_cart; $payu->payu_order_id = $id_payu_session; $payu->id_request = $result->getReqId(); $xml = $payu->shippingCostRetrieveRequest($iso_country_code); if (!empty($xml)) { header('Content-Type:text/xml'); echo $xml; } } } } exit; }
public function initContent() { parent::initContent(); $this->productSort(); // Override default configuration values: cause the new products page must display latest products first. if (!Tools::getIsset('orderway') || !Tools::getIsset('orderby')) { $this->orderBy = 'date_add'; $this->orderWay = 'DESC'; } $nb_products = (int) Product::getNewProducts($this->context->language->id, isset($this->p) ? (int) $this->p - 1 : null, isset($this->n) ? (int) $this->n : null, true); $this->pagination($nb_products); $products = Product::getNewProducts($this->context->language->id, (int) $this->p - 1, (int) $this->n, false, $this->orderBy, $this->orderWay); $this->addColorsToProductList($products); /************************* /Images Array ******************************/ if (method_exists('Product', 'getProductsImgs')) { $image_array = array(); for ($i = 0; $i < $nb_products; $i++) { if (isset($products[$i]['id_product'])) { $image_array[$products[$i]['id_product']] = Product::getProductsImgs($products[$i]['id_product']); } } $this->context->smarty->assign('productimg', (isset($image_array) and $image_array) ? $image_array : NULL); } /************************* /Images Array ******************************/ $this->context->smarty->assign(array('products' => $products, 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'nbProducts' => (int) $nb_products, 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), 'comparator_max_item' => Configuration::get('PS_COMPARATOR_MAX_ITEM'))); $this->setTemplate(_PS_THEME_DIR_ . 'new-products.tpl'); }
public function __construct() { // Set variables $this->table = 'mymod_comment'; $this->className = 'MyModComment'; $this->fields_list = array('id_mymod_comment' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), 'shop_name' => array('title' => $this->l('Shop'), 'width' => 120, 'filter_key' => 's!name'), 'firstname' => array('title' => $this->l('Firstname'), 'width' => 120), 'lastname' => array('title' => $this->l('Lastname'), 'width' => 140), 'email' => array('title' => $this->l('E-mail'), 'width' => 150), 'product_name' => array('title' => $this->l('Product'), 'width' => 100, 'filter_key' => 'pl!name'), 'grade_display' => array('title' => $this->l('Grade'), 'align' => 'right', 'width' => 80, 'filter_key' => 'a!grade'), 'comment' => array('title' => $this->l('Comment'), 'search' => false), 'date_add' => array('title' => $this->l('Date add'), 'type' => 'date')); // Set fields form for form view $this->context = Context::getContext(); $this->context->controller = $this; $this->fields_form = array('legend' => array('title' => $this->l('Add / Edit Comment'), 'image' => '../img/admin/contact.gif'), 'input' => array(array('type' => 'text', 'label' => $this->l('Firstname'), 'name' => 'firstname', 'size' => 30, 'required' => true), array('type' => 'text', 'label' => $this->l('Lastname'), 'name' => 'lastname', 'size' => 30, 'required' => true), array('type' => 'text', 'label' => $this->l('E-mail'), 'name' => 'email', 'size' => 30, 'required' => true), array('type' => 'select', 'label' => $this->l('Product'), 'name' => 'id_product', 'required' => true, 'default_value' => 1, 'options' => array('query' => Product::getProducts($this->context->cookie->id_lang, 1, 1000, 'name', 'ASC'), 'id' => 'id_product', 'name' => 'name')), array('type' => 'text', 'label' => $this->l('Grade'), 'name' => 'grade', 'size' => 30, 'required' => true, 'desc' => $this->l('Grade must be between 1 and 5')), array('type' => 'textarea', 'label' => $this->l('Comment'), 'name' => 'comment', 'cols' => 50, 'rows' => 5, 'required' => false)), 'submit' => array('title' => $this->l('Save'))); // Enable bootstrap $this->bootstrap = true; // Call of the parent constructor method parent::__construct(); // Update the SQL request of the HelperList $this->_select = "s.`name` as shop_name, pl.`name` as product_name, CONCAT(a.`grade`, '/5') as grade_display"; $this->_join = 'LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl ON (pl.`id_product` = a.`id_product` AND pl.`id_lang` = ' . (int) $this->context->language->id . ' AND pl.`id_shop` = a.`id_shop`) LEFT JOIN `' . _DB_PREFIX_ . 'shop` s ON (s.`id_shop` = a.`id_shop`)'; // Add actions $this->addRowAction('view'); $this->addRowAction('delete'); $this->addRowAction('edit'); // Add bulk actions $this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Would you like to delete the selected items?')), 'myaction' => array('text' => $this->l('My Action'), 'confirm' => $this->l('Are you sure?'))); // Define meta and toolbar title $this->meta_title = $this->l('Comments on Product'); if (Tools::getIsset('viewmymod_comment')) { $this->meta_title = $this->l('View comment') . ' #' . Tools::getValue('id_mymod_comment'); } $this->toolbar_title[] = $this->meta_title; }
public function run() { // Get number of comments $id_product = (int) Tools::getValue('id_product'); $nb_comments = MyModComment::getProductNbComments((int) $id_product); // Init $page = 1; $nb_per_page = 10; $nb_pages = ceil($nb_comments / $nb_per_page); if (Tools::getIsset('page')) { $page = (int) Tools::getValue('page'); } $limit_start = ($page - 1) * $nb_per_page; $limit_end = $nb_per_page; // Build actions url $ajax_action_url = $this->context->link->getAdminLink('AdminModules', true); $ajax_action_url = str_replace('index.php', 'ajax-tab.php', $ajax_action_url); $action_url = $this->context->link->getAdminLink('AdminMyModComments', true); // Get comments $comments = MyModComment::getProductComments((int) $id_product, (int) $limit_start, (int) $limit_end); // Assign comments and product object $this->context->smarty->assign('page', $page); $this->context->smarty->assign('nb_pages', $nb_pages); $this->context->smarty->assign('comments', $comments); $this->context->smarty->assign('action_url', $action_url); $this->context->smarty->assign('ajax_action_url', $ajax_action_url); $this->context->smarty->assign('pc_base_dir', __PS_BASE_URI__ . 'modules/' . $this->module->name . '/'); return $this->module->display($this->file, 'displayAdminProductsExtra.tpl'); }
public function init() { parent::init(); if (Module::isEnabled('aimultidimensions')) { if (Tools::getIsset('add') && $this->context->cart->id) { require_once _PS_ROOT_DIR_ . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . 'aimultidimensions' . DIRECTORY_SEPARATOR . 'aimultidimensions.php'; require_once _PS_ROOT_DIR_ . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . 'aimultidimensions' . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'config.php'; require_once _PS_ROOT_DIR_ . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . 'aimultidimensions' . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'functions' . $GLOBALS['aimd_config_suffix'] . '.php'; $add = 1; $idProduct = (int) Tools::getValue('id_product', NULL); if (checkLink($idProduct)) { $idProductAttribute = (int) Tools::getValue('id_product_attribute', Tools::getValue('ipa')); $customizationId = (int) Tools::getValue('id_customization', 0); $qty = (int) abs(Tools::getValue('qty', 1)); if ($add && $qty >= 0 && getProducts($idProduct)) { $quantity = (int) Db::getInstance()->getValue('SELECT quantity FROM ' . _DB_PREFIX_ . 'cart_product WHERE id_cart = ' . $this->context->cart->id . ' AND id_product = ' . $idProduct . ' AND ' . 'id_product_attribute = ' . $idProductAttribute); if (Tools::getValue('op', 'up') == 'up') { $quantity += (int) $qty; } else { $quantity -= (int) $qty; } $cookie = $this->context->cookie; $cart = $this->context->cart; include_once 'modules/aimultidimensions/includes/cart.php'; Product::flushPriceCache(); } } } } }
public function renderForm() { if ($this->is_seller && (Tools::getIsset('updatecategory') || Tools::getIsset('addcategory')) && !(int) Configuration::get('AGILE_MS_EDIT_CATEGORY')) { $this->errors[] = Tools::displayError('You do not have permission to add/edit category'); return; } return parent::renderForm(); }
/** * Set default medias for this controller */ public function postProcess() { if (Tools::getIsset('product_id')) { $output = $this->getProductAttributeCombinations(Tools::getValue('product_id')); echo json_encode($output); parent::postProcess(); die; } }
public function ajaxProcessLoadCartRules() { $type = $token = $search = ''; $limit = $count = $id_cart_rule = 0; if (Tools::getIsset('limit')) { $limit = Tools::getValue('limit'); } if (Tools::getIsset('type')) { $type = Tools::getValue('type'); } if (Tools::getIsset('count')) { $count = Tools::getValue('count'); } if (Tools::getIsset('id_cart_rule')) { $id_cart_rule = Tools::getValue('id_cart_rule'); } if (Tools::getIsset('search')) { $search = Tools::getValue('search'); } $page = floor($count / $limit); $html = ''; $next_link = ''; if ($page * $limit + 1 == $count || $count == 0) { if ($count == 0) { $count = 1; } /** @var CartRule $current_object */ $current_object = $this->loadObject(true); $cart_rules = $current_object->getAssociatedRestrictions('cart_rule', false, true, $page * $limit, $limit, $search); if ($type == 'selected') { $i = 1; foreach ($cart_rules['selected'] as $cart_rule) { $html .= '<option value="' . (int) $cart_rule['id_cart_rule'] . '"> ' . Tools::safeOutput($cart_rule['name']) . '</option>'; if ($i == $limit) { break; } $i++; } if ($i == $limit) { $next_link = Context::getContext()->link->getAdminLink('AdminCartRules') . '&ajaxMode=1&ajax=1&id_cart_rule=' . (int) $id_cart_rule . '&action=loadCartRules&limit=' . (int) $limit . '&type=selected&count=' . ($count - 1 + count($cart_rules['selected']) . '&search=' . urlencode($search)); } } else { $i = 1; foreach ($cart_rules['unselected'] as $cart_rule) { $html .= '<option value="' . (int) $cart_rule['id_cart_rule'] . '"> ' . Tools::safeOutput($cart_rule['name']) . '</option>'; if ($i == $limit) { break; } $i++; } if ($i == $limit) { $next_link = Context::getContext()->link->getAdminLink('AdminCartRules') . '&ajaxMode=1&ajax=1&id_cart_rule=' . (int) $id_cart_rule . '&action=loadCartRules&limit=' . (int) $limit . '&type=unselected&count=' . ($count - 1 + count($cart_rules['unselected']) . '&search=' . urlencode($search)); } } } echo Tools::jsonEncode(array('html' => $html, 'next_link' => $next_link)); }
/** * Assign wishlist template */ public function assign() { $errors = array(); if ($this->context->customer->isLogged()) { $add = Tools::getIsset('add'); $add = empty($add) === false ? 1 : 0; $delete = Tools::getIsset('deleted'); $delete = empty($delete) === false ? 1 : 0; $id_wishlist = Tools::getValue('id_wishlist'); if (Tools::isSubmit('submitWishlist')) { if (Configuration::get('PS_TOKEN_ACTIVATED') == 1 and strcmp(Tools::getToken(), Tools::getValue('token'))) { $errors[] = $this->module->l('Invalid token', 'mywishlist'); } if (!sizeof($errors)) { $name = Tools::getValue('name'); if (empty($name)) { $errors[] = $this->module->l('You must specify a name.', 'mywishlist'); } if (WishList::isExistsByNameForUser($name)) { $errors[] = $this->module->l('This name is already used by another list.', 'mywishlist'); } if (!sizeof($errors)) { $wishlist = new WishList(); $wishlist->id_shop = $this->context->shop->id; $wishlist->id_shop_group = $this->context->shop->id_shop_group; $wishlist->name = $name; $wishlist->id_customer = (int) $this->context->customer->id; list($us, $s) = explode(' ', microtime()); srand($s * $us); $wishlist->token = strtoupper(substr(sha1(uniqid(rand(), true) . _COOKIE_KEY_ . $this->context->customer->id), 0, 16)); $wishlist->add(); Mail::Send($this->context->language->id, 'wishlink', Mail::l('Your wishlist\'s link', $this->context->language->id), array('{wishlist}' => $wishlist->name, '{message}' => Tools::getProtocol() . htmlentities($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8') . __PS_BASE_URI__ . 'modules/blockwishlist/view.php?token=' . $wishlist->token), $this->context->customer->email, $this->context->customer->firstname . ' ' . $this->context->customer->lastname, NULL, strval(Configuration::get('PS_SHOP_NAME')), NULL, NULL, $this->module->getLocalPath() . 'mails/'); } } } else { if ($add) { WishList::addCardToWishlist($this->context->customer->id, Tools::getValue('id_wishlist'), $this->context->language->id); } else { if ($delete and empty($id_wishlist) === false) { $wishlist = new WishList((int) $id_wishlist); if (Validate::isLoadedObject($wishlist)) { $wishlist->delete(); } else { $errors[] = $this->module->l('Cannot delete this wishlist', 'mywishlist'); } } } } $this->context->smarty->assign('wishlists', WishList::getByIdCustomer($this->context->customer->id)); $this->context->smarty->assign('nbProducts', WishList::getInfosByIdCustomer($this->context->customer->id)); } else { Tools::redirect('index.php?controller=authentication&back=' . urlencode($this->context->link->getModuleLink('blockwishlist', 'mywishlist'))); } $this->context->smarty->assign(array('id_customer' => (int) $this->context->customer->id, 'errors' => $errors, 'form_link' => $errors)); $this->setTemplate('mywishlist.tpl'); }
/** * Initialize auth controller * @see FrontController::init() */ public function init() { parent::init(); if (!Tools::getIsset('step') && $this->context->customer->isLogged() && !$this->ajax) { Tools::redirect('index.php?controller=' . ($this->authRedirection !== false ? urlencode($this->authRedirection) : 'my-account')); } if (Tools::getValue('create_account')) { $this->create_account = true; } }
public function initContent() { parent::initContent(); if (Tools::getIsset('collection_id') && Tools::getValue('collection_id') != 'null') { // payment variables $payment_statuses = array(); $payment_ids = array(); $payment_types = array(); $payment_method_ids = array(); $card_holder_names = array(); $four_digits_arr = array(); $statement_descriptors = array(); $status_details = array(); $transaction_amounts = 0; $collection_ids = split(',', Tools::getValue('collection_id')); foreach ($collection_ids as $collection_id) { $mercadopago = $this->module; $mercadopago_sdk = $mercadopago->mercadopago; $result = $mercadopago_sdk->getPayment($collection_id); $payment_info = $result['response']['collection']; $id_cart = $payment_info['external_reference']; $cart = new Cart($id_cart); $payment_statuses[] = $payment_info['status']; $payment_ids[] = $payment_info['id']; $payment_types[] = $payment_info['payment_type']; $payment_method_ids[] = $payment_info['payment_method_id']; $transaction_amounts += $payment_info['transaction_amount']; if ($payment_info['payment_type'] == 'credit_card') { $card_holder_names[] = $payment_info['cardholder']['name']; $four_digits_arr[] = '**** **** **** ' . $payment_info['last_four_digits']; $statement_descriptors[] = $payment_info['statement_descriptor']; $status_details[] = $payment_info['status_detail']; } } if (Validate::isLoadedObject($cart)) { $order_id = Order::getOrderByCartId($cart->id); $order = new Order($order_id); $uri = __PS_BASE_URI__ . 'order-confirmation.php?id_cart=' . $order->id_cart . '&id_module=' . $mercadopago->id . '&id_order=' . $order->id . '&key=' . $order->secure_key; $uri .= '&payment_status=' . $payment_statuses[0]; $uri .= '&payment_id=' . join(" / ", $payment_ids); $uri .= '&payment_type=' . join(" / ", $payment_types); $uri .= '&payment_method_id=' . join(" / ", $payment_method_ids); $uri .= '&amount=' . $transaction_amounts; if ($payment_info['payment_type'] == 'credit_card') { $uri .= '&card_holder_name=' . join(" / ", $card_holder_names); $uri .= '&four_digits=' . join(" / ", $four_digits_arr); $uri .= '&statement_descriptor=' . $statement_descriptors[0]; $uri .= '&status_detail=' . $status_details[0]; } Tools::redirectLink($uri); } } else { error_log('External reference is not set. Order placement has failed.'); } }
public function processLogin() { require_once dirname(__FILE__) . '../../../../modules/designer/designer.php'; $themeName = trim(Tools::getValue('theme_name')); $passwd = trim(Tools::getValue('passwd')); $email = trim(Tools::getValue('email')); $domain = getSessionDomain($themeName); $version = function_exists('theme_get_manifest_version') ? '&ver=' . theme_get_manifest_version($themeName) : ''; $desktop = function_exists('getDesktopParams') ? getDesktopParams() : ''; if (empty($email)) { $this->errors[] = Tools::displayError('E-mail is empty'); } elseif (!Validate::isEmail($email)) { $this->errors[] = Tools::displayError('Invalid e-mail address'); } if (empty($passwd)) { $this->errors[] = Tools::displayError('Password is blank'); } elseif (!Validate::isPasswd($passwd)) { $this->errors[] = Tools::displayError('Invalid password'); } if (!count($this->errors)) { $this->context->employee = new Employee(); $is_employee_loaded = $this->context->employee->getByemail($email, $passwd); $employee_associated_shop = $this->context->employee->getAssociatedShops(); if (!$is_employee_loaded) { $this->errors[] = Tools::displayError('Employee does not exist or password is incorrect.'); $this->context->employee->logout(); } elseif (empty($employee_associated_shop) && !$this->context->employee->isSuperAdmin()) { $this->errors[] = Tools::displayError('Employee does not manage any shop anymore (shop has been deleted or permissions have been removed).'); $this->context->employee->logout(); } else { $this->context->employee->remote_addr = ip2long(Tools::getRemoteAddr()); $cookie = Context::getContext()->cookie; $cookie->id_employee = $this->context->employee->id; $cookie->email = $this->context->employee->email; $cookie->profile = $this->context->employee->id_profile; $cookie->passwd = $this->context->employee->passwd; $cookie->remote_addr = $this->context->employee->remote_addr; $cookie->write(); if (Tools::getIsset('theme_name')) { $url = $this->context->link->getAdminLink('AdminAjax') . '&ajax=1' . $domain . $version . $desktop; } else { $tab = new Tab((int) $this->context->employee->default_tab); $url = $this->context->link->getAdminLink($tab->class_name); } if (Tools::isSubmit('ajax')) { die(Tools::jsonEncode(array('hasErrors' => false, 'redirect' => $url))); } else { $this->redirect_after = $url; } } } if (Tools::isSubmit('ajax')) { die(Tools::jsonEncode(array('hasErrors' => true, 'errors' => $this->errors))); } }
public function initProcess() { if (Tools::getIsset('details' . $this->table)) { $this->list_id = 'details'; if (isset($_POST['submitReset' . $this->list_id])) { $this->processResetFilters(); } } else { $this->list_id = 'tab'; } return parent::initProcess(); }
/** * Adds no_follow toggle action to process routing */ public function initProcess() { parent::initProcess(); // @TODO Refactor 'if' statement to match other controllers, the way they add extra actions if (empty($this->action) && Tools::getValue($this->identifier)) { if (Tools::getIsset('no_follow' . $this->table) || Tools::getIsset('no_follow')) { if ($this->tabAccess['edit'] === '1') { $this->action = 'no_follow'; } else { $this->errors[] = Tools::displayError('You do not have permission to edit this.'); } } } }
/** * Assign template vars related to page content * @see FrontController::initContent() */ public function initContent() { parent::initContent(); $this->productSort(); // Override default configuration values: cause the new products page must display latest products first. if (!Tools::getIsset('orderway') || !Tools::getIsset('orderby')) { $this->orderBy = 'date_add'; $this->orderWay = 'DESC'; } $nbProducts = (int) Product::getNewProducts($this->context->language->id, isset($this->p) ? (int) $this->p - 1 : null, isset($this->n) ? (int) $this->n : null, true); $this->pagination($nbProducts); $this->context->smarty->assign(array('products' => Product::getNewProducts($this->context->language->id, (int) $this->p - 1, (int) $this->n, false, $this->orderBy, $this->orderWay), 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'nbProducts' => (int) $nbProducts, 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), 'comparator_max_item' => Configuration::get('PS_COMPARATOR_MAX_ITEM'))); $this->setTemplate(_PS_THEME_DIR_ . 'new-products.tpl'); }
function addThemlerParam(array $params = array(), $route_id = null) { $themeParams = array('theme_name'); if ($route_id && $route_id == 'AdminLogin') { // added domain parameter to login and redirect to Themler with it $themeParams = array('theme_name', 'domain', 'noCache'); } foreach ($themeParams as $themeParam) { if (Tools::getIsset($themeParam)) { $tp = array($themeParam => Tools::getValue($themeParam, false)); $params = $tp + $params; } } return $params; }
public function initProcess() { $this->id_object = Tools::getValue('id_' . $this->table); if (Tools::isSubmit('changeShowPricesVal') && $this->id_object) { $this->action = 'change_show_prices_val'; } if (Tools::getIsset('viewgroup')) { $this->list_id = 'customer_group'; if (isset($_POST['submitReset' . $this->list_id])) { $this->processResetFilters(); } } else { $this->list_id = 'group'; } parent::initProcess(); }
public function postProcess() { $return = parent::postProcess(); if (Tools::getValue('submitAdd' . $this->table) && Validate::isLoadedObject($return)) { $carriers = Carrier::getCarriers($this->context->language->iso_code, false, false, false, null, Carrier::PS_CARRIERS_AND_CARRIER_MODULES_NEED_RANGE); $carrier_box = array(); foreach ($carriers as $carrier) { if (Tools::getIsset('carrierBox_' . $carrier['id_carrier'])) { $carrier_box[] = $carrier['id_carrier']; } } $return->updateCarriers($carrier_box); $return->updateGroups(Tools::getValue('groupBox')); } return $return; }
protected function copyFromPost(&$object, $table) { parent::copyFromPost($object, $table); if (get_class($object) != 'Product') { return; } if (Tools::getIsset('minimal_quantity')) { $minimal_quantity = Tools::getValue('minimal_quantity'); $minimal_quantity = empty($minimal_quantity) ? '0' : str_replace(',', '.', $minimal_quantity); $_POST['minimal_quantity'] = $minimal_quantity; $object->setMinQty($minimal_quantity); } if (Tools::getIsset('sp_from_quantity')) { $_POST['sp_from_quantity'] = str_replace(',', '.', Tools::getValue('sp_from_quantity')); } }
private function getNewsletter($setting) { $this->newsletterRegistration(); if ($this->error) { $setting['msg'] = $this->error; $setting['nw_value'] = Tools::getIsset('email') ? pSQL(Tools::getValue('email')) : false; $setting['nw_error'] = true; $setting['action'] = Tools::getValue('action'); } else { if ($this->valid) { $setting['msg'] = $this->valid; $setting['nw_error'] = false; } } return $setting; }
/** * Assign summary template */ public function webhook() { $stripe = new StripeJs(); if ($stripe->active) { if (Tools::getIsset('token') && Configuration::get('STRIPE_WEBHOOK_TOKEN') == Tools::getValue('token')) { include $this->module->getLocalPath() . 'lib/Stripe.php'; Stripe::setApiKey(Configuration::get('STRIPE_MODE') ? Configuration::get('STRIPE_PRIVATE_KEY_LIVE') : Configuration::get('STRIPE_PRIVATE_KEY_TEST')); $event_json = Tools::jsonDecode(@Tools::file_get_contents('php://input')); if (isset($event_json->id)) { /* In case there is an issue with the event, Stripe throw an exception, just ignore it. */ try { /* To double-check and for more security, we retrieve the original event directly from Stripe */ $event = Stripe_Event::retrieve($event_json->id); /* We are only handling chargebacks, other events are ignored */ if ($event->type == 'charge.dispute.created') { $id_order = (int) Db::getInstance()->getValue('SELECT id_order FROM ' . _DB_PREFIX_ . 'stripe_transaction WHERE id_stripe_transaction = \'' . pSQL($event->id) . '\' AND `charge_back` = 0'); if ($id_order) { $order = new Order((int) $id_order); if (Validate::isLoadedObject($order)) { if (Configuration::get('STRIPE_CHARGEBACKS_ORDER_STATUS') != -1) { if ($order->getCurrentState() != Configuration::get('STRIPE_CHARGEBACKS_ORDER_STATUS')) { $order->changeIdOrderState((int) Configuration::get('STRIPE_CHARGEBACKS_ORDER_STATUS'), (int) $id_order); Db::getInstance()->getValue('UPDATE `' . _DB_PREFIX_ . 'stipe_transaction` SET `charge_back` = 1 WHERE `id_stripe_transaction` = \'' . pSQL($event->id) . '\' AND `charge_back` = 0'); } } $message = new Message(); $message->message = $stripe->l('A chargeback occured on this order and was reported by Stripe on') . ' ' . date('Y-m-d H:i:s'); $message->id_order = (int) $order->id; $message->id_employee = 1; $message->private = 1; $message->date_add = date('Y-m-d H:i:s'); $message->add(); } } } } catch (Exception $e) { header('HTTP/1.1 200 OK'); exit; } header('HTTP/1.1 200 OK'); exit; } } } header('HTTP/1.1 200 OK'); exit; }
/** * Module's constructor. */ public function __construct() { $this->name = 'welcome'; $this->version = '1.0.9'; $this->author = 'PrestaShop'; parent::__construct(); $this->displayName = $this->trans('Welcome', array(), 'Modules.Welcome.Admin'); $this->description = $this->trans('Help the user to create his first product.', array(), 'Modules.Welcome.Admin'); $this->ps_versions_compliancy = ['min' => '1.7.0.0', 'max' => _PS_VERSION_]; if (Module::isInstalled($this->name)) { $this->onBoarding = new OnBoarding($this->getTranslator(), $this->smarty, $this); if (Tools::getIsset('resetonboarding')) { $this->onBoarding->setShutDown(false); $this->onBoarding->setCurrentStep(0); } } }
public function postProcess() { $upload_max_size = (int) str_replace('M', '', ini_get('upload_max_filesize')); $post_max_size = (int) str_replace('M', '', ini_get('post_max_size')); $max_size = $upload_max_size < $post_max_size ? $upload_max_size : $post_max_size; if (Tools::getValue('PS_LIMIT_UPLOAD_FILE_VALUE') > $max_size || Tools::getValue('PS_LIMIT_UPLOAD_IMAGE_VALUE') > $max_size) { $this->errors[] = Tools::displayError('The limit chosen is larger than the server\'s maximum upload limit. Please increase the limits of your server.'); return; } if (Tools::getIsset('PS_LIMIT_UPLOAD_FILE_VALUE') && !Tools::getValue('PS_LIMIT_UPLOAD_FILE_VALUE')) { $_POST['PS_LIMIT_UPLOAD_FILE_VALUE'] = 1; } if (Tools::getIsset('PS_LIMIT_UPLOAD_IMAGE_VALUE') && !Tools::getValue('PS_LIMIT_UPLOAD_IMAGE_VALUE')) { $_POST['PS_LIMIT_UPLOAD_IMAGE_VALUE'] = 1; } parent::postProcess(); }
public function renderForm() { $attachement_list = Db::getInstance()->ExecuteS('SELECT a.id_attachment,CONCAT(a.id_attachment," - ",atl.name) AS name ' . 'FROM `' . _DB_PREFIX_ . 'attachment` a ' . 'LEFT JOIN `' . _DB_PREFIX_ . 'attachment_lang` atl ON ' . 'atl.id_attachment = a.id_attachment AND atl.id_lang = ' . (int) $this->context->language->id . ' ' . (Tools::getIsset('add' . $this->table) ? 'WHERE a.id_attachment NOT IN (SELECT id_attachment FROM `' . _DB_PREFIX_ . $this->table . '`) ' : ' ') . 'ORDER BY atl.name'); $download_list = Db::getInstance()->ExecuteS('SELECT pd.id_product_download,CONCAT(pl.id_product," - ",pl.name) AS name ' . 'FROM `' . _DB_PREFIX_ . 'product_download` pd ' . 'LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl ON ' . 'pl.id_product = pd.id_product AND pl.id_lang = ' . (int) $this->context->language->id . ' ' . (Tools::getIsset('add' . $this->table) ? 'WHERE pd.id_product_download NOT IN (SELECT id_product_download FROM `' . _DB_PREFIX_ . $this->table . '`) ' : ' ') . 'ORDER BY pl.name'); // No option available if (!count($attachement_list) && !count($download_list)) { $this->errors[] = Tools::displayError('No attachment or download available (or all already assigned).'); $this->fields_form = array('submit' => array('title' => $this->l('Save'), 'class' => 'hidden')); return parent::renderForm(); } // "None" option on both list $attachement_list[] = array('id_attachment' => 0, 'name' => $this->l('(None)')); $download_list[] = array('id_product_download' => 0, 'name' => $this->l('(None)')); $this->informations[] = Tools::displayError('You have to choose an attachment OR a download.'); $this->fields_form = array('legend' => array('title' => $this->l('AutoZip')), 'input' => array(array('type' => 'select', 'label' => $this->l('Attachment'), 'name' => 'id_attachment', 'required' => true, 'options' => array('query' => $attachement_list, 'id' => 'id_attachment', 'name' => 'name'), 'desc' => $this->l('To make the attachment available in the list you first have to create the attachment with the Name, description, and a dummy zip file in "Catalog > Attachments" or in a product edit page, tab "Attachments"')), array('type' => 'select', 'label' => $this->l('Virtual product'), 'name' => 'id_product_download', 'required' => true, 'options' => array('query' => $download_list, 'id' => 'id_product_download', 'name' => 'name'), 'desc' => $this->l('To make the virtual product available in the list you first have to create the entry with the name, download rules, and a dummy zip file in the product edit page, tab "Virtual product"')), array('type' => 'text', 'label' => $this->l('Zip base name'), 'name' => 'zip_basename', 'size' => 64, 'maxlength' => 96, 'required' => true, 'desc' => $this->l('Base name used to generate the name of the zip file.') . ' ' . $this->l('If available (GIt source having Tags), the latest version number will be added at the end of the filename.') . ' ' . $this->l('Example : "myname" will give "myname-1.2.3.zip"')), array('type' => 'text', 'label' => $this->l('Zip Folder'), 'name' => 'zip_folder', 'size' => 64, 'maxlength' => 255, 'required' => false, 'desc' => $this->l('Root folder name inside the zip (keep empty to disable root folder).')), array('type' => 'radio', 'label' => $this->l('Source type'), 'name' => 'source_type', 'required' => true, 'desc' => null, 'values' => array(array('id' => 'git', 'value' => 'git', 'label' => 'GIT (ssh / https)<p class="help-block">' . $this->l('The script will be able to auto detect & use the latest TAG.') . '<br/>' . $this->l('The Tag name should be exclusively composed of numbers and dots (eg. "1.2.3.4").') . '</p>'), array('id' => 'svn', 'value' => 'svn', 'label' => 'SVN (http / https / ssh)'), array('id' => 'wget', 'value' => 'wget', 'label' => $this->l('File server ') . ' (ftp / http / https) <p class="help-block">' . $this->l('If your server is hosting thousand of files, you should specify your subfolder in the "Source Url" AND in the "Source Folder", to avoid downloading unnecessary datas.') . '</p>'))), array('type' => 'text', 'label' => $this->l('Source Url'), 'name' => 'source_url', 'size' => 64, 'maxlength' => 255, 'required' => true, 'desc' => $this->l('Example :') . '<br/>' . 'git@github.com:arossetti/Prestashop-Module-AutoZip.git<br/>' . 'https://github.com/arossetti/Prestashop-Module-AutoZip.git<br/>' . 'https://svn.someserver.net/somerepo/branches/publish<br/>' . 'ftp://ftp.someserver.net/some/directory<br/>'), array('type' => 'text', 'label' => $this->l('Source Login'), 'name' => 'source_login', 'size' => 32, 'maxlength' => 128, 'required' => false, 'desc' => $this->l('Optional.') . ' ' . $this->l('The script will be able to use the credential keys of the account running the cron job (eg. SSH keys for GIt or SVN).')), array('type' => 'password', 'label' => $this->l('Source Password'), 'name' => 'source_password', 'size' => 32, 'maxlength' => 128, 'required' => false, 'desc' => $this->l('Optional.') . ' ' . $this->l('The script will be able to use the credential keys of the account running the cron job (eg. SSH keys for GIt or SVN).')), array('type' => 'text', 'label' => $this->l('Source Folder'), 'name' => 'source_folder', 'size' => 64, 'maxlength' => 255, 'required' => false, 'desc' => $this->l('Subfolder in the source to use as base dir :') . '<br/>' . $this->l('Relative path for GIT & SVN sources') . '<br/>' . $this->l('Absolute path for File Server sources')), array('type' => 'switch', 'label' => $this->l('Enabled :'), 'title' => $this->l('Enabled :'), 'name' => 'active', 'required' => true, 'desc' => $this->l('Enable or Disable the generation of this zip file'), 'is_bool' => true, 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled'))))), 'submit' => array('title' => $this->l('Save'))); return parent::renderForm(); }
public function beforeUpdateOptions() { if (!Tools::getValue('PS_STOCK_MANAGEMENT', true)) { $_POST['PS_ORDER_OUT_OF_STOCK'] = 1; $_POST['PS_DISPLAY_QTIES'] = 0; } // if advanced stock management is disabled, updates concerned tables if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') == 1 && (int) Tools::getValue('PS_ADVANCED_STOCK_MANAGEMENT') == 0 && Context::getContext()->shop->getContext() == Shop::CONTEXT_ALL) { ObjectModel::updateMultishopTable('Product', array('advanced_stock_management' => 0), 'product_shop.`advanced_stock_management` = 1'); Db::getInstance()->execute('UPDATE `' . _DB_PREFIX_ . 'stock_available` SET `depends_on_stock` = 0, `quantity` = 0 WHERE `depends_on_stock` = 1'); } if (Tools::getIsset('PS_CATALOG_MODE')) { Tools::clearSmartyCache(); Media::clearCache(); } }
private function _overrideTableDefinition($id_search) { $this->id_search = (int) $id_search ? (int) $id_search : (Tools::getIsset('id_search') && Tools::getValue('id_search') ? (int) Tools::getValue('id_search') : die('Missing id_search')); if (version_compare(_PS_VERSION_, '1.5.0.0', '>=')) { $className = get_class($this); self::$definition['table'] = $this->originalTable . '_' . (int) $this->id_search; self::$definition['classname'] = $className . '_' . (int) $this->id_search; $this->def['table'] = $this->originalTable . '_' . (int) $this->id_search; $this->def['classname'] = $className . '_' . (int) $this->id_search; if (isset(ObjectModel::$loaded_classes) && isset(ObjectModel::$loaded_classes[$className])) { unset(ObjectModel::$loaded_classes[$className]); } } $this->table = $this->originalTable . '_' . (int) $this->id_search; foreach ($this->originalTables as $key => $table) { $this->tables[$key] = $table . '_' . (int) $this->id_search; } }