public function postProcess()
 {
     global $currentIndex;
     if (Tools::isSubmit('submitPrint')) {
         if (!Validate::isDate(Tools::getValue('date_from'))) {
             $this->_errors[] = $this->l('Invalid from date');
         }
         if (!Validate::isDate(Tools::getValue('date_to'))) {
             $this->_errors[] = $this->l('Invalid end date');
         }
         if (!sizeof($this->_errors)) {
             $orders = Order::getOrdersIdInvoiceByDate(Tools::getValue('date_from'), Tools::getValue('date_to'), NULL, 'invoice');
             if (sizeof($orders)) {
                 Tools::redirectAdmin('pdf.php?invoices&date_from=' . urlencode(Tools::getValue('date_from')) . '&date_to=' . urlencode(Tools::getValue('date_to')) . '&token=' . $this->token);
             }
             $this->_errors[] = $this->l('No invoice found for this period');
         }
     } elseif (Tools::isSubmit('submitOptionsinvoice')) {
         if (intval(Tools::getValue('PS_INVOICE_NUMBER')) == 0) {
             $this->_errors[] = $this->l('Invalid invoice number');
         } else {
             parent::postProcess();
         }
     } else {
         parent::postProcess();
     }
 }
Example #2
0
    public function getContent()
    {
        $html = '';
        // If we try to update the settings
        if (Tools::isSubmit('submitModule')) {
            Configuration::updateValue('blockcontact_telnumber', Tools::getValue('telnumber'));
            Configuration::updateValue('blockcontact_email', Tools::getValue('email'));
            $html .= '<div class="confirm">' . $this->l('Configuration updated') . '</div>';
        }
        $html .= '
		<h2>' . $this->displayName . '</h2>
		<form action="' . Tools::htmlentitiesutf8($_SERVER['REQUEST_URI']) . '" method="post">
			<fieldset>			
				<label for="telnumber">' . $this->l('Telephone number:') . '</label>
				<input type="text" id="telnumber" name="telnumber" value="' . (Configuration::get('blockcontact_telnumber') != '' ? Tools::safeOutput(Configuration::get('blockcontact_telnumber')) : '') . '" />
				<div class="clear">&nbsp;</div>
				<label for="email">' . $this->l('Email:') . '</label>
				<input type="text" id="email" name="email" value="' . (Configuration::get('blockcontact_email') != '' ? Tools::safeOutput(Configuration::get('blockcontact_email')) : '') . '" />
				<div class="clear">&nbsp;</div>
				<div class="margin-form">
					<input type="submit" name="submitModule" value="' . $this->l('Update settings') . '" class="button" /></center>
				</div>
			</fieldset>
		</form>';
        return $html;
    }
Example #3
0
 public function getContent()
 {
     $output = '<h2>' . $this->displayName . '</h2>';
     if (Tools::isSubmit('submitBlockRss')) {
         $urlfeed = strval(Tools::getValue('urlfeed'));
         $title = strval(Tools::getValue('title'));
         $nbr = intval(Tools::getValue('nbr'));
         if ($urlfeed and !Validate::isUrl($urlfeed)) {
             $errors[] = $this->l('Invalid feed URL');
         } elseif (!$title or empty($title) or !Validate::isGenericName($title)) {
             $errors[] = $this->l('Invalid title');
         } elseif (!$nbr or $nbr <= 0 or !Validate::isInt($nbr)) {
             $errors[] = $this->l('Invalid number of feeds');
         } else {
             Configuration::updateValue('RSS_FEED_URL', $urlfeed);
             Configuration::updateValue('RSS_FEED_TITLE', $title);
             Configuration::updateValue('RSS_FEED_NBR', $nbr);
         }
         if (isset($errors) and sizeof($errors)) {
             $output .= $this->displayError(implode('<br />', $errors));
         } else {
             $output .= $this->displayConfirmation($this->l('Settings updated'));
         }
     }
     return $output . $this->displayForm();
 }
Example #4
0
 public function getContent()
 {
     $output = '';
     $errors = array();
     if (Tools::isSubmit('submitHomeFeatured')) {
         $nbr = Tools::getValue('HOME_FEATURED_NBR');
         if (!Validate::isInt($nbr) || $nbr <= 0) {
             $errors[] = $this->l('The number of products is invalid. Please enter a positive number.');
         }
         $cat = Tools::getValue('HOME_FEATURED_CAT');
         if (!Validate::isInt($cat) || $cat <= 0) {
             $errors[] = $this->l('The category ID is invalid. Please choose an existing category ID.');
         }
         $rand = Tools::getValue('HOME_FEATURED_RANDOMIZE');
         if (!Validate::isBool($rand)) {
             $errors[] = $this->l('Invalid value for the "randomize" flag.');
         }
         if (isset($errors) && count($errors)) {
             $output = $this->displayError(implode('<br />', $errors));
         } else {
             Configuration::updateValue('HOME_FEATURED_NBR', (int) $nbr);
             Configuration::updateValue('HOME_FEATURED_CAT', (int) $cat);
             Configuration::updateValue('HOME_FEATURED_RANDOMIZE', (bool) $rand);
             Tools::clearCache(Context::getContext()->smarty, $this->getTemplatePath('homefeatured.tpl'));
             $output = $this->displayConfirmation($this->l('Your settings have been updated.'));
         }
     }
     return $output . $this->renderForm();
 }
 public function getContent()
 {
     if (Tools::isSubmit('updatePositions')) {
         $this->updatePositionsDnd();
     }
     $helper = new HelperList();
     // Obligatoire
     $helper->shopLinkType = '';
     // Obligatoire. Correspondant souvent à id_*
     $helper->identifier = 'id_example_data';
     // Permet de ne pas afficher le header complet.
     $helper->simple_header = true;
     //
     $helper->module = $this;
     // Important.
     $helper->token = Tools::getAdminTokenLite('AdminModules');
     // Permet de définir le champ sur lequel est associé les positions.
     $helper->position_identifier = 'position';
     // Si utilisation des positions, obligatoire.
     $helper->orderBy = 'position';
     $helper->orderWay = 'ASC';
     // Permet de définir l'ID de la table. Le terme "module-" en préfixe est TRES important.
     $helper->table_id = 'module-helperlist_positions';
     // Ou encore
     $helper->table_id = 'module-' . $this->name;
     // Permet de récupérer les champs/headers de la liste. On passe par une méthode, par lisitibilité du code.
     $fields_list = $this->getListHeader();
     // Permet de récupérer les enregistrements/lignes de la liste. On passe par une méthode, par lisibilité du code.
     $values = $this->getListValues();
     return $helper->generateList($values, $fields_list);
 }
