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


PHP PrestaShopLogger类代码示例

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


在下文中一共展示了PrestaShopLogger类的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: addLog

 /**
  * add a log item to the database and send a mail if configured for this $severity
  *
  * @param string $message the log message
  * @param int $severity
  * @param int $error_code
  * @param string $object_type
  * @param int $object_id
  * @param bool $allow_duplicate if set to true, can log several time the same information (not recommended)
  * @return bool true if succeed
  */
 public static function addLog($message, $severity = 1, $error_code = null, $object_type = null, $object_id = null, $allow_duplicate = false, $id_employee = null)
 {
     $log = new PrestaShopLogger();
     $log->severity = (int) $severity;
     $log->error_code = (int) $error_code;
     $log->message = pSQL($message);
     $log->date_add = date('Y-m-d H:i:s');
     $log->date_upd = date('Y-m-d H:i:s');
     if ($id_employee === null && isset(Context::getContext()->employee) && Validate::isLoadedObject(Context::getContext()->employee)) {
         $id_employee = Context::getContext()->employee->id;
     }
     if ($id_employee !== null) {
         $log->id_employee = (int) $id_employee;
     }
     if (!empty($object_type) && !empty($object_id)) {
         $log->object_type = pSQL($object_type);
         $log->object_id = (int) $object_id;
     }
     if ($object_type != 'Swift_Message') {
         PrestaShopLogger::sendByMail($log);
     }
     if ($allow_duplicate || !$log->_isPresent()) {
         $res = $log->add();
         if ($res) {
             self::$is_present[$log->getHash()] = isset(self::$is_present[$log->getHash()]) ? self::$is_present[$log->getHash()] + 1 : 1;
             return true;
         }
     }
     return false;
 }
开发者ID:jpodracky,项目名称:dogs,代码行数:41,代码来源:PrestaShopLogger.php

示例3: 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

示例4: 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

示例5: 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

示例6: processUpdate

 public function processUpdate()
 {
     $existing_offer = $this->object;
     $this->checkOffer();
     if (!empty($this->errors)) {
         $this->display = 'edit';
         return false;
     }
     $id = (int) Tools::getValue('id_' . $this->table);
     /* Update an existing offer */
     if (isset($id) && !empty($id)) {
         /** @var Product $object */
         $object = new $this->className((int) $id);
         $this->object = $object;
         if (Validate::isLoadedObject($object)) {
             $this->copyFromPost($object, $this->table);
             $object->indexed = 0;
             if ($object->update()) {
                 PrestaShopLogger::addLog(sprintf($this->l('%s modification', 'AdminTab', false, false), $this->className), 1, null, $this->className, (int) $this->object->id, true, (int) $this->context->employee->id);
                 if (in_array(Shop::getContext(), array(Shop::CONTEXT_SHOP, Shop::CONTEXT_ALL))) {
                     if ($this->isTabSubmitted('Products')) {
                         $this->updateProducts($object);
                         $this->updateCustomPrices($object);
                     }
                     if ($this->isTabSubmitted('Shops')) {
                         $this->updateShops($object);
                         $this->updateCustomPrices($object);
                     }
                     if ($this->isTabSubmitted('Images')) {
                         $this->processImageLegends();
                     }
                 }
                 if (empty($this->errors)) {
                     $page = (int) Tools::getValue('page');
                     // Save and stay on same form
                     if ($this->display == 'edit') {
                         $this->confirmations[] = $this->l('Update successful');
                         $this->redirect_after = self::$currentIndex . '&id_offer=' . (int) $this->object->id . '&updateoffer&conf=4&key_tab=' . Tools::safeOutput(Tools::getValue('key_tab')) . ($page > 1 ? '&page=' . (int) $page : '') . '&token=' . $this->token;
                     } else {
                         // Default behavior (save and back)
                         $this->redirect_after = self::$currentIndex . '&conf=4' . ($page > 1 ? '&submitFilteroffer=' . (int) $page : '') . '&token=' . $this->token;
                     }
                 } else {
                     $this->display = 'edit';
                 }
             } else {
                 $this->errors[] = Tools::displayError('An error occurred while updating an object.') . ' <b>' . $this->table . '</b> (' . Db::getInstance()->getMsgError() . ')';
             }
         } else {
             $this->errors[] = Tools::displayError('An error occurred while updating an object.') . ' <b>' . $this->table . '</b> (' . Tools::displayError('The object cannot be loaded. ') . ')';
         }
         return $object;
     }
 }
开发者ID:paolobattistella,项目名称:aphro,代码行数:54,代码来源:AdminAphOffersController.php

示例7: 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

示例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: processDelete

 public function processDelete()
 {
     if (PrestaShopLogger::eraseAllLogs()) {
         Tools::redirectAdmin(Context::getContext()->link->getAdminLink('AdminLogs'));
     }
 }
开发者ID:jpodracky,项目名称:dogs,代码行数:6,代码来源:AdminLogsController.php

示例10: 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

示例11: processDelete

 public function processDelete()
 {
     return PrestaShopLogger::eraseAllLogs();
 }
开发者ID:IngenioContenidoDigital,项目名称:americana,代码行数:4,代码来源:AdminLogsController.php

示例12: init


