当前位置: 首页>>代码示例>>PHP>>正文


PHP Validate::isDiscountName方法代码示例

本文整理汇总了PHP中Validate::isDiscountName方法的典型用法代码示例。如果您正苦于以下问题:PHP Validate::isDiscountName方法的具体用法?PHP Validate::isDiscountName怎么用?PHP Validate::isDiscountName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Validate的用法示例。


在下文中一共展示了Validate::isDiscountName方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getContent

    public function getContent()
    {
        if (Tools::isSubmit('submitUpdate')) {
            Configuration::updateValue('NW_CONFIRMATION_EMAIL', (bool) Tools::getValue('NW_CONFIRMATION_EMAIL'));
            Configuration::updateValue('NW_VERIFICATION_EMAIL', (bool) Tools::getValue('NW_VERIFICATION_EMAIL'));
            $voucher = Tools::getValue('NW_VOUCHER_CODE');
            if ($voucher && !Validate::isDiscountName($voucher)) {
                $this->_html .= $this->displayError($this->l('The voucher code is invalid.'));
            } else {
                Configuration::updateValue('NW_VOUCHER_CODE', pSQL($voucher));
                $this->_html .= $this->displayConfirmation($this->l('Settings updated'));
            }
        } elseif (Tools::isSubmit('subscribedmerged')) {
            $id = Tools::getValue('id');
            if (preg_match('/(^N)/', $id)) {
                $id = (int) substr($id, 1);
                $sql = 'UPDATE ' . _DB_PREFIX_ . 'newsletter SET active = 0 WHERE id = ' . $id;
                Db::getInstance()->execute($sql);
            } else {
                $c = new Customer((int) $id);
                $c->newsletter = (int) (!$c->newsletter);
                $c->update();
            }
            Tools::redirectAdmin($this->context->link->getAdminLink('AdminModules', false) . '&configure=' . $this->name . '&conf=4&token=' . Tools::getAdminTokenLite('AdminModules'));
        } elseif (Tools::isSubmit('exportSubscribers')) {
            $header = array('id', 'shop_name', 'gender', 'lastname', 'firstname', 'email', 'subscribed', 'subscribed_on');
            // TODO
            $array_to_export = array_merge(array($header), $this->getSubscribers());
            $file_name = time() . '.csv';
            $fd = fopen($this->getLocalPath() . $file_name, 'w+');
            foreach ($array_to_export as $tab) {
                $line = implode(';', $tab);
                $line .= "\n";
                fwrite($fd, $line, 4096);
            }
            fclose($fd);
            Tools::redirect(_PS_BASE_URL_ . __PS_BASE_URI__ . 'modules/' . $this->name . '/' . $file_name);
        } elseif (Tools::isSubmit('exportOnlyBlockNews')) {
            $array_to_export = $this->getBlockNewsletterSubscriber();
            $file_name = time() . '.csv';
            $fd = fopen($this->getLocalPath() . $file_name, 'w+');
            foreach ($array_to_export as $tab) {
                $line = implode(';', $tab);
                $line .= "\n";
                fwrite($fd, $line, 4096);
            }
            fclose($fd);
            Tools::redirect(_PS_BASE_URL_ . __PS_BASE_URI__ . 'modules/' . $this->name . '/' . $file_name);
        } elseif (Tools::isSubmit('searchEmail')) {
            $this->_searched_email = Tools::getValue('searched_email');
        }
        $this->_html .= $this->renderForm();
        $this->_html .= $this->renderSearchForm();
        $this->_html .= $this->renderList();
        $this->_html .= '<div class="panel"><a href="' . $this->context->link->getAdminLink('AdminModules', false) . '&exportSubscribers&configure=' . $this->name . '&token=' . Tools::getAdminTokenLite('AdminModules') . '">
    <button class="btn btn-default btn-lg"><span class="icon icon-share"></span> ' . $this->l('Export as CSV') . '</button>
</a></div>';
        $this->_html .= $this->renderExportForm();
        return $this->_html;
    }
开发者ID:NathanGiesbrecht,项目名称:PrestaShopAutomationFramework,代码行数:60,代码来源:blocknewsletter.php