Example #6
0
 public function postProcess()
 {
     global $cookie;
     $this->tabAccess = Profile::getProfileAccess($cookie->profile, $this->id);
     if (Tools::isSubmit('submitAdd' . $this->table)) {
         if ($id_category = intval(Tools::getValue('id_category'))) {
             if (!Category::checkBeforeMove($id_category, intval(Tools::getValue('id_parent')))) {
                 $this->_errors[] = Tools::displayError('category cannot be moved here');
                 return false;
             }
             // Updating customer's group
             if ($this->tabAccess['edit'] !== '1') {
                 $this->_errors[] = Tools::displayError('You do not have permission to edit anything here.');
             } else {
                 $object = new $this->className($id_category);
                 if (Validate::isLoadedObject($object)) {
                     $object->updateGroup(Tools::getValue('groupBox'));
                 } else {
                     $this->_errors[] = Tools::displayError('an error occurred while updating object') . ' <b>' . $this->table . '</b> ' . Tools::displayError('(cannot load object)');
                 }
             }
         }
     }
     parent::postProcess();
 }
Example #7
0
 public function getContent()
 {
     $output = '';
     $errors = array();
     if (Tools::isSubmit('submitBlockTags')) {
         $tagsNbr = Tools::getValue('BLOCKTAGS_NBR');
         if (!strlen($tagsNbr)) {
             $errors[] = $this->l('Please complete the "Displayed tags" field.');
         } elseif (!Validate::isInt($tagsNbr) || (int) $tagsNbr <= 0) {
             $errors[] = $this->l('Invalid number.');
         }
         $tagsLevels = Tools::getValue('BLOCKTAGS_MAX_LEVEL');
         if (!strlen($tagsLevels)) {
             $errors[] = $this->l('Please complete the "Tag levels" field.');
         } elseif (!Validate::isInt($tagsLevels) || (int) $tagsLevels <= 0) {
             $errors[] = $this->l('Invalid value for "Tag levels". Choose a positive integer number.');
         }
         $randomize = Tools::getValue('BLOCKTAGS_RANDOMIZE');
         if (!strlen($randomize)) {
             $errors[] = $this->l('Please complete the "Randomize" field.');
         } elseif (!Validate::isBool($randomize)) {
             $errors[] = $this->l('Invalid value for "Randomize". It has to be a boolean.');
         }
         if (count($errors)) {
             $output = $this->displayError(implode('<br />', $errors));
         } else {
             Configuration::updateValue('BLOCKTAGS_NBR', (int) $tagsNbr);
             Configuration::updateValue('BLOCKTAGS_MAX_LEVEL', (int) $tagsLevels);
             Configuration::updateValue('BLOCKTAGS_RANDOMIZE', (bool) $randomize);
             $output = $this->displayConfirmation($this->l('Settings updated'));
         }
     }
     return $output . $this->renderForm();
 }
 public function preProcess()
 {
     parent::preProcess();
     $this->id_cart = (int) Tools::getValue('id_cart', 0);
     /* check if the cart has been made by a Guest customer, for redirect link */
     if (Cart::isGuestCartByCartId($this->id_cart)) {
         $redirectLink = 'guest-tracking.php';
     } else {
         $redirectLink = 'history.php';
     }
     $this->id_module = (int) Tools::getValue('id_module', 0);
     $this->id_order = Order::getOrderByCartId((int) $this->id_cart);
     $this->secure_key = Tools::getValue('key', false);
     if (!$this->id_order or !$this->id_module or !$this->secure_key or empty($this->secure_key)) {
         Tools::redirect($redirectLink . (Tools::isSubmit('slowvalidation') ? '?slowvalidation' : ''));
     }
     $order = new Order((int) $this->id_order);
     if (!Validate::isLoadedObject($order) or $order->id_customer != self::$cookie->id_customer or $this->secure_key != $order->secure_key) {
         Tools::redirect($redirectLink);
     }
     $module = Module::getInstanceById((int) $this->id_module);
     if ($order->payment != $module->displayName) {
         Tools::redirect($redirectLink);
     }
 }
 /**
  * Start forms process.
  *
  * @see FrontController::postProcess()
  */
 public function postProcess()
 {
     $order_reference = current(explode('#', Tools::getValue('order_reference')));
     $email = Tools::getValue('email');
     if (!$email && !$order_reference) {
         return;
     } elseif (!$email || !$order_reference) {
         $this->errors[] = $this->getTranslator()->trans('Please provide the required information', array(), 'Shop.Notifications.Error');
         return;
     }
     $isCustomer = Customer::customerExists($email, false, true);
     if ($isCustomer) {
         $this->info[] = $this->trans('Please log in to your customer account to view the order', array(), 'Shop.Notifications.Info');
         $this->redirectWithNotifications($this->context->link->getPageLink('history'));
     } else {
         $this->order = Order::getByReferenceAndEmail($order_reference, $email);
         if (!Validate::isLoadedObject($this->order)) {
             $this->errors[] = $this->getTranslator()->trans('We couldn\'t find your order with the information provided, please try again', array(), 'Shop.Notifications.Error');
         }
     }
     if (Tools::isSubmit('submitTransformGuestToCustomer') && Tools::getValue('password')) {
         $customer = new Customer((int) $this->order->id_customer);
         $password = Tools::getValue('password');
         if (strlen($password) < Validate::PASSWORD_LENGTH) {
             $this->errors[] = $this->trans('Your password must be at least %min% characters long.', array('%min%' => Validate::PASSWORD_LENGTH), 'Shop.Forms.Help');
         } elseif ($customer->transformToCustomer($this->context->language->id, $password)) {
             $this->success[] = $this->trans('Your guest account has been successfully transformed into a customer account. You can now log in as a registered shopper.', array(), 'Shop.Notifications.Success');
         } else {
             $this->success[] = $this->trans('An unexpected error occurred while creating your account.', array(), 'Shop.Notifications.Error');
         }
     }
 }
