diff --git a/admin-dev/ajax.php b/admin-dev/ajax.php index 978f1a741..1a6d0ff48 100644 --- a/admin-dev/ajax.php +++ b/admin-dev/ajax.php @@ -71,122 +71,14 @@ function displayJavascriptAlert($s) echo ''; } -if (Tools::isSubmit('ajaxProductManufacturers')) -{ - AdminTab::$currentIndex = 'index.php?tab=AdminCatalog'; - $manufacturers = Manufacturer::getManufacturers(); - $jsonArray = array(); - if ($manufacturers) - foreach ($manufacturers AS $manufacturer) - $jsonArray[] = '{"optionValue": "'.$manufacturer['id_manufacturer'].'", "optionDisplay": "'.htmlspecialchars(trim($manufacturer['name'])).'"}'; - die('['.implode(',', $jsonArray).']'); -} - - if (Tools::isSubmit('ajaxReferrers')) { require(_PS_CONTROLLER_DIR_.'admin/AdminReferrersController.php'); } -if (Tools::isSubmit('ajaxProductSuppliers')) -{ - AdminTab::$currentIndex = 'index.php?tab=AdminCatalog'; - $suppliers = Supplier::getSuppliers(); - if ($suppliers) - { - $jsonArray = array(); - foreach ($suppliers AS $supplier) - $jsonArray[] = '{"optionValue": "'.$supplier['id_supplier'].'", "optionDisplay": "'.htmlspecialchars(trim($supplier['name'])).'"}'; - die('['.implode(',', $jsonArray).']'); - } -} - -if (Tools::isSubmit('ajaxProductAccessories')) -{ - AdminTab::$currentIndex = 'index.php?tab=AdminCatalog'; - $jsonArray = array(); - - $products = Db::getInstance()->executeS(' - SELECT p.`id_product`, pl.`name` - FROM `'._DB_PREFIX_.'product` p - NATURAL LEFT JOIN `'._DB_PREFIX_.'product_lang` pl - WHERE pl.`id_lang` = '.(int)(Tools::getValue('id_lang')).' - '.Context::getContext()->shop->addSqlRestrictionOnLang('pl').' - AND p.`id_product` != '.(int)(Tools::getValue('id_product')).' - AND p.`id_product` NOT IN ( - SELECT a.`id_product_2` - FROM `'._DB_PREFIX_.'accessory` a - WHERE a.`id_product_1` = '.(int)(Tools::getValue('id_product')).') - ORDER BY pl.`name`'); - - foreach ($products AS $accessory) - $jsonArray[] = '{"value: "'.(int)($accessory['id_product']).'-'.addslashes($accessory['name']).'", "text":"'.(int)($accessory['id_product']).' - '.addslashes($accessory['name']).'"}'; - die('['.implode(',', $jsonArray).']'); -} - -if (Tools::isSubmit('ajaxDiscountCustomers')) -{ - AdminTab::$currentIndex = 'index.php?tab=AdminDiscounts'; - $jsonArray = array(); - $filter = Tools::getValue('filter'); - - if (Validate::isBool_Id($filter)) - $filterArray = explode('_', $filter); - - $customers = Db::getInstance()->executeS(' - SELECT `id_customer`, `email`, CONCAT(`lastname`, \' \', `firstname`) as name - FROM `'._DB_PREFIX_.'customer` - WHERE `deleted` = 0 AND is_guest = 0 - AND '.(Validate::isUnsignedInt($filter) ? '`id_customer` = '.(int)($filter) : '(`email` LIKE "%'.pSQL($filter).'%" - '.((Validate::isBool_Id($filter) AND $filterArray[0] == 0) ? 'OR `id_customer` = '.(int)($filterArray[1]) : '').' - '.(Validate::isUnsignedInt($filter) ? '`id_customer` = '.(int)($filter) : '').' - OR CONCAT(`firstname`, \' \', `lastname`) LIKE "%'.pSQL($filter).'%" - OR CONCAT(`lastname`, \' \', `firstname`) LIKE "%'.pSQL($filter).'%")').' - ORDER BY CONCAT(`lastname`, \' \', `firstname`) ASC - LIMIT 50'); - - $groups = Db::getInstance()->executeS(' - SELECT g.`id_group`, gl.`name` - FROM `'._DB_PREFIX_.'group` g - LEFT JOIN `'._DB_PREFIX_.'group_lang` AS gl ON (g.`id_group` = gl.`id_group` AND gl.`id_lang` = '.(int)($context->language->id).') - WHERE '.(Validate::isUnsignedInt($filter) ? 'g.`id_group` = '.(int)($filter) : 'gl.`name` LIKE "%'.pSQL($filter).'%" - '.((Validate::isBool_Id($filter) AND $filterArray[0] == 1) ? 'OR g.`id_group` = '.(int)($filterArray[1]) : '')).' - ORDER BY gl.`name` ASC - LIMIT 50'); - - $json = '{"customers" : '; - foreach ($customers AS $customer) - $jsonArray[] = '{"value":"0_'.(int)($customer['id_customer']).'", "text":"'.addslashes($customer['name']).' ('.addslashes($customer['email']).')"}'; - $json .= '['.implode(',', $jsonArray).'], - "groups" : '; - $jsonArray = array(); - foreach ($groups AS $group) - $jsonArray[] = '{"value":"1_'.(int)($group['id_group']).'", "text":"'.addslashes($group['name']).'"}'; - $json .= '['.implode(',', $jsonArray).']}'; - die($json); -} - if (Tools::getValue('page') == 'prestastore' AND @fsockopen('addons.prestashop.com', 80, $errno, $errst, 3)) readfile('http://addons.prestashop.com/adminmodules.php?lang='.$context->language->iso_code); -if ($step = (int)(Tools::getValue('ajaxProductTab'))) -{ - require_once(dirname(__FILE__).'/tabs/AdminCatalog.php'); - $catalog = new AdminCatalog(); - $admin = new AdminProducts(); - - $languages = Language::getLanguages(false); - $defaultLanguage = (int)(Configuration::get('PS_LANG_DEFAULT')); - $product = new Product((int)(Tools::getValue('id_product'))); - if (!Validate::isLoadedObject($product)) - die (Tools::displayError('Product cannot be loaded')); - - $switchArray = array(3 => 'displayFormPrices', 4 => 'displayFormAttributes', 5 => 'displayFormFeatures', 6 => 'displayFormCustomization', 7 => 'displayFormAttachments'); - AdminTab::$currentIndex = 'index.php?tab=AdminCatalog'; - if (key_exists($step, $switchArray)) - $admin->{$switchArray[$step]}($product, $languages, $defaultLanguage); -} - if (Tools::isSubmit('getAvailableFields') AND Tools::isSubmit('entity')) { $jsonArray = array(); diff --git a/admin-dev/ajax_category_list.php b/admin-dev/ajax_category_list.php deleted file mode 100755 index bbda0ee8a..000000000 --- a/admin-dev/ajax_category_list.php +++ /dev/null @@ -1,83 +0,0 @@ - -* @copyright 2007-2011 PrestaShop SA -* @version Release: $Revision: 6844 $ -* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -define('_PS_ADMIN_DIR_', getcwd()); -include_once('../config/config.inc.php'); -include_once('tabs/AdminCatalog.php'); -include_once('tabs/AdminProducts.php'); -include_once('init.php'); - -if (Tools::getValue('token') != Tools::getAdminTokenLite('AdminCatalog')) - die(1); - -$catalog = new AdminCatalog(); -$adminProducts = new AdminProducts(); - -echo ' - - - - - - - '.$adminProducts->getL('Catalog:').' - -
- - - - - - - '; - $done = array(); - $index = array(); - - $categoryBox = Tools::getValue('categoryBox'); - if ($categoryBox != '') - { - $categoryBox = @unserialize($categoryBox); - foreach ($categoryBox AS $k => $row) - $index[] = $row; - } - elseif ((int)Tools::getValue('id_product')) - $index = Product::getProductCategories((int)Tools::getValue('id_product')); - $adminProducts->recurseCategoryForInclude((int)(Tools::getValue('id_product')), $index, $categories, $categories[0][1], 1, (int)(Tools::getValue('id_category_default'))); - echo '
'.$adminProducts->getL('ID').''.$adminProducts->getL('Name').'
-

'.$adminProducts->getL('Mark all checkbox(es) of categories in which product is to appear').' *

-
- '; diff --git a/controllers/admin/AdminCatalogController.php b/controllers/admin/AdminCatalogController.php deleted file mode 100644 index b22e17f0f..000000000 --- a/controllers/admin/AdminCatalogController.php +++ /dev/null @@ -1,156 +0,0 @@ - -* @copyright 2007-2011 PrestaShop SA -* @version Release: $Revision: 7499 $ -* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - - -class AdminCatalogControllerCore extends AdminController -{ - /** @var object AdminCategories() instance */ - //private $adminCategories; - - /** @var object AdminProducts() instance */ - // private $adminProducts; - - /** @var object AttributeGenerator() instance */ - private $attributeGenerator; - - /** @var object imageResize() instance */ - private $imageResize; - - /** @var object Category() instance for navigation*/ - private static $_category = NULL; - - public function __construct() - { - /* Get current category */ - $id_category = abs(Tools::getValue('id_category')); - $shop = Context::getContext()->shop; - if (!$id_category) - $id_category = $shop->getCategory(); - else if ($id_category != $shop->getCategory()) - { - // Check if current category is "inside" shop default category - $sql = 'SELECT nleft, nright FROM '._DB_PREFIX_.'category - WHERE id_category = '.$shop->getCategory(); - if ($interval = Category::getInterval($shop->getCategory())) - { - $sql = 'SELECT id_category FROM '._DB_PREFIX_.'category - WHERE id_category = '.(int)$id_category.' - AND nleft >= '.$interval['nleft'].' - AND nright <= '.$interval['nright']; - if (!Db::getInstance()->getValue($sql)) - $id_category = $shop->getCategory(); - } - } - self::$_category = new Category($id_category); - if (!Validate::isLoadedObject(self::$_category)) - throw new PrestaShopException('Category cannot be loaded'); - - $this->table = array('category', 'product'); - // $this->adminCategories = new AdminCategories(); - // $this->adminProducts = new AdminProducts(); - - parent::__construct(); - } - - /** - * Return current category - * - * @return object - */ - public static function getCurrentCategory() - { - return self::$_category; - } - - public function viewAccess($disable = false) - { - $result = parent::viewAccess($disable); - $this->adminCategories->tabAccess = $this->tabAccess; - $this->adminProducts->tabAccess = $this->tabAccess; - return $result; - } - - public function postProcess() - { - if (isset($_GET['attributegenerator'])) - { - if (!isset($this->attributeGenerator)) - { - include_once(_PS_ADMIN_DIR_.'/tabs/AdminAttributeGenerator.php'); - $this->attributeGenerator = new AdminAttributeGenerator(); - } - $this->attributeGenerator->postProcess(); - } - // $this->adminProducts->postProcess($this->token); - } - public function ajaxProcess() - { - if (Tools::getValue('addImage') !== false) - $this->adminProducts->ajaxProcess(); - if (Tools::getValue('updateProductImageShopAsso')) - $this->adminProducts->ajaxProcess(); - if (Tools::getValue('deleteImage')) - $this->adminProducts->ajaxProcess(); - - } - - public function initContent() - { - // @todo : this has to be dealt in AdminAttributeGenerator !! - if (isset($_GET['attributegenerator'])) - { - if (!isset($this->attributeGenerator)) - { - include_once(_PS_ADMIN_DIR_.'/tabs/AdminAttributeGenerator.php'); - $this->attributeGenerator = new AdminAttributeGenerator(); - } - $this->attributeGenerator->displayForm(); - } - elseif (!isset($_GET['editImage'])) - { - $home = false; - $id_category = (int)(Tools::getValue('id_category')); - if (!$id_category) - { - $home = true; - $id_category = Context::getContext()->shop->getCategory(); - } - $catalog_tabs = array('category', 'product'); - // Cleaning links - $catBarIndex = self::$currentIndex; - foreach ($catalog_tabs AS $tab) - if (Tools::getValue($tab.'Orderby') && Tools::getValue($tab.'Orderway')) - $catBarIndex = preg_replace('/&'.$tab.'Orderby=([a-z _]*)&'.$tab.'Orderway=([a-z]*)/i', '', self::$currentIndex); - - $this->context->smarty->assign('cat_bar',getPath($catBarIndex, $id_category, '', '', 'catalog', $home)); - } - $this->content = ''; - parent::initContent(); - } -} - - diff --git a/controllers/admin/AdminGroupsController.php b/controllers/admin/AdminGroupsController.php index b2c980f1b..850398bed 100644 --- a/controllers/admin/AdminGroupsController.php +++ b/controllers/admin/AdminGroupsController.php @@ -273,36 +273,36 @@ class AdminGroupsControllerCore extends AdminController protected function formatCategoryDiscountList($id) { - $categorie = GroupReduction::getGroupReductions((int)$id, $this->context->language->id); - $categorie_reductions = array(); + $category = GroupReduction::getGroupReductions((int)$id, $this->context->language->id); + $category_reductions = array(); $category_reduction = Tools::getValue('category_reduction'); - foreach ($categorie as $category) + foreach ($category as $category) { if (is_array($category_reduction) && array_key_exists($category['id_category'], $category_reduction)) $category['reduction'] = $category_reduction[$category['id_category']]; $tmp = array(); - $tmp['path'] = getPath(self::$currentIndex.'?tab=AdminCatalog', (int)$category['id_category']); + $tmp['path'] = getPath(self::$currentIndex.'?tab=AdminCategories', (int)$category['id_category']); $tmp['reduction'] = (float)$category['reduction'] * 100; $tmp['id_category'] = (int)$category['id_category']; - $categorie_reductions[(int)$category['id_category']] = $tmp; + $category_reductions[(int)$category['id_category']] = $tmp; } if (is_array($category_reduction)) foreach ($category_reduction as $key => $val) { - if (!array_key_exists($key, $categorie_reductions)) + if (!array_key_exists($key, $category_reductions)) { $tmp = array(); - $tmp['path'] = getPath(self::$currentIndex.'?tab=AdminCatalog', (int)$key); + $tmp['path'] = getPath(self::$currentIndex.'?tab=AdminCategories', $key); $tmp['reduction'] = (float)$val * 100; $tmp['id_category'] = (int)$key; - $categorie_reductions[(int)$category['id_category']] = $tmp; + $category_reductions[(int)$category['id_category']] = $tmp; } } - return $categorie_reductions; + return $category_reductions; } public function formatModuleListAuth($id_group) @@ -388,7 +388,7 @@ class AdminGroupsControllerCore extends AdminController else { $result['id_category'] = (int)$id_category; - $result['catPath'] = getPath(self::$currentIndex.'?tab=AdminCatalog', (int)$id_category); + $result['catPath'] = getPath(self::$currentIndex.'?tab=AdminCategories', (int)$id_category); $result['discount'] = $category_reduction; $result['hasError'] = false; } diff --git a/controllers/admin/AdminToolsController.php b/controllers/admin/AdminToolsController.php deleted file mode 100644 index 67fa60368..000000000 --- a/controllers/admin/AdminToolsController.php +++ /dev/null @@ -1,31 +0,0 @@ - -* @copyright 2007-2011 PrestaShop SA -* @version Release: $Revision: 6844 $ -* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -class AdminToolsControllerCore extends AdminController -{ -} - diff --git a/modules/statscatalog/statscatalog.php b/modules/statscatalog/statscatalog.php index 8dbd3f1f3..2ac927e18 100644 --- a/modules/statscatalog/statscatalog.php +++ b/modules/statscatalog/statscatalog.php @@ -136,7 +136,7 @@ class StatsCatalog extends Module public function hookAdminStatsModules($params) { $categories = Category::getCategories($this->context->language->id, true, false); - $productToken = Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).(int)$this->context->employee->id); + $productToken = Tools::getAdminToken('AdminProducts'.(int)(Tab::getIdFromClassName('AdminProducts')).(int)$this->context->employee->id); $irow = 0; if ($id_category = (int)(Tools::getValue('id_category'))) @@ -216,7 +216,7 @@ class StatsCatalog extends Module '.$product['id_product'].' '.$product['name'].' - + '; diff --git a/modules/statsproduct/statsproduct.php b/modules/statsproduct/statsproduct.php index a7f7b941a..03fc826b8 100644 --- a/modules/statsproduct/statsproduct.php +++ b/modules/statsproduct/statsproduct.php @@ -224,11 +224,11 @@ class StatsProduct extends ModuleGraph '.$this->l('Average price').' '; - $tokenProducts = Tools::getAdminToken('AdminCatalog'.(int)Tab::getIdFromClassName('AdminCatalog').(int)$this->context->employee->id); + $tokenProducts = Tools::getAdminToken('AdminProducts'.(int)Tab::getIdFromClassName('AdminProducts').(int)$this->context->employee->id); foreach ($crossSelling as $selling) $this->html .= ' - '.$selling['pname'].' + '.$selling['pname'].' '.(int)$selling['pqty'].' '.Tools::displayprice($selling['pprice'], $currency).' '; diff --git a/override/controllers/admin/AdminCatalogController.php b/override/controllers/admin/AdminCatalogController.php deleted file mode 100644 index ecb02f57e..000000000 --- a/override/controllers/admin/AdminCatalogController.php +++ /dev/null @@ -1,7 +0,0 @@ -