示例2: processOrderStep

 function processOrderStep($params)
 {
     global $errors, $cart, $smarty, $order_pages_hook_stay;
     /* Manage discounts */
     if (intval(Tools::getValue('addDiscount')) == 1) {
         $discountName = Tools::getValue('discount_name');
         if (!Validate::isDiscountName($discountName)) {
             $errors[] = Tools::displayError('voucher name not valid');
         } else {
             $discount = new Discount(intval(Discount::getIdByName($discountName)));
             if (is_object($discount) and $discount->id) {
                 if ($tmpError = $cart->checkDiscountValidity($discount, $cart->getDiscounts(), $cart->getOrderTotalLC(), $cart->getProducts(), true)) {
                     $errors[] = $tmpError;
                 }
             } else {
                 $errors[] = Tools::displayError('voucher name not valid');
             }
             if (!sizeof($errors)) {
                 $cart->addDiscount(intval($discount->id));
             }
         }
         // Why do we need a redirect here? Copied from
         // original order.php source. Seems like
         // otherwize the cart display doesn't get
         // updated properly
         Tools::redirect('order.php?step=' . $params['step']);
     } elseif (intval(Tools::getValue('deleteDiscount')) == 1) {
         if (Validate::isUnsignedId($_GET['deleteDiscount'])) {
             $cart->deleteDiscount(intval($_GET['deleteDiscount']));
         }
         Tools::redirect('order.php?step=' . $params['step']);
     }
 }
开发者ID:redb,项目名称:prestashop,代码行数:33,代码来源:ordersummary.php

示例3: getContent

 public function getContent()
 {
     $this->_html = '<h2>' . $this->displayName . '</h2>';
     if (Tools::isSubmit('submitUpdate')) {
         if (isset($_POST['new_page']) and Validate::isBool((int) $_POST['new_page'])) {
             Configuration::updateValue('NW_CONFIRMATION_NEW_PAGE', $_POST['new_page']);
         }
         if (isset($_POST['conf_email']) and VAlidate::isBool((int) $_POST['conf_email'])) {
             Configuration::updateValue('NW_CONFIRMATION_EMAIL', pSQL($_POST['conf_email']));
         }
         if (!empty($_POST['voucher']) and !Validate::isDiscountName($_POST['voucher'])) {
             $this->_html .= '<div class="alert">' . $this->l('Voucher code is invalid') . '</div>';
         } else {
             Configuration::updateValue('NW_VOUCHER_CODE', pSQL($_POST['voucher']));
             $this->_html .= '<div class="conf ok">' . $this->l('Updated') . '</div>';
         }
     }
     return $this->_displayForm();
 }
开发者ID:greench,项目名称:prestashop,代码行数:19,代码来源:blocknewsletter.php

示例4: getIdByName

    /**
     * Get discount ID from name
     *
     * @param string $discountName Discount name
     * @return integer Discount ID
     */
    public static function getIdByName($discountName)
    {
        if (!Validate::isDiscountName($discountName)) {
            die(Tools::displayError());
        }
        $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
		SELECT `id_discount`
		FROM `' . _DB_PREFIX_ . 'discount`
		WHERE `name` = \'' . pSQL($discountName) . '\'');
        return isset($result['id_discount']) ? $result['id_discount'] : false;
    }
开发者ID:greench,项目名称:prestashop,代码行数:17,代码来源:Discount.php