Example #10
0
 /**
  * Prestashop config page
  */
 public function getContent()
 {
     global $smarty;
     $errors = array();
     if (Tools::isSubmit('submitMtgox')) {
         foreach ($this->getConfigFields() as $field) {
             $field_val = Tools::getValue(strtolower($field['config_name']));
             if (isset($field['empty']) and $field['empty'] == false) {
                 if ($field_val != '0' and empty($field_val)) {
                     $errors[] = $this->l($field['display_name'] . ' field cannot be empty');
                     continue;
                 }
             }
             if (isset($field['boolean']) and $field['boolean'] == true) {
                 if (!in_array($field_val, array('0', '1'))) {
                     $errors[] = $this->l($field['display_name'] . ' field must be a string containing 0 or 1');
                     continue;
                 }
             }
             Configuration::updateValue($field['config_name'], $field_val);
         }
         if (!$errors) {
             // Retro 1.4
             global $currentIndex;
             $curr_index = Tools::property_exists('AdminController', 'currentIndex') ? AdminController::$currentIndex : $currentIndex;
             Tools::redirectAdmin($curr_index . '&configure=mtgox&token=' . Tools::safeOutput(Tools::getValue('token')) . '&conf=4');
         }
     }
     $smarty->assign(array('displayName' => $this->displayName, 'requestUrl' => Tools::safeOutput($_SERVER['REQUEST_URI']), 'merchantId' => Tools::safeOutput(Tools::getValue('mtgox_merchant_id', Configuration::get('MTGOX_MERCHANT_ID'))), 'apiKey' => Tools::safeOutput(Tools::getValue('mtgox_api_key', Configuration::get('MTGOX_API_KEY'))), 'apiSecretKey' => Tools::safeOutput(Tools::getValue('mtgox_api_secret_key', Configuration::get('MTGOX_API_SECRET_KEY'))), 'paymentDescription' => Tools::safeOutput(Tools::getValue('mtgox_payment_description', Configuration::get('MTGOX_PAYMENT_DESCRIPTION'))), 'autosell' => Tools::safeOutput(Tools::getValue('mtgox_autosell', Configuration::get('MTGOX_AUTOSELL'))), 'email' => Tools::safeOutput(Tools::getValue('mtgox_email_on_success', Configuration::get('MTGOX_EMAIL_ON_SUCCESS'))), 'instantonly' => Tools::safeOutput(Tools::getValue('mtgox_instant_only', Configuration::get('MTGOX_INSTANT_ONLY'))), 'submit' => Tools::isSubmit('submitMtgox'), 'errors' => $errors));
     return $this->display(__FILE__, 'views/templates/back/configure.tpl');
 }
 public function postProcess()
 {
     ${"GLOBALS"}["blpimnned"] = "id_order_seller";
     $dbodbxes = "id_order";
     ${${"GLOBALS"}["qusrvgm"]} = (int) Tools::getValue("id_order");
     if (!$this->context->customer->isLogged() && !Tools::getValue("secure_key")) {
         Tools::redirect("index.php?controller=authentication&back=my-account");
     }
     ${"GLOBALS"}["tvasln"] = "id_order";
     $jpdhpfqcj = "id_order";
     if (!(int) Configuration::get("PS_INVOICE")) {
         die(Tools::displayError("Invoices are disabled in this shop."));
     }
     if (isset(${${"GLOBALS"}["qusrvgm"]}) && Validate::isUnsignedId(${$dbodbxes})) {
         ${${"GLOBALS"}["ymjzko"]} = new Order(${$jpdhpfqcj});
     }
     if (!isset(${${"GLOBALS"}["ymjzko"]}) || !Validate::isLoadedObject(${${"GLOBALS"}["ymjzko"]})) {
         die(Tools::displayError("Invoice not found"));
     }
     ${${"GLOBALS"}["vewtbt"]} = AgileSellerManager::getObjectOwnerID("order", ${${"GLOBALS"}["tvasln"]});
     ${${"GLOBALS"}["sokafjqdei"]} = AgileSellerManager::getLinkedSellerID($this->context->customer->id);
     if (${${"GLOBALS"}["blpimnned"]} != ${${"GLOBALS"}["sokafjqdei"]}) {
         die(Tools::displayError("You do not have permission to see this invoice"));
     }
     if (Tools::isSubmit("secure_key") && $order->secure_key != Tools::getValue("secure_key")) {
         die(Tools::displayError("You do not have permission to see this invoice"));
     }
     if (!OrderState::invoiceAvailable($order->getCurrentState()) && !$order->invoice_number) {
         die(Tools::displayError("No invoice available"));
     }
     $this->order = ${${"GLOBALS"}["ymjzko"]};
 }
    public function getContent()
    {
        global $cookie;
        $html = '
		<h2>' . $this->l('Payment logo') . '</h2>
		';
        if (Tools::isSubmit('submitConfiguration')) {
            if (Validate::isUnsignedInt(Tools::getValue('id_cms'))) {
                Configuration::updateValue('PS_PAYMENT_LOGO_CMS_ID', intval(Tools::getValue('id_cms')));
                $html .= $this->displayConfirmation($this->l('Settings are updated'));
            }
        }
        $cmss = CMS::listCms(intval($cookie->id_lang));
        if (!sizeof($cmss)) {
            $html .= $this->displayError($this->l('No CMS page is available'));
        } else {
            $html .= '
			<form action="' . $_SERVER['REQUEST_URI'] . '" method="post">
				<fieldset>
					<legend><img src="' . $this->_path . '/logo.gif" alt="" /> ' . $this->l('Configure') . '</legend>
					<label>' . $this->l('Page CMS for link') . ':</label>
					<div class="margin-form">
						<select name="id_cms">';
            foreach ($cmss as $cms) {
                $html .= '<option value="' . $cms['id_cms'] . '"' . (Configuration::get('PS_PAYMENT_LOGO_CMS_ID') == $cms['id_cms'] ? ' selected="selected"' : '') . '>' . $cms['meta_title'] . '</option>';
            }
            $html .= '</select>
					</div>
					<p class="center"><input class="button" type="submit" name="submitConfiguration" value="' . $this->l('Save settings') . '" /></p>
				</fieldset>
			</form>
			';
        }
        return $html;
    }
    public function getContent()
    {
        $html = '
		<h2>' . $this->l('Payment logo.') . '</h2>
		';
        if (Tools::isSubmit('submitConfiguration')) {
            if (Validate::isUnsignedInt(Tools::getValue('id_cms'))) {
                Configuration::updateValue('PS_PAYMENT_LOGO_CMS_ID', (int) Tools::getValue('id_cms'));
                $this->_clearCache('blockpaymentlogo.tpl');
                $html .= $this->displayConfirmation($this->l('The settings have been updated.'));
            }
        }
        $cmss = CMS::listCms($this->context->language->id);
        if (!count($cmss)) {
            $html .= $this->displayError($this->l('No CMS page is available.'));
        } else {
            $html .= '
			<form action="' . Tools::safeOutput($_SERVER['REQUEST_URI']) . '" method="post">
				<fieldset>
					<legend><img src="' . $this->_path . '/logo.gif" alt="" /> ' . $this->l('Configure') . '</legend>
					<label>' . $this->l('Page CMS for link') . ':</label>
					<div class="margin-form">
						<select name="id_cms"><option value="0">(' . $this->l('Select a page') . ')</option>';
            foreach ($cmss as $cms) {
                $html .= '<option value="' . $cms['id_cms'] . '"' . (Configuration::get('PS_PAYMENT_LOGO_CMS_ID') == $cms['id_cms'] ? ' selected="selected"' : '') . '>' . $cms['meta_title'] . '</option>';
            }
            $html .= '</select>
					</div>
					<p class="center"><input class="button" type="submit" name="submitConfiguration" value="' . $this->l('Save settings') . '" /></p>
				</fieldset>
			</form>
			';
        }
        return $html;
    }
 protected function postProcess()
 {
     $errors = '';
     if (Tools::isSubmit('deleteImage')) {
         if (!file_exists(dirname(__FILE__) . '/img/' . $this->_getUserImg())) {
             $errors .= $this->displayError($this->l('This action cannot be taken.'));
         } else {
             unlink(dirname(__FILE__) . '/img/' . $this->_getUserImg());
             Tools::redirectAdmin('index.php?tab=AdminModules&conf=4&configure=' . $this->name . '&token=' . Tools::getAdminToken('AdminModules' . (int) Tab::getIdFromClassName('AdminModules') . (int) $this->context->employee->id));
         }
     }
     if (Tools::isSubmit('submitUpdateScrolltop')) {
         if (isset($_FILES['image']) && $_FILES['image']['error'] == 0) {
             if ($error = ImageManager::validateUpload($_FILES['image'])) {
                 $errors .= $this->displayError($error);
             } elseif (!ImageManager::resize($_FILES['image']['tmp_name'], dirname(__FILE__) . '/img/' . $this->_getUserImg())) {
                 $errors .= $this->displayError($this->l('An error occurred during the image upload.'));
             }
         }
         foreach ($this->_scrollParams as $param => $value) {
             if ($val = (int) Tools::getValue($param)) {
                 $this->_setScrollParam($param, $val);
             } else {
                 $errors .= $this->displayError($this->l('"' . $param . '" is not valid.'));
             }
         }
         if (!$errors) {
             Tools::redirectAdmin('index.php?tab=AdminModules&conf=4&configure=' . $this->name . '&token=' . Tools::getAdminToken('AdminModules' . (int) Tab::getIdFromClassName('AdminModules') . (int) $this->context->employee->id));
         }
     }
     $this->_html .= $errors;
 }
 public function preProcess()
 {
     if (!Tools::hasFunction('admin_list')) {
         Tools::redirect('index.php');
     }
     $this->brandNavi[] = array("name" => "Admin List", "url" => $this->php_self);
     $idList = $_POST['idlist'] == '' ? '' : $_POST['idlist'];
     if (Tools::isSubmit("delete")) {
         if (is_array($idList)) {
             foreach ($idList as $aid) {
                 Member::DeleteMember($aid);
             }
         }
         exit;
     } else {
         if (Tools::isSubmit("del_permanent")) {
             if (is_array($idList)) {
                 foreach ($idList as $aid) {
                     Member::DeleteMemberPermanent($aid);
                 }
             }
             exit;
         } else {
             if (Tools::isSubmit("undel")) {
                 if (is_array($idList)) {
                     foreach ($idList as $aid) {
                         Member::UnDeleteMember($aid);
                     }
                 }
                 exit;
             }
         }
     }
 }
 /**
  * Initialize order confirmation controller
  * @see FrontController::init()
  */
 public function init()
 {
     parent::init();
     $this->id_cart = (int) Tools::getValue('id_cart', 0);
     $is_guest = false;
     /* check if the cart has been made by a Guest customer, for redirect link */
     if (Cart::isGuestCartByCartId($this->id_cart)) {
         $is_guest = true;
         $redirectLink = 'index.php?controller=guest-tracking';
     } else {
         $redirectLink = 'index.php?controller=history';
     }
     $this->id_module = (int) Tools::getValue('id_module', 0);
     $this->id_order = Order::getOrderByCartId((int) $this->id_cart);
     $this->secure_key = Tools::getValue('key', false);
     $order = new Order((int) $this->id_order);
     if ($is_guest) {
         $customer = new Customer((int) $order->id_customer);
         $redirectLink .= '&id_order=' . $order->reference . '&email=' . urlencode($customer->email);
     }
     if (!$this->id_order || !$this->id_module || !$this->secure_key || empty($this->secure_key)) {
         Tools::redirect($redirectLink . (Tools::isSubmit('slowvalidation') ? '&slowvalidation' : ''));
     }
     $this->reference = $order->reference;
     if (!Validate::isLoadedObject($order) || $order->id_customer != $this->context->customer->id || $this->secure_key != $order->secure_key) {
         Tools::redirect($redirectLink);
     }
     $module = Module::getInstanceById((int) $this->id_module);
     if ($order->payment != $module->displayName) {
         Tools::redirect($redirectLink);
     }
 }
