public function loadLocalisationPack($file, $selection, $install_mode = false, $iso_localization_pack = null)
 {
     if (!($xml = @simplexml_load_string($file))) {
         return false;
     }
     libxml_clear_errors();
     $main_attributes = $xml->attributes();
     $this->name = (string) $main_attributes['name'];
     $this->version = (string) $main_attributes['version'];
     if ($iso_localization_pack) {
         $id_country = (int) Country::getByIso($iso_localization_pack);
         if ($id_country) {
             $country = new Country($id_country);
         }
         if (!$id_country || !Validate::isLoadedObject($country)) {
             $this->_errors[] = Tools::displayError(sprintf('Cannot load country : %1d', $id_country));
             return false;
         }
         if (!$country->active) {
             $country->active = 1;
             if (!$country->update()) {
                 $this->_errors[] = Tools::displayError(sprintf('Cannot enable the associated country: %1s', $country->name));
             }
         }
     }
     $res = true;
     if (empty($selection)) {
         $res &= $this->_installStates($xml);
         $res &= $this->_installTaxes($xml);
         $res &= $this->_installCurrencies($xml, $install_mode);
         $res &= $this->installConfiguration($xml);
         $res &= $this->installModules($xml);
         $res &= $this->updateDefaultGroupDisplayMethod($xml);
         if (($res || $install_mode) && isset($this->iso_code_lang)) {
             if (!($id_lang = (int) Language::getIdByIso($this->iso_code_lang, true))) {
                 $id_lang = 1;
             }
             if (!$install_mode) {
                 Configuration::updateValue('PS_LANG_DEFAULT', $id_lang);
             }
         } elseif (!isset($this->iso_code_lang) && $install_mode) {
             $id_lang = 1;
         }
         if (!Language::isInstalled(Language::getIsoById($id_lang))) {
             $res &= $this->_installLanguages($xml, $install_mode);
             $res &= $this->_installUnits($xml);
         }
         if ($install_mode && $res && isset($this->iso_currency)) {
             Cache::clean('Currency::getIdByIsoCode_*');
             $res &= Configuration::updateValue('PS_CURRENCY_DEFAULT', (int) Currency::getIdByIsoCode($this->iso_currency));
             Currency::refreshCurrencies();
         }
     } else {
         foreach ($selection as $selected) {
             // No need to specify the install_mode because if the selection mode is used, then it's not the install
             $res &= Validate::isLocalizationPackSelection($selected) ? $this->{'_install' . $selected}($xml) : false;
         }
     }
     return $res;
 }
Exemple #2
0
 protected function tearDown()
 {
     $this->PDO->exec('TRUNCATE TABLE `' . PREFIX . 'training`');
     $this->PDO->exec('TRUNCATE TABLE `' . PREFIX . 'sport`');
     $this->PDO->exec('TRUNCATE TABLE `' . PREFIX . 'shoe`');
     \Cache::clean();
 }
Exemple #3
0
 public function initializeContext()
 {
     global $smarty;
     // Clean all cache values
     Cache::clean('*');
     Context::getContext()->shop = new Shop(1);
     Shop::setContext(Shop::CONTEXT_SHOP, 1);
     Configuration::loadConfiguration();
     if (!isset(Context::getContext()->language) || !Validate::isLoadedObject(Context::getContext()->language)) {
         if ($id_lang = (int) Configuration::get('PS_LANG_DEFAULT')) {
             Context::getContext()->language = new Language($id_lang);
         }
     }
     if (!isset(Context::getContext()->country) || !Validate::isLoadedObject(Context::getContext()->country)) {
         if ($id_country = (int) Configuration::get('PS_COUNTRY_DEFAULT')) {
             Context::getContext()->country = new Country((int) $id_country);
         }
     }
     if (!isset(Context::getContext()->currency) || !Validate::isLoadedObject(Context::getContext()->currency)) {
         if ($id_currency = (int) Configuration::get('PS_CURRENCY_DEFAULT')) {
             Context::getContext()->currency = new Currency((int) $id_currency);
         }
     }
     Context::getContext()->cart = new Cart();
     Context::getContext()->employee = new Employee(1);
     if (!defined('_PS_SMARTY_FAST_LOAD_')) {
         define('_PS_SMARTY_FAST_LOAD_', true);
     }
     require_once _PS_ROOT_DIR_ . '/config/smarty.config.inc.php';
     Context::getContext()->smarty = $smarty;
 }
Exemple #4
0
 public function update($null_values = false)
 {
     Cache::clean('getContextualValue_' . $this->id . '_*');
     if (!$this->reduction_currency) {
         $this->reduction_currency = (int) Configuration::get('PS_CURRENCY_DEFAULT');
     }
     return parent::update($null_values);
 }
Exemple #5
0
 protected function tearDown()
 {
     $this->PDO->exec('DELETE FROM `' . PREFIX . 'training`');
     $this->PDO->exec('DELETE FROM `' . PREFIX . 'sport`');
     $this->PDO->exec('DELETE FROM `' . PREFIX . 'equipment_type`');
     $Factory = new Model\Factory(0);
     $Factory->clearCache('sport');
     \Cache::clean();
 }
