예제 #1
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');
 }