//.........这里部分代码省略.........
             $this->context->country = $new_default;
         }
     } elseif (Configuration::get('PS_DETECT_COUNTRY')) {
         $has_currency = isset($this->context->cookie->id_currency) && (int) $this->context->cookie->id_currency;
         $has_country = isset($this->context->cookie->iso_code_country) && $this->context->cookie->iso_code_country;
         $has_address_type = false;
         if ((int) $this->context->cookie->id_cart && ($cart = new Cart($this->context->cookie->id_cart)) && Validate::isLoadedObject($cart)) {
             $has_address_type = isset($cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}) && $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')};
         }
         if ((!$has_currency || $has_country) && !$has_address_type) {
             $id_country = $has_country && !Validate::isLanguageIsoCode($this->context->cookie->iso_code_country) ? (int) Country::getByIso(strtoupper($this->context->cookie->iso_code_country)) : (int) Tools::getCountry();
             $country = new Country($id_country, (int) $this->context->cookie->id_lang);
             if (!$has_currency && validate::isLoadedObject($country) && $this->context->country->id !== $country->id) {
                 $this->context->country = $country;
                 $this->context->cookie->id_currency = (int) Currency::getCurrencyInstance($country->id_currency ? (int) $country->id_currency : (int) Configuration::get('PS_CURRENCY_DEFAULT'))->id;
                 $this->context->cookie->iso_code_country = strtoupper($country->iso_code);
             }
         }
     }
     $currency = Tools::setCurrency($this->context->cookie);
     if (isset($_GET['logout']) || $this->context->customer->logged && Customer::isBanned($this->context->customer->id)) {
         $this->context->customer->logout();
         Tools::redirect(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null);
     } elseif (isset($_GET['mylogout'])) {
         $this->context->customer->mylogout();
         Tools::redirect(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null);
     }
     /* Cart already exists */
     if ((int) $this->context->cookie->id_cart) {
         if (!isset($cart)) {
             $cart = new Cart($this->context->cookie->id_cart);
         }
         if (Validate::isLoadedObject($cart) && $cart->OrderExists()) {
             PrestaShopLogger::addLog('Frontcontroller::init - Cart cannot be loaded or an order has already been placed using this cart', 1, null, 'Cart', (int) $this->context->cookie->id_cart, true);
             unset($this->context->cookie->id_cart, $cart, $this->context->cookie->checkedTOS);
             $this->context->cookie->check_cgv = false;
         } elseif (intval(Configuration::get('PS_GEOLOCATION_ENABLED')) && !in_array(strtoupper($this->context->cookie->iso_code_country), explode(';', Configuration::get('PS_ALLOWED_COUNTRIES'))) && $cart->nbProducts() && intval(Configuration::get('PS_GEOLOCATION_NA_BEHAVIOR')) != -1 && !FrontController::isInWhitelistForGeolocation() && !in_array($_SERVER['SERVER_NAME'], array('localhost', '127.0.0.1'))) {
             /* Delete product of cart, if user can't make an order from his country */
             PrestaShopLogger::addLog('Frontcontroller::init - GEOLOCATION is deleting a cart', 1, null, 'Cart', (int) $this->context->cookie->id_cart, true);
             unset($this->context->cookie->id_cart, $cart);
         } elseif ($this->context->cookie->id_customer != $cart->id_customer || $this->context->cookie->id_lang != $cart->id_lang || $currency->id != $cart->id_currency) {
             // update cart values
             if ($this->context->cookie->id_customer) {
                 $cart->id_customer = (int) $this->context->cookie->id_customer;
             }
             $cart->id_lang = (int) $this->context->cookie->id_lang;
             $cart->id_currency = (int) $currency->id;
             $cart->update();
         }
         /* Select an address if not set */
         if (isset($cart) && (!isset($cart->id_address_delivery) || $cart->id_address_delivery == 0 || !isset($cart->id_address_invoice) || $cart->id_address_invoice == 0) && $this->context->cookie->id_customer) {
             $to_update = false;
             if (!isset($cart->id_address_delivery) || $cart->id_address_delivery == 0) {
                 $to_update = true;
                 $cart->id_address_delivery = (int) Address::getFirstCustomerAddressId($cart->id_customer);
             }
             if (!isset($cart->id_address_invoice) || $cart->id_address_invoice == 0) {
                 $to_update = true;
                 $cart->id_address_invoice = (int) Address::getFirstCustomerAddressId($cart->id_customer);
             }
             if ($to_update) {
                 $cart->update();
             }
         }
     }
     if (!isset($cart) || !$cart->id) {
开发者ID:M03G,项目名称:PrestaShop,代码行数:67,代码来源:FrontController.php

示例13: hookActionOrderReturn

 public function hookActionOrderReturn($params)
 {
     try {
         if ($this->isActive()) {
             $url = $this->getApiUrl('/prestashop/webhook-order-return', true);
             $body = Tools::jsonEncode($params);
             $this->webhook($url, $body);
         }
     } catch (Exception $exception) {
         $orderReturn = $params['orderReturn'];
         $id_order = $orderReturn->id_order;
         $message = 'Darwinpricing::hookActionOrderReturn - Cannot send order return details';
         PrestaShopLogger::addLog($message, 3, null, 'Order', $id_order);
     }
 }
开发者ID:darwinpricing,项目名称:darwinpricing-prestashop,代码行数:15,代码来源:darwinpricing.php

示例14: 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

示例15: 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


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