Exemple #6
0
 protected function tearDown()
 {
     $this->PDO->exec('DELETE FROM `' . PREFIX . 'training`');
     $this->PDO->exec('DELETE FROM `' . PREFIX . 'trackdata`');
     $this->PDO->exec('DELETE FROM `' . PREFIX . 'swimdata`');
     $this->PDO->exec('DELETE FROM `' . PREFIX . 'route`');
     $this->PDO->exec('DELETE FROM `' . PREFIX . 'sport`');
     \Cache::clean();
 }
 /**
  * Try to clear cache
  */
 protected function tryToClearCache()
 {
     try {
         new Cache();
         Cache::clean();
         $this->CacheWasCleared = true;
     } catch (Exception $e) {
         $this->CacheWasCleared = false;
     }
 }
Exemple #8
0
 /**
  * Run job
  */
 public function run()
 {
     if ($this->isRequested(self::ELEVATION)) {
         $this->runRouteLoop();
     }
     if (count($this->updateSet())) {
         $this->runActivityLoop();
         // This may be removed if single activities are not cached anymore.
         \Cache::clean();
     }
 }
 public function loadLocalisationPack($file, $selection, $install_mode = false)
 {
     if (!($xml = simplexml_load_string($file))) {
         return false;
     }
     $main_attributes = $xml->attributes();
     $this->name = (string) $main_attributes['name'];
     $this->version = (string) $main_attributes['version'];
     if (empty($selection)) {
         $res = true;
         $res &= $this->_installStates($xml);
         $res &= $this->_installTaxes($xml);
         $res &= $this->_installCurrencies($xml, $install_mode);
         $res &= $this->_installUnits($xml);
         $res &= $this->installConfiguration($xml);
         $res &= $this->installModules($xml);
         $res &= $this->_installLanguages($xml, $install_mode);
         if ($res && isset($this->iso_code_lang)) {
             if (!($id_lang = (int) Language::getIdByIso($this->iso_code_lang))) {
                 $id_lang = 1;
             }
             if (!$install_mode) {
                 Configuration::updateValue('PS_LANG_DEFAULT', $id_lang);
             }
         }
         if ($install_mode && $res && isset($this->iso_currency)) {
             Cache::clean('Currency::getIdByIsoCode_*');
             $res &= Configuration::updateValue('PS_CURRENCY_DEFAULT', (int) Currency::getIdByIsoCode($this->iso_currency));
             Currency::refreshCurrencies();
         }
         return $res;
     }
     foreach ($selection as $selected) {
         if (strtolower((string) $selected) == 'currencies') {
             if (!Validate::isLocalizationPackSelection($selected) || !$this->{'_install' . ucfirst($selected)}($xml, true)) {
                 return false;
             }
         } else {
             if (!Validate::isLocalizationPackSelection($selected) || !$this->{'_install' . ucfirst($selected)}($xml)) {
                 return false;
             }
         }
     }
     return true;
 }
Exemple #10
0
 public function loadLocalisationPack($file, $selection, $install_mode = false)
 {
     if (!($xml = simplexml_load_string($file))) {
         return false;
     }
     $main_attributes = $xml->attributes();
     $this->name = (string) $main_attributes['name'];
     $this->version = (string) $main_attributes['version'];
     $res = true;
     if (empty($selection)) {
         $res &= $this->_installStates($xml);
         $res &= $this->_installTaxes($xml);
         $res &= $this->_installCurrencies($xml, $install_mode);
         $res &= $this->_installUnits($xml);
         $res &= $this->installConfiguration($xml);
         $res &= $this->installModules($xml);
         $res &= $this->_installLanguages($xml, $install_mode);
         $res &= $this->updateDefaultGroupDisplayMethod($xml);
         if ($res && isset($this->iso_code_lang)) {
             if (!($id_lang = (int) Language::getIdByIso($this->iso_code_lang))) {
                 $id_lang = 1;
             }
             if (!$install_mode) {
                 Configuration::updateValue('PS_LANG_DEFAULT', $id_lang);
             }
         }
         if ($install_mode && $res && isset($this->iso_currency)) {
             Cache::clean('Currency::getIdByIsoCode_*');
             $res &= Configuration::updateValue('PS_CURRENCY_DEFAULT', (int) Currency::getIdByIsoCode($this->iso_currency));
             Currency::refreshCurrencies();
         }
     } else {
         foreach ($selection as $selected) {
             // No need to specify the install_mode because if the selection mode is used, then it's not the install
             $res &= Validate::isLocalizationPackSelection($selected) ? $this->{'_install' . $selected}($xml) : false;
         }
     }
     return $res;
 }
Exemple #11
0
 /**
  * Clear complete cache 
  */
 public static function clearCache()
 {
     Cache::clean();
 }
