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


PHP PrestaShopLogger::addLog方法代码示例

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


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

示例1: addQuickLink

 public function addQuickLink()
 {
     if (!isset($this->className) || empty($this->className)) {
         return false;
     }
     $this->validateRules();
     if (count($this->errors) <= 0) {
         $this->object = new $this->className();
         $this->copyFromPost($this->object, $this->table);
         $exists = Db::getInstance()->getValue('SELECT id_quick_access FROM ' . _DB_PREFIX_ . 'quick_access WHERE link = "' . pSQL($this->object->link) . '"');
         if ($exists) {
             return true;
         }
         $this->beforeAdd($this->object);
         if (method_exists($this->object, 'add') && !$this->object->add()) {
             $this->errors[] = Tools::displayError('An error occurred while creating an object.') . ' <b>' . $this->table . ' (' . Db::getInstance()->getMsgError() . ')</b>';
         } elseif (($_POST[$this->identifier] = $this->object->id) && $this->postImage($this->object->id) && !count($this->errors) && $this->_redirect) {
             PrestaShopLogger::addLog(sprintf($this->l('%s addition', 'AdminTab', false, false), $this->className), 1, null, $this->className, (int) $this->object->id, true, (int) $this->context->employee->id);
             $this->afterAdd($this->object);
         }
     }
     $this->errors = array_unique($this->errors);
     if (!empty($this->errors)) {
         $this->errors['has_errors'] = true;
         $this->ajaxDie(Tools::jsonEncode($this->errors));
         return false;
     }
     return $this->getQuickAccessesList();
 }
开发者ID:jpodracky,项目名称:dogs,代码行数:29,代码来源:AdminQuickAccessesController.php

示例2: postProcess

 /**
  * @see FrontController::postProcess()
  */
 public function postProcess()
 {
     // Log requests from Privat API side in Debug mode.
     if (Configuration::get('PRIVAT24_DEBUG_MODE')) {
         $logger = new FileLogger();
         $logger->setFilename(_PS_ROOT_DIR_ . '/log/' . $this->module->name . '_' . date('Ymd_His') . '_response.log');
         $logger->logError($_POST);
     }
     $payment = array();
     parse_str(Tools::getValue('payment'), $payment);
     $hash = sha1(md5(Tools::getValue('payment') . $this->module->merchant_password));
     if ($payment && $hash === Tools::getValue('signature')) {
         if ($payment['state'] == 'ok') {
             $state = Configuration::get('PRIVAT24_WAITINGPAYMENT_OS');
             $cart_id = (int) $payment['order'];
             $order = new Order(Order::getOrderByCartId($cart_id));
             if (!Validate::isLoadedObject($order)) {
                 PrestaShopLogger::addLog('Privat24: cannot get order by cart id ' . $cart_id, 3);
                 die;
             }
             if ($order->getCurrentState() != $state) {
                 PrestaShopLogger::addLog(sprintf('Privat24: order id %s current state %s !== expected state %s', $order->id, $order->getCurrentState(), $state), 3);
                 die;
             }
             // Check paid currency and paid amount.
             $id_currency = Currency::getIdByIsoCode($payment['ccy']);
             if (!$id_currency) {
                 PrestaShopLogger::addLog(sprintf('Privat24: order id %s cannot get currency id by iso code: %s', $order->id, $payment['ccy']), 3);
                 die;
             }
             if ($order->id_currency != $id_currency) {
                 PrestaShopLogger::addLog(sprintf('Privat 24: order id %s, order currency id %s does not match with %s', $order->id, $order->id_currency, $id_currency), 3);
                 die;
             }
             if ((double) $order->total_paid != (double) $payment['amt']) {
                 PrestaShopLogger::addLog(sprintf('Privat 24: order id %s order total paid %s does not match %s', $order->id, $order->total_paid, $payment['amt']), 3);
                 die;
             }
             $order_history = new OrderHistory();
             $order_history->id_order = $order->id;
             $order_history->changeIdOrderState(_PS_OS_PAYMENT_, $order->id);
             $order_history->addWithemail();
             $this->setPaymentTransaction($order, $payment);
             $this->module->paymentNotify($order, $payment);
             PrestaShopLogger::addLog(sprintf('Privat24 payment accepted: order id: %s, amount: %s, ref: %s', $order->id, $payment['amt'], $payment['ref']), 1);
         } else {
             PrestaShopLogger::addLog(sprintf('Privat24 payment failed: state: %s, order: %s, ref: %s', $payment['state'], $payment['order'], $payment['ref']), 3, null, null, null, true);
         }
     } else {
         PrestaShopLogger::addLog('Privat24: Payment callback bad signature.', 3, null, null, null, true);
     }
     die;
 }
开发者ID:skoro,项目名称:prestashop-privat24,代码行数:56,代码来源:validation.php

示例3: displayTechnicalError

 /**
  * Displays message about occured technical error.
  *
  * @param       Exception       $ex     Error cause.
  */
 protected function displayTechnicalError(Exception $ex)
 {
     PrestaShopLogger::addLog((string) $ex, 50);
     $this->context->smarty->assign('error_message', $this->module->l('Technical error occured'));
     if ($this->context->customer->is_guest) {
         $this->context->smarty->assign(array('reference_order' => $this->module->currentOrderReference, 'email' => $this->context->customer->email));
         /* If guest we clear the cookie for security reason */
         $this->context->customer->mylogout();
     }
     $this->setTemplate('payment_error.tpl');
     parent::display();
 }
开发者ID:payneteasy,项目名称:php-plugin-prestashop,代码行数:17,代码来源:startsale.php

