Skip to content

Commit

Permalink
Add PHP_CodeSniffer #21 & Customer information > Download a txt file #18
Browse files Browse the repository at this point in the history
  • Loading branch information
bastienlm committed Oct 26, 2018
1 parent 75f87a9 commit e823449
Show file tree
Hide file tree
Showing 10 changed files with 198 additions and 204 deletions.
94 changes: 26 additions & 68 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
# PH2M GDPR
GDPR Module for Magento 1
==================
Free Magento 1 module for respect reform of EU data protection rules (GDPR)

## Requirements
- Only test on Magento 1.9.x (but probably works on magento 1.4.x to 1.9.x)
![Latest version](https://img.shields.io/badge/latest-v1.1.2-green.svg)
![PHP >= 5.3](https://img.shields.io/badge/php-%3E=5.3-green.svg)
![Magento 1.9.3](https://img.shields.io/badge/magento-1.9.3-blue.svg)

## Changelog

Changelog
--------
See RELEASE_NOTES.txt

## Installation
Installation
---------
Composer :
```
composer require ph2m/gdpr
```

Manual :
Download this module and add 'app' and 'skin' directory to you magento

## Feature
Feature
-------
**Full manageable, you can enabled / disabled all functionality from your back-office**
- Download, remove and anonymize customer data
- Live system: customer can directly download or remove their own data from their dashboard
Expand All @@ -41,79 +48,30 @@ Download this module and add 'app' and 'skin' directory to you magento
- Display cookies consent banner and popup
- Compatible with magento google analytics (can be disabled)

## Usage
Usage
------
- Enable all feature who you want on 'System > Configuration > General > GDPR'
- You can test download data or remove data from your customer dashboard

## Password validation
You must customize your theme if you want to enable the JS password validation.
Follow these steps:
1. Uncomment the `password-validation.js` inclusion in `app/design/frontend/base/default/layout/ph/gdpr.xml`
2. In your theme's register template, replace the `validate-password` class by `validate-gdpr-password`. Usually, you should have `customer/form/register.phtml` and `checkout/onepage/billing.phtml`.

## Developer guide
#### ADD Custom process before / after customer download or remove data
- Download event:
```
request_customer_data_download_before [customer, customer_email]
```
call before delete customer data, or add download action in queue

```
request_customer_data_download_after [customer, customer_email]
```
call after delete customer data, or add download action in queue

```
customer_data_download_construct_data_before [customer, fileData]
```
call before construct file data, you can add your custom data on fileData Varien_Object

```
customer_data_download_construct_data_after [customer, fileData]
```
call after construct file data, you can update or remove data already in Varien_Object

- Remove event:

```
request_customer_data_remove_before [customer, customer_email]
```
call just before delete customer data, or remove action in queue

```
request_customer_data_remove_after [customer, customer_email]
```
call just after delete customer data, or remove action in queue

```
customer_data_remove_action_before [customer, customer_email]
```
call before customer data remove action

```
customer_data_remove_action_after [customer, customer_email]
```
call after customer data remove action
Documentation
-------
[Module documentation](https://github.com/PH2M/GDPR/wiki/Documentation).

#### ADD Custom process with queue system
You can add your own custom process thanks to the queue system. for this, follow this step :
1. create your own model, you need to implement `PH2M_Gdpr_Model_Interface` interface.
2. add your process to queue tab, you need to specified (use `Mage::getModel('phgdpr/queue')->addEntity()`:
- entity_type (is the name of your class, look `PH2M_Gdpr_Model_Queue_Entitytype` for example)
- params (you can add all info you want to get for you process)
- run_date (date when you want run your process, keep empty for run at the next queue running)
[Developer documentation](https://github.com/PH2M/GDPR/wiki/Developer-guide).

## Licence
Licence
-------
GNU General Public License, version 3 (GPLv3)

## Mini-help for contribution
Auto-generate modman with https://github.com/mhauri/generate-modman:
Mini-help for contribution
--------
Auto-generate [modman](https://github.com/mhauri/generate-modman)
```
make modman
```

## Configuration recommended (With magerun)
Configuration recommended (with [magerun](https://github.com/netz98/n98-magerun))
--------
```
magerun config:set "phgdpr/fonctionality/password_format_validation" "1"
magerun config:set "phgdpr/fonctionality/login_limit_attempts" "1"
Expand Down
2 changes: 2 additions & 0 deletions RELEASE_NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ Init module :
==== 1.1.3 ====

- [Fix] Improve password validation UX #10
- [Fix] When shipping address is null (e.g. virtual products) there is an error
- [Update] Check validity rules system
- [Update] Add php_codesniffer to composer
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 changes: 1 addition & 1 deletion app/code/community/PH2M/Gdpr/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public function log($message, $level = Zend_Log::NOTICE)
public function getCustomerDataFile($customerId)
{
$directory = Mage::getBaseDir('var') . DS . 'phgdpr';
$file = $directory . DS . 'customer-data-file-' . $customerId . '.json';
$file = $directory . DS . 'customer-data-file-' . $customerId . '.txt';

return $file;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ protected function sendCanDownloadFileMail($jsonData, $customer)
public function saveDataInFile($jsonData, $customer)
{
$directory = Mage::getBaseDir('var') . DS . 'phgdpr';
$file = $directory . DS . 'customer-data-file-' . $customer->getId() . '.json';
$file = $directory . DS . 'customer-data-file-' . $customer->getId() . '.txt';
if (!file_exists($directory)) {
mkdir($directory, 0777, true);
}
Expand Down
6 changes: 4 additions & 2 deletions app/code/community/PH2M/Gdpr/Model/Customer/Data/Remove.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,11 +264,12 @@ protected function getCustomerProductReviews($customer)
* anonymize customer details from the address
*
* @param Mage_Sales_Model_Order_Address|Mage_Sales_Model_Quote_Address $address
* @return bool
*/
protected function anonymizeSaleAddress($address)
{
if(empty($address)){
return;
if (empty($address)) {
return false;
}
$helper = Mage::helper('phgdpr');
$address->setFirstname($helper->getRandom());
Expand All @@ -282,6 +283,7 @@ protected function anonymizeSaleAddress($address)
$address->setPostcode($helper->getRandom());
$address->setTelephone($helper->getRandom());
$address->setFax($helper->getRandom());
return true;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function downloadFileAction()

if (file_exists($file)) {
$data = file_get_contents($file);
return $this->_prepareDownloadResponse('customer-information.json', $data);
return $this->_prepareDownloadResponse('customer-information.txt', $data);
}
Mage::getSingleton('core/session')->addError(Mage::helper('phgdpr')->__('Sorry, but this file does not exist'));
return $this->_redirectReferer();
Expand Down Expand Up @@ -136,7 +136,7 @@ public function downloadCustomerDataAction()
$data = Mage::getModel('phgdpr/customer_data_download')->requestRetrieveCustomerData($customer);

if (!Mage::getStoreConfig('phgdpr/customer_data_download/download_action_in_queue')) {
$this->_prepareDownloadResponse('customer-information.json', $data);
$this->_prepareDownloadResponse('customer-information.txt', $data);
} else {
Mage::getSingleton('core/session')->addSuccess(Mage::getStoreConfig('phgdpr/customer_data_download/queue_processing_message'));
$this->_redirectReferer();
Expand Down
6 changes: 2 additions & 4 deletions app/code/community/PH2M/Gdpr/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,12 @@
<customer_data_remove>
<confirm_email_template>phgdpr_customer_data_remove_confirm_email_template</confirm_email_template>
<email_sender_identity>general</email_sender_identity>
<lock_account_message>
<![CDATA[This account will be removed soon, during this process you can log to this account]]></lock_account_message>
<lock_account_message><![CDATA[This account will be removed soon, during this process you can log to this account]]></lock_account_message>
</customer_data_remove>
<customer_data_download>
<email_template>phgdpr_customer_data_download_email_template</email_template>
<email_sender_identity>general</email_sender_identity>
<queue_processing_message>
<![CDATA[We received your request, and we send you your data soon by email.]]></queue_processing_message>
<queue_processing_message><![CDATA[We received your request, and we send you your data soon by email.]]></queue_processing_message>
</customer_data_download>
</phgdpr>
</default>
Expand Down
2 changes: 1 addition & 1 deletion app/design/frontend/base/default/layout/ph/gdpr.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<layout version="0.1.0">
<default>
<reference name="head">
<!-- Uncomment these lines to enable JS password validation (see README) -->
<!-- Uncomment these lines to enable JS password validation (see developer documentation) -->
<!--<action method="addItem" ifconfig="phgdpr/fonctionality/password_format_validation" condition="1">-->
<!--<type>skin_js</type>-->
<!--<file>js/ph/gdpr/password-validation.js</file>-->
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
],
"require-dev": {
"generate-modman/generate-modman": "dev-master",
"friendsofphp/php-cs-fixer": "^2.13"
"friendsofphp/php-cs-fixer": "^2.13",
"squizlabs/php_codesniffer": "^3.3"
}
}
Loading

0 comments on commit e823449

Please sign in to comment.