Exemple #12
0
    public function removeCartRule($id_cart_rule)
    {
        Cache::clean('Cart::getCartRules' . $this->id . '-' . CartRule::FILTER_ACTION_ALL);
        Cache::clean('Cart::getCartRules' . $this->id . '-' . CartRule::FILTER_ACTION_SHIPPING);
        Cache::clean('Cart::getCartRules' . $this->id . '-' . CartRule::FILTER_ACTION_REDUCTION);
        Cache::clean('Cart::getCartRules' . $this->id . '-' . CartRule::FILTER_ACTION_GIFT);
        $result = Db::getInstance()->execute('
		DELETE FROM `' . _DB_PREFIX_ . 'cart_cart_rule`
		WHERE `id_cart_rule` = ' . (int) $id_cart_rule . '
		AND `id_cart` = ' . (int) $this->id . '
		LIMIT 1');
        $cart_rule = new CartRule($id_cart_rule, Configuration::get('PS_LANG_DEFAULT'));
        if ((int) $cart_rule->gift_product) {
            $this->updateQty(1, $cart_rule->gift_product, $cart_rule->gift_product_attribute, null, 'down', 0, null, false);
        }
        return $result;
    }
Exemple #13
0
 /**
  * Set the delivery option and id_carrier, if there is only one carrier
  */
 public function setDeliveryOption($delivery_option = null)
 {
     if (empty($delivery_option) || count($delivery_option) == 0) {
         $this->delivery_option = '';
         $this->id_carrier = 0;
         return;
     }
     Cache::clean('getContextualValue_*');
     $delivery_option_list = $this->getDeliveryOptionList(null, true);
     foreach ($delivery_option_list as $id_address => $options) {
         if (!isset($delivery_option[$id_address])) {
             foreach ($options as $key => $option) {
                 if ($option['is_best_price']) {
                     $delivery_option[$id_address] = $key;
                     break;
                 }
             }
         }
     }
     if (count($delivery_option) == 1) {
         $this->id_carrier = $this->getIdCarrierFromDeliveryOption($delivery_option);
     }
     $this->delivery_option = serialize($delivery_option);
 }
 public function validateOrder($id_cart, $id_order_state, $amountPaid, $paymentMethod = 'Unknown', $message = NULL, $extraVars = array(), $currency_special = NULL, $dont_touch_amount = false, $secure_key = false, Shop $shop = null)
 {
     @session_start();
     @set_time_limit(120);
     $_SESSION['id_cart_validating'] = (int) $id_cart;
     if (Module::isInstalled('agileprepaidcredit')) {
         require_once _PS_ROOT_DIR_ . "/modules/agileprepaidcredit/agileprepaidcredit.php";
         AgilePrepaidCredit::set_token_payment_processing_marker($id_cart, true);
     }
     if (!Module::isInstalled('agilemultipleseller')) {
         $ret = parent::validateOrder($id_cart, $id_order_state, $amountPaid, $paymentMethod, $message, $extraVars, $currency_special, $dont_touch_amount, $secure_key);
         if (Module::isInstalled('agileprepaidcredit')) {
             AgilePrepaidCredit::adjustOrderForTokens($this->currentOrder);
             if ($this->name == 'agilepaypalparallel' || ($this->name = 'agilepaypaladaptive')) {
                 AgilePrepaidCredit::checkOrderInvoicePayment($this->currentOrder);
             }
         }
         return $ret;
     }
     require_once _PS_ROOT_DIR_ . "/modules/agilemultipleseller/agilemultipleseller.php";
     $paymode = (int) Configuration::get('AGILE_MS_PAYMENT_MODE');
     $sellers = AgileMultipleSeller::getSellersByCart($id_cart);
     if (count($sellers) <= 1) {
         $id_cart_patent = AgileMultipleSeller::get_subcart_parentid($id_cart);
         $ordervalided = parent::validateOrder($id_cart, $id_order_state, $amountPaid, $paymentMethod, $message, $extraVars, $currency_special, $dont_touch_amount, $secure_key);
         $this->updateSellerCommissionRecordType($paymode, $message);
         if ($ordervalided and $id_cart_patent > 0) {
             AgileMultipleSeller::remove_subcart_items_from_maincart($id_cart, $this->currentOrder);
         }
         if (Module::isInstalled('agileprepaidcredit')) {
             AgilePrepaidCredit::adjustOrderForTokens($this->currentOrder);
             if ($this->name == 'agilepaypalparallel' || ($this->name = 'agilepaypaladaptive')) {
                 AgilePrepaidCredit::checkOrderInvoicePayment($this->currentOrder);
             }
         }
         return $ordervalided;
     }
     $cartinfos = AgileMultipleSeller::split_shopping_cart($id_cart, $sellers);
     if (empty($cartinfos)) {
         $ret = parent::validateOrder($id_cart, $id_order_state, $amountPaid, $paymentMethod, $message, $extraVars, $currency_special, $dont_touch_amount, $secure_key);
         $this->updateSellerCommissionRecordType($paymode, $message);
         if (Module::isInstalled('agileprepaidcredit')) {
             AgilePrepaidCredit::adjustOrderForTokens($this->currentOrder);
             if ($this->name == 'agilepaypalparallel' || ($this->name = 'agilepaypaladaptive')) {
                 AgilePrepaidCredit::checkOrderInvoicePayment($this->currentOrder);
             }
         }
         return $ret;
     }
     $ret = true;
     foreach ($cartinfos as $cartinfo) {
         $_SESSION['id_cart_validating'] = (int) $cartinfo['id_cart'];
         $this->context->cart = new Cart(intval($cartinfo['id_cart']));
         $this->context->cart->getPackageList(true);
         $filter = CartRule::FILTER_ACTION_ALL;
         $cache_key = 'Cart::getCartRules' . $cartinfo['id_cart'] . '-' . $filter;
         if (Cache::isStored($cache_key)) {
             Cache::clean($cache_key);
         }
         if (Module::isInstalled('agileprepaidcredit')) {
             AgilePrepaidCredit::set_token_payment_processing_marker($cartinfo['id_cart'], true);
         }
         $ret = $ret and parent::validateOrder($cartinfo['id_cart'], $id_order_state, $cartinfo['amountPaid'], $paymentMethod, $message, $extraVars, $currency_special, $dont_touch_amount, $secure_key);
         $this->updateSellerCommissionRecordType($paymode, $message);
         if ($this->name == 'agilepaypalparallel') {
             $this->updateTxnDetailCartID($message, $this->currentOrder, $cartinfo['id_cart']);
         }
         if (Module::isInstalled('agileprepaidcredit')) {
             AgilePrepaidCredit::adjustOrderForTokens($this->currentOrder);
             if ($this->name == 'agilepaypalparallel' || ($this->name = 'agilepaypaladaptive')) {
                 AgilePrepaidCredit::adjustOrderPaymentAmount($this->currentOrder, $this->name);
                 AgilePrepaidCredit::checkOrderInvoicePayment($this->currentOrder);
             }
         }
     }
     return $ret;
 }
    /**
     *
     * This method allows to add a payment to the current order
     * @since 1.5.0.1
     * @param float $amount_paid
     * @param string $payment_method
     * @param string $payment_transaction_id
     * @param Currency $currency
     * @param string $date
     * @param OrderInvoice $order_invoice
     * @return bool
     */
    public function addOrderPayment($amount_paid, $payment_method = null, $payment_transaction_id = null, $currency = null, $date = null, $order_invoice = null)
    {
        $order_payment = new OrderPayment();
        $order_payment->order_reference = $this->reference;
        $order_payment->id_currency = $currency ? $currency->id : $this->id_currency;
        // we kept the currency rate for historization reasons
        $order_payment->conversion_rate = $currency ? $currency->conversion_rate : 1;
        // if payment_method is define, we used this
        $order_payment->payment_method = $payment_method ? $payment_method : $this->payment;
        $order_payment->transaction_id = $payment_transaction_id;
        $order_payment->amount = $amount_paid;
        $order_payment->date_add = $date ? $date : null;
        // Update total_paid_real value for backward compatibility reasons
        if ($order_payment->id_currency == $this->id_currency) {
            $this->total_paid_real += $order_payment->amount;
        } else {
            $this->total_paid_real += Tools::ps_round(Tools::convertPrice($order_payment->amount, $order_payment->id_currency, false), 2);
        }
        // We put autodate parameter of add method to true if date_add field is null
        $res = $order_payment->add(is_null($order_payment->date_add)) && $this->update();
        if (!$res) {
            return false;
        }
        if (!is_null($order_invoice)) {
            $res = Db::getInstance()->execute('
			INSERT INTO `' . _DB_PREFIX_ . 'order_invoice_payment` (`id_order_invoice`, `id_order_payment`, `id_order`)
			VALUES(' . (int) $order_invoice->id . ', ' . (int) $order_payment->id . ', ' . (int) $this->id . ')');
            // Clear cache
            Cache::clean('order_invoice_paid_*');
        }
        return $res;
    }
Exemple #16
0
 public function update($null_values = false)
 {
     Cache::clean('getContextualValue_' . $this->id . '_*');
     return parent::update($null_values);
 }
 public function hookSubcartPaymentInfo($modulename, $formid, $is_parallel_payment = false)
 {
     global $smarty, $cookie;
     $_SESSION[self::SUBCART_SESSION_KEY] = 0;
     if (intval(Configuration::get("AGILE_MS_PAYMENT_MODE")) == self::PAYMENT_MODE_SELLER or ${${"GLOBALS"}["ecmmoezcsbwo"]} == "parallel_confirm_form") {
         include_once _PS_ROOT_DIR_ . "/modules/agilemultipleseller/SellerInfo.php";
         ${"GLOBALS"}["udjhod"] = "unpaid_sellers";
         include_once _PS_ROOT_DIR_ . "/modules/agilemultipleseller/AgileSellerPaymentInfo.php";
         ${${"GLOBALS"}["udjhod"]} = self::get_unpaid_sellers();
         if (!empty(${${"GLOBALS"}["uhnoyti"]}) and count(${${"GLOBALS"}["uhnoyti"]}) > 0) {
             $pegmrqvvh = "unpaid_sellers";
             $qfgtoxgglb = "unpaid_seller";
             ${"GLOBALS"}["owphoxzzq"] = "existSupportPayment";
             ${"GLOBALS"}["cqmbmhojw"] = "formid";
             ${"GLOBALS"}["ivclipi"] = "recepient";
             $gjsoifwdwzb = "is_parallel_payment";
             ${${"GLOBALS"}["vlhmfsabigj"]} = array();
             foreach (${$pegmrqvvh} as ${$qfgtoxgglb}) {
                 $cszptxpxew = "unpaid_seller";
                 ${"GLOBALS"}["kybolky"] = "id_seller";
                 ${"GLOBALS"}["tcdertwhmw"] = "subcart_discounts";
                 $iefslihwm = "id_seller";
                 $uzgiknt = "subcart_discounts";
                 ${"GLOBALS"}["vbpkbvdrm"] = "support_payment";
                 $lowipyaeb = "formid";
                 ${"GLOBALS"}["wvfdosp"] = "other_info";
                 $jabgpgnqebr = "id_seller";
                 ${${"GLOBALS"}["vbpkbvdrm"]} = 1;
                 $fdcpbg = "seller_name";
                 ${"GLOBALS"}["xbhypslnqt"] = "id_seller";
                 ${${"GLOBALS"}["qcrytsf"]} = ${$cszptxpxew}["id_owner"];
                 if (${$iefslihwm} > 0 && ${$lowipyaeb} != "parallel_confirm_form") {
                     $mpjbyikbk = "modulename";
                     ${"GLOBALS"}["jbztmlz"] = "modulename";
                     ${${"GLOBALS"}["tvyjtwh"]} = ${${"GLOBALS"}["zphwvfrdss"]};
                     $tekrbf = "paymentinfo";
                     if (${${"GLOBALS"}["jbztmlz"]} == "agilegooglecheckout") {
                         $frykoy = "payment_modulename";
                         ${$frykoy} = "googlecheckout";
                     } else {
                         if (${$mpjbyikbk} == "agilebankwire") {
                             ${"GLOBALS"}["humivxnjrbk"] = "payment_modulename";
                             ${${"GLOBALS"}["humivxnjrbk"]} = "bankwire";
                         }
                     }
                     ${"GLOBALS"}["lldqjfu"] = "payment_modulename";
                     ${$tekrbf} = AgileSellerPaymentInfo::getForSellerByModuleName(${${"GLOBALS"}["lldqjfu"]}, ${${"GLOBALS"}["qcrytsf"]});
                     if (!Validate::isLoadedObject(${${"GLOBALS"}["ntnrquojkaa"]})) {
                         ${${"GLOBALS"}["vjlgjofetoi"]} = 0;
                     } else {
                         if ($paymentinfo->in_use != 1) {
                             $brbrgptdpef = "support_payment";
                             ${$brbrgptdpef} = 0;
                         }
                     }
                 }
                 ${"GLOBALS"}["epycwhcjrfr"] = "seller_name";
                 $xerwnucdb = "cartinfo";
                 ${${"GLOBALS"}["oclbkvhtf"]} = AgileMultipleSeller::create_subcart_for_seller(${$jabgpgnqebr});
                 ${"GLOBALS"}["rivnorkzj"] = "moduleinstance";
                 ${"GLOBALS"}["ngpracnqrs"] = "moduleinstance";
                 $rmsixygh = "modulename";
                 ${${"GLOBALS"}["epycwhcjrfr"]} = "";
                 ${"GLOBALS"}["rgokucipqb"] = "subcart_total";
                 if (${${"GLOBALS"}["kybolky"]} == 0) {
                     ${${"GLOBALS"}["rcxekslsb"]} = Configuration::get("PS_SHOP_NAME");
                 } else {
                     ${"GLOBALS"}["polxsocg"] = "id_seller";
                     $iqphuuwjje = "seller_name";
                     ${${"GLOBALS"}["atnqtpp"]} = new SellerInfo(SellerInfo::getIdBSellerId(${${"GLOBALS"}["polxsocg"]}), $cookie->id_lang);
                     ${$iqphuuwjje} = isset(${${"GLOBALS"}["atnqtpp"]}) ? $sellerinfo->company : $this->getL("Unknow");
                 }
                 Cache::clean("Cart::getCartRules" . ${$xerwnucdb}["id_cart"] . "-*");
                 ${${"GLOBALS"}["uuouexp"]} = new Cart(${${"GLOBALS"}["oclbkvhtf"]}["id_cart"]);
                 ${${"GLOBALS"}["rgokucipqb"]} = $subcart->getOrderTotal(true, Cart::BOTH, null, null, false);
                 ${${"GLOBALS"}["tcdertwhmw"]} = $subcart->getOrderTotal(true, Cart::ONLY_DISCOUNTS, null, null, false);
                 ${${"GLOBALS"}["brvkng"]} = $subcart->getOrderTotal(true, Cart::BOTH) - $subcart->getOrderTotal(false, Cart::BOTH);
                 ${${"GLOBALS"}["gcpcmr"]} = Module::getInstanceByName(${$rmsixygh});
                 ${"GLOBALS"}["duvlppreoh"] = "recepients";
                 ${${"GLOBALS"}["krvwnkwth"]} = "";
                 if (Validate::isLoadedObject(${${"GLOBALS"}["rivnorkzj"]}) && method_exists(${${"GLOBALS"}["ngpracnqrs"]}, "getAdditionalInfo")) {
                     ${${"GLOBALS"}["krvwnkwth"]} = $moduleinstance->getAdditionalInfo(${${"GLOBALS"}["qcrytsf"]});
                 }
                 ${${"GLOBALS"}["duvlppreoh"]}[] = array("id_seller" => ${${"GLOBALS"}["xbhypslnqt"]}, "support_payment" => ${${"GLOBALS"}["vjlgjofetoi"]}, "seller_name" => ${$fdcpbg}, "products" => $subcart->getProducts(), "id_subcart" => $subcart->id, "total_tax" => ${${"GLOBALS"}["brvkng"]}, "shippingCost" => $subcart->getOrderTotal(true, Cart::ONLY_SHIPPING), "subcart_total" => ${${"GLOBALS"}["ewciuizck"]}, "subcart_totaldiscounts" => ${$uzgiknt}, "other_info" => ${${"GLOBALS"}["wvfdosp"]});
             }
             $wfvtkolo = "recepients";
             ${${"GLOBALS"}["oxuqpqbl"]} = false;
             foreach (${$wfvtkolo} as ${${"GLOBALS"}["ivclipi"]}) {
                 ${"GLOBALS"}["lwviwhhyz"] = "recepient";
                 if (${${"GLOBALS"}["lwviwhhyz"]}["support_payment"] == 1) {
                     ${"GLOBALS"}["imdsmll"] = "existSupportPayment";
                     ${${"GLOBALS"}["imdsmll"]} = true;
                     break;
                 }
             }
             if (!${${"GLOBALS"}["owphoxzzq"]}) {
                 return "";
             }
             $smarty->assign(array("recepients" => ${${"GLOBALS"}["vlhmfsabigj"]}, "modulename" => ${${"GLOBALS"}["zphwvfrdss"]}, "moduleformid" => ${${"GLOBALS"}["cqmbmhojw"]}, "is_parallel_payment" => ${$gjsoifwdwzb}));
             return $this->display($this->get_module_file(), "payment-subcart.tpl");
         }
     }
 }
Exemple #18
0
<pre>
<?php 
require_once '../../Nette/loader.php';
/*use Nette\Caching\Cache;*/
/*use Nette\Debug;*/
$tmpDir = dirname(__FILE__) . '/tmp';
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($tmpDir), RecursiveIteratorIterator::CHILD_FIRST) as $entry) {
    // delete all files
    if ($entry->isDir()) {
        @rmdir($entry);
    } else {
        @unlink($entry);
    }
}
$storage = new FileStorage($tmpDir);
$cache = new Cache($storage);
echo "Writing cache...\n";
$cache->save('key1', 'value1', array(Cache::TAGS => array('one', 'two')));
$cache->save('key2', 'value2', array(Cache::TAGS => array('one', 'three')));
$cache->save('key3', 'value3', array(Cache::TAGS => array('two', 'three')));
$cache['key4'] = 'value4';
echo "Cleaning by tags...\n";
$cache->clean(array(Cache::TAGS => 'one'));
echo "Is cached key1?\n";
Debug::dump(isset($cache['key1']));
echo "Is cached key2?\n";
Debug::dump(isset($cache['key2']));
echo "Is cached key3?\n";
Debug::dump(isset($cache['key3']));
echo "Is cached key4?\n";
Debug::dump(isset($cache['key4']));
 function premoder($module)
 {
     $Register = Register::getInstance();
     $Model = $Register['ModManager']->getModelInstance($module);
     $entity = $Model->getById(intval($_GET['id']));
     if (!empty($entity)) {
         $status = $_GET['status'];
         if (!in_array($status, array('rejected', 'confirmed'))) {
             $status = 'nochecked';
         }
         $entity->setPremoder($status);
         $entity->save();
         $_SESSION['message'] = __('Saved');
         //clean cache
         $Cache = new Cache();
         $Cache->clean(CACHE_MATCHING_ANY_TAG, array('module_' . $module));
     } else {
         $_SESSION['errors'] = __('Some error occurred');
     }
     redirect('/admin/materials_list.php?m=' . $module . '&premoder=1');
 }
 /**
  * Cleans the cache for specific cache key.
  *
  * @param $key
  */
 public function clean($key)
 {
     Cache::clean($key);
 }