示例5: preProcess

 public function preProcess()
 {
     global $isVirtualCart;
     parent::preProcess();
     // Redirect to the good order process
     if (Configuration::get('PS_ORDER_PROCESS_TYPE') == 0 and strpos($_SERVER['PHP_SELF'], 'order.php') === false) {
         Tools::redirect('order.php');
     }
     if (Configuration::get('PS_ORDER_PROCESS_TYPE') == 1 and strpos($_SERVER['PHP_SELF'], 'order-opc.php') === false) {
         if (isset($_GET['step']) and $_GET['step'] == 3) {
             Tools::redirect('order-opc.php?isPaymentStep=true');
         }
         Tools::redirect('order-opc.php');
     }
     if (Configuration::get('PS_CATALOG_MODE')) {
         $this->errors[] = Tools::displayError('This store has not accepted your new order.');
     }
     if (Tools::isSubmit('submitReorder') and $id_order = (int) Tools::getValue('id_order')) {
         $oldCart = new Cart(Order::getCartIdStatic((int) $id_order, (int) self::$cookie->id_customer));
         $duplication = $oldCart->duplicate();
         if (!$duplication or !Validate::isLoadedObject($duplication['cart'])) {
             $this->errors[] = Tools::displayError('Sorry, we cannot renew your order.');
         } elseif (!$duplication['success']) {
             $this->errors[] = Tools::displayError('Missing items - we are unable renew your order');
         } else {
             self::$cookie->id_cart = $duplication['cart']->id;
             self::$cookie->write();
             if (Configuration::get('PS_ORDER_PROCESS_TYPE') == 1) {
                 Tools::redirect('order-opc.php');
             }
             Tools::redirect('order.php');
         }
     }
     if ($this->nbProducts) {
         if (Tools::isSubmit('submitAddDiscount') and Tools::getValue('discount_name')) {
             $discountName = Tools::getValue('discount_name');
             if (!Validate::isDiscountName($discountName)) {
                 $this->errors[] = Tools::displayError('Voucher name invalid.');
             } else {
                 $discount = new Discount((int) Discount::getIdByName($discountName));
                 if (Validate::isLoadedObject($discount)) {
                     if ($tmpError = self::$cart->checkDiscountValidity($discount, self::$cart->getDiscounts(), self::$cart->getOrderTotal(), self::$cart->getProducts(), true)) {
                         $this->errors[] = $tmpError;
                     }
                 } else {
                     $this->errors[] = Tools::displayError('Voucher name invalid.');
                 }
                 if (!sizeof($this->errors)) {
                     self::$cart->addDiscount((int) $discount->id);
                     Tools::redirect('order-opc.php');
                 }
             }
             self::$smarty->assign(array('errors' => $this->errors, 'discount_name' => Tools::safeOutput($discountName)));
         } elseif (isset($_GET['deleteDiscount']) and Validate::isUnsignedId($_GET['deleteDiscount'])) {
             self::$cart->deleteDiscount((int) $_GET['deleteDiscount']);
             Tools::redirect('order-opc.php');
         }
         /* Is there only virtual product in cart */
         if ($isVirtualCart = self::$cart->isVirtualCart()) {
             $this->_setNoCarrier();
         }
     }
     self::$smarty->assign('back', Tools::safeOutput(Tools::getValue('back')));
 }
开发者ID:hecbuma,项目名称:quali-fisioterapia,代码行数:64,代码来源:ParentOrderController.php