Example #17
0
    public static function getJobForm($title = 'New cron task', $update = false)
    {
        $form = array(array('form' => array('legend' => array('title' => self::$module->l($title), 'icon' => 'icon-plus'), 'input' => array(), 'submit' => array('title' => self::$module->l('Save', 'CronJobsForms'), 'type' => 'submit', 'class' => 'btn btn-default pull-right'))));
        $id_shop = (int) Context::getContext()->shop->id;
        $id_shop_group = (int) Context::getContext()->shop->id_shop_group;
        $currencies_cron_url = Tools::getShopDomain(true, true) . __PS_BASE_URI__ . basename(_PS_ADMIN_DIR_);
        $currencies_cron_url .= '/cron_currency_rates.php?secure_key=' . md5(_COOKIE_KEY_ . Configuration::get('PS_SHOP_NAME'));
        if ($update == true && Tools::isSubmit('id_cronjob')) {
            $id_cronjob = (int) Tools::getValue('id_cronjob');
            $id_module = (int) Db::getInstance()->getValue('SELECT `id_module` FROM `' . _DB_PREFIX_ . self::$module->name . '`
				WHERE `id_cronjob` = \'' . (int) $id_cronjob . '\'
					AND `id_shop` = \'' . $id_shop . '\' AND `id_shop_group` = \'' . $id_shop_group . '\'');
            if ((bool) $id_module == true) {
                $form[0]['form']['input'][] = array('type' => 'free', 'name' => 'description', 'label' => self::$module->l('Task description', 'CronJobsForms'), 'placeholder' => self::$module->l('Update my currencies', 'CronJobsForms'));
                $form[0]['form']['input'][] = array('type' => 'free', 'name' => 'task', 'label' => self::$module->l('Target link', 'CronJobsForms'));
            } else {
                $form[0]['form']['input'][] = array('type' => 'text', 'name' => 'description', 'label' => self::$module->l('Task description', 'CronJobsForms'), 'desc' => self::$module->l('Enter a description for this task.', 'CronJobsForms'), 'placeholder' => self::$module->l('Update my currencies', 'CronJobsForms'));
                $form[0]['form']['input'][] = array('type' => 'text', 'name' => 'task', 'label' => self::$module->l('Target link', 'CronJobsForms'), 'desc' => self::$module->l('Set the link of your cron task.', 'CronJobsForms'), 'placeholder' => $currencies_cron_url);
            }
        } else {
            $form[0]['form']['input'][] = array('type' => 'text', 'name' => 'description', 'label' => self::$module->l('Task description', 'CronJobsForms'), 'desc' => self::$module->l('Enter a description for this task.', 'CronJobsForms'), 'placeholder' => self::$module->l('Update my currencies', 'CronJobsForms'));
            $form[0]['form']['input'][] = array('type' => 'text', 'name' => 'task', 'label' => self::$module->l('Target link', 'CronJobsForms'), 'desc' => self::$module->l('Do not forget to use an absolute URL to make it valid! The link also has to be on the same domain as the shop.', 'CronJobsForms'), 'placeholder' => $currencies_cron_url);
        }
        $form[0]['form']['input'][] = array('type' => 'select', 'name' => 'hour', 'label' => self::$module->l('Task frequency', 'CronJobsForms'), 'desc' => self::$module->l('At what time should this task be executed?', 'CronJobsForms'), 'options' => array('query' => self::getHoursFormOptions(), 'id' => 'id', 'name' => 'name'));
        $form[0]['form']['input'][] = array('type' => 'select', 'name' => 'day', 'desc' => self::$module->l('On which day of the month should this task be executed?', 'CronJobsForms'), 'options' => array('query' => self::getDaysFormOptions(), 'id' => 'id', 'name' => 'name'));
        $form[0]['form']['input'][] = array('type' => 'select', 'name' => 'month', 'desc' => self::$module->l('On what month should this task be executed?', 'CronJobsForms'), 'options' => array('query' => self::getMonthsFormOptions(), 'id' => 'id', 'name' => 'name'));
        $form[0]['form']['input'][] = array('type' => 'select', 'name' => 'day_of_week', 'desc' => self::$module->l('On which day of the week should this task be executed?', 'CronJobsForms'), 'options' => array('query' => self::getDaysofWeekFormOptions(), 'id' => 'id', 'name' => 'name'));
        return $form;
    }
 public function postProcess()
 {
     global $currentIndex;
     if (isset($_POST['submitLocalization' . $this->table])) {
         if ($this->tabAccess['edit'] === '1') {
             $this->_postConfig($this->_fieldsLocalization);
         } else {
             $this->_errors[] = Tools::displayError('You do not have permission to edit here.');
         }
     } elseif (Tools::isSubmit('submitLocalizationPack')) {
         if (!($pack = @Tools::file_get_contents('http://www.prestashop.com/download/localization/' . Tools::getValue('iso_localization_pack') . '.xml')) and !($pack = @Tools::file_get_contents(dirname(__FILE__) . '/../../localization/' . Tools::getValue('iso_localization_pack') . '.xml'))) {
             $this->_errors[] = Tools::displayError('Cannot load localization pack (from prestashop.com and from your local folder "localization")');
         } elseif (!($selection = Tools::getValue('selection'))) {
             $this->_errors[] = Tools::displayError('Please select at least one content item to import.');
         } else {
             foreach ($selection as $selected) {
                 if (!Validate::isLocalizationPackSelection($selected)) {
                     $this->_errors[] = Tools::displayError('Invalid selection');
                     return;
                 }
             }
             $localizationPack = new LocalizationPack();
             if (!$localizationPack->loadLocalisationPack($pack, $selection)) {
                 $this->_errors = array_merge($this->_errors, $localizationPack->getErrors());
             } else {
                 Tools::redirectAdmin($currentIndex . '&conf=23&token=' . $this->token);
             }
         }
     }
     parent::postProcess();
 }
 public function postProcess()
 {
     if (Tools::isSubmit('submitLocalizationPack')) {
         $version = str_replace('.', '', _PS_VERSION_);
         $version = substr($version, 0, 2);
         if (Validate::isFileName(Tools::getValue('iso_localization_pack'))) {
             $pack = @Tools::file_get_contents('http://api.prestashop.com/localization/' . $version . '/' . Tools::getValue('iso_localization_pack') . '.xml');
             if (!$pack && !($pack = @Tools::file_get_contents(dirname(__FILE__) . '/../../localization/' . Tools::getValue('iso_localization_pack') . '.xml'))) {
                 $this->errors[] = Tools::displayError('Cannot load the localization pack.');
             }
             if (!($selection = Tools::getValue('selection'))) {
                 $this->errors[] = Tools::displayError('Please select at least one item to import.');
             } else {
                 foreach ($selection as $selected) {
                     if (!Validate::isLocalizationPackSelection($selected)) {
                         $this->errors[] = Tools::displayError('Invalid selection');
                         return;
                     }
                 }
                 $localization_pack = new LocalizationPack();
                 if (!$localization_pack->loadLocalisationPack($pack, $selection)) {
                     $this->errors = array_merge($this->errors, $localization_pack->getErrors());
                 } else {
                     Tools::redirectAdmin(self::$currentIndex . '&conf=23&token=' . $this->token);
                 }
             }
         }
     }
     // Remove the module list cache if the default country changed
     if (Tools::isSubmit('submitOptionsconfiguration') && file_exists(Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST)) {
         @unlink(Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST);
     }
     parent::postProcess();
 }