Exemple #21
0
 /**
  * Set TaxRulesGroup
  *
  * @param  int $id_tax_rules_group    Set the TaxRulesGroup with the given ID
  *                                    as this Carrier's TaxRulesGroup
  * @param bool $all_shops             True if this should be done for all shops
  *
  * @return bool Whether the TaxRulesGroup has been succesfully set
  *              for this Carrier in this Shop or all given Shops
  */
 public function setTaxRulesGroup($id_tax_rules_group, $all_shops = false)
 {
     if (!Validate::isUnsignedId($id_tax_rules_group)) {
         die(Tools::displayError());
     }
     if (!$all_shops) {
         $shops = Shop::getContextListShopID();
     } else {
         $shops = Shop::getShops(true, null, true);
     }
     $this->deleteTaxRulesGroup($shops);
     $values = array();
     foreach ($shops as $id_shop) {
         $values[] = array('id_carrier' => (int) $this->id, 'id_tax_rules_group' => (int) $id_tax_rules_group, 'id_shop' => (int) $id_shop);
     }
     Cache::clean('carrier_id_tax_rules_group_' . (int) $this->id . '_' . (int) Context::getContext()->shop->id);
     return Db::getInstance()->insert('carrier_tax_rules_group_shop', $values);
 }
Exemple #22
0
 public static function syncProducts($products, $context, $id_lang, $request_context = null, $log_type = false)
 {
     if (!$products) {
         return;
     }
     $date = date('Y-m-d H:i:s');
     // Get errors back
     if (file_exists(dirname(__FILE__) . '/../log/syncError.php')) {
         include dirname(__FILE__) . '/../log/syncError.php';
     }
     $tab_error = array();
     // Up the time limit
     @set_time_limit(3600);
     $product_ids = array_map(array('EbaySynchronizer', 'getIdProduct'), $products);
     if (method_exists('Cache', 'clean')) {
         Cache::clean('StockAvailable::getQuantityAvailableByProduct_*');
     }
     foreach ($products as $p) {
         $product = new Product((int) $p['id_product'], true, $id_lang);
         $product_configuration = EbayProductConfiguration::getByProductIdAndProfile($p['id_product'], $p['id_ebay_profile']);
         // make sure that product exists in the db and has a default category
         if (!Validate::isLoadedObject($product) || !$product->id_category_default) {
             continue;
         }
         $quantity_product = EbaySynchronizer::_getProductQuantity($product, (int) $p['id_product']);
         $ebay_profile = new EbayProfile((int) $p['id_ebay_profile']);
         if (!$ebay_profile->getConfiguration('EBAY_HAS_SYNCED_PRODUCTS')) {
         }
         $ebay_profile->setConfiguration('EBAY_HAS_SYNCED_PRODUCTS', 1);
         $ebay_category = EbaySynchronizer::_getEbayCategory($product->id_category_default, $ebay_profile);
         $variations = EbaySynchronizer::_loadVariations($product, $ebay_profile, $context, $ebay_category);
         $ebay = new EbayRequest((int) $p['id_ebay_profile'], $request_context);
         if (!$product->active || $product_configuration && $product_configuration['blacklisted']) {
             // try to stop sale on eBay
             $ebay = EbaySynchronizer::endProductOnEbay($ebay, $ebay_profile, $context, $id_lang, null, $product->id);
             if (!empty($ebay->error)) {
                 $tab_error = EbaySynchronizer::_updateTabError($ebay->error, str_replace('&', '&amp;', $product->name));
                 if ($log_type) {
                     EbayLog::write('Error: ' . $ebay->error, $log_type);
                 }
             }
             continue;
         }
         $pictures = EbaySynchronizer::_getPictures($product, $ebay_profile, $id_lang, $context, $variations);
         // Load basic price
         list($price, $price_original) = EbaySynchronizer::_getPrices($product->id, $ebay_category->getPercent(), $ebay_profile);
         $conditions = $ebay_category->getConditionsValues($p['id_ebay_profile']);
         $ebay_store_category_id = pSQL(EbayStoreCategoryConfiguration::getEbayStoreCategoryIdByIdProfileAndIdCategory($ebay_profile->id, $product->id_category_default));
         // Generate array and try insert in database
         $data = array('price' => $price, 'quantity' => $quantity_product, 'categoryId' => $ebay_category->getIdCategoryRef(), 'variations' => $variations, 'pictures' => $pictures['general'], 'picturesMedium' => $pictures['medium'], 'picturesLarge' => $pictures['large'], 'condition' => $conditions[$product->condition], 'shipping' => EbaySynchronizer::_getShippingDetailsForProduct($product, $ebay_profile), 'id_lang' => $id_lang, 'real_id_product' => (int) $p['id_product'], 'ebay_store_category_id' => $ebay_store_category_id);
         $data = array_merge($data, EbaySynchronizer::_getProductData($product, $ebay_profile));
         // Fix hook update product
         if (Tools::getValue('id_product_attribute')) {
             $id_product_attribute_fix = (int) Tools::getValue('id_product_attribute');
             $key = $product_id . '-' . $id_product_attribute_fix . '_' . $ebay_profile->id;
             if (isset($data['variations'][$key]['quantity'])) {
                 $data['variations'][$key]['quantity'] = EbaySynchronizer::_fixHookUpdateProduct($context, $product_id, $data['variations'][$key]['quantity']);
             }
         }
         // Price Update
         if (isset($p['noPriceUpdate'])) {
             $data['noPriceUpdate'] = $p['noPriceUpdate'];
         }
         $clean_percent = $ebay_category->getCleanPercent();
         // Save percent and price discount
         if ($clean_percent < 0) {
             $data['price_original'] = round($price_original, 2);
             //				$data['price_percent'] = round($clean_percent);
         } elseif ($price_original > $price) {
             $data['price_original'] = round($price_original, 2);
         }
         if (isset($data['price_original'])) {
             $data['price_percent'] = round(($price_original - $price) / $price_original * 100.0);
         }
         $data['description'] = EbaySynchronizer::_getEbayDescription($product, $ebay_profile, $id_lang);
         // Export to eBay
         $ebay = EbaySynchronizer::_exportProductToEbay($product, $data, $p['id_ebay_profile'], $ebay_category, $ebay, $date, $context, $id_lang);
         if (!empty($ebay->error)) {
             $tab_error = EbaySynchronizer::_updateTabError($ebay->error, $data['name']);
             if ($log_type) {
                 EbayLog::write('Error: ' . $ebay->error, $log_type);
             }
         } elseif ($log_type) {
             EbayLog::write('Success', $log_type);
         }
         if ($request_context == 'CRON') {
             Configuration::updateValue('NB_PRODUCTS_LAST', (int) Configuration::get('NB_PRODUCTS_LAST') + 1);
         }
     }
     if (count($tab_error)) {
         if (isset($all_error)) {
             foreach ($all_error as $key => $value) {
                 if (isset($tab_error[$key])) {
                     $tab_error[$key]['products'] = array_merge($all_error[$key]['products'], $tab_error[$key]['products']);
                 } else {
                     $tab_error[$key] = $all_error[$key];
                 }
             }
         }
         file_put_contents(dirname(__FILE__) . '/../log/syncError.php', '<?php $all_error = ' . var_export($tab_error, true) . '; ' . ($ebay->itemConditionError ? '$itemConditionError = true; ' : '$itemConditionError = false;') . ' ?>');
     }
 }
