Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Index et htaccess, nouvelle route, et déduction du groupe de client via l'année courante getGroupMembersId #3

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Apache 2.2
<IfModule !mod_authz_core.c>
Order deny,allow
Deny from all
<Files ~ "(?i)^.*\.(jpg|jpeg|gif|png|bmp|tiff|svg|pdf|mov|mpeg|mp4|avi|mpg|wma|flv|webm|ico|webp|woff|woff2|ttf|eot|otf|css|js)$">
Allow from all
</Files>
</IfModule>

# Apache 2.4
<IfModule mod_authz_core.c>
Require all denied
<Files ~ "(?i)^.*\.(jpg|jpeg|gif|png|bmp|tiff|svg|pdf|mov|mpeg|mp4|avi|mpg|wma|flv|webm|ico|webp|woff|woff2|ttf|eot|otf|css|js)$">
Require all granted
</Files>
</IfModule>
34 changes: 34 additions & 0 deletions controllers/front/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
/**
* 2007-2020 PrestaShop SA and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://www.prestashop.com for more information.
*
* @author PrestaShop SA <[email protected]>
* @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;
2 changes: 1 addition & 1 deletion controllers/front/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 34 additions & 0 deletions controllers/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
/**
* 2007-2020 PrestaShop SA and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://www.prestashop.com for more information.
*
* @author PrestaShop SA <[email protected]>
* @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;
53 changes: 49 additions & 4 deletions fopmembers.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -36,19 +36,51 @@ 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) {
foreach ($customerIds as $customerId) {
$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);
Expand Down Expand Up @@ -80,4 +112,17 @@ public function getCustomersByGroupId($groupId)

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'];
}
}

return false;
}
}
34 changes: 34 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
/**
* 2007-2020 PrestaShop SA and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://www.prestashop.com for more information.
*
* @author PrestaShop SA <[email protected]>
* @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;
34 changes: 34 additions & 0 deletions upgrade/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
/**
* 2007-2020 PrestaShop SA and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://www.prestashop.com for more information.
*
* @author PrestaShop SA <[email protected]>
* @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;
28 changes: 28 additions & 0 deletions upgrade/upgrade-1.0.1.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
/**
* 2008-today Mediacom87
*
* NOTICE OF LICENSE
*
* Read in the module
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author Mediacom87 <[email protected]>
* @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;
}
34 changes: 34 additions & 0 deletions views/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
/**
* 2007-2020 PrestaShop SA and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://www.prestashop.com for more information.
*
* @author PrestaShop SA <[email protected]>
* @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;
34 changes: 34 additions & 0 deletions views/templates/front/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
/**
* 2007-2020 PrestaShop SA and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://www.prestashop.com for more information.
*
* @author PrestaShop SA <[email protected]>
* @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;
2 changes: 1 addition & 1 deletion views/templates/front/list.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
{/foreach}
</ul>
{else}
<p>Nothing here</p>
<p>{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'}</p>
{/if}
{/block}
34 changes: 34 additions & 0 deletions views/templates/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
/**
* 2007-2020 PrestaShop SA and Contributors
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://www.prestashop.com for more information.
*
* @author PrestaShop SA <[email protected]>
* @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;