Example #20
0
 /**
  * @see InstallAbstractModel::processNextStep()
  */
 public function processNextStep()
 {
     if (Tools::isSubmit('shop_name')) {
         // Save shop configuration
         $this->session->shop_name = trim(Tools::getValue('shop_name'));
         $this->session->shop_activity = Tools::getValue('shop_activity');
         $this->session->install_type = Tools::getValue('db_mode');
         $this->session->shop_country = Tools::getValue('shop_country');
         $this->session->shop_timezone = Tools::getValue('shop_timezone');
         // Save admin configuration
         $this->session->admin_firstname = trim(Tools::getValue('admin_firstname'));
         $this->session->admin_lastname = trim(Tools::getValue('admin_lastname'));
         $this->session->admin_email = trim(Tools::getValue('admin_email'));
         $this->session->send_informations = Tools::getValue('send_informations');
         if ($this->session->send_informations) {
             $params = http_build_query(array('email' => $this->session->admin_email, 'method' => 'addMemberToNewsletter', 'language' => $this->session->lang, 'visitorType' => 1, 'source' => 'installer'));
             Tools::file_get_contents('http://www.prestashop.com/ajax/controller.php?' . $params);
         }
         // If password fields are empty, but are already stored in session, do not fill them again
         if (!$this->session->admin_password || trim(Tools::getValue('admin_password'))) {
             $this->session->admin_password = trim(Tools::getValue('admin_password'));
         }
         if (!$this->session->admin_password_confirm || trim(Tools::getValue('admin_password_confirm'))) {
             $this->session->admin_password_confirm = trim(Tools::getValue('admin_password_confirm'));
         }
     }
 }