Exemple #23
0
    /**
     * Removes a given product from the stock available
     *
     * @param int $id_product
     * @param int $id_product_attribute Optional
     * @param mixed $id_shop shop id or shop object Optional
     */
    public static function removeProductFromStockAvailable($id_product, $id_product_attribute = null, $shop = null)
    {
        if (!Validate::isUnsignedId($id_product)) {
            return false;
        }
        if (Shop::getContext() == SHOP::CONTEXT_SHOP) {
            if (Shop::getContextShopGroup()->share_stock == 1) {
                $pa_sql = '';
                if ($id_product_attribute !== null) {
                    $pa_sql = '_attribute';
                    $id_product_attribute_sql = $id_product_attribute;
                } else {
                    $id_product_attribute_sql = $id_product;
                }
                if ((int) Db::getInstance()->getValue('SELECT COUNT(*)
						FROM ' . _DB_PREFIX_ . 'product' . $pa_sql . '_shop
						WHERE id_product' . $pa_sql . '=' . (int) $id_product_attribute_sql . ' 
							AND id_shop IN (' . implode(',', array_map('intval', Shop::getContextListShopID(SHOP::SHARE_STOCK))) . ')')) {
                    return true;
                }
            }
        }
        $res = Db::getInstance()->execute('
		DELETE FROM ' . _DB_PREFIX_ . 'stock_available
		WHERE id_product = ' . (int) $id_product . ($id_product_attribute ? ' AND id_product_attribute = ' . (int) $id_product_attribute : '') . StockAvailable::addSqlShopRestriction(null, $shop));
        if ($id_product_attribute) {
            if ($shop === null || !Validate::isLoadedObject($shop)) {
                $shop_datas = array();
                StockAvailable::addSqlShopParams($shop_datas);
                $id_shop = (int) $shop_datas['id_shop'];
            } else {
                $id_shop = (int) $shop->id;
            }
            $stock_available = new StockAvailable();
            $stock_available->id_product = (int) $id_product;
            $stock_available->id_product_attribute = (int) $id_product;
            $stock_available->id_shop = (int) $id_shop;
            $stock_available->postSave();
        }
        Cache::clean('StockAvailable::getQuantityAvailableByProduct_' . (int) $id_product . '*');
        return $res;
    }
Exemple #24
0
 public function add($autodate = true, $null_values = false)
 {
     Cache::clean('hook_idsbyname');
     return parent::add($autodate, $null_values);
 }
 public function __destruct()
 {
     if (is_object($this)) {
         $class = get_class($this);
         if (method_exists('Cache', 'clean')) {
             Cache::clean('objectmodel_def_' . $class);
         }
         if (method_exists($this, 'clearCache')) {
             $this->clearCache(true);
         }
     }
 }
Exemple #26
0
 /**
  * Delete module from datable
  *
  * @return boolean result
  */
 public function uninstall()
 {
     // Check module installation id validation
     if (!Validate::isUnsignedId($this->id)) {
         $this->_errors[] = $this->l('The module is not installed.');
         return false;
     }
     // Uninstall overrides
     if (!$this->uninstallOverrides()) {
         return false;
     }
     // Retrieve hooks used by the module
     $sql = 'SELECT `id_hook` FROM `' . _DB_PREFIX_ . 'hook_module` WHERE `id_module` = ' . (int) $this->id;
     $result = Db::getInstance()->executeS($sql);
     foreach ($result as $row) {
         $this->unregisterHook((int) $row['id_hook']);
         $this->unregisterExceptions((int) $row['id_hook']);
     }
     // Disable the module for all shops
     $this->disable(true);
     // Delete permissions module access
     Db::getInstance()->execute('DELETE FROM `' . _DB_PREFIX_ . 'module_access` WHERE `id_module` = ' . (int) $this->id);
     // Remove restrictions for client groups
     Group::truncateRestrictionsByModule($this->id);
     // Uninstall the module
     if (Db::getInstance()->execute('DELETE FROM `' . _DB_PREFIX_ . 'module` WHERE `id_module` = ' . (int) $this->id)) {
         Cache::clean('Module::isInstalled' . $this->name);
         return true;
     }
     return false;
 }
 public function cleanCache($module, $search)
 {
     if (self::$is_cache_enabled) {
         if ($module) {
             Cache::clean($this->class_name . self::CACHE_PREFIX_MODEL . $this->id);
         }
         if ($search) {
             Cache::clean($this->class_name . self::CACHE_PREFIX_SEARCH . '*');
         }
     }
 }
Exemple #28
0
 * @author Hannes Christiansen
 * @package Runalyze\PHPUnit
 */
//ini_set('include_path', ini_get('include_path').PATH_SEPARATOR.dirname(__FILE__).'/../../../php/PEAR');
if (!defined('RUNALYZE_TEST')) {
    define('RUNALYZE_TEST', true);
}
if (!defined('FRONTEND_PATH')) {
    define('FRONTEND_PATH', dirname(__FILE__) . '/../inc/');
}
require_once FRONTEND_PATH . 'system/class.Autoloader.php';
new Autoloader();
require_once FRONTEND_PATH . '../lib/phpfastcache/phpfastcache.php';
require_once FRONTEND_PATH . 'system/class.Cache.php';
new Cache();
Cache::clean();
date_default_timezone_set('Europe/Berlin');
if (!defined('NL')) {
    define('NL', "\n");
}
if (!defined('NBSP')) {
    define('NBSP', '&nbsp;');
}
if (!defined('PREFIX')) {
    define('PREFIX', 'runalyze_');
}
if (!defined('DAY_IN_S')) {
    define('DAY_IN_S', 86400);
}
$_SERVER['REQUEST_URI'] = '/runalyze/index.php';
$_SERVER['SCRIPT_NAME'] = '/runalyze/index.php';
Exemple #29
0
 /**
  * Clears cache entries that have this object's ID.
  *
  * @param bool $all If true, clears cache for all objects
  */
 public function clearCache($all = false)
 {
     if ($all) {
         Cache::clean('objectmodel_' . $this->def['classname'] . '_*');
     } elseif ($this->id) {
         Cache::clean('objectmodel_' . $this->def['classname'] . '_' . (int) $this->id . '_*');
     }
 }
Exemple #30
0
 public function testClean()
 {
     $this->cacheConfig->expects($this->once())->method('remove')->with($this->cacheKey);
     $this->model->clean();
 }