diff --git a/composer.json b/composer.json index 1cdbd782..3fba4221 100644 --- a/composer.json +++ b/composer.json @@ -3,6 +3,7 @@ "description": "PrestaShop - Link list", "homepage": "https://github.com/PrestaShop/ps_linklist", "license": "AFL-3.0", + "version": "3.0.2", "authors": [ { "name": "PrestaShop SA", diff --git a/config.xml b/config.xml index eaf8be93..bcb01366 100644 --- a/config.xml +++ b/config.xml @@ -2,7 +2,7 @@ ps_linklist - + diff --git a/config/services.yml b/config/services.yml index 8acafb63..fe8d02ef 100644 --- a/config/services.yml +++ b/config/services.yml @@ -1,4 +1,7 @@ services: + _defaults: + public: true + prestashop.module.link_block.cache: class: PrestaShop\Module\LinkList\Cache\LegacyLinkBlockCache arguments: @@ -122,6 +125,7 @@ services: prestashop.module.link_block.custom_url_type: class: PrestaShop\Module\LinkList\Form\Type\CustomUrlType parent: 'form.type.translatable.aware' + public: true tags: - { name: form.type } diff --git a/ps_linklist.php b/ps_linklist.php index 2102934c..7522a458 100644 --- a/ps_linklist.php +++ b/ps_linklist.php @@ -35,7 +35,6 @@ use PrestaShop\Module\LinkList\Model\LinkBlockLang; use PrestaShop\Module\LinkList\Repository\LinkBlockRepository; use PrestaShop\PrestaShop\Adapter\SymfonyContainer; -use PrestaShop\PrestaShop\Adapter\Cache\CacheClearer; use PrestaShop\PrestaShop\Adapter\LegacyContext; use PrestaShop\PrestaShop\Adapter\Shop\Context; @@ -67,9 +66,17 @@ public function __construct() { $this->name = 'ps_linklist'; $this->author = 'PrestaShop'; - $this->version = '3.0.1'; + $this->version = '3.0.2'; $this->need_instance = 0; $this->tab = 'front_office_features'; + $this->tabs = [ + [ + 'class_name' => 'AdminLinkWidget', + 'visible' => true, + 'name' => 'Link Widget', + 'parent_class_name' => 'AdminParentThemes', + ], + ]; $this->bootstrap = true; parent::__construct(); @@ -90,7 +97,7 @@ public function install() if (!parent::install()) { return false; } - $installed = true; + if (null !== $this->getRepository()) { $installed = $this->installFixtures(); } else { @@ -101,17 +108,23 @@ public function install() && $this->registerHook('displayFooter') && $this->registerHook('actionUpdateLangAfter') && $this->installTab()) { - //Clear Symfony cache to update routing rules - Tools::clearSf2Cache(); - return true; } - parent::uninstall(); + $this->uninstall(); return false; } + public function enable($force_all = false) + { + if (!$this->installTab()) { + return false; + } + + return parent::enable($force_all); + } + /** * @return bool * @@ -146,10 +159,6 @@ private function installLegacyFixtures() public function uninstall() { $uninstalled = true; - if (!$this->uninstallTab()) { - $this->_errors[] = $this->trans('Could not remove Tab.', array(), 'Admin.Modules.Notification'); - $uninstalled = false; - } $errors = $this->getRepository()->dropTables(); if (!empty($errors)) { $this->addModuleErrors($errors); @@ -159,8 +168,20 @@ public function uninstall() return $uninstalled && parent::uninstall(); } + /** + * The Core is supposed to register the tabs automatically thanks to the getTabs() return. + * However in 1.7.5 it only works when the module contains a AdminLinkWidgetController file, + * this works fine when module has been upgraded and the former file is still present however + * for a fresh install we need to install it manually until the core is able to manage new modules. + * + * @return bool + */ public function installTab() { + if (Tab::getIdFromClassName('AdminLinkWidget')) { + return true; + } + $tab = new Tab(); $tab->active = 1; $tab->class_name = 'AdminLinkWidget'; @@ -174,14 +195,6 @@ public function installTab() return $tab->add(); } - public function uninstallTab() - { - $id_tab = (int) Tab::getIdFromClassName('AdminLinkWidget'); - $tab = new Tab($id_tab); - - return $tab->delete(); - } - public function hookActionUpdateLangAfter($params) { if (!empty($params['lang']) && $params['lang'] instanceof Language) { diff --git a/src/Controller/Admin/Improve/Design/LinkBlockController.php b/src/Controller/Admin/Improve/Design/LinkBlockController.php index 0dfe3195..ae64b424 100644 --- a/src/Controller/Admin/Improve/Design/LinkBlockController.php +++ b/src/Controller/Admin/Improve/Design/LinkBlockController.php @@ -131,7 +131,7 @@ public function editAction(Request $request, $linkBlockId) } /** - * @AdminSecurity("is_granted('update', request.get('_legacy_controller'))", message="Access denied.") + * @AdminSecurity("is_granted('create', request.get('_legacy_controller'))", message="Access denied.") * * @param Request $request * @@ -160,6 +160,8 @@ public function editProcessAction(Request $request, $linkBlockId) } /** + * @AdminSecurity("is_granted('delete', request.get('_legacy_controller'))", message="Access denied.") + * * @param int $linkBlockId * * @return RedirectResponse @@ -189,6 +191,8 @@ public function deleteAction($linkBlockId) } /** + * @AdminSecurity("is_granted('update', request.get('_legacy_controller'))", message="Access denied.") + * * @param Request $request * @param int $hookId * diff --git a/src/Core/Grid/Definition/Factory/LinkBlockDefinitionFactory.php b/src/Core/Grid/Definition/Factory/LinkBlockDefinitionFactory.php index 07400e77..b0067235 100644 --- a/src/Core/Grid/Definition/Factory/LinkBlockDefinitionFactory.php +++ b/src/Core/Grid/Definition/Factory/LinkBlockDefinitionFactory.php @@ -100,7 +100,7 @@ protected function getColumns() 'update_method' => 'POST', 'record_route_params' => [ 'id_hook' => 'hookId', - ] + ], ]) ) ->add((new ActionColumn('actions')) diff --git a/src/Form/LinkBlockFormDataProvider.php b/src/Form/LinkBlockFormDataProvider.php index c30e6345..9178df07 100644 --- a/src/Form/LinkBlockFormDataProvider.php +++ b/src/Form/LinkBlockFormDataProvider.php @@ -264,6 +264,7 @@ private function validateLinkBlock(array $data) /** * @param array $custom + * * @return bool */ private function isEmptyCustom(array $custom) diff --git a/src/Presenter/LinkBlockPresenter.php b/src/Presenter/LinkBlockPresenter.php index ff8069d5..62383258 100644 --- a/src/Presenter/LinkBlockPresenter.php +++ b/src/Presenter/LinkBlockPresenter.php @@ -209,7 +209,7 @@ private function makeCustomLinks($customContent) $self = $this; $customLinks = array_map(function ($el) use ($self) { return array( - 'id' => 'link-custom-page-' . $el['title'], + 'id' => 'link-custom-page-' . Tools::link_rewrite($el['title']), 'class' => 'custom-page-link', 'title' => $el['title'], 'description' => '', diff --git a/upgrade/upgrade-3.0.php b/upgrade/upgrade-3.0.php index 4ee6d2b9..7b5b3153 100644 --- a/upgrade/upgrade-3.0.php +++ b/upgrade/upgrade-3.0.php @@ -27,9 +27,6 @@ exit; } -use PrestaShop\PrestaShop\Adapter\SymfonyContainer; -use PrestaShop\PrestaShop\Adapter\Cache\CacheClearer; - function upgrade_module_3_0($object) { Configuration::deleteByName('FOOTER_CMS'); @@ -41,12 +38,7 @@ function upgrade_module_3_0($object) Configuration::deleteByName('FOOTER_CONTACT'); Configuration::deleteByName('FOOTER_SITEMAP'); - Db::getInstance()->execute('DROP TABLE `' . _DB_PREFIX_ . 'cms_block_page`'); - - $object->reset(); - - //Clear Symfony cache to update routing rules - Tools::clearSf2Cache(); + Db::getInstance()->execute('DROP TABLE IF EXISTS `' . _DB_PREFIX_ . 'cms_block_page`'); return true; } diff --git a/views/package.json b/views/package.json index f77ee3f0..0ab3355e 100644 --- a/views/package.json +++ b/views/package.json @@ -1,6 +1,6 @@ { "name": "ps_linklist", - "version": "3.0.1", + "version": "3.0.2", "description": "", "scripts": { "build": "NODE_ENV=production webpack --progress --colors --debug --display-chunks",