// Release branch merged

This commit is contained in:
François Gaillard
2013-03-27 10:25:16 +01:00
1089 changed files with 4260 additions and 52622 deletions
@@ -90,6 +90,41 @@ class AdminGroupsControllerCore extends AdminController
WHERE jc.`deleted` != 1
'.Shop::addSqlRestriction(Shop::SHARE_CUSTOMER).'
AND jcg.`id_group` = a.`id_group`) AS nb';
$groups = Group::getGroups(Context::getContext()->language->id, true);
if (Shop::isFeatureActive())
$this->fields_options = array(
'general' => array(
'title' => $this->l('Default groups options'),
'fields' => array(
'PS_UNIDENTIFIED_GROUP' => array(
'title' => $this->l('Visitors group:'),
'desc' => $this->l('The group defined for your un-identified visitors'),
'cast' => 'intval',
'type' => 'select',
'list' => $groups,
'identifier' => 'id_group'
),
'PS_GUEST_GROUP' => array(
'title' => $this->l('Guests group:'),
'desc' => $this->l('The group defined for your identified guest customers (used in guest checkout)'),
'cast' => 'intval',
'type' => 'select',
'list' => $groups,
'identifier' => 'id_group'
),
'PS_CUSTOMER_GROUP' => array(
'title' => $this->l('Customers group:'),
'desc' => $this->l('The group defined for your identified customers'),
'cast' => 'intval',
'type' => 'select',
'list' => $groups,
'identifier' => 'id_group'
),
),
'submit' => array()
),
);
}
public function setMedia()
+4 -7
View File
@@ -480,10 +480,8 @@ class AdminHomeControllerCore extends AdminController
$stream_context = @stream_context_create(array('http' => array('method'=> 'GET', 'timeout' => 2)));
// SCREENCAST
if (@fsockopen('screencasts.prestashop.com', 80, $errno, $errst, AdminHomeController::TIPS_TIMEOUT))
$result['screencast'] = 'OK';
else
$result['screencast'] = 'NOK';
$result['screencast'] = 'OK';
// PREACTIVATION
$result['partner_preactivation'] = $this->getBlockPartners();
@@ -491,8 +489,7 @@ class AdminHomeControllerCore extends AdminController
// DISCOVER PRESTASHOP
$result['discover_prestashop'] = '<div id="block_tips">'.$this->getBlockDiscover().'</div>';
if (@fsockopen('api.prestashop.com', 80, $errno, $errst, AdminHomeController::TIPS_TIMEOUT))
$result['discover_prestashop'] .= '<div class="row-news"><div id="block_discover"><iframe frameborder="no" style="margin: 0px; padding: 0px; width: 100%; height:300px; overflow:hidden;" src="'.$protocol.'://api.prestashop.com/rss2/news2.php?v='._PS_VERSION_.'&lang='.$isoUser.'"></iframe></div>';
$result['discover_prestashop'] .= '<div class="row-news"><div id="block_discover"><iframe frameborder="no" style="margin: 0px; padding: 0px; width: 100%; height:300px; overflow:hidden;" src="'.$protocol.'://api.prestashop.com/rss2/news2.php?v='._PS_VERSION_.'&lang='.$isoUser.'"></iframe></div>';
// SHOW TIPS OF THE DAY
$content = @file_get_contents($protocol.'://api.prestashop.com/partner/tipsoftheday/?protocol='.$protocol.'&iso_country='.$isoCountry.'&iso_lang='.Tools::strtolower($isoUser), false, $stream_context);
@@ -672,7 +669,7 @@ class AdminHomeControllerCore extends AdminController
}
if (!$this->isFresh(Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST, 86400))
file_put_contents(_PS_ROOT_DIR_.Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST, $this->addonsRequest('native'));
file_put_contents(_PS_ROOT_DIR_.Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST, Tools::addonsRequest('native'));
$tpl_vars['upgrade'] = $upgrade;
+4 -1
View File
@@ -645,7 +645,7 @@ class AdminImportControllerCore extends AdminController
do $uniqid_path = _PS_UPLOAD_DIR_.uniqid(); while (file_exists($uniqid_path));
file_put_contents($uniqid_path, $field);
$tab = '';
if(!empty($uniqid_path))
if (!empty($uniqid_path))
{
$fd = fopen($uniqid_path, 'r');
$tab = fgetcsv($fd, MAX_LINE_SIZE, $separator);
@@ -1261,6 +1261,9 @@ class AdminImportControllerCore extends AdminController
foreach (Product::$definition['fields'] as $key => $array)
if ($array['type'] == Product::TYPE_FLOAT)
$product->{$key} = str_replace(',', '.', $product->{$key});
// Indexation is already 0 if it's a new product, but not if it's an update
$product->indexed = 0;
$res = false;
$field_error = $product->validateFields(UNFRIENDLY_ERROR, true);
@@ -485,10 +485,10 @@ class AdminLanguagesControllerCore extends AdminController
$this->status = 'error';
$this->errors[] = '[TECHNICAL ERROR] ps_version not set or empty';
}
if (@fsockopen('www.prestashop.com', 80))
// Get all iso code available
if($lang_packs = Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/get_language_pack.php?version='.(string)$_GET['ps_version'].'&iso_lang='.(string)$_GET['iso_lang']))
{
// Get all iso code available
$lang_packs = Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/get_language_pack.php?version='.(string)$_GET['ps_version'].'&iso_lang='.(string)$_GET['iso_lang']);
$result = Tools::jsonDecode($lang_packs);
if ($lang_packs !== '' && $result && !isset($result->error))
{
@@ -510,7 +510,7 @@ class AdminLanguagesControllerCore extends AdminController
$this->errors[] = '[TECHNICAL ERROR] Server unreachable';
}
}
protected function checkEmployeeIdLang($current_id_lang)
{
//update employee lang if current id lang is disabled
+5 -3
View File
@@ -69,18 +69,20 @@ class AdminLoginControllerCore extends AdminController
}
if (file_exists(_PS_ADMIN_DIR_.'/../install'))
$this->context->smarty->assign('wrong_folder_name', true);
$this->context->smarty->assign('wrong_install_name', true);
if (file_exists(_PS_ADMIN_DIR_.'/../admin'))
{
{
$rand = sprintf('%04d', rand(0, 9999));
if (@rename(_PS_ADMIN_DIR_.'/../admin', _PS_ADMIN_DIR_.'/../admin'.$rand))
Tools::redirectAdmin('../admin'.$rand);
else
$this->context->smarty->assign(array(
'randomNb' => rand(100, 999),
'wrong_folder_name' => true
));
}
$this->context->smarty->assign(array(
'randomNb' => rand(0, 9999)
));
// Redirect to admin panel
if (Tools::isSubmit('redirect') && Validate::isControllerName(Tools::getValue('redirect')))
+24 -10
View File
@@ -156,7 +156,7 @@ class AdminModulesControllerCore extends AdminController
{
if (!$this->isFresh(Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST, 86400))
{
if (file_put_contents(_PS_ROOT_DIR_.Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST, $this->addonsRequest('native')))
if (file_put_contents(_PS_ROOT_DIR_.Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST, Tools::addonsRequest('native')))
$this->status = 'refresh';
else
$this->status = 'error';
@@ -166,7 +166,7 @@ class AdminModulesControllerCore extends AdminController
if (!$this->isFresh(Module::CACHE_FILE_MUST_HAVE_MODULES_LIST, 86400))
{
if (file_put_contents(_PS_ROOT_DIR_.Module::CACHE_FILE_MUST_HAVE_MODULES_LIST, $this->addonsRequest('must-have')))
if (file_put_contents(_PS_ROOT_DIR_.Module::CACHE_FILE_MUST_HAVE_MODULES_LIST, Tools::addonsRequest('must-have')))
$this->status = 'refresh';
else
$this->status = 'error';
@@ -180,7 +180,7 @@ class AdminModulesControllerCore extends AdminController
{
if (!$this->isFresh(Module::CACHE_FILE_CUSTOMER_MODULES_LIST, 60))
{
if (file_put_contents(_PS_ROOT_DIR_.Module::CACHE_FILE_CUSTOMER_MODULES_LIST, $this->addonsRequest('customer')))
if (file_put_contents(_PS_ROOT_DIR_.Module::CACHE_FILE_CUSTOMER_MODULES_LIST, Tools::addonsRequest('customer')))
$this->status = 'refresh';
else
$this->status = 'error';
@@ -198,7 +198,7 @@ class AdminModulesControllerCore extends AdminController
public function ajaxProcessLogOnAddonsWebservices()
{
$content = $this->addonsRequest('check_customer', array('username_addons' => pSQL(trim(Tools::getValue('username_addons'))), 'password_addons' => pSQL(trim(Tools::getValue('password_addons')))));
$content = Tools::addonsRequest('check_customer', array('username_addons' => pSQL(trim(Tools::getValue('username_addons'))), 'password_addons' => pSQL(trim(Tools::getValue('password_addons')))));
$xml = @simplexml_load_string($content, null, LIBXML_NOCDATA);
if (!$xml)
die('KO');
@@ -250,11 +250,25 @@ class AdminModulesControllerCore extends AdminController
{
if (in_array($module->name, $tab_modules_list))
{
$this->fillModuleData($module, 'select', $back);
$perm = true;
if ($module->id)
$modules_list['installed'][] = $module;
$perm &= Module::getPermissionStatic($module->id, 'configure');
else
$modules_list['not_installed'][] = $module;
{
$id_admin_module = Tab::getIdFromClassName('AdminModules');
$access = Profile::getProfileAccess($this->context->employee->id_profile, $id_admin_module);
if (!$access['edit'])
$perm &= false;
}
if ($perm)
{
$this->fillModuleData($module, 'select', $back);
if ($module->id)
$modules_list['installed'][] = $module;
else
$modules_list['not_installed'][] = $module;
}
}
}
}
@@ -615,10 +629,10 @@ class AdminModulesControllerCore extends AdminController
if ($name == $modaddons->name && isset($modaddons->id) && ($this->logged_on_addons || $f['loggedOnAddons'] == 0))
{
if ($f['loggedOnAddons'] == 0)
if (file_put_contents('../modules/'.$modaddons->name.'.zip', $this->addonsRequest('module', array('id_module' => pSQL($modaddons->id)))))
if (file_put_contents('../modules/'.$modaddons->name.'.zip', Tools::addonsRequest('module', array('id_module' => pSQL($modaddons->id)))))
$this->extractArchive('../modules/'.$modaddons->name.'.zip', false);
if ($f['loggedOnAddons'] == 1 && $this->logged_on_addons)
if (file_put_contents('../modules/'.$modaddons->name.'.zip', $this->addonsRequest('module', array('id_module' => pSQL($modaddons->id), 'username_addons' => pSQL(trim($this->context->cookie->username_addons)), 'password_addons' => pSQL(trim($this->context->cookie->password_addons))))))
if (file_put_contents('../modules/'.$modaddons->name.'.zip', Tools::addonsRequest('module', array('id_module' => pSQL($modaddons->id), 'username_addons' => pSQL(trim($this->context->cookie->username_addons)), 'password_addons' => pSQL(trim($this->context->cookie->password_addons))))))
$this->extractArchive('../modules/'.$modaddons->name.'.zip', false);
}
}
@@ -781,7 +795,7 @@ class AdminModulesControllerCore extends AdminController
// Call appropriate module callback
if (!isset($ppmReturn))
$this->postProcessCallback();
if ($back = Tools::getValue('back'))
Tools::redirectAdmin($back);
}
@@ -303,7 +303,7 @@ class AdminModulesPositionsControllerCore extends AdminController
{
$url = $this->context->shop->getBaseURL().Dispatcher::getInstance()->createUrl('index', (int)$this->context->language->id, $live_edit_params);
if (Configuration::get('PS_REWRITING_SETTINGS'))
$url = str_replace('index.php', '', $url);
$url = str_replace('index.php', Language::getIsoById($this->context->employee->id_lang).'/', $url);
return $url;
}
+25 -7
View File
@@ -126,6 +126,15 @@ class AdminProductsControllerCore extends AdminController
if (Tools::getValue('reset_filter_category'))
$this->context->cookie->id_category_products_filter = false;
if (Shop::isFeatureActive() && $this->context->cookie->id_category_products_filter)
{
$category = new Category((int)$this->context->cookie->id_category_products_filter);
if (!$category->inShop())
{
$this->context->cookie->id_category_products_filter = false;
Tools::redirectAdmin($this->context->link->getAdminLink('AdminProducts'));
}
}
/* Join categories table */
if ($id_category = (int)Tools::getValue('productFilter_cl!name'))
{
@@ -162,7 +171,6 @@ class AdminProductsControllerCore extends AdminController
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON ('.$alias.'.`id_category_default` = cl.`id_category` AND b.`id_lang` = cl.`id_lang` AND cl.id_shop = '.(int)$this->context->shop->id.')
LEFT JOIN `'._DB_PREFIX_.'shop` shop ON (shop.id_shop = '.(int)$this->context->shop->id.')
LEFT JOIN `'._DB_PREFIX_.'image_shop` image_shop ON (image_shop.`id_image` = i.`id_image` AND image_shop.`cover` = 1 AND image_shop.id_shop='.(int)$this->context->shop->id.')';
$this->_where .= 'AND (i.id_image IS NULL OR image_shop.id_shop='.(int)$this->context->shop->id.')';
}
else
{
@@ -170,7 +178,6 @@ class AdminProductsControllerCore extends AdminController
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON ('.$alias.'.`id_category_default` = cl.`id_category` AND b.`id_lang` = cl.`id_lang` AND cl.id_shop = a.id_shop_default)
LEFT JOIN `'._DB_PREFIX_.'shop` shop ON (shop.id_shop = a.id_shop_default)
LEFT JOIN `'._DB_PREFIX_.'image_shop` image_shop ON (image_shop.`id_image` = i.`id_image` AND image_shop.`cover` = 1 AND image_shop.id_shop=a.id_shop_default)';
$this->_where .= 'AND (i.id_image IS NULL OR image_shop.id_shop=a.id_shop_default)';
}
$this->_select .= 'shop.name as shopname, ';
}
@@ -181,11 +188,15 @@ class AdminProductsControllerCore extends AdminController
$this->_join .= 'LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON ('.$alias.'.`id_category_default` = cl.`id_category` AND b.`id_lang` = cl.`id_lang` AND cl.id_shop = 1)';
}
$this->_select .= 'MAX('.$alias_image.'.id_image) id_image,';
$this->_join .= ($join_category ? 'INNER JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_product` = a.`id_product` AND cp.`id_category` = '.(int)$this->_category->id.')' : '').'
LEFT JOIN `'._DB_PREFIX_.'stock_available` sav ON (sav.`id_product` = a.`id_product` AND sav.`id_product_attribute` = 0
'.StockAvailable::addSqlShopRestriction(null, null, 'sav').') ';
$this->_select .= 'cl.name `name_category` '.($join_category ? ', cp.`position`' : '').', '.$alias_image.'.`id_image`, '.$alias.'.`price`, 0 AS price_final, sav.`quantity` as sav_quantity, '.$alias.'.`active`';
$this->_group = 'GROUP BY '.$alias.'.id_product';
$this->fields_list = array();
$this->fields_list['id_product'] = array(
'title' => $this->l('ID'),
@@ -356,7 +367,16 @@ class AdminProductsControllerCore extends AdminController
{
$result = parent::loadObject($opt);
if ($result && Validate::isLoadedObject($this->object))
{
if (Shop::getContext() == Shop::CONTEXT_SHOP && !$this->object->isAssociatedToShop())
{
$default_product = new Product((int)$this->object->id, false, null, (int)$this->object->id_shop_default);
$def = ObjectModel::getDefinition($this->object);
foreach ($def['fields'] as $field_name => $row)
$this->object->$field_name = $default_product->$field_name;
}
$this->object->loadStockData();
}
return $result;
}
@@ -710,6 +730,8 @@ class AdminProductsControllerCore extends AdminController
}
if (!count($this->errors))
$success &= $product->delete();
else
$success = 0;
}
}
@@ -2184,10 +2206,6 @@ class AdminProductsControllerCore extends AdminController
foreach ($this->available_tabs as $product_tab => $value)
{
// if it's the quantities tab and stock management is disabled, continue
if ($stock_management_active == 0 && $product_tab == 'Quantities')
continue;
// if it's the warehouses tab and advanced stock management is disabled, continue
if ($advanced_stock_management_active == 0 && $product_tab == 'Warehouses')
continue;
@@ -35,6 +35,7 @@ class AdminStatusesControllerCore extends AdminController
$this->colorOnBackground = false;
$this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?')));
$this->context = Context::getContext();
$this->multishop_context = Shop::CONTEXT_ALL;
$this->imageType = 'gif';
$this->fieldImageSettings = array(
'name' => 'icon',
@@ -31,6 +31,7 @@ class AdminTabsControllerCore extends AdminController
public function __construct()
{
$this->context = Context::getContext();
$this->multishop_context = Shop::CONTEXT_ALL;
$this->table = 'tab';
$this->className = 'Tab';
$this->lang = true;
@@ -687,18 +687,25 @@ class AdminTranslationsControllerCore extends AdminController
if (pathinfo($file2check['filename'], PATHINFO_BASENAME) == 'index.php' && file_put_contents(_PS_TRANSLATIONS_DIR_.'../'.$file2check['filename'], Tools::getDefaultIndexContent()))
continue;
AdminTranslationsController::checkAndAddMailsFiles($iso_code, $files_list);
$this->checkAndAddThemesFiles($files_list, $themes_selected);
$tab_errors = AdminTranslationsController::addNewTabs($iso_code, $files_list);
if (count($tab_errors))
{
$this->errors += $tab_errors;
return false;
}
if (Validate::isLanguageFileName($filename))
{
if (!Language::checkAndAddLanguage($iso_code))
$conf = 20;
else
{
// Reset cache
Language::loadLanguages();
AdminTranslationsController::checkAndAddMailsFiles($iso_code, $files_list);
$this->checkAndAddThemesFiles($files_list, $themes_selected);
$tab_errors = AdminTranslationsController::addNewTabs($iso_code, $files_list);
if (count($tab_errors))
{
$this->errors += $tab_errors;
return false;
}
}
}
$this->redirect(false, (isset($conf) ? $conf : '15'));
}
@@ -719,32 +726,39 @@ class AdminTranslationsControllerCore extends AdminController
@stream_context_create(array('http' => array('method' => 'GET', 'timeout' => 5)))))
{
$file = _PS_TRANSLATIONS_DIR_.$arr_import_lang[0].'.gzip';
if (file_put_contents($file, $content))
if ((bool)@file_put_contents($file, $content))
{
$gz = new Archive_Tar($file, true);
$files_list = $gz->listContent();
if ($gz->extract(_PS_TRANSLATIONS_DIR_.'../', false))
if ($error = $gz->extract(_PS_TRANSLATIONS_DIR_.'../', false))
{
AdminTranslationsController::checkAndAddMailsFiles($arr_import_lang[0], $files_list);
$tab_errors = AdminTranslationsController::addNewTabs($arr_import_lang[0], $files_list);
if (count($tab_errors))
$this->errors += $tab_errors;
if (is_object($error) && !empty($error->message))
$this->errors[] = Tools::displayError('The archive cannot be extracted.'). ' '.$error->message;
else
{
if (!Language::checkAndAddLanguage($arr_import_lang[0]))
$conf = 20;
}
if (!unlink($file))
$this->errors[] = Tools::displayError('Cannot delete the archive.');
else
{
// Reset cache
Language::loadLanguages();
$this->redirect(false, (isset($conf) ? $conf : '15'));
AdminTranslationsController::checkAndAddMailsFiles($arr_import_lang[0], $files_list);
if ($tab_errors = AdminTranslationsController::addNewTabs($arr_import_lang[0], $files_list))
$this->errors += $tab_errors;
}
if (!unlink($file))
$this->errors[] = sprintf(Tools::displayError('Cannot delete the archive %s.'), $file);
$this->redirect(false, (isset($conf) ? $conf : '15'));
}
}
$this->errors[] = Tools::displayError('The archive cannot be extracted.');
if (!unlink($file))
$this->errors[] = Tools::displayError('Cannot delete the archive.');
elseif (!unlink($file))
$this->errors[] = sprintf(Tools::displayError('Cannot delete the archive %s.'), $file);
}
else
$this->errors[] = Tools::displayError('The server does not have permissions for writing.');
$this->errors[] = Tools::displayError('The server does not have permissions for writing.'. ' '.sprintf(Tools::displayError('Please check rights for %s'), dirname($file)));
}
else
$this->errors[] = Tools::displayError('Language not found.');