Example #21
0
 public function postProcess()
 {
     parent::postProcess();
     if (Tools::isSubmit('markAsReceived')) {
         $idOrder = (int) Tools::getValue('id_order');
         $order = new Order($idOrder);
         if (Validate::isLoadedObject($order)) {
             if ($order->getCurrentState() == 15) {
                 $new_history = new OrderHistory();
                 $new_history->id_order = (int) $order->id;
                 $new_history->changeIdOrderState(16, $order);
                 // 16: Ready for Production
                 //var_dump($order,$new_history);
                 $myfile = fopen(PS_PRODUCT_IMG_PATH . "/orders/" . $order->reference . ".txt", "w") or die("Unable to open file!");
                 $txt = "Order Confirmed\n Order Reference: " . $order->reference;
                 fwrite($myfile, $txt);
                 fclose($myfile);
                 $new_history->addWithemail(true);
             }
             $this->context->smarty->assign('receipt_confirmation', true);
         } else {
             $this->_errors[] = Tools::displayError('Error: Invalid order number');
         }
     }
 }
 public function postProcess()
 {
     if (Tools::isSubmit('submitStoreConf')) {
         Configuration::updateValue('PRODUCTPAYMENTLOGOS_LINK', Tools::getValue('PRODUCTPAYMENTLOGOS_LINK'));
         Configuration::updateValue('PRODUCTPAYMENTLOGOS_TITLE', Tools::getValue('PRODUCTPAYMENTLOGOS_TITLE'));
         if (isset($_FILES['PRODUCTPAYMENTLOGOS_IMG']) && isset($_FILES['PRODUCTPAYMENTLOGOS_IMG']['tmp_name']) && !empty($_FILES['PRODUCTPAYMENTLOGOS_IMG']['tmp_name'])) {
             if (ImageManager::validateUpload($_FILES['PRODUCTPAYMENTLOGOS_IMG'], 4000000)) {
                 return $this->displayError($this->l('Invalid image'));
             } else {
                 $ext = Tools::substr($_FILES['PRODUCTPAYMENTLOGOS_IMG']['name'], Tools::strrpos($_FILES['PRODUCTPAYMENTLOGOS_IMG']['name'], '.') + 1);
                 $file_name = md5($_FILES['PRODUCTPAYMENTLOGOS_IMG']['name']) . '.' . $ext;
                 if (!move_uploaded_file($_FILES['PRODUCTPAYMENTLOGOS_IMG']['tmp_name'], dirname(__FILE__) . '/img/' . $file_name)) {
                     return $this->displayError($this->l('An error occurred while attempting to upload the file.'));
                 } else {
                     $file_path = dirname(__FILE__) . '/img/' . Configuration::get('PRODUCTPAYMENTLOGOS_IMG');
                     if (Configuration::hasContext('PRODUCTPAYMENTLOGOS_IMG', null, Shop::getContext()) && Configuration::get('PRODUCTPAYMENTLOGOS_IMG') != $file_name && file_exists($file_path)) {
                         unlink($file_path);
                     }
                     Configuration::updateValue('PRODUCTPAYMENTLOGOS_IMG', $file_name);
                     $this->_clearCache('productpaymentlogos.tpl');
                     Tools::redirectAdmin('index.php?tab=AdminModules&conf=6&configure=' . $this->name . '&token=' . Tools::getAdminTokenLite('AdminModules'));
                 }
             }
         }
         $this->_clearCache('productpaymentlogos.tpl');
     }
     return '';
 }