示例4: displayAjax

 public function displayAjax()
 {
     if (Configuration::get('MERCADOPAGO_LOG') == 'true') {
         PrestaShopLogger::addLog('Debug Mode :: displayAjax - topic = ' . Tools::getValue('topic'), MP::INFO, 0);
         PrestaShopLogger::addLog('Debug Mode :: displayAjax - id = ' . Tools::getValue('id'), MP::INFO, 0);
         PrestaShopLogger::addLog('Debug Mode :: displayAjax - checkout = ' . Tools::getValue('checkout'), MP::INFO, 0);
     }
     if (Tools::getValue('topic') && Tools::getValue('id')) {
         $mercadopago = new MercadoPago();
         $mercadopago->listenIPN(Tools::getValue('checkout'), Tools::getValue('topic'), Tools::getValue('id'));
     }
 }
开发者ID:tusconsu,项目名称:cart-prestashop,代码行数:12,代码来源:notification.php

示例5: postProcess

 public function postProcess()
 {
     /* PrestaShop demo mode */
     if (_PS_MODE_DEMO_) {
         $this->errors[] = Tools::displayError('This functionality has been disabled.');
         return;
     }
     if (Tools::isSubmit('import')) {
         // Check if the CSV file exist
         if (Tools::getValue('csv')) {
             // If i am a superadmin, i can truncate table
             if ((Shop::isFeatureActive() && $this->context->employee->isSuperAdmin() || !Shop::isFeatureActive()) && Tools::getValue('truncate')) {
                 $this->truncateTables((int) Tools::getValue('entity'));
             }
             $import_type = false;
             switch ((int) Tools::getValue('entity')) {
                 case $this->entities[$import_type = $this->l('Categories')]:
                     $this->categoryImport();
                     $this->clearSmartyCache();
                     break;
                 case $this->entities[$import_type = $this->l('Products')]:
                     $this->productImport();
                     $this->clearSmartyCache();
                     break;
                 case $this->entities[$import_type = $this->l('Customers')]:
                     $this->customerImport();
                     break;
                 case $this->entities[$import_type = $this->l('Addresses')]:
                     $this->addressImport();
                     break;
                 case $this->entities[$import_type = $this->l('Combinations')]:
                     $this->attributeImport();
                     $this->clearSmartyCache();
                     break;
                 case $this->entities[$import_type = $this->l('Manufacturers')]:
                     $this->manufacturerImport();
                     $this->clearSmartyCache();
                     break;
                 case $this->entities[$import_type = $this->l('Suppliers')]:
                     $this->supplierImport();
                     $this->clearSmartyCache();
                     break;
                 case $this->entities[$import_type = $this->l('Alias')]:
                     $this->aliasImport();
                     break;
             }
             // @since 1.5.0
             if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) {
                 switch ((int) Tools::getValue('entity')) {
                     case $this->entities[$import_type = $this->l('Supply Orders')]:
                         if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) {
                             $this->supplyOrdersImport();
                         }
                         break;
                     case $this->entities[$import_type = $this->l('Supply Order Details')]:
                         if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) {
                             $this->supplyOrdersDetailsImport();
                         }
                         break;
                 }
             }
             if ($import_type !== false) {
                 $log_message = sprintf($this->l('%s import', 'AdminTab', false, false), $import_type);
                 if (Tools::getValue('truncate')) {
                     $log_message .= ' ' . $this->l('with truncate', 'AdminTab', false, false);
                 }
                 PrestaShopLogger::addLog($log_message, 1, null, $import_type, null, true, (int) $this->context->employee->id);
             }
         } else {
             $this->errors[] = $this->l('You must upload a file in order to proceed to the next step');
         }
     } elseif ($filename = Tools::getValue('csvfilename')) {
         $filename = urldecode($filename);
         $file = AdminImportController::getPath(basename($filename));
         if (realpath(dirname($file)) != realpath(AdminImportController::getPath())) {
             exit;
         }
         if (!empty($filename)) {
             $b_name = basename($filename);
             if (Tools::getValue('delete') && file_exists($file)) {
                 @unlink($file);
             } elseif (file_exists($file)) {
                 $b_name = explode('.', $b_name);
                 $b_name = strtolower($b_name[count($b_name) - 1]);
                 $mime_types = array('csv' => 'text/csv');
                 if (isset($mime_types[$b_name])) {
                     $mime_type = $mime_types[$b_name];
                 } else {
                     $mime_type = 'application/octet-stream';
                 }
                 if (ob_get_level() && ob_get_length() > 0) {
                     ob_end_clean();
                 }
                 header('Content-Transfer-Encoding: binary');
                 header('Content-Type: ' . $mime_type);
                 header('Content-Length: ' . filesize($file));
                 header('Content-Disposition: attachment; filename="' . $filename . '"');
                 $fp = fopen($file, 'rb');
                 while (is_resource($fp) && !feof($fp)) {
                     echo fgets($fp, 16384);
//.........这里部分代码省略.........
开发者ID:ecssjapan,项目名称:guiding-you-afteropen,代码行数:101,代码来源:AdminImportController.php

示例6: sendCampaign

    public function sendCampaign()
    {
        // get abandoned cart :
        $sql = "SELECT * FROM (\n\t\tSELECT\n\t\tCONCAT(LEFT(c.`firstname`, 1), '. ', c.`lastname`) `customer`, a.id_cart total, ca.name carrier, c.id_customer, a.id_cart, a.date_upd,a.date_add,\n\t\t\t\tIF (IFNULL(o.id_order, 'Non ordered') = 'Non ordered', IF(TIME_TO_SEC(TIMEDIFF('" . date('Y-m-d H:i:s') . "', a.`date_add`)) > 86000, 'Abandoned cart', 'Non ordered'), o.id_order) id_order, IF(o.id_order, 1, 0) badge_success, IF(o.id_order, 0, 1) badge_danger, IF(co.id_guest, 1, 0) id_guest\n\t\tFROM `" . _DB_PREFIX_ . "cart` a  \n\t\t\t\tJOIN `" . _DB_PREFIX_ . "customer` c ON (c.id_customer = a.id_customer)\n\t\t\t\tLEFT JOIN `" . _DB_PREFIX_ . "currency` cu ON (cu.id_currency = a.id_currency)\n\t\t\t\tLEFT JOIN `" . _DB_PREFIX_ . "carrier` ca ON (ca.id_carrier = a.id_carrier)\n\t\t\t\tLEFT JOIN `" . _DB_PREFIX_ . "orders` o ON (o.id_cart = a.id_cart)\n\t\t\t\tLEFT JOIN `" . _DB_PREFIX_ . "connections` co ON (a.id_guest = co.id_guest AND TIME_TO_SEC(TIMEDIFF('" . date('Y-m-d H:i:s') . "', co.`date_add`)) < 1800)\n\t\t\t\tWHERE a.date_add > (NOW() - INTERVAL 60 DAY) ORDER BY a.id_cart DESC \n\t\t) AS toto WHERE id_order='Abandoned cart'";
        $currency = Context::getContext()->currency->sign;
        $defaultLanguage = new Language((int) Configuration::get('PS_LANG_DEFAULT'));
        $abandoned_carts = Db::getInstance()->ExecuteS($sql);
        // get all available campaigns
        $sqlCampaigns = 'SELECT * FROM `' . _DB_PREFIX_ . 'campaign` WHERE active=1';
        $allCampaigns = Db::getInstance()->ExecuteS($sqlCampaigns);
        if (!$allCampaigns || empty($allCampaigns)) {
            die('NO CAMPAIGN');
        }
        // loop on all abandoned carts
        foreach ($abandoned_carts as $abncart) {
            if (Cart::getNbProducts((int) $abncart['id_cart']) > 0) {
                $emailsSent = 0;
                // loop on all available campaigns
                foreach ($allCampaigns as $camp) {
                    if (DEBUG_SAC) {
                        echo 'IdCustomer : ' . $abncart['id_customer'] . ' - IdCart : ' . $abncart['id_cart'] . '<br/>';
                    }
                    $cartIsOnCampaign = $this->checkIfCartIsOnCampaign($abncart['date_add'], $camp['execution_time_day'], $camp['execution_time_hour']);
                    if ($cartIsOnCampaign) {
                        if (DEBUG_SAC) {
                            echo 'Cart on campaign</br>';
                        }
                        $id_lang = (int) Configuration::get('PS_LANG_DEFAULT');
                        $customer = new Customer($abncart['id_customer']);
                        $cart = new Cart($abncart['id_cart']);
                        $products = $cart->getProducts();
                        $tpl_vars = array('{firstname}' => $customer->firstname, '{lastname}' => $customer->lastname, '{campaign_name}' => $camp['name'], '{track_url}' => $this->getBaseURL() . '?id_cart=' . (int) $abncart['id_cart'] . '&id_customer=' . (int) $abncart['id_customer'], '{track_request}' => '?id_cart=' . (int) $abncart['id_cart'] . '&id_customer=' . (int) $abncart['id_customer']);
                        $campM = new Campaign($camp['id_campaign']);
                        if ($campM->voucher_amount && $campM->voucher_day && $campM->voucher_amount_type) {
                            $campM->clean_old_reduction($campM->voucher_prefix);
                            $customerVoucher = $campM->registerDiscount($customer->id, $campM->voucher_amount, $campM->voucher_day, $campM->voucher_amount_type, $campM->voucher_prefix);
                            $tpl_vars['{coupon_name}'] = $customerVoucher->name;
                            $tpl_vars['{coupon_code}'] = $customerVoucher->code;
                            $tpl_vars['{coupon_value}'] = $camp['voucher_amount_type'] == 'percent' ? $customerVoucher->reduction_percent . '%' : Tools::displayprice($customerVoucher->reduction_amount);
                            $tpl_vars['{coupon_valid_to}'] = date('d/m/Y', strtotime($customerVoucher->date_to));
                        }
                        if (!empty($products)) {
                            $cart_content = $campM->getCartContentHeader();
                        } else {
                            $cart_content = '';
                        }
                        foreach ($products as $prod) {
                            $p = new Product($prod['id_product'], true, $id_lang);
                            $price_no_tax = Product::getPriceStatic($p->id, false, null, 2, null, false, true, 1, false, null, $abncart['id_cart'], null, $null, true, true, null, false, false);
                            $total_no_tax = $prod['cart_quantity'] * $price_no_tax;
                            $images = Image::getImages((int) $id_lang, (int) $p->id);
                            $link = new Link();
                            $cart_content .= '<tr>
											<td align="center" ><img src="' . Tools::getShopProtocol() . $link->getImageLink($p->link_rewrite, $images[0]['id_image']) . '" width="80"/></td>
											<td align="center" ><a href="' . $link->getProductLink($p) . '?id_cart=' . (int) $abncart['id_cart'] . '&id_customer=' . (int) $abncart['id_customer'] . '"/>' . $p->name . '</a></td>
											<td align="center" >' . Tools::displayprice($price_no_tax) . '</td>
											<td align="center" >' . $prod['cart_quantity'] . '</td>
											<td align="center" >' . Tools::displayprice($total_no_tax) . '</td>
										</tr>';
                        }
                        $cart_content .= '</table>';
                        $tpl_vars['{cart_content}'] = $cart_content;
                        $path = _PS_ROOT_DIR_ . '/modules/superabandonedcart/mails/';
                        // send email to customer :
                        $mailUser = Mail::Send($id_lang, $campM->getFileName(), $camp['name'], $tpl_vars, $customer->email, null, null, null, null, null, $path, false, Context::getContext()->shop->id);
                        // if mail user is successfully sent :
                        if ($mailUser) {
                            $history = new CampaignHistory();
                            $history->id_campaign = (int) $camp['id_campaign'];
                            $history->id_customer = $abncart['id_customer'];
                            $history->id_cart = $abncart['id_cart'];
                            $history->id_cart_rule = isset($customerVoucher->id) ? $customerVoucher->id : 0;
                            $history->click = 0;
                            $history->converted = 0;
                            $history->date_update = date('Y-m-d H:i:s', time());
                            $history->save();
                            // Email to admin :
                            Mail::Send($id_lang, $campM->getFileName(), Mail::l(sprintf('Email sent to %s %s for campaign %s', $customer->lastname, $customer->firstname, $camp['name'])), $tpl_vars, Configuration::get('PS_SHOP_EMAIL'), null, null, null, null, null, $path, false, Context::getContext()->shop->id);
                            ++$emailsSent;
                        } else {
                            PrestaShopLogger::addLog('Error when sending user email (tpl:' . $campM->getFileName() . ',customer:' . $customer->email . ', campagne : ' . $camp['name'], 3);
                        }
                    }
                }
                // log emailing results :
                if ($emailsSent > 0) {
                    PrestaShopLogger::addLog($emailsSent . ' emails sent for ' . $camp['name'] . ' campaign', 1);
                }
            }
        }
    }
开发者ID:ChDUP,项目名称:superabandonedcart,代码行数:91,代码来源:launch_campaings.php

示例7: log

 public function log($severity, $message, $mid = null)
 {
     if (!class_exists('PrestaShopLogger')) {
         return;
     }
     $objectType = $mid ? 'Cart' : null;
     $objectId = $mid;
     PrestaShopLogger::addLog($message, $severity, null, $objectType, $objectId);
 }
开发者ID:aplazame,项目名称:prestashop,代码行数:9,代码来源:aplazame.php

示例8: validateOrder

 public function validateOrder($id_cart, $id_order_state, $amount_paid, $payment_method = 'Unknown', $message = null, $extra_vars = array(), $currency_special = null, $dont_touch_amount = false, $secure_key = false, Shop $shop = null)
 {
     if (self::DEBUG_MODE) {
         PrestaShopLogger::addLog('PaymentModule::validateOrder - Function called', 1, null, 'Cart', (int) $id_cart, true);
     }
     if (!isset($this->context)) {
         $this->context = Context::getContext();
     }
     $this->context->cart = new Cart($id_cart);
     $this->context->customer = new Customer($this->context->cart->id_customer);
     // The tax cart is loaded before the customer so re-cache the tax calculation method
     $this->context->cart->setTaxCalculationMethod();
     $this->context->language = new Language($this->context->cart->id_lang);
     $this->context->shop = $shop ? $shop : new Shop($this->context->cart->id_shop);
     ShopUrl::resetMainDomainCache();
     $id_currency = $currency_special ? (int) $currency_special : (int) $this->context->cart->id_currency;
     $this->context->currency = new Currency($id_currency, null, $this->context->shop->id);
     if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') {
         $context_country = $this->context->country;
     }
     $order_status = new OrderState((int) $id_order_state, (int) $this->context->language->id);
     if (!Validate::isLoadedObject($order_status)) {
         PrestaShopLogger::addLog('PaymentModule::validateOrder - Order Status cannot be loaded', 3, null, 'Cart', (int) $id_cart, true);
         throw new PrestaShopException('Can\'t load Order status');
     }
     if (!$this->active) {
         PrestaShopLogger::addLog('PaymentModule::validateOrder - Module is not active', 3, null, 'Cart', (int) $id_cart, true);
         die(Tools::displayError());
     }
     // Does order already exists ?
     if (Validate::isLoadedObject($this->context->cart) && $this->context->cart->OrderExists() == false) {
         if ($secure_key !== false && $secure_key != $this->context->cart->secure_key) {
             PrestaShopLogger::addLog('PaymentModule::validateOrder - Secure key does not match', 3, null, 'Cart', (int) $id_cart, true);
             die(Tools::displayError());
         }
         // For each package, generate an order
         $delivery_option_list = $this->context->cart->getDeliveryOptionList();
         $package_list = $this->context->cart->getPackageList();
         $cart_delivery_option = $this->context->cart->getDeliveryOption();
         // If some delivery options are not defined, or not valid, use the first valid option
         foreach ($delivery_option_list as $id_address => $package) {
             if (!isset($cart_delivery_option[$id_address]) || !array_key_exists($cart_delivery_option[$id_address], $package)) {
                 foreach ($package as $key => $val) {
                     $cart_delivery_option[$id_address] = $key;
                     break;
                 }
             }
         }
         $order_list = array();
         $order_detail_list = array();
         do {
             $reference = Order::generateReference();
         } while (Order::getByReference($reference)->count());
         $this->currentOrderReference = $reference;
         $order_creation_failed = false;
         $cart_total_paid = (double) Tools::ps_round((double) $this->context->cart->getOrderTotal(true, Cart::BOTH), 2);
         foreach ($cart_delivery_option as $id_address => $key_carriers) {
             foreach ($delivery_option_list[$id_address][$key_carriers]['carrier_list'] as $id_carrier => $data) {
                 foreach ($data['package_list'] as $id_package) {
                     // Rewrite the id_warehouse
                     $package_list[$id_address][$id_package]['id_warehouse'] = (int) $this->context->cart->getPackageIdWarehouse($package_list[$id_address][$id_package], (int) $id_carrier);
                     $package_list[$id_address][$id_package]['id_carrier'] = $id_carrier;
                 }
             }
         }
         // Make sure CartRule caches are empty
         CartRule::cleanCache();
         $cart_rules = $this->context->cart->getCartRules();
         foreach ($cart_rules as $cart_rule) {
             if (($rule = new CartRule((int) $cart_rule['obj']->id)) && Validate::isLoadedObject($rule)) {
                 if ($error = $rule->checkValidity($this->context, true, true)) {
                     $this->context->cart->removeCartRule((int) $rule->id);
                     if (isset($this->context->cookie) && isset($this->context->cookie->id_customer) && $this->context->cookie->id_customer && !empty($rule->code)) {
                         if (Configuration::get('PS_ORDER_PROCESS_TYPE') == 1) {
                             Tools::redirect('index.php?controller=order-opc&submitAddDiscount=1&discount_name=' . urlencode($rule->code));
                         }
                         Tools::redirect('index.php?controller=order&submitAddDiscount=1&discount_name=' . urlencode($rule->code));
                     } else {
                         $rule_name = isset($rule->name[(int) $this->context->cart->id_lang]) ? $rule->name[(int) $this->context->cart->id_lang] : $rule->code;
                         $error = Tools::displayError(sprintf('CartRule ID %1s (%2s) used in this cart is not valid and has been withdrawn from cart', (int) $rule->id, $rule_name));
                         PrestaShopLogger::addLog($error, 3, '0000002', 'Cart', (int) $this->context->cart->id);
                     }
                 }
             }
         }
         foreach ($package_list as $id_address => $packageByAddress) {
             foreach ($packageByAddress as $id_package => $package) {
                 $order = new Order();
                 $order->product_list = $package['product_list'];
                 if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_delivery') {
                     $address = new Address($id_address);
                     $this->context->country = new Country($address->id_country, $this->context->cart->id_lang);
                     if (!$this->context->country->active) {
                         throw new PrestaShopException('The delivery address country is not active.');
                     }
                 }
                 $carrier = null;
                 if (!$this->context->cart->isVirtualCart() && isset($package['id_carrier'])) {
                     $carrier = new Carrier($package['id_carrier'], $this->context->cart->id_lang);
                     $order->id_carrier = (int) $carrier->id;
//.........这里部分代码省略.........
开发者ID:Oldwo1f,项目名称:yakaboutique,代码行数:101,代码来源:PaymentModule.php

示例9: processBulkDelete

 /**
  * Delete multiple items
  *
  * @return boolean true if succcess
  */
 protected function processBulkDelete()
 {
     if (is_array($this->boxes) && !empty($this->boxes)) {
         $object = new $this->className();
         if (isset($object->noZeroObject)) {
             $objects_count = count(call_user_func(array($this->className, $object->noZeroObject)));
             // Check if all object will be deleted
             if ($objects_count <= 1 || count($this->boxes) == $objects_count) {
                 $this->errors[] = Tools::displayError('You need at least one object.') . ' <b>' . $this->table . '</b><br />' . Tools::displayError('You cannot delete all of the items.');
             }
         } else {
             $result = true;
             foreach ($this->boxes as $id) {
                 $to_delete = new $this->className($id);
                 $delete_ok = true;
                 if ($this->deleted) {
                     $to_delete->deleted = 1;
                     if (!$to_delete->update()) {
                         $result = false;
                         $delete_ok = false;
                     }
                 } else {
                     if (!$to_delete->delete()) {
                         $result = false;
                         $delete_ok = false;
                     }
                 }
                 if ($delete_ok) {
                     PrestaShopLogger::addLog(sprintf($this->l('%s deletion', 'AdminTab', false, false), $this->className), 1, null, $this->className, (int) $to_delete->id, true, (int) $this->context->employee->id);
                 } else {
                     $this->errors[] = sprintf(Tools::displayError('Can\'t delete #%d'), $id);
                 }
             }
             if ($result) {
                 $this->redirect_after = self::$currentIndex . '&conf=2&token=' . $this->token;
             }
             $this->errors[] = Tools::displayError('An error occurred while deleting this selection.');
         }
     } else {
         $this->errors[] = Tools::displayError('You must select at least one element to delete.');
     }
     if (isset($result)) {
         return $result;
     } else {
         return false;
     }
 }
开发者ID:ramzzes52,项目名称:Uni3,代码行数:52,代码来源:AdminController.php

示例10: importByGroups


//.........这里部分代码省略.........
             }
         }
         Db::getInstance()->disableCache();
         switch ((int) Tools::getValue('entity')) {
             case $this->entities[$import_type = $this->l('Categories')]:
                 $doneCount += $this->categoryImport($offset, $limit, $crossStepsVariables, $validateOnly);
                 $this->clearSmartyCache();
                 break;
             case $this->entities[$import_type = $this->l('Products')]:
                 if (!defined('PS_MASS_PRODUCT_CREATION')) {
                     define('PS_MASS_PRODUCT_CREATION', true);
                 }
                 $moreStepLabels = array($this->l('Linking Accessories...'));
                 $doneCount += $this->productImport($offset, $limit, $crossStepsVariables, $validateOnly, $moreStep);
                 $this->clearSmartyCache();
                 break;
             case $this->entities[$import_type = $this->l('Customers')]:
                 $doneCount += $this->customerImport($offset, $limit, $validateOnly);
                 break;
             case $this->entities[$import_type = $this->l('Addresses')]:
                 $doneCount += $this->addressImport($offset, $limit, $validateOnly);
                 break;
             case $this->entities[$import_type = $this->l('Combinations')]:
                 $doneCount += $this->attributeImport($offset, $limit, $crossStepsVariables, $validateOnly);
                 $this->clearSmartyCache();
                 break;
             case $this->entities[$import_type = $this->l('Brands')]:
                 $doneCount += $this->manufacturerImport($offset, $limit, $validateOnly);
                 $this->clearSmartyCache();
                 break;
             case $this->entities[$import_type = $this->l('Suppliers')]:
                 $doneCount += $this->supplierImport($offset, $limit, $validateOnly);
                 $this->clearSmartyCache();
                 break;
             case $this->entities[$import_type = $this->l('Alias')]:
                 $doneCount += $this->aliasImport($offset, $limit, $validateOnly);
                 break;
             case $this->entities[$import_type = $this->l('Store contacts')]:
                 $doneCount += $this->storeContactImport($offset, $limit, $validateOnly);
                 $this->clearSmartyCache();
                 break;
         }
         // @since 1.5.0
         if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) {
             switch ((int) Tools::getValue('entity')) {
                 case $this->entities[$import_type = $this->l('Supply Orders')]:
                     if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) {
                         $doneCount += $this->supplyOrdersImport($offset, $limit, $validateOnly);
                     }
                     break;
                 case $this->entities[$import_type = $this->l('Supply Order Details')]:
                     if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) {
                         $doneCount += $this->supplyOrdersDetailsImport($offset, $limit, $crossStepsVariables, $validateOnly);
                     }
                     break;
             }
         }
         if ($results !== null) {
             $results['isFinished'] = $doneCount < $limit;
             $results['doneCount'] = $offset + $doneCount;
             if ($offset === 0) {
                 // compute total count only once, because it takes time
                 $handle = $this->openCsvFile(0);
                 if ($handle) {
                     $count = 0;
                     while (fgetcsv($handle, MAX_LINE_SIZE, $this->separator)) {
                         $count++;
                     }
                     $results['totalCount'] = $count;
                 }
                 $this->closeCsvFile($handle);
             }
             if (!$results['isFinished'] || !$validateOnly && $moreStep < count($moreStepLabels)) {
                 // Since we'll have to POST this array from ajax for the next call, we should care about it size.
                 $nextPostSize = mb_strlen(json_encode($crossStepsVariables));
                 $results['crossStepsVariables'] = $crossStepsVariables;
                 $results['nextPostSize'] = $nextPostSize + 1024 * 64;
                 // 64KB more for the rest of the POST query.
                 $results['postSizeLimit'] = Tools::getMaxUploadSize();
             }
             if ($results['isFinished'] && !$validateOnly && $moreStep < count($moreStepLabels)) {
                 $results['oneMoreStep'] = $moreStep + 1;
                 $results['moreStepLabel'] = $moreStepLabels[$moreStep];
             }
         }
         if ($import_type !== false) {
             $log_message = sprintf($this->l('%s import', 'AdminTab', false, false), $import_type);
             if ($offset !== false && $limit !== false) {
                 $log_message .= ' ' . sprintf($this->l('(from %s to %s)', 'AdminTab', false, false), $offset, $limit);
             }
             if (Tools::getValue('truncate')) {
                 $log_message .= ' ' . $this->l('with truncate', 'AdminTab', false, false);
             }
             PrestaShopLogger::addLog($log_message, 1, null, $import_type, null, true, (int) $this->context->employee->id);
         }
         Db::getInstance()->enableCache();
     } else {
         $this->errors[] = $this->l('To proceed, please upload a file first.');
     }
 }