示例6: postProcess

 public function postProcess()
 {
     global $currentIndex, $cookie;
     $token = Tools::getValue('token') ? Tools::getValue('token') : $this->token;
     if ($discountName = Tools::getValue('name') and Validate::isDiscountName($discountName) and Discount::discountExists($discountName, Tools::getValue('id_discount'))) {
         $this->_errors[] = Tools::displayError('A voucher of this name already exists. Please choose another name.');
     }
     if (Tools::getValue('submitAdd' . $this->table)) {
         if (Tools::getValue('id_discount_type') == 0) {
             $this->_errors[] = Tools::displayError('Please set a type for this voucher.');
         }
         if (Tools::getValue('id_discount_type') == 2 and Tools::getValue('id_currency') == 0) {
             $this->_errors[] = Tools::displayError('Please set a currency for this voucher.');
         }
         if ((Tools::getValue('id_discount_type') == 1 || Tools::getValue('id_discount_type') == 2) && !Tools::getValue('value')) {
             $this->_errors[] = Tools::displayError('Please set a amount for this voucher.');
         }
         if (!Validate::isBool_Id(Tools::getValue('id_target'))) {
             $this->_errors[] = Tools::displayError('Invalid customer or group ID field');
         } else {
             $rules = explode('_', Tools::getValue('id_target'));
             /* In form, there is one field for two differents fields in object*/
             $_POST[$rules[0] ? 'id_group' : 'id_customer'] = $rules[1];
         }
         /* Checking fields validity */
         $this->validateRules();
         if (!sizeof($this->_errors)) {
             $id = (int) Tools::getValue($this->identifier);
             /* Object update */
             if (isset($id) and !empty($id)) {
                 if ($this->tabAccess['edit'] === '1') {
                     $object = new $this->className($id);
                     if (Validate::isLoadedObject($object)) {
                         /* Specific to objects which must not be deleted */
                         if ($this->deleted and $this->beforeDelete($object)) {
                             $object->deleted = 1;
                             $object->update();
                             $objectNew = new $this->className();
                             $this->copyFromPost($objectNew, $this->table);
                             $result = $objectNew->add();
                             if (Validate::isLoadedObject($objectNew)) {
                                 $this->afterDelete($objectNew, $object->id);
                             }
                         } else {
                             if (($categories = Tools::getValue('categoryBox')) === false or !empty($categories) and !is_array($categories)) {
                                 $this->_errors[] = Tools::displayError('Please set a category for this voucher.');
                             }
                             $this->copyFromPost($object, $this->table);
                             if ($object->id_discount_type == 3) {
                                 $object->id_currency = 0;
                                 $object->value = 0;
                             } elseif ($object->id_discount_type == 1) {
                                 $object->id_currency = 0;
                             }
                             $result = $object->update(true, false, $categories);
                         }
                         if (!$result) {
                             $this->_errors[] = Tools::displayError('An error occurred while updating object.') . ' <b>' . $this->table . '</b>';
                         } elseif ($this->postImage($object->id)) {
                             if ($back = Tools::getValue('back')) {
                                 Tools::redirectAdmin(urldecode($back) . '&conf=4');
                             }
                             if (Tools::getValue('stay_here') == 'on' || Tools::getValue('stay_here') == 'true' || Tools::getValue('stay_here') == '1') {
                                 Tools::redirectAdmin($currentIndex . '&' . $this->identifier . '=' . $object->id . '&conf=4&updatescene&token=' . $token);
                             }
                             Tools::redirectAdmin($currentIndex . '&' . $this->identifier . '=' . $object->id . '&conf=4&token=' . $token);
                         }
                     } else {
                         $this->_errors[] = Tools::displayError('An error occurred while updating object.') . ' <b>' . $this->table . '</b> ' . Tools::displayError('(cannot load object)');
                     }
                 } else {
                     $this->_errors[] = Tools::displayError('You do not have permission to edit here.');
                 }
             } else {
                 if ($this->tabAccess['add'] === '1') {
                     $object = new $this->className();
                     $this->copyFromPost($object, $this->table);
                     $categories = Tools::getValue('categoryBox', null);
                     if (!$object->add(true, false, $categories)) {
                         $this->_errors[] = Tools::displayError('An error occurred while creating object.') . ' <b>' . $this->table . '</b>';
                     } elseif ($_POST[$this->identifier] = $object->id and $this->postImage($object->id) and $this->_redirect) {
                         Tools::redirectAdmin($currentIndex . '&' . $this->identifier . '=' . $object->id . '&conf=3&token=' . $token);
                     }
                 } else {
                     $this->_errors[] = Tools::displayError('You do not have permission to add here.');
                 }
             }
         }
         $this->_errors = array_unique($this->_errors);
     } else {
         return parent::postProcess();
     }
 }
开发者ID:Evil1991,项目名称:PrestaShop-1.4,代码行数:93,代码来源:AdminDiscounts.php

示例7: getContent

 public function getContent()
 {
     if (Tools::isSubmit('submitUpdate')) {
         Configuration::updateValue('NW_CONFIRMATION_EMAIL', (bool) Tools::getValue('NW_CONFIRMATION_EMAIL'));
         Configuration::updateValue('NW_VERIFICATION_EMAIL', (bool) Tools::getValue('NW_VERIFICATION_EMAIL'));
         $voucher = Tools::getValue('NW_VOUCHER_CODE');
         if ($voucher && !Validate::isDiscountName($voucher)) {
             $this->_html .= $this->displayError($this->l('The voucher code is invalid.'));
         } else {
             Configuration::updateValue('NW_VOUCHER_CODE', pSQL($voucher));
             $this->_html .= $this->displayConfirmation($this->l('Settings updated'));
         }
     } elseif (Tools::isSubmit('subscribedmerged')) {
         $id = Tools::getValue('id');
         if (preg_match('/(^N)/', $id)) {
             $id = (int) substr($id, 1);
             $sql = 'UPDATE ' . _DB_PREFIX_ . 'newsletter SET active = 0 WHERE id = ' . $id;
             Db::getInstance()->execute($sql);
         } else {
             $c = new Customer((int) $id);
             $c->newsletter = (int) (!$c->newsletter);
             $c->update();
         }
         Tools::redirectAdmin($this->context->link->getAdminLink('AdminModules', false) . '&configure=' . $this->name . '&conf=4&token=' . Tools::getAdminTokenLite('AdminModules'));
     } elseif (Tools::isSubmit('submitExport') && ($action = Tools::getValue('action'))) {
         $this->export_csv();
     } elseif (Tools::isSubmit('searchEmail')) {
         $this->_searched_email = Tools::getValue('searched_email');
     }
     $this->_html .= $this->renderForm();
     $this->_html .= $this->renderSearchForm();
     $this->_html .= $this->renderList();
     $this->_html .= $this->renderExportForm();
     return $this->_html;
 }