Example #23
0
 /**
  * Start forms process
  * @see FrontController::postProcess()
  */
 public function postProcess()
 {
     if (Tools::isSubmit('submitMessage')) {
         $idOrder = (int) Tools::getValue('id_order');
         $msgText = Tools::getValue('msgText');
         if (!$idOrder || !Validate::isUnsignedId($idOrder)) {
             $this->errors[] = Tools::displayError('The order is no longer valid.');
         } elseif (empty($msgText)) {
             $this->errors[] = Tools::displayError('The message cannot be blank.');
         } elseif (!Validate::isMessage($msgText)) {
             $this->errors[] = Tools::displayError('This message is invalid (HTML is not allowed).');
         }
         if (!count($this->errors)) {
             $order = new Order($idOrder);
             if (Validate::isLoadedObject($order) && $order->id_customer == $this->context->customer->id) {
                 //check if a thread already exist
                 $id_customer_thread = CustomerThread::getIdCustomerThreadByEmailAndIdOrder($this->context->customer->email, $order->id);
                 $cm = new CustomerMessage();
                 if (!$id_customer_thread) {
                     $ct = new CustomerThread();
                     $ct->id_contact = 0;
                     $ct->id_customer = (int) $order->id_customer;
                     $ct->id_shop = (int) $this->context->shop->id;
                     if (($id_product = (int) Tools::getValue('id_product')) && $order->orderContainProduct((int) $id_product)) {
                         $ct->id_product = $id_product;
                     }
                     $ct->id_order = (int) $order->id;
                     $ct->id_lang = (int) $this->context->language->id;
                     $ct->email = $this->context->customer->email;
                     $ct->status = 'open';
                     $ct->token = Tools::passwdGen(12);
                     $ct->add();
                 } else {
                     $ct = new CustomerThread((int) $id_customer_thread);
                 }
                 $cm->id_customer_thread = $ct->id;
                 $cm->message = $msgText;
                 $cm->ip_address = ip2long($_SERVER['REMOTE_ADDR']);
                 $cm->add();
                 if (!Configuration::get('PS_MAIL_EMAIL_MESSAGE')) {
                     $to = strval(Configuration::get('PS_SHOP_EMAIL'));
                 } else {
                     $to = new Contact((int) Configuration::get('PS_MAIL_EMAIL_MESSAGE'));
                     $to = strval($to->email);
                 }
                 $toName = strval(Configuration::get('PS_SHOP_NAME'));
                 $customer = $this->context->customer;
                 if (Validate::isLoadedObject($customer)) {
                     Mail::Send($this->context->language->id, 'order_customer_comment', Mail::l('Message from a customer'), array('{lastname}' => $customer->lastname, '{firstname}' => $customer->firstname, '{email}' => $customer->email, '{id_order}' => (int) $order->id, '{order_name}' => $order->getUniqReference(), '{message}' => Tools::nl2br($msgText)), $to, $toName, $customer->email, $customer->firstname . ' ' . $customer->lastname);
                 }
                 if (Tools::getValue('ajax') != 'true') {
                     Tools::redirect('index.php?controller=order-detail&id_order=' . (int) $idOrder);
                 }
                 $this->context->smarty->assign('message_confirmation', true);
             } else {
                 $this->errors[] = Tools::displayError('Order not found');
             }
         }
     }
 }
 public function renderList()
 {
     if (Tools::isSubmit('submitBulkdelete' . $this->table) || Tools::isSubmit('delete' . $this->table)) {
         $this->tpl_list_vars = array('delete_whitelist' => true, 'REQUEST_URI' => $_SERVER['REQUEST_URI'], 'POST' => $_POST);
     }
     return parent::renderList();
 }
Example #25
0
 public function getContent()
 {
     $output = '';
     if (Tools::isSubmit('submitBlockLeoBlogs')) {
         if (!($productNbr = Tools::getValue('BLEOBLOGS_NBR')) || empty($productNbr)) {
             $output .= $this->displayError($this->l('You must fill in the \'Products displayed\' field.'));
         } elseif ((int) $productNbr == 0) {
             $output .= $this->displayError($this->l('Invalid number.'));
         } else {
             Configuration::updateValue('BLEOBLOGS_NBR', (int) $productNbr);
             Configuration::updateValue('BLEOBLOGS_WIDTH', (int) Tools::getValue('BLEOBLOGS_WIDTH'));
             Configuration::updateValue('BLEOBLOGS_HEIGHT', (int) Tools::getValue('BLEOBLOGS_HEIGHT'));
             Configuration::updateValue('BLEOBLOGS_PAGE', (int) Tools::getValue('BLEOBLOGS_PAGE'));
             Configuration::updateValue('BLEOBLOGS_COL', (int) Tools::getValue('BLEOBLOGS_COL'));
             Configuration::updateValue('BLEOBLOGS_INTV', (int) Tools::getValue('BLEOBLOGS_INTV'));
             Configuration::updateValue('BLEOBLOGS_SHOW', (int) Tools::getValue('BLEOBLOGS_SHOW'));
             Configuration::updateValue('BLEOBLOGS_SDES', (int) Tools::getValue('BLEOBLOGS_SDES'));
             Configuration::updateValue('BLEOBLOGS_SIMA', (int) Tools::getValue('BLEOBLOGS_SIMA'));
             Configuration::updateValue('BLEOBLOGS_SAUT', (int) Tools::getValue('BLEOBLOGS_SAUT'));
             Configuration::updateValue('BLEOBLOGS_SCAT', (int) Tools::getValue('BLEOBLOGS_SCAT'));
             Configuration::updateValue('BLEOBLOGS_SCRE', (int) Tools::getValue('BLEOBLOGS_SCRE'));
             Configuration::updateValue('BLEOBLOGS_STITLE', (int) Tools::getValue('BLEOBLOGS_STITLE'));
             Configuration::updateValue('BLEOBLOGS_SCOUN', (int) Tools::getValue('BLEOBLOGS_SCOUN'));
             Configuration::updateValue('BLEOBLOGS_SHITS', (int) Tools::getValue('BLEOBLOGS_SHITS'));
             $output .= $this->displayConfirmation($this->l('Settings updated'));
         }
     }
     return $output . $this->renderForm();
 }
Example #26
0
 public function getContent()
 {
     if (Tools::isSubmit('submit')) {
         if (!sizeof($this->_postErrors)) {
             $t = getdate();
             $date = $t["year"] . "-" . $t["mon"] . "-" . $t["mday"] . "(" . $t["hours"] . ":" . $t["minutes"] . ":" . $t["seconds"] . ")";
             Configuration::updateValue('gw_alipay_mer_id', Tools::getValue('shop_code'), true);
             Configuration::updateValue('gw_alipay_encryption', Tools::getValue('encryption_code'), true);
             $this->_html .= '<div class="conf confirm">' . $this->l('Success Updata') . "   " . $date . '</div>';
         } else {
             foreach ($this->_postErrors as $err) {
                 $this->_html .= '<div class"alert error">' . $err . "</div>";
             }
         }
     }
     //如果Configuration資料庫已經有greenworld_vacc_encryption_code 與 greenworld_vacc_shop_code
     //的值,則直接抓取出來資料並顯示。
     if (!Configuration::get($this->name . '_encry_code') == null) {
         $this->_encryption_code = Configuration::get($this->name . '_encry_code');
     } else {
         $this->_encryption_code = 'Enter Encryption Code';
     }
     if (!Configuration::get($this->name . '_shop_code') == null) {
         $this->_shop_code = Configuration::get($this->name . '_shop_code');
     } else {
         $this->_shop_code = 'Enter Shop Code';
     }
     $this->_displayForm();
     return $this->_html;
 }