开发者ID:M03G,项目名称:PrestaShop,代码行数:101,代码来源:AdminImportController.php

示例11: catchUrls

 public function catchUrls()
 {
     if (Tools::getValue('ajax') && (bool) Tools::getValue('ajax') == true) {
         return;
     }
     // Setup
     $uri_var = $this->formatLink($_SERVER['REQUEST_URI']);
     $id_shop = Shop::getContextShopID();
     $db = Db::getInstance();
     $redir = array();
     $cache_enabled = (bool) Configuration::get('MGRT_URLCACHE');
     $cache_name = 'MR1_' . $id_shop . '_' . Tools::str2url($uri_var);
     $cache_file = $this->cache_folder . md5($cache_name);
     // Better checking this before
     if ($cache_enabled === true && is_writable(_PS_CACHE_DIR_) && file_exists($this->cache_folder)) {
         $time_cache = (int) Configuration::get('MGRT_CACHETIME');
         if (file_exists($cache_file) && filemtime($cache_file) > time() - $time_cache * 60) {
             $datas = Tools::file_get_contents($cache_file);
             $redir = unserialize($datas);
             return $this->makeRedirection($redir);
         }
     }
     $sql_redir = $db->getRow('SELECT * FROM ' . _DB_PREFIX_ . 'redirect r, ' . _DB_PREFIX_ . 'redirect_shop rs WHERE rs.id_redirect = r.id_redirect AND r.old = "' . pSQL($uri_var) . '" AND rs.id_shop = ' . (int) $id_shop . ' AND r.active = 1 AND r.regex = 0 ORDER BY date_upd DESC');
     if (empty($sql_redir)) {
         $sql_regex = $db->executeS('SELECT * FROM ' . _DB_PREFIX_ . 'redirect r, ' . _DB_PREFIX_ . 'redirect_shop rs WHERE rs.id_redirect = r.id_redirect AND rs.id_shop = ' . (int) $id_shop . ' AND r.active = 1 AND r.regex = 1 ORDER BY date_upd DESC');
         $before = '/\\';
         $after = '/i';
         if (!empty($sql_regex)) {
             foreach ($sql_regex as $value) {
                 $test = preg_match($before . $value['old'] . $after, $uri_var);
                 if ((bool) $test === true) {
                     $redir['new'] = preg_replace($before . $value['old'] . $after, $value['new'], $uri_var);
                     $redir['type'] = $value['type'];
                     break;
                 }
             }
         }
     } else {
         // Match
         $redir = $sql_redir;
     }
     if ($cache_enabled === true && is_writable(_PS_CACHE_DIR_) && file_exists($this->cache_folder)) {
         try {
             file_put_contents($cache_file, serialize($redir), LOCK_EX);
         } catch (Exception $e) {
             PrestaShopLogger::addLog('Redirect Cache folder not writable, please check your modules folder permissions.');
         }
     }
     $this->makeRedirection($redir);
 }