开发者ID:informaticapb,项目名称:Prestashop,代码行数:35,代码来源:blocknewsletter.php

示例8: preProcess

 public function preProcess()
 {
     global $isVirtualCart, $cookie;
     parent::preProcess();
     // Redirect to the good order process
     if (Configuration::get('PS_ORDER_PROCESS_TYPE') == 0 and (strpos($_SERVER['PHP_SELF'], 'order.php') === false and strpos($_SERVER['PHP_SELF'], 'cart-summary-large.php') === false)) {
         Tools::redirect('order.php');
     }
     if (Configuration::get('PS_ORDER_PROCESS_TYPE') == 1 and strpos($_SERVER['PHP_SELF'], 'order-opc.php') === false) {
         if (isset($_GET['step']) and $_GET['step'] == 3) {
             Tools::redirect('order-opc.php?isPaymentStep=true');
         }
         Tools::redirect('order-opc.php');
     }
     if (Configuration::get('PS_CATALOG_MODE')) {
         $this->errors[] = Tools::displayError('This store has not accepted your new order.');
     }
     if (Tools::isSubmit('submitReorder') and $id_order = (int) Tools::getValue('id_order')) {
         $oldCart = new Cart(Order::getCartIdStatic((int) $id_order, (int) self::$cookie->id_customer));
         $duplication = $oldCart->duplicate();
         if (!$duplication or !Validate::isLoadedObject($duplication['cart'])) {
             $this->errors[] = Tools::displayError('Sorry, we cannot renew your order.');
         } elseif (!$duplication['success']) {
             $this->errors[] = Tools::displayError('Missing items - we are unable to renew your order');
         } else {
             self::$cookie->id_cart = $duplication['cart']->id;
             self::$cookie->write();
             if (Configuration::get('PS_ORDER_PROCESS_TYPE') == 1) {
                 Tools::redirect('order-opc.php');
             }
             Tools::redirect('order.php');
         }
     }
     if (Tools::isSubmit('submit_instructions')) {
         $instructions = Tools::getValue('special_instructions');
         self::$cart->gift_message = pSQL($instructions);
         self::$cart->update();
         Tools::redirect('order?step=3');
     }
     if ($this->nbProducts) {
         /* check discount validity */
         $cartDiscounts = self::$cart->getDiscounts();
         $discountInvalid = false;
         foreach ($cartDiscounts as $k => $cartDiscount) {
             if ($error = self::$cart->checkDiscountValidity(new Discount((int) $cartDiscount['id_discount']), $cartDiscounts, self::$cart->getOrderTotal(true, Cart::ONLY_PRODUCTS_WITHOUT_SHIPPING), self::$cart->getProducts())) {
                 self::$cart->deleteDiscount((int) $cartDiscount['id_discount']);
                 $discountInvalid = true;
             }
         }
         if ($discountInvalid) {
             Tools::redirect('order-opc.php');
         }
         if (Tools::getValue('redeem_points')) {
             $points = (int) Tools::getValue('redeem_points');
             if ($points < 1) {
                 self::$smarty->assign('redeem_points', $points);
                 $this->errors[] = Tools::displayError('You can redeem minimum of 1 coin in an order.');
             }
             $orderTotal = self::$cart->getOrderTotal(true, Cart::ONLY_PRODUCTS);
             $redemption_status = VBRewards::checkPointsValidity($cookie->id_customer, $points + self::$cart->getPoints(), $orderTotal);
             if ($redemption_status === CAN_REDEEM_COINS) {
                 self::$cart->addPoints($points);
                 self::$smarty->assign('redeem_points', (int) self::$cart->getPoints());
             } else {
                 if ($redemption_status === INSUFFICIENT_VALID_ORDERS) {
                     $this->errors[] = Tools::displayError('Coins can be redeemed from second purchase onwards.');
                 } else {
                     if ($redemption_status === MIN_CRITERIA_NOT_MET) {
                         $this->errors[] = Tools::displayError('Order value should be more than 100 USD to redeem coins');
                     }
                 }
             }
             $this->adjustPoints();
         } elseif (Tools::getValue('deletePoints')) {
             self::$cart->deletePoints();
         }
         if (Tools::isSubmit('submitAddDiscount') and Tools::getValue('discount_name')) {
             $discountName = Tools::getValue('discount_name');
             if (!Validate::isDiscountName($discountName)) {
                 $this->errors[] = Tools::displayError('Voucher name invalid.');
             } else {
                 $discount = new Discount((int) Discount::getIdByName($discountName));
                 if (Validate::isLoadedObject($discount)) {
                     if ($tmpError = self::$cart->checkDiscountValidity($discount, self::$cart->getDiscounts(), self::$cart->getOrderTotal(), self::$cart->getProducts(), true)) {
                         $this->errors[] = $tmpError;
                     }
                 } else {
                     $this->errors[] = Tools::displayError('Voucher name invalid.');
                 }
                 if (!sizeof($this->errors)) {
                     self::$cart->addDiscount((int) $discount->id);
                     Tools::redirect('order-opc.php');
                 }
             }
             self::$smarty->assign(array('errors' => $this->errors, 'discount_name' => Tools::safeOutput($discountName)));
             $this->adjustPoints();
         } elseif (isset($_GET['deleteDiscount']) and Validate::isUnsignedId($_GET['deleteDiscount'])) {
             self::$cart->deleteDiscount((int) $_GET['deleteDiscount']);
             Tools::redirect('order-opc.php');
         }
//.........这里部分代码省略.........
开发者ID:priyankajsr19,项目名称:indusdiva2,代码行数:101,代码来源:ParentOrderController.php

示例9: floatval

$orderTotal = $cart->getOrderTotal();
$orderTotalDefaultCurrency = Tools::convertPrice($cart->getOrderTotal(true, 1), Currency::getCurrency(intval(Configuration::get('PS_CURRENCY_DEFAULT'))));
$minimalPurchase = floatval(Configuration::get('PS_PURCHASE_MINIMUM'));
if ($orderTotalDefaultCurrency < $minimalPurchase) {
    $step = 0;
    $errors[] = Tools::displayError('A minimum purchase total of') . ' ' . Tools::displayPrice($minimalPurchase, Currency::getCurrency(intval($cart->id_currency))) . ' ' . Tools::displayError('is required in order to validate your order');
}
if (!$cookie->isLogged() and in_array($step, array(1, 2, 3))) {
    Tools::redirect('authentication.php?back=order.php?step=' . $step);
}
$smarty->assign('back', Tools::safeOutput(Tools::getValue('back')));
if ($cart->nbProducts()) {
    /* Manage discounts */
    if ((Tools::isSubmit('submitDiscount') or Tools::isSubmit('submitDiscount')) and Tools::getValue('discount_name')) {
        $discountName = Tools::getValue('discount_name');
        if (!Validate::isDiscountName($discountName)) {
            $errors[] = Tools::displayError('voucher name not valid');
        } else {
            $discount = new Discount(intval(Discount::getIdByName($discountName)));
            if (is_object($discount) and $discount->id) {
                if ($tmpError = $cart->checkDiscountValidity($discount, $cart->getDiscounts(), $cart->getOrderTotal(), $cart->getProducts(), true)) {
                    $errors[] = $tmpError;
                }
            } else {
                $errors[] = Tools::displayError('voucher name not valid');
            }
            if (!sizeof($errors)) {
                $cart->addDiscount(intval($discount->id));
                Tools::redirect('order.php');
            } else {
                $smarty->assign(array('errors' => $errors, 'discount_name' => Tools::safeOutput($discountName)));
开发者ID:vincent,项目名称:theinvertebrates,代码行数:31,代码来源:order.php

示例10: getContent

 public function getContent()
 {
     $this->_html = '';
     if (Tools::isSubmit('submitUpdate')) {
         $conf_email = Tools::getValue('NW_CONFIRMATION_EMAIL');
         if ($conf_email && Validate::isBool((int) $conf_email)) {
             Configuration::updateValue('NW_CONFIRMATION_EMAIL', (int) $conf_email);
         }
         $verif_email = Tools::getValue('NW_VERIFICATION_EMAIL');
         if ($verif_email && Validate::isBool((int) $verif_email)) {
             Configuration::updateValue('NW_VERIFICATION_EMAIL', (int) $verif_email);
         }
         $voucher = Tools::getValue('NW_VOUCHER_CODE');
         if ($voucher && !Validate::isDiscountName($voucher)) {
             $this->_html .= $this->displayError($this->l('The voucher code is invalid.'));
         } else {
             Configuration::updateValue('NW_VOUCHER_CODE', pSQL($voucher));
             $this->_html .= $this->displayConfirmation($this->l('Settings updated'));
         }
     }
     return $this->_html . $this->renderForm();
 }
开发者ID:gks-stage,项目名称:prestashop,代码行数:22,代码来源:blocknewsletter.php

示例11: postProcess

 public function postProcess()
 {
     global $currentIndex, $cookie;
     $token = Tools::getValue('token') ? Tools::getValue('token') : $this->token;
     if ($discountName = Tools::getValue('name') and Validate::isDiscountName($discountName) and Discount::discountExists($discountName, Tools::getValue('id_discount'))) {
         $this->_errors[] = Tools::displayError('A voucher of this name already exists. Please choose another name.');
     }
     if (Tools::getValue('submitAdd' . $this->table)) {
         /* Checking fields validity */
         $this->validateRules();
         if (!sizeof($this->_errors)) {
             $id = intval(Tools::getValue($this->identifier));
             /* Object update */
             if (isset($id) and !empty($id)) {
                 if ($this->tabAccess['edit'] === '1') {
                     $object = new $this->className($id);
                     if (Validate::isLoadedObject($object)) {
                         /* Specific to objects which must not be deleted */
                         if ($this->deleted and $this->beforeDelete($object)) {
                             $object->deleted = 1;
                             $object->update();
                             $objectNew = new $this->className();
                             $this->copyFromPost($objectNew, $this->table);
                             $result = $objectNew->add();
                             if (Validate::isLoadedObject($objectNew)) {
                                 $this->afterDelete($objectNew, $object->id);
                             }
                         } else {
                             if (($categories = Tools::getValue('categoryBox')) === false or !empty($categories) and !is_array($categories)) {
                                 die(Tools::displayError());
                             }
                             $this->copyFromPost($object, $this->table);
                             $result = $object->update(true, false, $categories);
                         }
                         if (!$result) {
                             $this->_errors[] = Tools::displayError('an error occurred while updating object') . ' <b>' . $this->table . '</b>';
                         } elseif ($this->postImage($object->id)) {
                             if ($back = Tools::getValue('back')) {
                                 Tools::redirectAdmin(urldecode($back) . '&conf=4');
                             }
                             if (Tools::getValue('stay_here') == 'on' || Tools::getValue('stay_here') == 'true' || Tools::getValue('stay_here') == '1') {
                                 Tools::redirectAdmin($currentIndex . '&' . $this->identifier . '=' . $object->id . '&conf=4&updatescene&token=' . $token);
                             }
                             Tools::redirectAdmin($currentIndex . '&' . $this->identifier . '=' . $object->id . '&conf=4&token=' . $token);
                         }
                     } else {
                         $this->_errors[] = Tools::displayError('an error occurred while updating object') . ' <b>' . $this->table . '</b> ' . Tools::displayError('(cannot load object)');
                     }
                 } else {
                     $this->_errors[] = Tools::displayError('You do not have permission to edit anything here.');
                 }
             } else {
                 if ($this->tabAccess['add'] === '1') {
                     $object = new $this->className();
                     $this->copyFromPost($object, $this->table);
                     $categories = Tools::getValue('categoryBox', null);
                     if (!$object->add(true, false, $categories)) {
                         $this->_errors[] = Tools::displayError('an error occurred while creating object') . ' <b>' . $this->table . '</b>';
                     } elseif ($_POST[$this->identifier] = $object->id and $this->postImage($object->id) and $this->_redirect) {
                         Tools::redirectAdmin($currentIndex . '&' . $this->identifier . '=' . $object->id . '&conf=3&token=' . $token);
                     }
                 } else {
                     $this->_errors[] = Tools::displayError('You do not have permission to add anything here.');
                 }
             }
         }
         $this->_errors = array_unique($this->_errors);
     } else {
         return parent::postProcess();
     }
 }
开发者ID:Bruno-2M,项目名称:prestashop,代码行数:71,代码来源:AdminDiscounts.php

示例12: getContent

    public function getContent()
    {
        $this->_html = '';
        $dbquery = new DbQuery();
        $dbquery->select('c.`id_customer`, c.`id_shop`, c.`lastname`, c.`firstname`, c.`email`, c.`newsletter_date_add`')->from('customer', 'c')->where('c.`newsletter` = 1');
        $customers = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($dbquery->build());
        $non_customers = Db::getInstance()->executeS('SELECT `email`, `id_shop`, `newsletter_date_add` FROM `' . _DB_PREFIX_ . 'newsletter` WHERE `active` = 1');
        foreach ($non_customers as &$non_customer) {
            $non_customer['id_customer'] = '';
            $non_customer['lastname'] = '';
            $non_customer['firstname'] = '';
        }
        $customers = array_merge($customers, $non_customers);
        foreach ($customers as &$customer) {
            ksort($customer);
        }
        if (Tools::isSubmit('submitUpdate')) {
            $conf_email = Tools::getValue('NW_CONFIRMATION_EMAIL');
            if ($conf_email && Validate::isBool((int) $conf_email)) {
                Configuration::updateValue('NW_CONFIRMATION_EMAIL', (int) $conf_email);
            }
            $verif_email = Tools::getValue('NW_VERIFICATION_EMAIL');
            if ($verif_email && Validate::isBool((int) $verif_email)) {
                Configuration::updateValue('NW_VERIFICATION_EMAIL', (int) $verif_email);
            }
            $voucher = Tools::getValue('NW_VOUCHER_CODE');
            if ($voucher && !Validate::isDiscountName($voucher)) {
                $this->_html .= $this->displayError($this->l('The voucher code is invalid.'));
            } else {
                Configuration::updateValue('NW_VOUCHER_CODE', pSQL($voucher));
                $this->_html .= $this->displayConfirmation($this->l('Settings updated'));
            }
        } elseif (Tools::isSubmit('exportCustomers')) {
            $header = array('email', 'firstname', 'id_customer', 'id_shop', 'lastname', 'newsletter_date_add');
            $array_to_export = array_merge(array($header), $customers);
            $file_name = time() . '.csv';
            $fd = fopen($this->getLocalPath() . $file_name, 'w+');
            foreach ($array_to_export as $tab) {
                $line = implode(';', $tab);
                $line .= "\n";
                fwrite($fd, $line, 4096);
            }
            fclose($fd);
            $this->_html .= $this->displayConfirmation('<a href="' . $this->_path . $file_name . '">' . $file_name . '</a>');
        }
        $fields_list = array('id_customer' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 'auto'), 'id_shop' => array('title' => $this->l('Shop ID'), 'align' => 'center', 'width' => 'auto'), 'lastname' => array('title' => $this->l('Last name'), 'align' => 'center', 'width' => 'auto'), 'firstname' => array('title' => $this->l('First name'), 'align' => 'center', 'width' => 'auto'), 'email' => array('title' => $this->l('Email address'), 'align' => 'center', 'width' => 'auto'), 'newsletter_date_add' => array('title' => $this->l('Registration date'), 'align' => 'center', 'width' => 'auto'));
        $helper_list = new HelperList();
        $helper_list->module = $this;
        $helper_list->title = $this->l('Newsletter registrations');
        $helper_list->shopLinkType = '';
        $helper_list->no_link = true;
        $helper_list->simple_header = true;
        $helper_list->identifier = 'id_customer';
        $helper_list->table = 'customer';
        $helper_list->currentIndex = $this->context->link->getAdminLink('AdminModules', false) . '&configure=' . $this->name;
        $helper_list->token = Tools::getAdminTokenLite('AdminModules');
        $helper_list->actions = array('viewCustomer');
        $helper_list = $helper_list->generateList($customers, $fields_list);
        $button = '<div class="panel"><a href="' . $this->context->link->getAdminLink('AdminModules', false) . '&exportCustomers&configure=' . $this->name . '&token=' . Tools::getAdminTokenLite('AdminModules') . '">
    <button class="btn btn-default">' . $this->l('Export as CSV') . '</button>
</a></div>';
        return $this->_html . $this->renderForm() . $helper_list . $button;
    }
开发者ID:dev-lav,项目名称:htdocs,代码行数:63,代码来源:blocknewsletter.php


注:本文中的Validate::isDiscountName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。