Example #27
0
 function getContent()
 {
     $output = '';
     if (Tools::isSubmit('submitBlockSuppliers')) {
         $text_list = (int) Tools::getValue('SUPPLIER_DISPLAY_TEXT');
         $text_nb = (int) Tools::getValue('SUPPLIER_DISPLAY_TEXT_NB');
         $form_list = (int) Tools::getValue('SUPPLIER_DISPLAY_FORM');
         if ($text_list and !Validate::isUnsignedInt($text_nb)) {
             $errors[] = $this->l('Invalid number of elements.');
         } elseif (!$text_list and !$form_list) {
             $errors[] = $this->l('Please activate at least one type of list.');
         } else {
             Configuration::updateValue('SUPPLIER_DISPLAY_TEXT', $text_list);
             Configuration::updateValue('SUPPLIER_DISPLAY_TEXT_NB', $text_nb);
             Configuration::updateValue('SUPPLIER_DISPLAY_FORM', $form_list);
             $this->_clearCache('blocksupplier.tpl');
         }
         if (isset($errors) and sizeof($errors)) {
             $output .= $this->displayError(implode('<br />', $errors));
         } else {
             $output .= $this->displayConfirmation($this->l('Settings updated.'));
         }
     }
     return $output . $this->renderForm();
 }
Example #28
0
    public function getContent()
    {
        $this->_html = '';
        if (Tools::isSubmit('submitCross') and Tools::getValue('displayPrice') != 0 and Tools::getValue('displayPrice') != 1) {
            $this->_html .= $this->displayError('Invalid displayPrice');
        } elseif (Tools::isSubmit('submitCross')) {
            Configuration::updateValue('CROSSSELLING_DISPLAY_PRICE', (int) Tools::getValue('displayPrice'));
            $this->_html .= $this->displayConfirmation($this->l('Settings updated successfully'));
        }
        $this->_html .= '
		<form action="' . Tools::safeOutput($_SERVER['REQUEST_URI']) . '" method="post">
		<fieldset><legend><img src="' . $this->_path . 'logo.gif" alt="" title="" />' . $this->l('Settings') . '</legend>
			<label>' . $this->l('Display price on products') . '</label>
			<div class="margin-form">
				<input type="radio" name="displayPrice" id="display_on" value="1" ' . (Configuration::get('CROSSSELLING_DISPLAY_PRICE') ? 'checked="checked" ' : '') . '/>
				<label class="t" for="display_on"> <img src="../img/admin/enabled.gif" alt="' . $this->l('Enabled') . '" title="' . $this->l('Enabled') . '" /></label>
				<input type="radio" name="displayPrice" id="display_off" value="0" ' . (!Configuration::get('CROSSSELLING_DISPLAY_PRICE') ? 'checked="checked" ' : '') . '/>
				<label class="t" for="display_off"> <img src="../img/admin/disabled.gif" alt="' . $this->l('Disabled') . '" title="' . $this->l('Disabled') . '" /></label>
				<p class="clear">' . $this->l('Show the price on the products in the block.') . '</p>
			</div>
			<center><input type="submit" name="submitCross" value="' . $this->l('Save') . '" class="button" /></center>
		</fieldset>
		</form>';
        return $this->_html;
    }
 public function postProcess()
 {
     if (Tools::isSubmit('submitAdd' . $this->table)) {
         if ($id = intval(Tools::getValue('id_attachment')) and $a = new Attachment($id)) {
             $_POST['file'] = $a->file;
             $_POST['mime'] = $a->mime;
         }
         if (!sizeof($this->_errors)) {
             if (isset($_FILES['file']) and is_uploaded_file($_FILES['file']['tmp_name'])) {
                 if ($_FILES['file']['size'] > $this->maxFileSize) {
                     $this->_errors[] = $this->l('File too large, maximum size allowed:') . ' ' . $this->maxFileSize / 1000 . ' ' . $this->l('kb');
                 } else {
                     $uploadDir = dirname(__FILE__) . '/../../download/';
                     do {
                         $uniqid = sha1(microtime());
                     } while (file_exists($uploadDir . $uniqid));
                     if (!copy($_FILES['file']['tmp_name'], $uploadDir . $uniqid)) {
                         $this->_errors[] = $this->l('File copy failed');
                     }
                     @unlink($_FILES['file']['tmp_name']);
                     $_POST['name_2'] .= '.' . pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION);
                     $_POST['file'] = $uniqid;
                     $_POST['mime'] = $_FILES['file']['type'];
                 }
             }
         }
         $this->validateRules();
     }
     return parent::postProcess();
 }
 public function getContent()
 {
     $output = '<h2>' . $this->displayName . '</h2>';
     if (Tools::isSubmit('submitBlockManufacturers')) {
         $text_list = (int) Tools::getValue('text_list');
         $text_nb = (int) Tools::getValue('text_nb');
         $form_list = (int) Tools::getValue('form_list');
         if ($text_list && !Validate::isUnsignedInt($text_nb)) {
             $errors[] = $this->l('There is an invalid number of elements');
         } elseif (!$text_list && !$form_list) {
             $errors[] = $this->l('Please activate at least one system list.');
         } else {
             Configuration::updateValue('MANUFACTURER_DISPLAY_TEXT', $text_list);
             Configuration::updateValue('MANUFACTURER_DISPLAY_TEXT_NB', $text_nb);
             Configuration::updateValue('MANUFACTURER_DISPLAY_FORM', $form_list);
             $this->_clearCache('blockmanufacturer.tpl');
         }
         if (isset($errors) && count($errors)) {
             $output .= $this->displayError(implode('<br />', $errors));
         } else {
             $output .= $this->displayConfirmation($this->l('Settings updated'));
         }
     }
     return $output . $this->displayForm();
 }