开发者ID:acreno,项目名称:pm-ps,代码行数:50,代码来源:magicredirect.php

示例12: smartyTranslate

function smartyTranslate($params, &$smarty)
{
    $htmlentities = !isset($params['js']);
    $pdf = isset($params['pdf']);
    $addslashes = isset($params['slashes']) || isset($params['js']);
    $sprintf = isset($params['sprintf']) ? $params['sprintf'] : array();
    if (!empty($params['d'])) {
        if (isset($params['tags'])) {
            $backTrace = debug_backtrace();
            $errorMessage = sprintf('Unable to translate "%s" in %s. tags() is not supported anymore, please use sprintf().', $params['s'], $backTrace[0]['args'][1]->template_resource);
            if (_PS_MODE_DEV_) {
                throw new Exception($errorMessage);
            } else {
                PrestaShopLogger::addLog($errorMessage);
            }
        }
        if (!is_array($sprintf)) {
            $backTrace = debug_backtrace();
            $errorMessage = sprintf('Unable to translate "%s" in %s. sprintf() parameter should be an array.', $params['s'], $backTrace[0]['args'][1]->template_resource);
            if (_PS_MODE_DEV_) {
                throw new Exception($errorMessage);
            } else {
                PrestaShopLogger::addLog($errorMessage);
                return $params['s'];
            }
        }
        return Context::getContext()->getTranslator()->trans($params['s'], $sprintf, $params['d']);
    }
    if ($pdf) {
        return Translate::smartyPostProcessTranslation(Translate::getPdfTranslation($params['s'], $sprintf), $params);
    }
    $filename = !isset($smarty->compiler_object) || !is_object($smarty->compiler_object->template) ? $smarty->template_resource : $smarty->compiler_object->template->getTemplateFilepath();
    // If the template is part of a module
    if (!empty($params['mod'])) {
        return Translate::smartyPostProcessTranslation(Translate::getModuleTranslation($params['mod'], $params['s'], basename($filename, '.tpl'), $sprintf, isset($params['js'])), $params);
    }
    // If the tpl is at the root of the template folder
    if (dirname($filename) == '.') {
        $class = 'index';
    }
    // If the tpl is used by a Helper
    if (strpos($filename, 'helpers') === 0) {
        $class = 'Helper';
    } else {
        // If the tpl is used by a Controller
        if (!empty(Context::getContext()->override_controller_name_for_translations)) {
            $class = Context::getContext()->override_controller_name_for_translations;
        } elseif (isset(Context::getContext()->controller)) {
            $class_name = get_class(Context::getContext()->controller);
            $class = substr($class_name, 0, strpos(Tools::strtolower($class_name), 'controller'));
        } else {
            // Split by \ and / to get the folder tree for the file
            $folder_tree = preg_split('#[/\\\\]#', $filename);
            $key = array_search('controllers', $folder_tree);
            // If there was a match, construct the class name using the child folder name
            // Eg. xxx/controllers/customers/xxx => AdminCustomers
            if ($key !== false) {
                $class = 'Admin' . Tools::toCamelCase($folder_tree[$key + 1], true);
            } elseif (isset($folder_tree[0])) {
                $class = 'Admin' . Tools::toCamelCase($folder_tree[0], true);
            }
        }
    }
    return Translate::smartyPostProcessTranslation(Translate::getAdminTranslation($params['s'], $class, $addslashes, $htmlentities, $sprintf), $params);
}
开发者ID:M03G,项目名称:PrestaShop,代码行数:65,代码来源:smartyadmin.config.inc.php

