Exemplo n.º 1
0
 /**
  * Get all site information - both Jirafe specific and general
  * @return array $sites An array of site information as per Jirafe API spec
  */
 public function getSites()
 {
     $sites = array();
     // First, get the general site info from the Prestashop database
     Shop::cacheShops(true);
     // we must refresh cache to get last insertion
     $psShops = Shop::getShops();
     // Get the Jirafe specific information about Prestashop sites
     $jsites = unserialize(base64_decode($this->get('sites')));
     if (!empty($psShops)) {
         foreach ($psShops as $psShop) {
             if ($psShop['active']) {
                 $shopId = $psShop['id_shop'];
                 $site = array();
                 $site['external_id'] = $shopId;
                 $site['description'] = $psShop['name'];
                 $site['url'] = 'http://' . $psShop['domain'] . $psShop['uri'];
                 $site['timezone'] = Configuration::get('PS_TIMEZONE');
                 $site['currency'] = $this->_getCurrency($shopId);
                 if (!empty($jsites[$shopId])) {
                     $site += $jsites[$shopId];
                 }
                 // new sites in prestashop are created without url
                 // api require a valid unique url
                 if ($site['url'] === 'http://') {
                     $site['url'] = 'http://example.' . md5(time() + $site['external_id']) . '.com';
                 }
                 // Add the site to the list of sites to return
                 $sites[] = $site;
             }
         }
     }
     return $sites;
 }
Exemplo n.º 2
0
 /**
  * Get all groups and associated shops as subarrays
  *
  * @return array
  */
 public static function getTree()
 {
     Shop::cacheShops();
     return self::$shops;
 }
Exemplo n.º 3
0
    } else {
        $domains = null;
        if ($context->shop->domain != $context->shop->domain_ssl) {
            $domains = array($context->shop->domain_ssl, $context->shop->domain);
        }
        $cookie = new Cookie('ps-s' . $context->shop->id, '', $cookie_lifetime, $domains, false, $force_ssl);
    }
}
$context->cookie = $cookie;
/* Create employee if in BO, customer else */
if (defined('_PS_ADMIN_DIR_')) {
    $employee = new Employee($cookie->id_employee);
    $context->employee = $employee;
    /* Auth on shops are recached after employee assignation */
    if ($employee->id_profile != _PS_ADMIN_PROFILE_) {
        Shop::cacheShops(true);
    }
    $cookie->id_lang = (int) $employee->id_lang;
}
/* if the language stored in the cookie is not available language, use default language */
if (isset($cookie->id_lang) && $cookie->id_lang) {
    $language = new Language($cookie->id_lang);
}
if (!isset($language) || !Validate::isLoadedObject($language)) {
    $language = new Language(Configuration::get('PS_LANG_DEFAULT'));
}
$context->language = $language;
if (!defined('_PS_ADMIN_DIR_')) {
    if (isset($cookie->id_customer) && (int) $cookie->id_customer) {
        $customer = new Customer($cookie->id_customer);
        if (!Validate::isLoadedObject($customer)) {