From 7d3f6997b302fd03b6a6abdb5888cf8eab2b96b9 Mon Sep 17 00:00:00 2001 From: Mediacom87 Date: Fri, 26 Jul 2024 15:40:15 +0200 Subject: [PATCH 1/3] Add Index et htaccess Add Index files and htaccess. --- .htaccess | 16 ++++++++++++++++ controllers/front/index.php | 34 +++++++++++++++++++++++++++++++++ controllers/index.php | 34 +++++++++++++++++++++++++++++++++ index.php | 34 +++++++++++++++++++++++++++++++++ views/index.php | 34 +++++++++++++++++++++++++++++++++ views/templates/front/index.php | 34 +++++++++++++++++++++++++++++++++ views/templates/index.php | 34 +++++++++++++++++++++++++++++++++ 7 files changed, 220 insertions(+) create mode 100644 .htaccess create mode 100644 controllers/front/index.php create mode 100644 controllers/index.php create mode 100644 index.php create mode 100644 views/index.php create mode 100644 views/templates/front/index.php create mode 100644 views/templates/index.php diff --git a/.htaccess b/.htaccess new file mode 100644 index 0000000..00359fa --- /dev/null +++ b/.htaccess @@ -0,0 +1,16 @@ +# Apache 2.2 + + Order deny,allow + Deny from all + + Allow from all + + + +# Apache 2.4 + + Require all denied + + Require all granted + + \ No newline at end of file diff --git a/controllers/front/index.php b/controllers/front/index.php new file mode 100644 index 0000000..6028c7f --- /dev/null +++ b/controllers/front/index.php @@ -0,0 +1,34 @@ + + * @copyright 2007-2020 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) + * International Registered Trademark & Property of PrestaShop SA + */ +header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); +header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); + +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); + +header('Location: ../'); +exit; diff --git a/controllers/index.php b/controllers/index.php new file mode 100644 index 0000000..6028c7f --- /dev/null +++ b/controllers/index.php @@ -0,0 +1,34 @@ + + * @copyright 2007-2020 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) + * International Registered Trademark & Property of PrestaShop SA + */ +header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); +header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); + +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); + +header('Location: ../'); +exit; diff --git a/index.php b/index.php new file mode 100644 index 0000000..6028c7f --- /dev/null +++ b/index.php @@ -0,0 +1,34 @@ + + * @copyright 2007-2020 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) + * International Registered Trademark & Property of PrestaShop SA + */ +header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); +header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); + +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); + +header('Location: ../'); +exit; diff --git a/views/index.php b/views/index.php new file mode 100644 index 0000000..6028c7f --- /dev/null +++ b/views/index.php @@ -0,0 +1,34 @@ + + * @copyright 2007-2020 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) + * International Registered Trademark & Property of PrestaShop SA + */ +header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); +header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); + +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); + +header('Location: ../'); +exit; diff --git a/views/templates/front/index.php b/views/templates/front/index.php new file mode 100644 index 0000000..6028c7f --- /dev/null +++ b/views/templates/front/index.php @@ -0,0 +1,34 @@ + + * @copyright 2007-2020 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) + * International Registered Trademark & Property of PrestaShop SA + */ +header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); +header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); + +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); + +header('Location: ../'); +exit; diff --git a/views/templates/index.php b/views/templates/index.php new file mode 100644 index 0000000..6028c7f --- /dev/null +++ b/views/templates/index.php @@ -0,0 +1,34 @@ + + * @copyright 2007-2020 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) + * International Registered Trademark & Property of PrestaShop SA + */ +header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); +header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); + +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); + +header('Location: ../'); +exit; From 4238e032002b9ad0dd961e350f751f467ed7e680 Mon Sep 17 00:00:00 2001 From: Mediacom87 Date: Fri, 26 Jul 2024 16:25:15 +0200 Subject: [PATCH 2/3] Automatic recovery of customer group Added a method for automatically retrieving the group of members who have paid their membership fees for the current calendar year. --- controllers/front/list.php | 3 +++ fopmembers.php | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/controllers/front/list.php b/controllers/front/list.php index 5286a18..0dcb23b 100644 --- a/controllers/front/list.php +++ b/controllers/front/list.php @@ -16,3 +16,6 @@ public function initContent() $this->setTemplate('module:fopmembers/views/templates/front/list.tpl'); } } +s/templates/front/list.tpl'); + } +} diff --git a/fopmembers.php b/fopmembers.php index d00dae3..ba93213 100644 --- a/fopmembers.php +++ b/fopmembers.php @@ -80,4 +80,18 @@ public function getCustomersByGroupId($groupId) return $customerIds; } +} + return $customerIds; + } + + // Get group id for members of the year + public function getGroupMembersId() + { + $groups = Group::getGroups($this->context->language->id); + foreach ($groups as $group) { + if (preg_match('/' . date('Y') . '/', $group['name'])) { + return $group['id_group']; + } + } + } } From f72711e23bf623e2e942964e018293d5877ca71c Mon Sep 17 00:00:00 2001 From: Mediacom87 Date: Fri, 26 Jul 2024 17:08:43 +0200 Subject: [PATCH 3/3] 1.0.1 Add module route. --- controllers/front/list.php | 5 +--- fopmembers.php | 45 ++++++++++++++++++++++++++++------ upgrade/index.php | 34 +++++++++++++++++++++++++ upgrade/upgrade-1.0.1.php | 28 +++++++++++++++++++++ views/templates/front/list.tpl | 2 +- 5 files changed, 102 insertions(+), 12 deletions(-) create mode 100644 upgrade/index.php create mode 100644 upgrade/upgrade-1.0.1.php diff --git a/controllers/front/list.php b/controllers/front/list.php index 0dcb23b..5d7f6e6 100644 --- a/controllers/front/list.php +++ b/controllers/front/list.php @@ -6,7 +6,7 @@ public function initContent() { parent::initContent(); - // Load customers of group ID 4 + // Loading of association members up to date with current year's fees $customers = $this->module->getFoPMembers(); // Assign customers to the template @@ -16,6 +16,3 @@ public function initContent() $this->setTemplate('module:fopmembers/views/templates/front/list.tpl'); } } -s/templates/front/list.tpl'); - } -} diff --git a/fopmembers.php b/fopmembers.php index ba93213..c6e6bb8 100644 --- a/fopmembers.php +++ b/fopmembers.php @@ -26,7 +26,7 @@ public function __construct() { $this->name = 'fopmembers'; $this->tab = 'front_office_features'; - $this->version = '1.0.0'; + $this->version = '1.0.1'; $this->author = 'Friends of Presta'; $this->need_instance = 0; @@ -36,9 +36,41 @@ public function __construct() $this->description = $this->l('Display customers of group adherents.'); } + public function install() + { + if (!parent::install() + || !$this->registerHook('moduleRoutes')) { + return false; + } + + return true; + } + + public function hookModuleRoutes($params) + { + $id_lang = $this->context->language->id; + $alias = 'annuaire-fop'; + + return [ + 'module-' . $this->name . '-list' => [ + 'controller' => 'list', + 'rule' => $alias, + 'keywords' => [ + 'controller' => [ + 'regexp' => $alias, + ], + ], + 'params' => [ + 'fc' => 'module', + 'module' => $this->name, + ], + ], + ]; + } + public function getFoPMembers() { - $customerIds = $this->getCustomersByGroupId(6); + $customerIds = $this->getCustomersByGroupId($this->getGroupMembersId()); // Load customer objects $customers = []; if ($customerIds) { @@ -46,9 +78,9 @@ public function getFoPMembers() $customer = new Customer($customerId); $customers[$customerId] = $customer->getFields(); $id_address = Address::getFirstCustomerAddressId($customerId); - if((int)$id_address>0){ + if ((int) $id_address > 0) { $address = new Address($id_address); - $customers[$customerId]['postcode'] = substr($address->postcode, 0,2); + $customers[$customerId]['postcode'] = substr($address->postcode, 0, 2); $customers[$customerId]['city'] = $address->city; $customers[$customerId]['country'] = Country::getNameById(Context::getContext()->language->id, $address->id_country); unset($address); @@ -80,9 +112,6 @@ public function getCustomersByGroupId($groupId) return $customerIds; } -} - return $customerIds; - } // Get group id for members of the year public function getGroupMembersId() @@ -93,5 +122,7 @@ public function getGroupMembersId() return $group['id_group']; } } + + return false; } } diff --git a/upgrade/index.php b/upgrade/index.php new file mode 100644 index 0000000..6028c7f --- /dev/null +++ b/upgrade/index.php @@ -0,0 +1,34 @@ + + * @copyright 2007-2020 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) + * International Registered Trademark & Property of PrestaShop SA + */ +header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); +header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); + +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); + +header('Location: ../'); +exit; diff --git a/upgrade/upgrade-1.0.1.php b/upgrade/upgrade-1.0.1.php new file mode 100644 index 0000000..39eee91 --- /dev/null +++ b/upgrade/upgrade-1.0.1.php @@ -0,0 +1,28 @@ + + * @copyright 2008-today Mediacom87 + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ +if (!defined('_PS_VERSION_')) { + exit; +} + +function upgrade_module_1_0_1($module) +{ + $module->registerHook('moduleRoutes'); + + return true; +} diff --git a/views/templates/front/list.tpl b/views/templates/front/list.tpl index 436c077..012d345 100644 --- a/views/templates/front/list.tpl +++ b/views/templates/front/list.tpl @@ -21,6 +21,6 @@ {/foreach} {else} -

Nothing here

+

{l s='If you'd like to be the first to appear in our directory, all you have to do is join our association. Don't delay!' mod='fopmembers'}

{/if} {/block} \ No newline at end of file