示例13: listenIPN

 public function listenIPN($checkout, $topic, $id)
 {
     $payment_method_ids = array();
     $payment_ids = array();
     $payment_statuses = array();
     $payment_types = array();
     $credit_cards = array();
     $transaction_amounts = 0;
     $cardholders = array();
     $external_reference = '';
     if (Configuration::get('MERCADOPAGO_LOG') == 'true') {
         PrestaShopLogger::addLog('MercadoPago :: listenIPN - topic = ' . $topic, MP::INFO, 0);
         PrestaShopLogger::addLog('MercadoPago :: listenIPN - id = ' . $id, MP::INFO, 0);
         PrestaShopLogger::addLog('MercadoPago :: listenIPN - checkout = ' . $checkout, MP::INFO, 0);
     }
     if ($checkout == "standard" && $topic == 'merchant_order' && $id > 0) {
         // get merchant order info
         $result = $this->mercadopago->getMerchantOrder($id);
         $merchant_order_info = $result['response'];
         $payments = $merchant_order_info['payments'];
         $external_reference = $merchant_order_info['external_reference'];
         foreach ($payments as $payment) {
             // get payment info
             $result = $this->mercadopago->getPayment($payment['id']);
             $payment_info = $result['response']['collection'];
             // colect payment details
             $payment_ids[] = $payment_info['id'];
             $payment_statuses[] = $payment_info['status'];
             $payment_types[] = $payment_info['payment_type'];
             $transaction_amounts += $payment_info['transaction_amount'];
             if ($payment_info['payment_type'] == 'credit_card') {
                 $payment_method_ids[] = isset($payment_info['payment_method_id']) ? $payment_info['payment_method_id'] : "";
                 $credit_cards[] = isset($payment_info['last_four_digits']) ? '**** **** **** ' . $payment_info['last_four_digits'] : "";
                 $cardholders[] = $payment_info['cardholder']['name'];
             }
         }
         if ($merchant_order_info['total_amount'] == $transaction_amounts) {
             $this->updateOrder($payment_ids, $payment_statuses, $payment_method_ids, $payment_types, $credit_cards, $cardholders, $transaction_amounts, $external_reference);
         }
     } else {
         if ($checkout == "custom" && $topic == 'payment' && $id > 0) {
             $result = $this->mercadopago->getPayment($id);
             $payment_info = $result['response']['collection'];
             $external_reference = $payment_info['external_reference'];
             // colect payment details
             $payment_ids[] = $payment_info['id'];
             $payment_statuses[] = $payment_info['status'];
             $payment_types[] = $payment_info['payment_type'];
             $transaction_amounts += $payment_info['transaction_amount'];
             if ($payment_info['payment_type'] == 'credit_card') {
                 $payment_method_ids[] = $payment_info['payment_method_id'];
                 $credit_cards[] = '**** **** **** ' . $payment_info['last_four_digits'];
                 $cardholders[] = $payment_info['cardholder']['name'];
             }
             $this->updateOrder($payment_ids, $payment_statuses, $payment_method_ids, $payment_types, $credit_cards, $cardholders, $transaction_amounts, $external_reference);
         }
     }
 }
