Skip to content

Commit

Permalink
Merge branch 'develop' into patch-2
Browse files Browse the repository at this point in the history
  • Loading branch information
bastienlm authored Nov 2, 2018
2 parents 581b756 + e823449 commit 8ab0be7
Show file tree
Hide file tree
Showing 20 changed files with 369 additions and 312 deletions.
102 changes: 27 additions & 75 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
# PH2M GDPR

GDPR Module for Magento 1
==================
Free Magento 1 module for respect reform of EU data protection rules (GDPR)

![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)

## Requirements

- Only test on Magento 1.9.x (but probably work on magento 1.4.x to 1.9.x)

## 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 @@ -44,82 +48,31 @@ 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'
- Run cron phgdpr_check_rules and check GDPR validity on 'System > Configuration > General > GDPR > Status'
- You can test download data or remove data from your customer dashboard

## 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
Documentation
-------
[Module documentation](https://github.com/PH2M/GDPR/wiki/Documentation).

```
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

#### 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)



## Licence
[Developer documentation](https://github.com/PH2M/GDPR/wiki/Developer-guide).

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 All @@ -136,5 +89,4 @@ magerun config:set "phgdpr/customer_data_download/enable_customer_download_addr
magerun config:set "phgdpr/customer_data_download/address_attribute_to_export" "prefix,firstname,middlename,lastname,suffix,company,street,city,country_id,region,postcode,telephone,fax"
magerun config:set "phgdpr/customer_data_download/enable_customer_download_orders" "1"
magerun config:set "phgdpr/customer_data_download/order_attribute_to_export" "created_at,customer_dob,customer_email,customer_firstname,customer_gender,customer_lastname,customer_middlename,customer_prefix,customer_suffix,discount_amount,grand_total,shipping_amount,increment_id"
```
```
18 changes: 18 additions & 0 deletions RELEASE_NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,21 @@ Init module :
- [Fix] #11 #9 #13 #15
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
==== 1.1.1 ====

- [Update] Modman update
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
==== 1.1.2 ====

- [Update] Modman update / composer update / PSR2 validity
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
==== 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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
*
*/

class PH2M_Gdpr_Block_Adminhtml_Gdpr_Status extends Mage_Core_Block_Template
class PH2M_Gdpr_Block_Adminhtml_Gdpr_Rules_Status extends Mage_Core_Block_Template
{
/**
* Constructor. Set template.
*/
protected function _construct()
{
parent::_construct();
$this->setTemplate('ph/gdpr/system/config/status.phtml');
$this->setTemplate('ph/gdpr/system/config/rules/status.phtml');
}


Expand All @@ -38,8 +38,6 @@ public function getCssClass($config)
$config = Mage::getStoreConfig($config);
if ($config == PH2M_Gdpr_Model_System_Config_Source_Rulesvalidity::NO_VALID) {
return 'bad';
} elseif ($config == PH2M_Gdpr_Model_System_Config_Source_Rulesvalidity::WAIT_MANUAL_VALIDATION) {
return 'wait';
}
return 'good';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,16 @@
*
*/

class PH2M_Gdpr_Block_Adminhtml_System_Config_Gdpr_Status extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
class PH2M_Gdpr_Block_Adminhtml_System_Config_Gdpr_Rules extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
{
/**
* @param Varien_Data_Form_Element_Abstract $element
* @return string
*/
public function render(Varien_Data_Form_Element_Abstract $element)
{
$html = Mage::getBlockSingleton('phgdpr/adminhtml_gdpr_status')->toHtml();
$status = Mage::getBlockSingleton('phgdpr/adminhtml_gdpr_rules_status')->toHtml();

return $html;
return $status;
}
}
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
10 changes: 7 additions & 3 deletions app/code/community/PH2M/Gdpr/Helper/Password.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@
*
*/

/**
* Class PH2M_Gdpr_Helper_Password
*/
class PH2M_Gdpr_Helper_Password
{
const MIN_PASSWORD_LENGTH = 8;

/**
* Check if the password is valid for gdpr
Expand All @@ -27,8 +31,8 @@ class PH2M_Gdpr_Helper_Password
public function invalidPasswordFormat($password)
{
$errorCount = 1;
if (strlen($password) < '8') {
return Mage::helper('phgdpr')->__('Your password must contain at least 8 characters.');
if (strlen($password) < self::MIN_PASSWORD_LENGTH) {
return Mage::helper('phgdpr')->__('Your password must contain at least %s characters.', self::MIN_PASSWORD_LENGTH);
}
if (!preg_match("#[0-9]+#", $password)) {
$errorCount++;
Expand All @@ -44,7 +48,7 @@ public function invalidPasswordFormat($password)
}

if ($errorCount >= 3) {
return Mage::helper('phgdpr')->__('Please enter valid password, with 3 or more than options, numeric, lowercase, uppercase, special character');
return Mage::helper('phgdpr')->__('Your password must respect at least 3 of the following conditions: one capital letter, one lowercase letter, one number, one special character and contains at least 8 characters.');
}
return false;
}
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
5 changes: 5 additions & 0 deletions app/code/community/PH2M/Gdpr/Model/Customer/Data/Remove.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,13 @@ 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 false;
}
$helper = Mage::helper('phgdpr');
$address->setFirstname($helper->getRandom());
$address->setMiddlename($helper->getRandom());
Expand All @@ -279,6 +283,7 @@ protected function anonymizeSaleAddress($address)
$address->setPostcode($helper->getRandom());
$address->setTelephone($helper->getRandom());
$address->setFax($helper->getRandom());
return true;
}

/**
Expand Down
59 changes: 2 additions & 57 deletions app/code/community/PH2M/Gdpr/Model/Observer.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,71 +16,16 @@
*/
class PH2M_Gdpr_Model_Observer
{
protected $configModel;
const EXCEPTION_ACCOUNT_GDPR_LOCK = 20;
const DEFAULT_ATTEMPS_NUMBER = 5;
const DEFAULT_TIME_BLOCKED = 5;


/**
* Check if all config for respect GDPR is enabled
*/
public function checkRulesValidity()
{
$this->configModel = Mage::getConfig();
$this->checkNewsletterDoubleOptIn();
$this->checkPasswordFormatValidation();
$this->checkLoginLimitAttempts();
$this->checkCustomerCanRemoveData();
$this->checkCustomerCanDownloadData();
}

protected function checkCustomerCanRemoveData()
{
if (Mage::getStoreConfig('phgdpr/customer_data_remove/enable')) {
$this->configModel->saveConfig('phgdpr/valid_rules/customer_data_remove', PH2M_Gdpr_Model_System_Config_Source_Rulesvalidity::WAIT_MANUAL_VALIDATION, 'default', 0);
} else {
$this->configModel->saveConfig('phgdpr/valid_rules/customer_data_remove', PH2M_Gdpr_Model_System_Config_Source_Rulesvalidity::NO_VALID, 'default', 0);
}
}

protected function checkCustomerCanDownloadData()
public function checkRulesValidity(Varien_Event_Observer $observer)
{
if (Mage::getStoreConfig('phgdpr/customer_data_download/enable')) {
$this->configModel->saveConfig('phgdpr/valid_rules/customer_download_own_information', PH2M_Gdpr_Model_System_Config_Source_Rulesvalidity::WAIT_MANUAL_VALIDATION, 'default', 0);
} else {
$this->configModel->saveConfig('phgdpr/valid_rules/customer_download_own_information', PH2M_Gdpr_Model_System_Config_Source_Rulesvalidity::NO_VALID, 'default', 0);
}
Mage::getModel('phgdpr/rules_validity')->checkRulesValidity();
}

protected function checkNewsletterDoubleOptIn()
{
if (Mage::getStoreConfig('newsletter/subscription/confirm')) {
$this->configModel->saveConfig('phgdpr/valid_rules/newsletter_double_optin', PH2M_Gdpr_Model_System_Config_Source_Rulesvalidity::WAIT_MANUAL_VALIDATION, 'default', 0);
} else {
$this->configModel->saveConfig('phgdpr/valid_rules/newsletter_double_optin', PH2M_Gdpr_Model_System_Config_Source_Rulesvalidity::NO_VALID, 'default', 0);
}
}

protected function checkPasswordFormatValidation()
{
if (Mage::getStoreConfig('phgdpr/fonctionality/password_format_validation')) {
$this->configModel->saveConfig('phgdpr/valid_rules/customer_complex_password', PH2M_Gdpr_Model_System_Config_Source_Rulesvalidity::WAIT_MANUAL_VALIDATION, 'default', 0);
} else {
$this->configModel->saveConfig('phgdpr/valid_rules/customer_complex_password', PH2M_Gdpr_Model_System_Config_Source_Rulesvalidity::NO_VALID, 'default', 0);
}
}

protected function checkLoginLimitAttempts()
{
if (Mage::getStoreConfig('phgdpr/fonctionality/login_limit_attempts')) {
$this->configModel->saveConfig('phgdpr/valid_rules/customer_login_limit_attempts', PH2M_Gdpr_Model_System_Config_Source_Rulesvalidity::WAIT_MANUAL_VALIDATION, 'default', 0);
} else {
$this->configModel->saveConfig('phgdpr/valid_rules/customer_login_limit_attempts', PH2M_Gdpr_Model_System_Config_Source_Rulesvalidity::NO_VALID, 'default', 0);
}
}


/**
* If customer try to login too many time during 30 seconds,
* lock the login system during 30 seconds
Expand Down
Loading

0 comments on commit 8ab0be7

Please sign in to comment.