예제 #1
0
/**
 * 2007-2015 PrestaShop
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@prestashop.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
 * versions in the future. If you wish to customize PrestaShop for your
 * needs please refer to http://www.prestashop.com for more information.
 *
 *  @author    PrestaShop SA <*****@*****.**>
 *  @copyright 2007-2015 PrestaShop SA
 *  @license   http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 *  International Registered Trademark & Property of PrestaShop SA
 */
function upgrade_module_1_8($module)
{
    include dirname(__FILE__) . '/sql/sql-upgrade-1-8.php';
    if (!empty($sql) && is_array($sql)) {
        foreach ($sql as $request) {
            if (!Db::getInstance()->execute($request)) {
                return false;
            }
        }
    }
    // upgrade existing profiles
    $profiles = EbayProfile::getProfilesByIdShop();
    foreach ($profiles as $profile) {
        $ebay_profile = new EbayProfile($profile['id_ebay_profile']);
        // set id_lang if not set
        if (!$profile['id_lang']) {
            $ebay_profile->id_lang = (int) Configuration::get('PS_LANG_DEFAULT');
            $ebay_profile->save();
        }
        if ($ebay_profile->ebay_site_id) {
            $ebay_shop_country = EbayCountrySpec::getIsoCodeBySiteId($ebay_profile->ebay_site_id);
            $ebay_site_id = $ebay_profile->ebay_site_id;
        } else {
            if ($ebay_profile->getConfiguration('EBAY_COUNTRY_DEFAULT')) {
                $ebay_shop_country = $ebay_profile->getConfiguration('EBAY_COUNTRY_DEFAULT');
            } else {
                $ebay_shop_country = 'fr';
                $ebay_profile->setConfiguration('EBAY_COUNTRY_DEFAULT', $ebay_shop_country);
            }
            $ebay_profile->ebay_site_id = EbayCountrySpec::getSiteIdByIsoCode($ebay_shop_country);
            $ebay_profile->save();
            $ebay_site_id = $ebay_profile->ebay_site_id;
        }
        // we set EBAY_SHOP_COUNTRY
        $ebay_profile->setConfiguration('EBAY_SHOP_COUNTRY', $ebay_shop_country);
        // update ebay_category
        Db::getInstance()->autoExecute(_DB_PREFIX_ . 'ebay_category', array('id_country' => $ebay_site_id), 'UPDATE');
        if (Configuration::get('EBAY_CATEGORY_LOADED')) {
            Configuration::updateValue('EBAY_CATEGORY_LOADED_' . $ebay_site_id, 1, false, 0, 0);
        }
        // update ebay_category_specific
        Db::getInstance()->autoExecute(_DB_PREFIX_ . 'ebay_category_specific', array('ebay_site_id' => $ebay_site_id), 'UPDATE');
        // update ebay_product_configuration
        $ebay_profile = EbayProfile::getCurrent();
        Db::getInstance()->autoExecute(_DB_PREFIX_ . 'ebay_product_configuration', array('id_ebay_profile' => $ebay_profile->id), 'UPDATE');
    }
    return true;
}
예제 #2
0
 public static function setProfile($id_ebay_profile)
 {
     $id_shop = (int) EbayProfile::_getIdShop(false);
     // check that this profile is for the current shop
     $shop_profiles = EbayProfile::getProfilesByIdShop($id_shop);
     if ($id_shop) {
         $is_shop_profile = false;
         foreach ($shop_profiles as $profile) {
             if ($profile['id_ebay_profile'] == $id_ebay_profile) {
                 $is_shop_profile = true;
                 break;
             }
         }
         if (!$is_shop_profile) {
             return false;
         }
     }
     Configuration::updateValue('EBAY_CURRENT_PROFILE', $id_ebay_profile . '_' . $id_shop, false, 0, 0);
     return true;
 }
예제 #3
0
 /**
  * Register Form Config Methods
  **/
 private function _displayFormRegister()
 {
     $ebay = new EbayRequest();
     $smarty_vars = array();
     if (Tools::getValue('relogin')) {
         $session_id = $ebay->login();
         $this->context->cookie->eBaySession = $session_id;
         Configuration::updateValue('EBAY_API_SESSION', $session_id, false, 0, 0);
         $smarty_vars = array_merge($smarty_vars, array('relogin' => true, 'redirect_url' => $ebay->getLoginUrl() . '?SignIn&runame=' . $ebay->runame . '&SessID=' . $this->context->cookie->eBaySession));
     } else {
         $smarty_vars['relogin'] = false;
     }
     $logged = !empty($this->context->cookie->eBaySession) && Tools::getValue('action') == 'logged';
     $smarty_vars['logged'] = $logged;
     $id_shop = version_compare(_PS_VERSION_, '1.5', '>') ? Shop::getContextShopID() : Shop::getCurrentShop();
     if ($logged) {
         if ($ebay_username = Tools::getValue('eBayUsernamesList')) {
             if ($ebay_username == -1) {
                 $ebay_username = Tools::getValue('eBayUsername');
             }
             $this->context->cookie->eBayUsername = $ebay_username;
             $this->ebay_profile = EbayProfile::getByLangShopSiteAndUsername((int) Tools::getValue('ebay_language'), $id_shop, Tools::getValue('ebay_country'), $ebay_username, EbayProductTemplate::getContent($this, $this->smarty));
             EbayProfile::setProfile($this->ebay_profile->id);
         }
         $smarty_vars['check_token_tpl'] = $this->_displayCheckToken();
     } else {
         if (empty($this->context->cookie->eBaySession)) {
             $session_id = $ebay->login();
             $this->context->cookie->eBaySession = $session_id;
             Configuration::updateValue('EBAY_API_SESSION', $session_id, false, 0, 0);
             $this->context->cookie->write();
         }
         if (isset($this->ebay_profile->id_shop)) {
             $ebay_profiles = EbayProfile::getProfilesByIdShop($this->ebay_profile->id_shop);
         } else {
             $ebay_profiles = array();
         }
         foreach ($ebay_profiles as &$profile) {
             $profile['site_extension'] = EbayCountrySpec::getSiteExtensionBySiteId($profile['ebay_site_id']);
         }
         $smarty_vars = array_merge($smarty_vars, array('action_url' => $_SERVER['REQUEST_URI'] . '&action=logged', 'ebay_username' => $this->context->cookie->eBayUsername, 'window_open_url' => '?SignIn&runame=' . $ebay->runame . '&SessID=' . $this->context->cookie->eBaySession, 'ebay_countries' => EbayCountrySpec::getCountries($ebay->getDev()), 'default_country' => EbayCountrySpec::getKeyForEbayCountry(), 'ebay_user_identifiers' => EbayProfile::getEbayUserIdentifiers(), 'ebay_profiles' => $ebay_profiles, 'languages' => Language::getLanguages(true, $this->ebay_profile ? $this->ebay_profile->id_shop : $id_shop)));
     }
     $this->smarty->assign($smarty_vars);
     return $this->display(__FILE__, 'views/templates/hook/formRegister.tpl');
 }