开发者ID:tusconsu,项目名称:cart-prestashop,代码行数:58,代码来源:mercadopago.php

示例14: smartyTranslate

function smartyTranslate($params, &$smarty)
{
    global $_LANG;
    if (!isset($params['js'])) {
        $params['js'] = false;
    }
    if (!isset($params['pdf'])) {
        $params['pdf'] = false;
    }
    if (!isset($params['mod'])) {
        $params['mod'] = false;
    }
    if (!isset($params['sprintf'])) {
        $params['sprintf'] = array();
    }
    if (!isset($params['d'])) {
        $params['d'] = null;
    }
    if (!is_null($params['d'])) {
        if (isset($params['tags'])) {
            $backTrace = debug_backtrace();
            $errorMessage = sprintf('Unable to translate "%s" in %s. tags() is not supported anymore, please use sprintf().', $params['s'], $backTrace[0]['args'][1]->template_resource);
            if (_PS_MODE_DEV_) {
                throw new Exception($errorMessage);
            } else {
                PrestaShopLogger::addLog($errorMessage);
            }
        }
        if (!is_array($params['sprintf'])) {
            $backTrace = debug_backtrace();
            $errorMessage = sprintf('Unable to translate "%s" in %s. sprintf() parameter should be an array.', $params['s'], $backTrace[0]['args'][1]->template_resource);
            if (_PS_MODE_DEV_) {
                throw new Exception($errorMessage);
            } else {
                PrestaShopLogger::addLog($errorMessage);
                return $params['s'];
            }
        }
    }
    if (($translation = Context::getContext()->getTranslator()->trans($params['s'], $params['sprintf'], $params['d'])) !== $params['s']) {
        return $translation;
    }
    $string = str_replace('\'', '\\\'', $params['s']);
    $filename = !isset($smarty->compiler_object) || !is_object($smarty->compiler_object->template) ? $smarty->template_resource : $smarty->compiler_object->template->getTemplateFilepath();
    $basename = basename($filename, '.tpl');
    $key = $basename . '_' . md5($string);
    if (isset($smarty->source) && strpos($smarty->source->filepath, DIRECTORY_SEPARATOR . 'override' . DIRECTORY_SEPARATOR) !== false) {
        $key = 'override_' . $key;
    }
    if ($params['mod']) {
        return Translate::smartyPostProcessTranslation(Translate::getModuleTranslation($params['mod'], $params['s'], $basename, $params['sprintf'], $params['js']), $params);
    } elseif ($params['pdf']) {
        return Translate::smartyPostProcessTranslation(Translate::getPdfTranslation($params['s'], $params['sprintf']), $params);
    }
    if ($_LANG != null && isset($_LANG[$key])) {
        $msg = $_LANG[$key];
    } elseif ($_LANG != null && isset($_LANG[Tools::strtolower($key)])) {
        $msg = $_LANG[Tools::strtolower($key)];
    } else {
        $msg = $params['s'];
    }
    if ($msg != $params['s'] && !$params['js']) {
        $msg = stripslashes($msg);
    } elseif ($params['js']) {
        $msg = addslashes($msg);
    }
    if ($params['sprintf'] !== null) {
        $msg = Translate::checkAndReplaceArgs($msg, $params['sprintf']);
    }
    return Translate::smartyPostProcessTranslation($params['js'] ? $msg : Tools::safeOutput($msg), $params);
}
开发者ID:M03G,项目名称:PrestaShop,代码行数:71,代码来源:smartyfront.config.inc.php

示例15: initContent

 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'));
         $mercadopago = $this->module;
         $mercadopago_sdk = $mercadopago->mercadopago;
         foreach ($collection_ids as $collection_id) {
             $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)) {
             $total = (double) number_format($payment_info['transaction_amount'], 2, '.', '');
             $extra_vars = array('{bankwire_owner}' => $mercadopago->textshowemail, '{bankwire_details}' => '', '{bankwire_address}' => '');
             $order_status = null;
             $payment_status = $payment_info['status'];
             switch ($payment_status) {
                 case 'in_process':
                     $order_status = 'MERCADOPAGO_STATUS_0';
                     break;
                 case 'approved':
                     $order_status = 'MERCADOPAGO_STATUS_1';
                     break;
                 case 'pending':
                     $order_status = 'MERCADOPAGO_STATUS_7';
                     break;
             }
             $order_id = Order::getOrderByCartId($cart->id);
             if ($order_status != null) {
                 if (!$order_id) {
                     $mercadopago->validateOrder($cart->id, Configuration::get($order_status), $total, $mercadopago->displayName, null, $extra_vars, $cart->id_currency, false, $cart->secure_key);
                 }
                 $order_id = !$order_id ? Order::getOrderByCartId($cart->id) : $order_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;
                 $order_payments = $order->getOrderPayments();
                 $order_payments[0]->transaction_id = Tools::getValue('collection_id');
                 $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];
                     $order_payments[0]->card_number = join(" / ", $four_digits_arr);
                     $order_payments[0]->card_brand = join(" / ", $payment_method_ids);
                     $order_payments[0]->card_holder = join(" / ", $card_holder_names);
                 }
                 $order_payments[0]->save();
                 Tools::redirectLink($uri);
             }
         }
     } else {
         PrestaShopLogger::addLog("MercadoPagoStandardReturnModuleFrontController::initContent = " . 'External reference is not set. Order placement has failed.', MP::ERROR, 0);
     }
 }
开发者ID:kocholes,项目名称:cart-prestashop,代码行数:82,代码来源:standardreturn.php


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