Include rgpd module with name DataPolicies

This commit is contained in:
Laurent Destailleur 2018-10-06 02:51:47 +02:00
parent 5437c2ae85
commit d1dde0ffac
21 changed files with 2674 additions and 0 deletions

View File

@ -0,0 +1,283 @@
<?php
/* Copyright (C) 2004-2018 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \defgroup datapolicies Module datapolicies
* \brief datapolicies module descriptor.
*
* \file htdocs/datapolicies/core/modules/modGdpr.class.php
* \ingroup datapolicies
* \brief Description and activation file for module DATAPOLICIES
*/
include_once DOL_DOCUMENT_ROOT . '/core/modules/DolibarrModules.class.php';
// The class name should start with a lower case mod for Dolibarr to pick it up
// so we ignore the Squiz.Classes.ValidClassName.NotCamelCaps rule.
// @codingStandardsIgnoreStart
/**
* Description and activation class for module datapolicies
*/
class modDataPolicies extends DolibarrModules {
// @codingStandardsIgnoreEnd
/**
* Constructor. Define names, constants, directories, boxes, permissions
*
* @param DoliDB $db Database handler
*/
public function __construct($db) {
global $langs, $conf;
$this->db = $db;
// Id for module (must be unique).
// Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id).
$this->numero = 4100;
// Key text used to identify module (for permissions, menus, etc...)
$this->rights_class = 'datapolicies';
// Family can be 'base' (core modules),'crm','financial','hr','projects','products','ecm','technic' (transverse modules),'interface' (link with external tools),'other','...'
// It is used to group modules by family in module setup page
$this->family = "hr";
// Module position in the family on 2 digits ('01', '10', '20', ...)
$this->module_position = '90';
// Gives the possibility to the module, to provide his own family info and position of this family (Overwrite $this->family and $this->module_position. Avoid this)
//$this->familyinfo = array('myownfamily' => array('position' => '01', 'label' => $langs->trans("MyOwnFamily")));
// Module label (no space allowed), used if translation string 'ModuledatapoliciesName' not found (MyModue is name of module).
$this->name = preg_replace('/^mod/i', '', get_class($this));
// Module description, used if translation string 'ModuledatapoliciesDesc' not found (MyModue is name of module).
$this->description = "Module to manage Data policies (for compliance with GDPR in Europe or other Data policies rules)";
// Used only if file README.md and README-LL.md not found.
$this->descriptionlong = "";
$this->editor_name = 'Inovea Conseil';
// Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z'
$this->version = 'development';
// Key used in llx_const table to save module status enabled/disabled (where datapolicies is value of property name of module in uppercase)
$this->const_name = 'MAIN_MODULE_' . strtoupper($this->name);
// Name of image file used for this module.
// If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'
// If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'
$this->picto = 'generic';
// Defined all module parts (triggers, login, substitutions, menus, css, etc...)
// for default path (eg: /datapolicies/core/xxxxx) (0=disable, 1=enable)
// for specific path of parts (eg: /datapolicies/core/modules/barcode)
// for specific css file (eg: /datapolicies/css/datapolicies.css.php)
$this->module_parts = array(
'triggers' => 0, // Set this to 1 if module has its own trigger directory (core/triggers)
'login' => 0, // Set this to 1 if module has its own login method file (core/login)
'substitutions' => 0, // Set this to 1 if module has its own substitution function file (core/substitutions)
'menus' => 0, // Set this to 1 if module has its own menus handler directory (core/menus)
'theme' => 0, // Set this to 1 if module has its own theme directory (theme)
'tpl' => 0, // Set this to 1 if module overwrite template dir (core/tpl)
'barcode' => 0, // Set this to 1 if module has its own barcode directory (core/modules/barcode)
'models' => 0, // Set this to 1 if module has its own models directory (core/modules/xxx)
'css' => array('/datapolicies/css/datapolicies.css.php'), // Set this to relative path of css file if module has its own css file
'js' => array('/datapolicies/js/datapolicies.js.php'), // Set this to relative path of js file if module must load a js on all pages
'hooks' => array('data' => array('membercard', 'contactcard', 'thirdpartycard'), 'entity' => $conf->entity) // Set here all hooks context managed by module. To find available hook context, make a "grep -r '>initHooks(' *" on source code. You can also set hook context 'all'
);
// Data directories to create when module is enabled.
// Example: this->dirs = array("/datapolicies/temp","/datapolicies/subdir");
$this->dirs = array("/datapolicies/temp");
// Config pages. Put here list of php page, stored into datapolicies/admin directory, to use to setup module.
$this->config_page_url = array("setup.php@datapolicies");
// Dependencies
$this->hidden = false; // A condition to hide module
$this->depends = array(); // List of module class names as string that must be enabled if this module is enabled
$this->requiredby = array(); // List of module ids to disable if this one is disabled
$this->conflictwith = array(); // List of module class names as string this module is in conflict with
$this->langfiles = array("datapolicies@datapolicies");
$this->phpmin = array(5, 3); // Minimum version of PHP required by module
$this->need_dolibarr_version = array(4, 0); // Minimum version of Dolibarr required by module
$this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
$this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
//$this->automatic_activation = array('FR'=>'datapoliciesWasAutomaticallyActivatedBecauseOfYourCountryChoice');
//$this->always_enabled = true; // If true, can't be disabled
// Constants
// List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive)
// Example: $this->const=array(0=>array('datapolicies_MYNEWCONST1','chaine','myvalue','This is a constant to add',1),
// 1=>array('datapolicies_MYNEWCONST2','chaine','myvalue','This is another constant to add',0, 'current', 1)
// );
$this->const = array(
array('DATAPOLICIES_TIERS_CLIENT', 'chaine', '', 'Nombre de mois avant suppression des données', 0),
array('DATAPOLICIES_TIERS_PROSPECT', 'chaine', '', 'Nombre de mois avant suppression des données', 0),
array('DATAPOLICIES_TIERS_PROSPECT_CLIENT', 'chaine', '', 'Nombre de mois avant suppression des données', 0),
array('DATAPOLICIES_TIERS_NIPROSPECT_NICLIENT', 'chaine', '', 'Nombre de mois avant suppression des données', 0),
array('DATAPOLICIES_TIERS_FOURNISSEUR', 'chaine', '', 'Nombre de mois avant suppression des données', 0),
array('DATAPOLICIES_CONTACT_CLIENT', 'chaine', '', 'Nombre de mois avant suppression des données', 0),
array('DATAPOLICIES_CONTACT_PROSPECT', 'chaine', '', 'Nombre de mois avant suppression des données', 0),
array('DATAPOLICIES_CONTACT_PROSPECT_CLIENT', 'chaine', '', 'Nombre de mois avant suppression des données', 0),
array('DATAPOLICIES_CONTACT_NIPROSPECT_NICLIENT', 'chaine', '', 'Nombre de mois avant suppression des données', 0),
array('DATAPOLICIES_CONTACT_FOURNISSEUR', 'chaine', '', 'Nombre de mois avant suppression des données', 0),
array('DATAPOLICIES_ADHERENT', 'chaine', '', 'Nombre de mois avant suppression des données', 0),
);
$country = explode(":", $conf->global->MAIN_INFO_SOCIETE_COUNTRY);
if ($country[0] == $conf->entity && $country[2] == "France")
$this->editor_url = "https://www.inovea-conseil.com (<a target='_blank' href='https://www.dolibiz.com/wp-content/uploads/attestation/attestation-" . $this->name . "-" . $this->version . ".pdf'>Attestation NF525</a>)";
else
$this->editor_url = 'https://www.inovea-conseil.com';
// Some keys to add into the overwriting translation tables
/* $this->overwrite_translation = array(
'en_US:ParentCompany'=>'Parent company or reseller',
'fr_FR:ParentCompany'=>'Maison mère ou revendeur'
) */
if (!isset($conf->datapolicies) || !isset($conf->datapolicies->enabled)) {
$conf->datapolicies = new stdClass();
$conf->datapolicies->enabled = 0;
}
// Array to add new pages in new tabs
$this->tabs = array();
// Example:
// $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@datapolicies:$user->rights->datapolicies->read:/datapolicies/mynewtab1.php?id=__ID__'); // To add a new tab identified by code tabname1
// $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@datapolicies:$user->rights->othermodule->read:/datapolicies/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key.
// $this->tabs[] = array('data'=>'objecttype:-tabname:NU:conditiontoremove'); // To remove an existing tab identified by code tabname
//
// Where objecttype can be
// 'categories_x' to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member)
// 'contact' to add a tab in contact view
// 'contract' to add a tab in contract view
// 'group' to add a tab in group view
// 'intervention' to add a tab in intervention view
// 'invoice' to add a tab in customer invoice view
// 'invoice_supplier' to add a tab in supplier invoice view
// 'member' to add a tab in fundation member view
// 'opensurveypoll' to add a tab in opensurvey poll view
// 'order' to add a tab in customer order view
// 'order_supplier' to add a tab in supplier order view
// 'payment' to add a tab in payment view
// 'payment_supplier' to add a tab in supplier payment view
// 'product' to add a tab in product view
// 'propal' to add a tab in propal view
// 'project' to add a tab in project view
// 'stock' to add a tab in stock view
// 'thirdparty' to add a tab in third party view
// 'user' to add a tab in user view
// Dictionaries
$this->dictionaries = array();
/* Example:
$this->dictionaries=array(
'langs'=>'mylangfile@datapolicies',
'tabname'=>array(MAIN_DB_PREFIX."table1",MAIN_DB_PREFIX."table2",MAIN_DB_PREFIX."table3"), // List of tables we want to see into dictonnary editor
'tablib'=>array("Table1","Table2","Table3"), // Label of tables
'tabsql'=>array('SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table1 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table2 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table3 as f'), // Request to select fields
'tabsqlsort'=>array("label ASC","label ASC","label ASC"), // Sort order
'tabfield'=>array("code,label","code,label","code,label"), // List of fields (result of select to show dictionary)
'tabfieldvalue'=>array("code,label","code,label","code,label"), // List of fields (list of fields to edit a record)
'tabfieldinsert'=>array("code,label","code,label","code,label"), // List of fields (list of fields for insert)
'tabrowid'=>array("rowid","rowid","rowid"), // Name of columns with primary key (try to always name it 'rowid')
'tabcond'=>array($conf->datapolicies->enabled,$conf->datapolicies->enabled,$conf->datapolicies->enabled) // Condition to show each dictionary
);
*/
// Boxes/Widgets
// Add here list of php file(s) stored in datapolicies/core/boxes that contains class to show a widget.
$this->boxes = array();
// Cronjobs (List of cron jobs entries to add when module is enabled)
// unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week
$this->cronjobs = array(
0 => array('label' => 'DATAPOLICIES Cron', 'jobtype' => 'method', 'class' => '/datapolicies/class/datapoliciesCron.class.php', 'objectname' => 'RgpdCron', 'method' => 'exec', 'parameters' => '', 'comment' => 'Comment', 'frequency' => 1, 'unitfrequency' => 86400, 'status' => 1, 'test' => true),
1 => array('label' => 'DATAPOLICIES Mailing', 'jobtype' => 'method', 'class' => '/datapolicies/class/datapoliciesCron.class.php', 'objectname' => 'RgpdCron', 'method' => 'sendMailing', 'parameters' => '', 'comment' => 'Comment', 'frequency' => 1, 'unitfrequency' => 86400, 'status' => 0, 'test' => true)
);
// Example: $this->cronjobs=array(0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>true),
// 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'status'=>0, 'test'=>true)
// );
// Permissions
$this->rights = array(); // Permission array used by this module
// Main menu entries
$this->menu = array(); // List of menus to add
$r = 0;
}
/**
* Function called when module is enabled.
* The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
* It also creates data directories
*
* @param string $options Options when enabling module ('', 'noboxes')
* @return int 1 if OK, 0 if KO
*/
public function init($options = '') {
global $langs;
$this->_load_tables('/datapolicies/sql/');
// Create extrafields
include_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
$extrafields = new ExtraFields($this->db);
// Extrafield contact
//$result1=$extrafields->addExtraField('datapolicies_separate', "DATAPOLICIES_BLOCKCHECKBOX", 'separate', 100, 1, 'thirdparty', 0, 0, '', '', 1, '', '1', 0, '', '', 'datapolicies@datapolicies', '$conf->datapolicies->enabled');
$result1 = $extrafields->addExtraField('datapolicies_consentement', "DATAPOLICIES_consentement", 'boolean', 101, 3, 'thirdparty', 0, 0, '', '', 1, '', '3', 0, '', '', 'datapolicies@datapolicies', '$conf->datapolicies->enabled');
$result1 = $extrafields->addExtraField('datapolicies_opposition_traitement', "DATAPOLICIES_opposition_traitement", 'boolean', 102, 3, 'thirdparty', 0, 0, '', '', 1, '', '3', 0, '', '', 'datapolicies@datapolicies', '$conf->datapolicies->enabled');
$result1 = $extrafields->addExtraField('datapolicies_opposition_prospection', "DATAPOLICIES_opposition_prospection", 'boolean', 103, 3, 'thirdparty', 0, 0, '', '', 1, '', '3', 0, '', '', 'datapolicies@datapolicies', '$conf->datapolicies->enabled');
$result1 = $extrafields->addExtraField('datapolicies_date', $langs->trans("DATAPOLICIES_date"), 'date', 104, 3, 'thirdparty', 0, 0, '', '', 1, '', '3', 0);
$result1 = $extrafields->addExtraField('datapolicies_send', $langs->trans("DATAPOLICIES_send"), 'date', 105, 3, 'thirdparty', 0, 0, '', '', 0, '', '0', 0);
// Extrafield Tiers
//$result1=$extrafields->addExtraField('datapolicies_separate', "DATAPOLICIES_BLOCKCHECKBOX", 'separate', 100, 1, 'contact', 0, 0, '', '', 1, '', '1', 0, '', '', 'datapolicies@datapolicies', '$conf->datapolicies->enabled');
$result1 = $extrafields->addExtraField('datapolicies_consentement', "DATAPOLICIES_consentement", 'boolean', 101, 3, 'contact', 0, 0, '', '', 1, '', '3', 0, '', '', 'datapolicies@datapolicies', '$conf->datapolicies->enabled');
$result1 = $extrafields->addExtraField('datapolicies_opposition_traitement', "DATAPOLICIES_opposition_traitement", 'boolean', 102, 3, 'contact', 0, 0, '', '', 1, '', '3', 0, '', '', 'datapolicies@datapolicies', '$conf->datapolicies->enabled');
$result1 = $extrafields->addExtraField('datapolicies_opposition_prospection', "DATAPOLICIES_opposition_prospection", 'boolean', 103, 3, 'contact', 0, 0, '', '', 1, '', '3', 0, '', '', 'datapolicies@datapolicies', '$conf->datapolicies->enabled');
$result1 = $extrafields->addExtraField('datapolicies_date', $langs->trans("DATAPOLICIES_date"), 'date', 104, 3, 'contact', 0, 0, '', '', 1, '', '3', 0);
$result1 = $extrafields->addExtraField('datapolicies_send', $langs->trans("DATAPOLICIES_send"), 'date', 105, 3, 'contact', 0, 0, '', '', 0, '', '0', 0);
// Extrafield Adherent
//$result1=$extrafields->addExtraField('datapolicies_separate', "DATAPOLICIES_BLOCKCHECKBOX", 'separate', 100, 1, 'adherent', 0, 0, '', '', 1, '', '1', 0, '', '', 'datapolicies@datapolicies', '$conf->datapolicies->enabled');
$result1 = $extrafields->addExtraField('datapolicies_consentement', "DATAPOLICIES_consentement", 'boolean', 101, 3, 'adherent', 0, 0, '', '', 1, '', '3', 0, '', '', 'datapolicies@datapolicies', '$conf->datapolicies->enabled');
$result1 = $extrafields->addExtraField('datapolicies_opposition_traitement', "DATAPOLICIES_opposition_traitement", 'boolean', 102, 3, 'adherent', 0, 0, '', '', 1, '', '3', 0, '', '', 'datapolicies@datapolicies', '$conf->datapolicies->enabled');
$result1 = $extrafields->addExtraField('datapolicies_opposition_prospection', "DATAPOLICIES_opposition_prospection", 'boolean', 103, 3, 'adherent', 0, 0, '', '', 1, '', '3', 0, '', '', 'datapolicies@datapolicies', '$conf->datapolicies->enabled');
$result1 = $extrafields->addExtraField('datapolicies_date', $langs->trans("DATAPOLICIES_date"), 'date', 104, 3, 'adherent', 0, 0, '', '', 1, '', '3', 0);
$result1 = $extrafields->addExtraField('datapolicies_send', $langs->trans("DATAPOLICIES_send"), 'date', 105, 3, 'adherent', 0, 0, '', '', 0, '', '0', 0);
$sql = array();
return $this->_init($sql, $options);
}
/**
* Function called when module is disabled.
* Remove from database constants, boxes and permissions from Dolibarr database.
* Data directories are not deleted
*
* @param string $options Options when enabling module ('', 'noboxes')
* @return int 1 if OK, 0 if KO
*/
public function remove($options = '') {
$sql = array();
return $this->_remove($sql, $options);
}
}

View File

@ -0,0 +1,24 @@
**2.2**
* Fix link to accept or refuse
**2.1**
* Change IT translations
**2.0**
* Add date of agreement
* Add possibility to send e-mail
* Save the agreement by e-mail
**1.2**
* Bug fixed
**1.1**
* Add some translations
* Add some type of company
* Bug fixed
**1.0**
* The end of the beginning

View File

@ -0,0 +1,217 @@
<?php
/* Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file datapolicies/admin/setup.php
* \ingroup datapolicies
* \brief datapolicies setup page.
*/
// Load Dolibarr environment
$res=0;
// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include($_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php");
// Try main.inc.php into web root detected using web root caluclated from SCRIPT_FILENAME
$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1;
while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; }
if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include(substr($tmp, 0, ($i+1))."/main.inc.php");
if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php");
// Try main.inc.php using relative path
if (! $res && file_exists("../../main.inc.php")) $res=@include("../../main.inc.php");
if (! $res && file_exists("../../../main.inc.php")) $res=@include("../../../main.inc.php");
if (! $res) die("Include of main fails");
global $langs, $user;
// Libraries
require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php";
require_once '../lib/datapolicies.lib.php';
//require_once "../class/myclass.class.php";
// Translations
$langs->load('admin');
$langs->load('companies');
$langs->load('members');
$langs->load('datapolicies@datapolicies');
// Access control
if (! $user->admin) accessforbidden();
// Parameters
$action = GETPOST('action', 'alpha');
$backtopage = GETPOST('backtopage', 'alpha');
$arrayofparameters=array(
'DATAPOLICIES_TIERS_CLIENT'=>array('css'=>'minwidth200'),
'DATAPOLICIES_TIERS_PROSPECT'=>array('css'=>'minwidth200'),
'DATAPOLICIES_TIERS_PROSPECT_CLIENT'=>array('css'=>'minwidth200'),
'DATAPOLICIES_TIERS_NIPROSPECT_NICLIENT'=>array('css'=>'minwidth200'),
'DATAPOLICIES_TIERS_FOURNISSEUR'=>array('css'=>'minwidth200'),
'DATAPOLICIES_CONTACT_CLIENT'=>array('css'=>'minwidth200'),
'DATAPOLICIES_CONTACT_PROSPECT'=>array('css'=>'minwidth200'),
'DATAPOLICIES_CONTACT_PROSPECT_CLIENT'=>array('css'=>'minwidth200'),
'DATAPOLICIES_CONTACT_NIPROSPECT_NICLIENT'=>array('css'=>'minwidth200'),
'DATAPOLICIES_CONTACT_FOURNISSEUR'=>array('css'=>'minwidth200'),
'DATAPOLICIES_ADHERENT'=>array('css'=>'minwidth200'),
);
/*
* Actions
*/
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if (DOL_VERSION < '7' && $action == 'update') {
foreach ($arrayofparameters as $k => $v) {
$res = dolibarr_set_const($db,$k,GETPOST($k),'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
}
if (! $error)
{
$db->commit();
if (empty($nomessageinsetmoduleoptions)) setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
else
{
$db->rollback();
if (empty($nomessageinsetmoduleoptions)) setEventMessages($langs->trans("SetupNotSaved"), null, 'errors');
}
}
$arrayofparameters=array(
'ThirdParty' => array(
'DATAPOLICIES_TIERS_CLIENT'=>array('css'=>'minwidth200'),
'DATAPOLICIES_TIERS_PROSPECT'=>array('css'=>'minwidth200'),
'DATAPOLICIES_TIERS_PROSPECT_CLIENT'=>array('css'=>'minwidth200'),
'DATAPOLICIES_TIERS_NIPROSPECT_NICLIENT'=>array('css'=>'minwidth200'),
'DATAPOLICIES_TIERS_FOURNISSEUR'=>array('css'=>'minwidth200'),
),
'Contact' => array(
'DATAPOLICIES_CONTACT_CLIENT'=>array('css'=>'minwidth200'),
'DATAPOLICIES_CONTACT_PROSPECT'=>array('css'=>'minwidth200'),
'DATAPOLICIES_CONTACT_PROSPECT_CLIENT'=>array('css'=>'minwidth200'),
'DATAPOLICIES_CONTACT_NIPROSPECT_NICLIENT'=>array('css'=>'minwidth200'),
'DATAPOLICIES_CONTACT_FOURNISSEUR'=>array('css'=>'minwidth200'),
),
'Member' => array(
'DATAPOLICIES_ADHERENT'=>array('css'=>'minwidth200'),
)
);
$valTab = array(
'' => $langs->trans('None'),
'6' => $langs->trans('NB_MONTHS', 6),
'12' => $langs->trans('ONE_YEAR'),
'24' => $langs->trans('NB_YEARS', 2),
'36' => $langs->trans('NB_YEARS', 3),
'48' => $langs->trans('NB_YEARS', 4),
'60' => $langs->trans('NB_YEARS', 5),
'120' => $langs->trans('NB_YEARS', 10),
);
/*
* View
*/
$page_name = "datapoliciesSetup";
llxHeader('', $langs->trans($page_name));
// Subheader
$linkback = '<a href="'.($backtopage?$backtopage:DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1').'">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans($page_name), $linkback, 'object_datapolicies@datapolicies');
// Configuration header
$head = datapoliciesAdminPrepareHead();
dol_fiche_head($head, 'settings', '', -1, "datapolicies@datapolicies");
// Setup page goes here
echo $langs->trans("datapoliciesSetupPage");
if ($action == 'edit')
{
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="update">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
foreach($arrayofparameters as $title => $tab)
{
print '<tr class="liste_titre"><td class="titlefield" colspan="2">'.$langs->trans($title).'</td></tr>';
foreach($tab as $key => $val)
{
print '<tr class="oddeven"><td>';
print $form->textwithpicto($langs->trans($key),$langs->trans($key.'Tooltip'));
print '</td><td>';
print '<select name="'.$key.'" class="flat '.(empty($val['css'])?'minwidth200':$val['css']).'">';
foreach ($valTab as $key1 => $val1) {
print '<option value="'.$key1.'" ' . ($conf->global->$key == $key1 ? 'selected="selected"' : '') . '>';
print $val1;
print '</option>';
}
print '</select>';
print '</td></tr>';
}
}
print '</table>';
print '<br><div class="center">';
print '<input class="button" type="submit" value="'.$langs->trans("Save").'">';
print '</div>';
print '</form>';
print '<br>';
}
else
{
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
foreach($arrayofparameters as $title => $tab)
{
print '<tr class="liste_titre"><td class="titlefield" colspan="2">'.$langs->trans($title).'</td></tr>';
foreach($tab as $key => $val)
{
print '<tr class="oddeven"><td>';
print $form->textwithpicto($langs->trans($key),$langs->trans('DATAPOLICIES_Tooltip_SETUP'));
print '</td><td>' . ($conf->global->$key == '' ? $langs->trans('None') : $valTab[$conf->global->$key]) . '</td></tr>';
}
}
print '</table>';
print '<div class="tabsAction">';
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit">'.$langs->trans("Modify").'</a>';
print '</div>';
}
// Page end
dol_fiche_end();
llxFooter();
$db->close();

View File

@ -0,0 +1,203 @@
<?php
/* Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file datapolicies/admin/setupmail.php
* \ingroup datapolicies
* \brief datapolicies setup page.
*/
// Load Dolibarr environment
$res = 0;
// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"]))
$res = @include($_SERVER["CONTEXT_DOCUMENT_ROOT"] . "/main.inc.php");
// Try main.inc.php into web root detected using web root caluclated from SCRIPT_FILENAME
$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME'];
$tmp2 = realpath(__FILE__);
$i = strlen($tmp) - 1;
$j = strlen($tmp2) - 1;
while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) {
$i--;
$j--;
}
if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1)) . "/main.inc.php"))
$res = @include(substr($tmp, 0, ($i + 1)) . "/main.inc.php");
if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1))) . "/main.inc.php"))
$res = @include(dirname(substr($tmp, 0, ($i + 1))) . "/main.inc.php");
// Try main.inc.php using relative path
if (!$res && file_exists("../../main.inc.php"))
$res = @include("../../main.inc.php");
if (!$res && file_exists("../../../main.inc.php"))
$res = @include("../../../main.inc.php");
if (!$res)
die("Include of main fails");
global $langs, $user;
// Libraries
require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php";
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formadmin.class.php';
require_once '../lib/datapolicies.lib.php';
//require_once "../class/myclass.class.php";
// Translations
$langs->load('admin');
$langs->load('companies');
$langs->load('members');
$langs->load('datapolicies@datapolicies');
// Parameters
$action = GETPOST('action', 'alpha');
$backtopage = GETPOST('backtopage', 'alpha');
$formadmin = new FormAdmin($db);
if (GETPOST('l')) {
$l = GETPOST('l');
} else {
$l = $langs->defaultlang;
}
// Access control
if (!$user->admin)
accessforbidden();
/*
* Actions
*/
include DOL_DOCUMENT_ROOT . '/core/actions_setmoduleoptions.inc.php';
if ($action == 'setvalue' && $user->admin) {
$db->begin();
$sub = "DATAPOLICIESSUBJECT_" . $l;
$result = dolibarr_set_const($db, $sub, GETPOST($sub), 'chaine', 0, '', $conf->entity);
$cont = "DATAPOLICIESCONTENT_" . $l;
$result = dolibarr_set_const($db, $cont, GETPOST($cont), 'chaine', 0, '', $conf->entity);
$cont = "TXTLINKDATAPOLICIESACCEPT_" . $l;
$result = dolibarr_set_const($db, $cont, GETPOST($cont), 'chaine', 0, '', $conf->entity);
$cont = "TXTLINKDATAPOLICIESREFUSE_" . $l;
$result = dolibarr_set_const($db, $cont, GETPOST($cont), 'chaine', 0, '', $conf->entity);
$sub = "DATAPOLICIESACCEPT_" . $l;
$result = dolibarr_set_const($db, $sub, GETPOST($sub), 'chaine', 0, '', $conf->entity);
$sub = "DATAPOLICIESREFUSE_" . $l;
$result = dolibarr_set_const($db, $sub, GETPOST($sub), 'chaine', 0, '', $conf->entity);
if (!$result > 0)
$error++;
if (!$error) {
$db->commit();
setEventMessage($langs->trans("SetupSaved"));
} else {
$db->rollback();
dol_print_error($db);
}
}
/*
* View
*/
$page_name = "datapoliciesSetup";
llxHeader('', $langs->trans($page_name));
// Subheader
$linkback = '<a href="' . ($backtopage ? $backtopage : DOL_URL_ROOT . '/admin/modules.php?restore_lastsearch_values=1') . '">' . $langs->trans("BackToModuleList") . '</a>';
print load_fiche_titre($langs->trans($page_name), $linkback, 'object_datapolicies@datapolicies');
// Configuration header
$head = datapoliciesAdminPrepareHead();
dol_fiche_head($head, 'settings', '', -1, "datapolicies@datapolicies");
print "<script type='text/javascript'>
$(document).ready(function(){
$('#default_lang').change(function(){
lang=$('#default_lang').val();
window.location.replace('" . $_SERVER['PHP_SELF'] . "?l='+lang);
});
});
</script>";
print '<form method="post" action="' . $_SERVER["PHP_SELF"] . '?l=' . $l . '">';
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<input type="hidden" name="action" value="setvalue">';
print '<table>';
if ($conf->global->MAIN_MULTILANGS) {
print '<tr><td>' . fieldLabel('DefaultLang', 'default_lang') . '</td><td colspan="3" class="maxwidthonsmartphone">' . "\n";
print $formadmin->select_language((GETPOST('l') ? GETPOST('l') : $langs->defaultlang), 'default_lang', 0, 0, 1, 0, 0, 'maxwidth200onsmartphone');
print '</tr>';
}
$subject = 'DATAPOLICIESSUBJECT_' . $l;
$linka = 'TXTLINKDATAPOLICIESACCEPT_' . $l;
$linkr = 'TXTLINKDATAPOLICIESREFUSE_' . $l;
$content = 'DATAPOLICIESCONTENT_' . $l;
$acc = 'DATAPOLICIESACCEPT_' . $l;
$ref = 'DATAPOLICIESREFUSE_' . $l;
print '<tr ' . $bc[$var] . '><td class="fieldrequired">';
print $langs->trans('DATAPOLICIESSUBJECTMAIL') . '</td><td>';
print '<input type="text" size="100" name="' . $subject . '" value="' . $conf->global->$subject . '" />';
print '</td><tr>';
print '<tr ' . $bc[$var] . '><td class="fieldrequired">';
print $langs->trans('DATAPOLICIESCONTENTMAIL').'</td><td>';
print $langs->trans('DATAPOLICIESSUBSITUTION');echo'__LINKACCEPT__,__LINKREFUSED__,__FIRSTNAME__,__NAME__,__CIVILITY__';
$doleditor = new DolEditor($content, $conf->global->$content, '', 250, 'Full', '', false, true, 1, 200, 70);
$doleditor->Create();
print '</td><tr>';
print '<tr ' . $bc[$var] . '><td class="fieldrequired">';
print $langs->trans('TXTLINKDATAPOLICIESACCEPT') . '</td><td>';
print '<input type="text" size="200" name="' . $linka . '" value="' . $conf->global->$linka . '" />';
print '</td><tr>';
print '<tr ' . $bc[$var] . '><td class="fieldrequired">';
print $langs->trans('TXTLINKDATAPOLICIESREFUSE') . '</td><td>';
print '<input type="text" size="200" name="' . $linkr . '" value="' . $conf->global->$linkr . '" />';
print '</td><tr>';
print '<tr ' . $bc[$var] . '><td class="fieldrequired">';
print $langs->trans('DATAPOLICIESACCEPT').'</td><td>';
$doleditor = new DolEditor($acc, $conf->global->$acc, '', 250, 'Full', '', false, true, 1, 200, 70);
$doleditor->Create();
print '</td><tr>';
print '<tr ' . $bc[$var] . '><td class="fieldrequired">';
print $langs->trans('DATAPOLICIESREFUSE').'</td><td>';
print $langs->trans('');
$doleditor = new DolEditor($ref, $conf->global->$ref, '', 250, 'Full', '', false, true, 1, 200, 70);
$doleditor->Create();
print '</td><tr>';
print '</table>';
print '<br><center><input type="submit" class="button" value="' . $langs->trans("Modify") . '"></center>';
print '</form>';
dol_fiche_end();
print '<br><br>';
print $langs->trans('SendAgreementText');
print '<a class="button" href="'.dol_buildpath('/datapolicies/mailing.php').'">'.$langs->trans('SendAgreement').'</a>';
llxFooter();
$db->close();

View File

@ -0,0 +1,450 @@
<?php
/* Copyright (C) 2018 SuperAdmin
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file datapolicies/class/actions_datapolicies.class.php
* \ingroup datapolicies
* \brief Example hook overload.
*
* Put detailed description here.
*/
/**
* Class Actionsdatapolicies
*/
class Actionsdatapolicies {
/**
* @var DoliDB Database handler.
*/
public $db;
/**
* @var string Error
*/
public $error = '';
/**
* @var array Errors
*/
public $errors = array();
/**
* @var array Hook results. Propagated to $hookmanager->resArray for later reuse
*/
public $results = array();
/**
* @var string String displayed by executeHook() immediately after return
*/
public $resprints;
/**
* Constructor
*
* @param DoliDB $db Database handler
*/
public function __construct($db) {
$this->db = $db;
}
/**
* Execute action
*
* @param array $parameters Array of parameters
* @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...)
* @param string $action 'add', 'update', 'view'
* @return int <0 if KO,
* =0 if OK but we want to process standard actions too,
* >0 if OK and we want to replace standard actions.
*/
function getNomUrl($parameters, &$object, &$action) {
global $db, $langs, $conf, $user;
$this->resprints = '';
return 0;
}
/**
* Overloading the doActions function : replacing the parent's function with the one below
*
* @param array $parameters Hook metadatas (context, etc...)
* @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...)
* @param string $action Current action (if set). Generally create or edit or null
* @param HookManager $hookmanager Hook manager propagated to allow calling another hook
* @return int < 0 on error, 0 on success, 1 to replace standard code
*/
public function doActions($parameters, &$object, &$action, $hookmanager) {
global $conf, $user, $langs;
$langs->load('datapolicies@datapolicies');
$error = 0; // Error counter
if (GETPOST('socid') && $parameters['currentcontext'] == 'thirdpartycard') {
$object->fetch(GETPOST('socid'));
}
if ($parameters['currentcontext'] == 'thirdpartycard' && $action == 'anonymiser' && ($object->forme_juridique_code == 11 || $object->forme_juridique_code == 12 || $object->forme_juridique_code == 13 || $object->forme_juridique_code == 15 || $object->forme_juridique_code == 17 || $object->forme_juridique_code == 18 || $object->forme_juridique_code == 19 || $object->forme_juridique_code == 35 || $object->forme_juridique_code == 60 || $object->forme_juridique_code == 200 || $object->forme_juridique_code == 311 || $object->forme_juridique_code == 312 || $object->forme_juridique_code == 316 || $object->forme_juridique_code == 401 || $object->forme_juridique_code == 600 || $object->forme_juridique_code == 700 || $object->forme_juridique_code == 1005 || $object->typent_id == 8)) {
// on verifie si l'objet est utilisé
if ($object->isObjectUsed(GETPOST('socid'))) {
$object->name = $langs->trans('ANONYME');
$object->name_bis = '';
$object->name_alias = '';
$object->address = '';
$object->town = '';
$object->zip = '';
$object->phone = '';
$object->email = '';
$object->url = '';
$object->fax = '';
$object->state = '';
$object->country = '';
$object->state_id = '';
$object->skype = '';
$object->country_id = '';
$object->note_private = $object->note_private . '<br/>' . $langs->trans('ANONYMISER_AT', dol_print_date(time()));
if ($object->update($object->id, $user, 0)) {
// On supprime les contacts associé
$sql = "DELETE FROM " . MAIN_DB_PREFIX . "socpeople WHERE fk_soc = " . $object->id;
$this->db->query($sql);
setEventMessages($langs->trans('ANONYMISER_SUCCESS'), array());
header('Location:' . $_SERVER["PHP_SELF"] . "?socid=" . $object->id);
}
}
} elseif ($parameters['currentcontext'] == 'thirdpartycard' && $action == 'datapolicies_portabilite') {
header('Content-Type: application/csv');
header('Content-Disposition: attachment; filename=datapolicies_portabilite.csv');
header('Pragma: no-cache');
$object->fetch(GETPOST('socid'));
echo 'Nom;Prénom;Civilite;Tiers;Poste/Fonction;Adresse;CP;Ville;Département;Pays;Email;Tel Pro;Tel Perso;Tel Portable;Messagerie instantanée;Date de naissance;' . PHP_EOL;
echo $object->name . ';';
echo ';';
echo ';';
echo ';';
echo ';';
echo $object->address . ';';
echo $object->zip . ';';
echo $object->town . ';';
echo $object->state . ';';
echo $object->country . ';';
echo $object->email . ';';
echo $object->phone . ';';
echo ';';
echo ';';
echo $object->skype . ';';
echo ';';
exit;
} elseif ($parameters['currentcontext'] == 'membercard' && $action == 'datapolicies_portabilite') {
header('Content-Type: application/csv');
header('Content-Disposition: attachment; filename=datapolicies_portabilite.csv');
header('Pragma: no-cache');
$soc = $object->fetch_thirdparty();
echo 'Nom;Prénom;Civilite;Tiers;Poste/Fonction;Adresse;CP;Ville;Département;Pays;Email;Tel Pro;Tel Perso;Tel Portable;Messagerie instantanée;Date de naissance;' . PHP_EOL;
echo $object->lastname . ';';
echo $object->firstname . ';';
echo $object->getCivilityLabel() . ';';
echo ($soc != -1 ? $object->thirdparty->name : '') . ';';
echo ';';
echo $object->address . ';';
echo $object->zip . ';';
echo $object->town . ';';
echo $object->state . ';';
echo $object->country . ';';
echo $object->email . ';';
echo $object->phone . ';';
echo $object->phone_perso . ';';
echo $object->phone_mobile . ';';
echo $object->skype . ';';
echo dol_print_date($object->birth) . ';';
exit;
} elseif ($parameters['currentcontext'] == 'contactcard' && $action == 'datapolicies_portabilite') {
$object->fetch(GETPOST('id'));
header('Content-Type: application/csv');
header('Content-Disposition: attachment; filename=datapolicies_portabilite.csv');
header('Pragma: no-cache');
$soc = $object->fetch_thirdparty();
echo 'Nom;Prénom;Civilite;Tiers;Poste/Fonction;Adresse;CP;Ville;Département;Pays;Email;Tel Pro;Tel Perso;Tel Portable;Messagerie instantanée;Date de naissance;' . PHP_EOL;
echo $object->lastname . ';';
echo $object->firstname . ';';
echo $object->getCivilityLabel() . ';';
echo ($soc != -1 ? $object->thirdparty->name : '') . ';';
echo $object->poste . ';';
echo $object->address . ';';
echo $object->zip . ';';
echo $object->town . ';';
echo $object->state . ';';
echo $object->country . ';';
echo $object->email . ';';
echo $object->phone_pro . ';';
echo $object->phone_perso . ';';
echo $object->phone_mobile . ';';
echo $object->jabberid . ';';
echo dol_print_date($object->birth) . ';';
exit;
} elseif ($parameters['currentcontext'] == 'contactcard' && $action == 'send_datapolicies') {
$object->fetch(GETPOST('id'));
dol_include_once('/contact/class/contact.class.php');
dol_include_once('/datapolicies/class/datapolicies.class.php');
DataPolicies::sendMailDataPoliciesContact($object);
}
elseif ($parameters['currentcontext'] == 'membercard' && $action == 'send_datapolicies') {
$object->fetch(GETPOST('id'));
dol_include_once('/adherents/class/adherent.class.php');
dol_include_once('/datapolicies/class/datapolicies.class.php');
DataPolicies::sendMailDataPoliciesAdherent($object);
} elseif ($parameters['currentcontext'] == 'thirdpartycard' && $action == 'send_datapolicies') {
$object->fetch(GETPOST('socid'));
dol_include_once('/societe/class/societe.class.php');
dol_include_once('/datapolicies/class/datapolicies.class.php');
DataPolicies::sendMailDataPoliciesCompany($object);
}
if (!$error) {
$this->results = array('myreturn' => 999);
$this->resprints = 'A text to show';
return 0; // or return 1 to replace standard code
} else {
$this->errors[] = 'Error message';
return -1;
}
}
/**
* Overloading the doActions function : replacing the parent's function with the one below
*
* @param array $parameters Hook metadatas (context, etc...)
* @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...)
* @param string $action Current action (if set). Generally create or edit or null
* @param HookManager $hookmanager Hook manager propagated to allow calling another hook
* @return int < 0 on error, 0 on success, 1 to replace standard code
*/
public function doMassActions($parameters, &$object, &$action, $hookmanager) {
global $conf, $user, $langs;
$error = 0; // Error counter
/* print_r($parameters); print_r($object); echo "action: " . $action; */
if (in_array($parameters['currentcontext'], array('somecontext1', 'somecontext2'))) { // do something only for the context 'somecontext1' or 'somecontext2'
foreach ($parameters['toselect'] as $objectid) {
// Do action on each object id
}
}
if (!$error) {
$this->results = array('myreturn' => 999);
$this->resprints = 'A text to show';
return 0; // or return 1 to replace standard code
} else {
$this->errors[] = 'Error message';
return -1;
}
}
/**
* Overloading the addMoreMassActions function : replacing the parent's function with the one below
*
* @param array $parameters Hook metadatas (context, etc...)
* @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...)
* @param string $action Current action (if set). Generally create or edit or null
* @param HookManager $hookmanager Hook manager propagated to allow calling another hook
* @return int < 0 on error, 0 on success, 1 to replace standard code
*/
public function addMoreMassActions($parameters, &$object, &$action, $hookmanager) {
global $conf, $user, $langs;
$error = 0; // Error counter
/* print_r($parameters); print_r($object); echo "action: " . $action; */
if (in_array($parameters['currentcontext'], array('somecontext1', 'somecontext2'))) { // do something only for the context 'somecontext1' or 'somecontext2'
$this->resprints = '<option value="0"' . ($disabled ? ' disabled="disabled"' : '') . '>' . $langs->trans("datapoliciesMassAction") . '</option>';
}
if (!$error) {
return 0; // or return 1 to replace standard code
} else {
$this->errors[] = 'Error message';
return -1;
}
}
/**
* Execute action
*
* @param array $parameters Array of parameters
* @param Object $object Object output on PDF
* @param string $action 'add', 'update', 'view'
* @return int <0 if KO,
* =0 if OK but we want to process standard actions too,
* >0 if OK and we want to replace standard actions.
*/
function beforePDFCreation($parameters, &$object, &$action) {
global $conf, $user, $langs;
global $hookmanager;
$outputlangs = $langs;
$ret = 0;
$deltemp = array();
dol_syslog(get_class($this) . '::executeHooks action=' . $action);
/* print_r($parameters); print_r($object); echo "action: " . $action; */
if (in_array($parameters['currentcontext'], array('somecontext1', 'somecontext2'))) { // do something only for the context 'somecontext1' or 'somecontext2'
}
return $ret;
}
/**
* Execute action
*
* @param array $parameters Array of parameters
* @param Object $pdfhandler PDF builder handler
* @param string $action 'add', 'update', 'view'
* @return int <0 if KO,
* =0 if OK but we want to process standard actions too,
* >0 if OK and we want to replace standard actions.
*/
function afterPDFCreation($parameters, &$pdfhandler, &$action) {
global $conf, $user, $langs;
global $hookmanager;
$outputlangs = $langs;
$ret = 0;
$deltemp = array();
dol_syslog(get_class($this) . '::executeHooks action=' . $action);
/* print_r($parameters); print_r($object); echo "action: " . $action; */
if (in_array($parameters['currentcontext'], array('somecontext1', 'somecontext2'))) { // do something only for the context 'somecontext1' or 'somecontext2'
}
return $ret;
}
function addMoreActionsButtons($parameters, &$object, &$action, $hookmanager) {
global $conf, $user, $langs;
$langs->load('datapolicies@datapolicies');
$dialog = '<div id="dialogdatapolicies" style="display:none;" title="' . $langs->trans('DATAPOLICIES_PORTABILITE_TITLE') . '">';
$dialog .= '<div class="confirmmessage">' . img_help('', '') . ' ' . $langs->trans('DATAPOLICIES_PORTABILITE_CONFIRMATION') . '</div>';
$dialog .= "</div>";
$dialog .= '<script>
$( function() {
$("#rpgpdbtn").on("click", function(){
var href = $(this).attr("href");
$( "#dialogdatapolicies" ).dialog({
modal: true,
buttons: {
"OK": function() {
window.open(href);
$( this ).dialog( "close" );
},
"' . $langs->trans('Cancel') . '": function() {
$( this ).dialog( "close" );
}
}
});
return false;
});
} );
</script>';
echo $dialog;
if ($parameters['currentcontext'] == 'thirdpartycard' && $object->forme_juridique_code == 11 || $object->forme_juridique_code == 12 || $object->forme_juridique_code == 13 || $object->forme_juridique_code == 15 || $object->forme_juridique_code == 17 || $object->forme_juridique_code == 18 || $object->forme_juridique_code == 19 || $object->forme_juridique_code == 35 || $object->forme_juridique_code == 60 || $object->forme_juridique_code == 200 || $object->forme_juridique_code == 311 || $object->forme_juridique_code == 312 || $object->forme_juridique_code == 316 || $object->forme_juridique_code == 401 || $object->forme_juridique_code == 600 || $object->forme_juridique_code == 700 || $object->forme_juridique_code == 1005 || $object->typent_id == 8) {
echo '<div class="inline-block divButAction"><a target="_blank" id="rpgpdbtn" class="butAction" href="' . $_SERVER["PHP_SELF"] . "?socid=" . $object->id . '&action=datapolicies_portabilite" title="' . $langs->trans('DATAPOLICIES_PORTABILITE_TITLE') . '">' . $langs->trans("DATAPOLICIES_PORTABILITE") . '</a></div>';
} elseif ($parameters['currentcontext'] == 'membercard') {
echo '<div class="inline-block divButAction"><a target="_blank" id="rpgpdbtn" class="butAction" href="' . $_SERVER["PHP_SELF"] . "?rowid=" . $object->id . '&action=datapolicies_portabilite" title="' . $langs->trans('DATAPOLICIES_PORTABILITE_TITLE') . '">' . $langs->trans("DATAPOLICIES_PORTABILITE") . '</a></div>';
} elseif ($parameters['currentcontext'] == 'contactcard') {
echo '<div class="inline-block divButAction"><a target="_blank" id="rpgpdbtn" class="butAction" href="' . $_SERVER["PHP_SELF"] . "?id=" . $object->id . '&action=datapolicies_portabilite" title="' . $langs->trans('DATAPOLICIES_PORTABILITE_TITLE') . '">' . $langs->trans("DATAPOLICIES_PORTABILITE") . '</a></div>';
}
if (!empty($object->mail) && empty($object->array_options['options_datapolicies_send']) && $parameters['currentcontext'] == 'thirdpartycard' && $object->forme_juridique_code == 11 || $object->forme_juridique_code == 12 || $object->forme_juridique_code == 13 || $object->forme_juridique_code == 15 || $object->forme_juridique_code == 17 || $object->forme_juridique_code == 18 || $object->forme_juridique_code == 19 || $object->forme_juridique_code == 35 || $object->forme_juridique_code == 60 || $object->forme_juridique_code == 200 || $object->forme_juridique_code == 311 || $object->forme_juridique_code == 312 || $object->forme_juridique_code == 316 || $object->forme_juridique_code == 401 || $object->forme_juridique_code == 600 || $object->forme_juridique_code == 700 || $object->forme_juridique_code == 1005 || $object->typent_id == 8) {
echo '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . "?socid=" . $object->id . '&action=send_datapolicies" title="' . $langs->trans('DATAPOLICIES_SEND') . '">' . $langs->trans("DATAPOLICIES_SEND") . '</a></div>';
} elseif (!empty($object->mail) && empty($object->array_options['options_datapolicies_send']) && $parameters['currentcontext'] == 'membercard') {
echo '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . "?rowid=" . $object->id . '&action=send_datapolicies" title="' . $langs->trans('DATAPOLICIES_SEND') . '">' . $langs->trans("DATAPOLICIES_SEND") . '</a></div>';
} elseif (!empty($object->mail) && empty($object->array_options['options_datapolicies_send']) && $parameters['currentcontext'] == 'contactcard') {
echo '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . "?id=" . $object->id . '&action=send_datapolicies" title="' . $langs->trans('DATAPOLICIES_SEND') . '">' . $langs->trans("DATAPOLICIES_SEND") . '</a></div>';
}
}
function printCommonFooter($parameters, &$object, &$action, $hookmanager) {
global $conf, $user, $langs;
$jsscript = '';
if ($parameters['currentcontext'] == 'thirdpartycard') {
if (GETPOST('action') == 'create' || GETPOST('action') == 'edit' || GETPOST('action') == '') {
$jsscript .= '<script>';
$jsscript .= "var elementToHide = 'tr.societe_extras_datapolicies_consentement, tr.societe_extras_datapolicies_opposition_traitement, tr.societe_extras_datapolicies_opposition_prospection';" . PHP_EOL;
$jsscript .= "var forme_juridique = [" . PHP_EOL;
$jsscript .= "11, 12, 13, 15, 17, 18, 19, 35, 60, 200, 311, 312, 316, 401, 600, 700, 1005" . PHP_EOL;
$jsscript .= "];" . PHP_EOL;
$jsscript .= "function hideRgPD() { if ($('#typent_id').val() == 8 || forme_juridique.indexOf(parseInt($('#forme_juridique_code').val())) > -1) { console.log(elementToHide); $('tr.societe_extras_datapolicies_consentement, tr.societe_extras_datapolicies_opposition_traitement, tr.societe_extras_datapolicies_opposition_prospection').show(); } else { $('tr.societe_extras_datapolicies_consentement, tr.societe_extras_datapolicies_opposition_traitement, tr.societe_extras_datapolicies_opposition_prospection').hide(); }}" . PHP_EOL;
$jsscript .= "hideRgPD();" . PHP_EOL;
$jsscript .= "$('#forme_juridique_code, #typent_id').change(function(){ hideRgPD(); });" . PHP_EOL;
$jsscript .= '</script>';
} elseif (GETPOST('action') == 'confirm_delete' && GETPOST('confirm') == 'yes' && GETPOST('socid') > 0) {
// La suppression n'a pas été possible
require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
$societe = new Societe($this->db);
$societe->fetch(GETPOST('socid'));
// On vérifie si il est utilisé
if (($societe->forme_juridique_code == 11 || $societe->forme_juridique_code == 12 || $societe->forme_juridique_code == 13 || $societe->forme_juridique_code == 15 || $societe->forme_juridique_code == 17 || $societe->forme_juridique_code == 18 || $societe->forme_juridique_code == 19 || $societe->forme_juridique_code == 35 || $societe->forme_juridique_code == 60 || $societe->forme_juridique_code == 200 || $societe->forme_juridique_code == 311 || $societe->forme_juridique_code == 312 || $societe->forme_juridique_code == 316 || $societe->forme_juridique_code == 401 || $societe->forme_juridique_code == 600 || $societe->forme_juridique_code == 700 || $societe->forme_juridique_code == 1005 || $societe->typent_id == 8) && $societe->isObjectUsed(GETPOST('socid'))) {
require_once DOL_DOCUMENT_ROOT . '/core/class/html.form.class.php';
$form = new Form($this->db);
echo $form->formconfirm($_SERVER["PHP_SELF"] . "?socid=" . GETPOST('socid'), substr($langs->trans("DATAPOLICIES_POPUP_ANONYME_TITLE"), 0, strlen($langs->trans("DATAPOLICIES_POPUP_ANONYME_TITLE")) - 2), $langs->trans("DATAPOLICIES_POPUP_ANONYME_TEXTE"), 'anonymiser', '', '', 1);
}
}
if (GETPOST('socid')) {
require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
$societe = new Societe($this->db);
$societe->fetch(GETPOST('socid'));
if ($societe->forme_juridique_code != 11 && $societe->forme_juridique_code != 12 && $societe->forme_juridique_code != 13 && $societe->forme_juridique_code != 15 && $societe->forme_juridique_code != 17 && $societe->forme_juridique_code != 18 && $societe->forme_juridique_code != 19 && $societe->forme_juridique_code != 35 && $societe->forme_juridique_code != 60 && $societe->forme_juridique_code != 200 && $societe->forme_juridique_code != 311 && $societe->forme_juridique_code != 312 && $societe->forme_juridique_code != 316 && $societe->forme_juridique_code != 401 && $societe->forme_juridique_code != 600 && $societe->forme_juridique_code != 700 && $societe->forme_juridique_code != 1005 && $societe->typent_id != 8) {
require_once DOL_DOCUMENT_ROOT . '/core/class/html.form.class.php';
$jsscript .= '<script>';
$jsscript .= "var elementToHide = 'td.societe_extras_datapolicies_opposition_traitement, td.societe_extras_datapolicies_opposition_prospection, td.societe_extras_datapolicies_consentement';" . PHP_EOL;
$jsscript .= "$(elementToHide).parent('tr').hide();" . PHP_EOL;
$jsscript .= '</script>';
}
}
} elseif ($parameters['currentcontext'] == 'contactcard') {
if (GETPOST('action') == 'create' || GETPOST('action') == 'edit') {
$jsscript .= '<script>';
$jsscript .= "$('#options_datapolicies_opposition_traitement, #options_datapolicies_opposition_prospection, input[name=\"options_datapolicies_opposition_traitement\"], input[name=\"options_datapolicies_opposition_prospection\"]').change(function(){
if($('#options_datapolicies_opposition_traitement').prop('checked') == true || $('input[name=options_datapolicies_opposition_traitement]').prop('checked') || $('#options_datapolicies_opposition_prospection').prop('checked') || $('input[name=options_datapolicies_opposition_prospection]').prop('checked')) {
$('#no_email').val(1);
}
});";
$jsscript .= '</script>';
}
}
echo $jsscript;
}
}

View File

@ -0,0 +1,320 @@
<?php
/* Copyright (C) 2018 SuperAdmin
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file datapolicies/class/actions_datapolicies.class.php
* \ingroup datapolicies
* \brief Example hook overload.
*
* Put detailed description here.
*/
include_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php';
include_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
include_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php';
/**
* Class datapolicies
*/
Class DataPolicies extends Contact {
function getAllContactNotInformed() {
global $langs, $conf, $db, $user;
$langs->load("companies");
$sql = "SELECT c.rowid";
$sql .= " FROM " . MAIN_DB_PREFIX . "socpeople as c";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as s ON c.fk_soc = s.rowid";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "socpeople_extrafields as spe ON spe.fk_object = c.rowid";
$sql .= " WHERE (c.statut=1 AND c.no_email=0 AND (spe.datapolicies_consentement=0 OR spe.datapolicies_consentement IS NULL) AND (spe.datapolicies_opposition_traitement=0 OR spe.datapolicies_opposition_traitement IS NULL) AND (spe.datapolicies_opposition_prospection=0 OR spe.datapolicies_opposition_prospection IS NULL))";
$sql .= " AND spe.datapolicies_send IS NULL";
$sql .= " AND c.entity=" . $conf->entity;
$resql = $this->db->query($sql);
if ($resql) {
$num = $this->db->num_rows($resql);
$i = 0;
while ($i < $num) {
$obj = $this->db->fetch_object($resql);
//echo "<pre>".print_r($obj,1)."</pre>";
$contact = new Contact($db);
$contact->fetch($obj->rowid);
DataPolicies::sendMailDataPoliciesContact($contact);
$i++;
}
} else {
$this->error = $this->db->error();
return -1;
}
}
function getAllCompaniesNotInformed() {
global $langs, $conf, $db, $user;
$langs->load("companies");
$sql = "SELECT s.rowid";
$sql .= " FROM " . MAIN_DB_PREFIX . "societe as s";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_extrafields as se ON se.fk_object = s.rowid";
$sql .= " WHERE s.statut=0 AND (se.datapolicies_consentement=0 OR se.datapolicies_consentement IS NULL) AND (se.datapolicies_opposition_traitement=0 OR se.datapolicies_opposition_traitement IS NULL) AND (se.datapolicies_opposition_prospection=0 OR se.datapolicies_opposition_prospection IS NULL)";
$sql .= " AND se.datapolicies_send IS NULL";
$sql .= " AND s.entity=" . $conf->entity;
$resql = $this->db->query($sql);
if ($resql) {
$num = $this->db->num_rows($resql);
$i = 0;
while ($i < $num) {
$obj = $this->db->fetch_object($resql);
//echo "<pre>".print_r($obj,1)."</pre>";
$societe = new Societe($db);
$societe->fetch($obj->rowid);
DataPolicies::sendMailDataPoliciesCompany($societe);
$i++;
}
} else {
$this->error = $this->db->error();
return -1;
}
}
function getAllAdherentsNotInformed() {
global $langs, $conf, $db, $user;
$langs->load("adherent");
$sql = "SELECT a.rowid";
$sql .= " FROM " . MAIN_DB_PREFIX . "adherent as a";
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "adherent_extrafields as ae ON ae.fk_object = a.rowid";
$sql .= " WHERE a.statut=0 AND (ae.datapolicies_consentement=0 OR ae.datapolicies_consentement IS NULL) AND (ae.datapolicies_opposition_traitement=0 OR ae.datapolicies_opposition_traitement IS NULL) AND (ae.datapolicies_opposition_prospection=0 OR ae.datapolicies_opposition_prospection IS NULL)";
$sql .= " AND ae.datapolicies_send IS NULL";
$sql .= " AND a.entity=" . $conf->entity;
$resql = $this->db->query($sql);
if ($resql) {
$num = $this->db->num_rows($resql);
$i = 0;
while ($i < $num) {
$obj = $this->db->fetch_object($resql);
//echo "<pre>".print_r($obj,1)."</pre>";
$adherent = new Adherent($db);
$adherent->fetch($obj->rowid);
DataPolicies::sendMailDataPoliciesAdherent($adherent);
$i++;
}
} else {
$this->error = $this->db->error();
return -1;
}
}
function sendMailDataPoliciesContact($contact) {
global $langs, $conf, $db, $user;
$from = $user->getFullName($langs) . ' <' . $user->email . '>';
$replyto = $from;
$sendto = $contact->email;
//echo "<pre>".print_r($contact,1)."</pre>";
$code= md5($contact->email);
if (!empty($contact->default_lang)) {
$l = $contact->default_lang;
} else {
$l = $langs->defaultlang;
}
$s = "DATAPOLICIESSUBJECT_" . $l;
$ma = "DATAPOLICIESCONTENT_" . $l;
$la = 'TXTLINKDATAPOLICIESACCEPT_' . $l;
$lr = 'TXTLINKDATAPOLICIESREFUSE_' . $l;
$subject = $conf->global->$s;
$message = $conf->global->$ma;
$linka = $conf->global->$la;
$linkr = $conf->global->$lr;
$substitutionarray = array(
'__LINKACCEPT__' => '<a href="'.dol_buildpath('/datapolicies/public/index.php?action=1&c='.$contact->id.'&l='.$l.'&key='.$code,3).'" target="_blank">'.$linka.'</a>',
'__LINKREFUSED__' => '<a href="'.dol_buildpath('/datapolicies/public/index.php?action=2&c='.$contact->id.'&l='.$l.'&key='.$code,3).'" target="_blank">'.$linkr.'</a>',
'__FIRSTNAME__' => $contact->firstname,
'__NAME__' => $contact->lastname,
'__CIVILITY__' => $contact->civility,
);
$subject = make_substitutions($subject, $substitutionarray);
$message = make_substitutions($message, $substitutionarray);
$actiontypecode = 'AC_EMAIL';
$actionmsg = $langs->transnoentities('MailSentBy') . ' ' . $from . ' ' . $langs->transnoentities('To') . ' ' . $sendto;
if ($message) {
if ($sendtocc)
$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . $sendtocc);
$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject);
$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":");
$actionmsg = dol_concatdesc($actionmsg, $message);
}
// Send mail
require_once(DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php');
$mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1);
if ($mailfile->error) {
$resultmasssend .= '<div class="error">' . $mailfile->error . '</div>';
} else {
$result4 = $mailfile->sendfile();
if (!$error) {
$resultmasssend .= $langs->trans("MailSent") . ': ' . $sendto . "<br>";
$contact->array_options['options_datapolicies_send'] = date('Y-m-d', time());
$contact->update($contact->id);
} else {
dol_print_error($db);
}
}
setEventMessage($resultmasssend);
}
function sendMailDataPoliciesCompany($societe) {
global $langs, $conf, $db, $user;
$from = $user->getFullName($langs) . ' <' . $user->email . '>';
$replyto = $from;
$sendto = $societe->email;
$code= md5($societe->email);
if (!empty($societe->default_lang)) {
$l = $societe->default_lang;
} else {
$l = $langs->defaultlang;
}
$s = "DATAPOLICIESSUBJECT_" . $l;
$ma = "DATAPOLICIESCONTENT_" . $l;
$la = 'TXTLINKDATAPOLICIESACCEPT_' . $l;
$lr = 'TXTLINKDATAPOLICIESREFUSE_' . $l;
$subject = $conf->global->$s;
$message = $conf->global->$ma;
$linka = $conf->global->$la;
$linkr = $conf->global->$lr;
$substitutionarray = array(
'__LINKACCEPT__' => '<a href="'.dol_buildpath('/datapolicies/public/index.php?action=1&c='.$societe->id.'&l='.$l.'&key='.$code,3).'" target="_blank">'.$linka.'</a>',
'__LINKREFUSED__' => '<a href="'.dol_buildpath('/datapolicies/public/index.php?action=2&c='.$societe->id.'&l='.$l.'&key='.$code,3).'" target="_blank">'.$linkr.'</a>',
);
$subject = make_substitutions($subject, $substitutionarray);
$message = make_substitutions($message, $substitutionarray);
$actiontypecode = 'AC_EMAIL';
$actionmsg = $langs->transnoentities('MailSentBy') . ' ' . $from . ' ' . $langs->transnoentities('To') . ' ' . $sendto;
if ($message) {
if ($sendtocc)
$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . $sendtocc);
$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject);
$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":");
$actionmsg = dol_concatdesc($actionmsg, $message);
}
// Send mail
require_once(DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php');
$mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1);
if ($mailfile->error) {
$resultmasssend .= '<div class="error">' . $mailfile->error . '</div>';
} else {
$result4 = $mailfile->sendfile();
if (!$error) {
$resultmasssend .= $langs->trans("MailSent") . ': ' . $sendto . "<br>";
$societe->array_options['options_datapolicies_send'] = date('Y-m-d', time());
$societe->update($societe->id);
} else {
dol_print_error($db);
}
}
setEventMessage($resultmasssend);
}
function sendMailDataPoliciesAdherent($adherent) {
global $langs, $conf, $db, $user;
$from = $user->getFullName($langs) . ' <' . $user->email . '>';
$replyto = $from;
$sendto = $adherent->email;
$code= md5($adherent->email);
if (!empty($adherent->default_lang)) {
$l = $adherent->default_lang;
} else {
$l = $langs->defaultlang;
}
$la = 'TXTLINKDATAPOLICIESACCEPT_' . $l;
$lr = 'TXTLINKDATAPOLICIESREFUSE_' . $l;
$subject = $conf->global->$s;
$message = $conf->global->$ma;
$linka = $conf->global->$la;
$linkr = $conf->global->$lr;
$substitutionarray = array(
'__LINKACCEPT__' => '<a href="'.dol_buildpath('/datapolicies/public/index.php?action=1&c='.$adherent->id.'&l='.$l.'&key='.$code,3).'" target="_blank">'.$linka.'</a>',
'__LINKREFUSED__' => '<a href="'.dol_buildpath('/datapolicies/public/index.php?action=2&c='.$adherent->id.'&l='.$l.'&key='.$code,3).'" target="_blank">'.$linkr.'</a>',
);
$subject = make_substitutions($subject, $substitutionarray);
$message = make_substitutions($message, $substitutionarray);
$actiontypecode = 'AC_EMAIL';
$actionmsg = $langs->transnoentities('MailSentBy') . ' ' . $from . ' ' . $langs->transnoentities('To') . ' ' . $sendto;
if ($message) {
if ($sendtocc)
$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . $sendtocc);
$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject);
$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":");
$actionmsg = dol_concatdesc($actionmsg, $message);
}
// Send mail
require_once(DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php');
$mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1);
if ($mailfile->error) {
$resultmasssend .= '<div class="error">' . $mailfile->error . '</div>';
} else {
$result4 = $mailfile->sendfile();
if (!$error) {
$resultmasssend .= $langs->trans("MailSent") . ': ' . $sendto . "<br>";
$adherent->array_options['options_datapolicies_send'] = date('Y-m-d', time());
$adherent->update($user);
} else {
dol_print_error($db);
}
}
setEventMessage($resultmasssend);
}
}

View File

@ -0,0 +1,487 @@
<?php
class datapoliciesCron {
public function exec() {
global $conf, $db, $langs, $user;
$langs->load('datapolicies@datapolicies');
$arrayofparameters=array(
'DATAPOLICIES_TIERS_CLIENT' => array(
'sql' => "
SELECT s.rowid FROM ".MAIN_DB_PREFIX."societe as s
WHERE (s.fk_forme_juridique = 19 OR s.fk_forme_juridique = 11 OR s.fk_forme_juridique = 12 OR s.fk_forme_juridique = 13 OR s.fk_forme_juridique = 15 OR s.fk_forme_juridique = 17 OR s.fk_forme_juridique = 18 OR s.fk_forme_juridique = 35 OR s.fk_forme_juridique = 60 OR s.fk_forme_juridique = 312 OR s.fk_forme_juridique = 316 OR s.fk_forme_juridique = 401 OR s.fk_forme_juridique = 600 OR s.fk_forme_juridique = 700 OR s.fk_forme_juridique = 1005 OR s.fk_typent = 8)
AND s.entity = %d
AND s.client = 1
AND s.fournisseur = 0
AND s.tms < DATE_SUB(NOW(), INTERVAL %d MONTH)
AND s.rowid NOT IN (
SELECT DISTINCT a.fk_soc
FROM ".MAIN_DB_PREFIX."actioncomm as a
WHERE a.tms > DATE_SUB(NOW(), INTERVAL %d MONTH)
AND a.fk_soc IS NOT NULL
)
",
"class" => "Societe",
"file" => DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php',
'fields_anonym' => array(
'name' => $langs->trans('ANONYME'),
'name_bis' => '',
'name_alias' => '',
'address' => '',
'town' => '',
'zip' => '',
'phone' => '',
'email' => '',
'url' => '',
'fax' => '',
'state' => '',
'country' => '',
'state_id' => '',
'skype' => '',
'country_id' => '',
)
),
'DATAPOLICIES_TIERS_PROSPECT' => array(
'sql' => "
SELECT s.rowid FROM ".MAIN_DB_PREFIX."societe as s
WHERE (s.fk_forme_juridique = 19 OR s.fk_forme_juridique = 11 OR s.fk_forme_juridique = 12 OR s.fk_forme_juridique = 13 OR s.fk_forme_juridique = 15 OR s.fk_forme_juridique = 17 OR s.fk_forme_juridique = 18 OR s.fk_forme_juridique = 35 OR s.fk_forme_juridique = 60 OR s.fk_forme_juridique = 312 OR s.fk_forme_juridique = 316 OR s.fk_forme_juridique = 401 OR s.fk_forme_juridique = 600 OR s.fk_forme_juridique = 700 OR s.fk_forme_juridique = 1005 OR s.fk_typent = 8)
AND s.entity = %d
AND s.client = 2
AND s.fournisseur = 0
AND s.tms < DATE_SUB(NOW(), INTERVAL %d MONTH)
AND s.rowid NOT IN (
SELECT DISTINCT a.fk_soc
FROM ".MAIN_DB_PREFIX."actioncomm as a
WHERE a.tms > DATE_SUB(NOW(), INTERVAL %d MONTH)
AND a.fk_soc IS NOT NULL
)
",
"class" => "Societe",
"file" => DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php',
'fields_anonym' => array(
'name' => $langs->trans('ANONYME'),
'name_bis' => '',
'name_alias' => '',
'address' => '',
'town' => '',
'zip' => '',
'phone' => '',
'email' => '',
'url' => '',
'fax' => '',
'state' => '',
'country' => '',
'state_id' => '',
'skype' => '',
'country_id' => '',
)
),
'DATAPOLICIES_TIERS_PROSPECT_CLIENT' => array(
'sql' => "
SELECT s.rowid FROM ".MAIN_DB_PREFIX."societe as s
WHERE (s.fk_forme_juridique = 19 OR s.fk_forme_juridique = 11 OR s.fk_forme_juridique = 12 OR s.fk_forme_juridique = 13 OR s.fk_forme_juridique = 15 OR s.fk_forme_juridique = 17 OR s.fk_forme_juridique = 18 OR s.fk_forme_juridique = 35 OR s.fk_forme_juridique = 60 OR s.fk_forme_juridique = 312 OR s.fk_forme_juridique = 316 OR s.fk_forme_juridique = 401 OR s.fk_forme_juridique = 600 OR s.fk_forme_juridique = 700 OR s.fk_forme_juridique = 1005 OR s.fk_typent = 8)
AND s.entity = %d
AND s.client = 3
AND s.fournisseur = 0
AND s.tms < DATE_SUB(NOW(), INTERVAL %d MONTH)
AND s.rowid NOT IN (
SELECT DISTINCT a.fk_soc
FROM ".MAIN_DB_PREFIX."actioncomm as a
WHERE a.tms > DATE_SUB(NOW(), INTERVAL %d MONTH)
AND a.fk_soc IS NOT NULL
)
",
"class" => "Societe",
"file" => DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php',
'fields_anonym' => array(
'name' => $langs->trans('ANONYME'),
'name_bis' => '',
'name_alias' => '',
'address' => '',
'town' => '',
'zip' => '',
'phone' => '',
'email' => '',
'url' => '',
'fax' => '',
'state' => '',
'country' => '',
'state_id' => '',
'skype' => '',
'country_id' => '',
)
),
'DATAPOLICIES_TIERS_NIPROSPECT_NICLIENT' => array(
'sql' => "
SELECT s.rowid FROM ".MAIN_DB_PREFIX."societe as s
WHERE (s.fk_forme_juridique = 19 OR s.fk_forme_juridique = 11 OR s.fk_forme_juridique = 12 OR s.fk_forme_juridique = 13 OR s.fk_forme_juridique = 15 OR s.fk_forme_juridique = 17 OR s.fk_forme_juridique = 18 OR s.fk_forme_juridique = 35 OR s.fk_forme_juridique = 60 OR s.fk_forme_juridique = 312 OR s.fk_forme_juridique = 316 OR s.fk_forme_juridique = 401 OR s.fk_forme_juridique = 600 OR s.fk_forme_juridique = 700 OR s.fk_forme_juridique = 1005 OR s.fk_typent = 8)
AND s.entity = %d
AND s.client = 0
AND s.fournisseur = 0
AND s.tms < DATE_SUB(NOW(), INTERVAL %d MONTH)
AND s.rowid NOT IN (
SELECT DISTINCT a.fk_soc
FROM ".MAIN_DB_PREFIX."actioncomm as a
WHERE a.tms > DATE_SUB(NOW(), INTERVAL %d MONTH)
AND a.fk_soc IS NOT NULL
)
",
"class" => "Societe",
"file" => DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php',
'fields_anonym' => array(
'name' => $langs->trans('ANONYME'),
'name_bis' => '',
'name_alias' => '',
'address' => '',
'town' => '',
'zip' => '',
'phone' => '',
'email' => '',
'url' => '',
'fax' => '',
'state' => '',
'country' => '',
'state_id' => '',
'skype' => '',
'country_id' => '',
)
),
'DATAPOLICIES_TIERS_FOURNISSEUR' => array(
'sql' => "
SELECT s.rowid FROM ".MAIN_DB_PREFIX."societe as s
WHERE (s.fk_forme_juridique = 19 OR s.fk_forme_juridique = 11 OR s.fk_forme_juridique = 12 OR s.fk_forme_juridique = 13 OR s.fk_forme_juridique = 15 OR s.fk_forme_juridique = 17 OR s.fk_forme_juridique = 18 OR s.fk_forme_juridique = 35 OR s.fk_forme_juridique = 60 OR s.fk_forme_juridique = 312 OR s.fk_forme_juridique = 316 OR s.fk_forme_juridique = 401 OR s.fk_forme_juridique = 600 OR s.fk_forme_juridique = 700 OR s.fk_forme_juridique = 1005 OR s.fk_typent = 8)
AND s.entity = %d
AND s.fournisseur = 1
AND s.tms < DATE_SUB(NOW(), INTERVAL %d MONTH)
AND s.rowid NOT IN (
SELECT DISTINCT a.fk_soc
FROM ".MAIN_DB_PREFIX."actioncomm as a
WHERE a.tms > DATE_SUB(NOW(), INTERVAL %d MONTH)
AND a.fk_contact IS NOT NULL
)
",
"class" => "Societe",
"file" => DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php',
'fields_anonym' => array(
'name' => $langs->trans('ANONYME'),
'name_bis' => '',
'name_alias' => '',
'address' => '',
'town' => '',
'zip' => '',
'phone' => '',
'email' => '',
'url' => '',
'fax' => '',
'state' => '',
'country' => '',
'state_id' => '',
'skype' => '',
'country_id' => '',
)
),
'DATAPOLICIES_CONTACT_CLIENT' => array(
'sql' => "
SELECT c.rowid FROM ".MAIN_DB_PREFIX."socpeople as c
INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = c.fk_soc
WHERE c.entity = %d
AND c.tms < DATE_SUB(NOW(), INTERVAL %d MONTH)
AND s.client = 1
AND s.fournisseur = 0
AND c.rowid NOT IN (
SELECT DISTINCT a.fk_contact
FROM ".MAIN_DB_PREFIX."actioncomm as a
WHERE a.tms > DATE_SUB(NOW(), INTERVAL %d MONTH)
AND a.fk_contact IS NOT NULL
)
",
"class" => "Contact",
"file" => DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php',
'fields_anonym' => array(
'lastname' => $langs->trans('ANONYME'),
'firstname' => '',
'civility_id' => '',
'poste' => '',
'address' => '',
'town' => '',
'zip' => '',
'phone_pro' => '',
'phone_perso' => '',
'phone_mobile' => '',
'email' => '',
'url' => '',
'fax' => '',
'state' => '',
'country' => '',
'state_id' => '',
'skype' => '',
'jabberid' => '',
'country_id' => '',
)
),
'DATAPOLICIES_CONTACT_PROSPECT' => array(
'sql' => "
SELECT c.rowid FROM ".MAIN_DB_PREFIX."socpeople as c
INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = c.fk_soc
WHERE c.entity = %d
AND c.tms < DATE_SUB(NOW(), INTERVAL %d MONTH)
AND s.client = 2
AND s.fournisseur = 0
AND c.rowid NOT IN (
SELECT DISTINCT a.fk_contact
FROM ".MAIN_DB_PREFIX."actioncomm as a
WHERE a.tms > DATE_SUB(NOW(), INTERVAL %d MONTH)
AND a.fk_contact IS NOT NULL
)
",
"class" => "Contact",
"file" => DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php',
'fields_anonym' => array(
'lastname' => $langs->trans('ANONYME'),
'firstname' => '',
'civility_id' => '',
'poste' => '',
'address' => '',
'town' => '',
'zip' => '',
'phone_pro' => '',
'phone_perso' => '',
'phone_mobile' => '',
'email' => '',
'url' => '',
'fax' => '',
'state' => '',
'country' => '',
'state_id' => '',
'skype' => '',
'jabberid' => '',
'country_id' => '',
)
),
'DATAPOLICIES_CONTACT_PROSPECT_CLIENT' => array(
'sql' => "
SELECT c.rowid FROM ".MAIN_DB_PREFIX."socpeople as c
INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = c.fk_soc
WHERE c.entity = %d
AND c.tms < DATE_SUB(NOW(), INTERVAL %d MONTH)
AND s.client = 3
AND s.fournisseur = 0
AND c.rowid NOT IN (
SELECT DISTINCT a.fk_contact
FROM ".MAIN_DB_PREFIX."actioncomm as a
WHERE a.tms > DATE_SUB(NOW(), INTERVAL %d MONTH)
AND a.fk_contact IS NOT NULL
)
",
"class" => "Contact",
"file" => DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php',
'fields_anonym' => array(
'lastname' => $langs->trans('ANONYME'),
'firstname' => '',
'civility_id' => '',
'poste' => '',
'address' => '',
'town' => '',
'zip' => '',
'phone_pro' => '',
'phone_perso' => '',
'phone_mobile' => '',
'email' => '',
'url' => '',
'fax' => '',
'state' => '',
'country' => '',
'state_id' => '',
'skype' => '',
'jabberid' => '',
'country_id' => '',
)
),
'DATAPOLICIES_CONTACT_NIPROSPECT_NICLIENT' => array(
'sql' => "
SELECT c.rowid FROM ".MAIN_DB_PREFIX."socpeople as c
INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = c.fk_soc
WHERE c.entity = %d
AND c.tms < DATE_SUB(NOW(), INTERVAL %d MONTH)
AND s.client = 0
AND s.fournisseur = 0
AND c.rowid NOT IN (
SELECT DISTINCT a.fk_contact
FROM ".MAIN_DB_PREFIX."actioncomm as a
WHERE a.tms > DATE_SUB(NOW(), INTERVAL %d MONTH)
AND a.fk_contact IS NOT NULL
)
",
"class" => "Contact",
"file" => DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php',
'fields_anonym' => array(
'lastname' => $langs->trans('ANONYME'),
'firstname' => '',
'civility_id' => '',
'poste' => '',
'address' => '',
'town' => '',
'zip' => '',
'phone_pro' => '',
'phone_perso' => '',
'phone_mobile' => '',
'email' => '',
'url' => '',
'fax' => '',
'state' => '',
'country' => '',
'state_id' => '',
'skype' => '',
'jabberid' => '',
'country_id' => '',
)
),
'DATAPOLICIES_CONTACT_FOURNISSEUR' => array(
'sql' => "
SELECT c.rowid FROM ".MAIN_DB_PREFIX."socpeople as c
INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = c.fk_soc
WHERE c.entity = %d
AND c.tms < DATE_SUB(NOW(), INTERVAL %d MONTH)
AND s.fournisseur = 1
AND c.rowid NOT IN (
SELECT DISTINCT a.fk_contact
FROM ".MAIN_DB_PREFIX."actioncomm as a
WHERE a.tms > DATE_SUB(NOW(), INTERVAL %d MONTH)
AND a.fk_contact IS NOT NULL
)
",
"class" => "Contact",
"file" => DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php',
'fields_anonym' => array(
'lastname' => $langs->trans('ANONYME'),
'firstname' => '',
'civility_id' => '',
'poste' => '',
'address' => '',
'town' => '',
'zip' => '',
'phone_pro' => '',
'phone_perso' => '',
'phone_mobile' => '',
'email' => '',
'url' => '',
'fax' => '',
'state' => '',
'country' => '',
'state_id' => '',
'skype' => '',
'jabberid' => '',
'country_id' => '',
)
),
'DATAPOLICIES_ADHERENT' => array(
'sql' => "
SELECT a.rowid FROM ".MAIN_DB_PREFIX."adherent as a
WHERE a.entity = %d
AND a.tms < DATE_SUB(NOW(), INTERVAL %d MONTH)
AND a.rowid NOT IN (
SELECT DISTINCT a.fk_element
FROM ".MAIN_DB_PREFIX."actioncomm as a
WHERE a.tms > DATE_SUB(NOW(), INTERVAL %d MONTH)
AND a.elementtype LIKE 'member'
AND a.fk_element IS NOT NULL
)
",
"class" => "Adherent",
"file" => DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php',
'fields_anonym' => array(
'lastname' => $langs->trans('ANONYME'),
'firstname' => $langs->trans('ANONYME'),
'civility_id' => '',
'societe' => '',
'address' => '',
'town' => '',
'zip' => '',
'phone' => '',
'phone_perso' => '',
'phone_mobile' => '',
'email' => '',
'url' => '',
'fax' => '',
'state' => '',
'country' => '',
'state_id' => '',
'skype' => '',
'country_id' => '',
)
),
);
foreach ($arrayofparameters as $key => $params) {
if ($conf->global->$key != '' && is_numeric($conf->global->$key) && (int)$conf->global->$key > 0) {
$sql = sprintf($params['sql'], (int)$conf->entity, (int)$conf->global->$key, (int)$conf->global->$key);
$resql = $db->query($sql);
if ($resql && $db->num_rows($resql) > 0) {
$num = $db->num_rows($resql);
$i = 0;
require_once $params['file'];
$object = new $params['class']($db);
while ($i < $num)
{
$obj = $db->fetch_object($resql);
$object->fetch($obj->rowid);
$object->id = $obj->rowid;
if ($object->isObjectUsed($obj->rowid) > 0) {
foreach ($params['fields_anonym'] as $fields => $val) {
$object->$fields = $val;
}
$object->update($obj->rowid, $user);
if ($params['class'] == 'Societe') {
// On supprime les contacts associé
$sql = "DELETE FROM ".MAIN_DB_PREFIX."socpeople WHERE fk_soc = " . $obj->rowid;
$db->query($sql);
}
} else {
if (DOL_VERSION < 8) {
$ret = $object->delete($obj->rowid, $user);
} else {
if ($object->element == 'adherent') {
$ret = $object->delete($obj->rowid);
} else {
$ret = $object->delete();
}
}
}
$i++;
}
}
}
}
return true;
}
public function sendMailing() {
global $conf, $db, $langs, $user;
$langs->load('datapolicies@datapolicies');
dol_include_once('/datapolicies/class/datapolicies.class.php');
$contacts = new DataPolicies($db);
$contacts->getAllContactNotInformed();
$contacts->getAllCompaniesNotInformed();
$contacts->getAllAdherentsNotInformed();
return true;
}
}

View File

@ -0,0 +1,74 @@
<?php
/* Copyright (C) 2018 SuperAdmin
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file rgpd/css/rgpd.css.php
* \ingroup rgpd
* \brief CSS file for module rgpd.
*/
//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled because need to load personalized language
//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled. Language code is found on url.
if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Not disabled because need to do translations
if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK',1);
if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1);
if (! defined('NOLOGIN')) define('NOLOGIN',1); // File must be accessed by logon page so without login
//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU',1); // We need top menu content
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML',1);
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
// Load Dolibarr environment
$res=0;
// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include($_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php");
// Try main.inc.php into web root detected using web root caluclated from SCRIPT_FILENAME
$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1;
while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; }
if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include(substr($tmp, 0, ($i+1))."/main.inc.php");
if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/../main.inc.php")) $res=@include(substr($tmp, 0, ($i+1))."/../main.inc.php");
// Try main.inc.php using relative path
if (! $res && file_exists("../../main.inc.php")) $res=@include("../../main.inc.php");
if (! $res && file_exists("../../../main.inc.php")) $res=@include("../../../main.inc.php");
if (! $res) die("Include of main fails");
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
session_cache_limiter(false);
// Load user to have $user->conf loaded (not done by default here because of NOLOGIN constant defined) and load permission if we need to use them in CSS
/*if (empty($user->id) && ! empty($_SESSION['dol_login']))
{
$user->fetch('',$_SESSION['dol_login']);
$user->getrights();
}*/
// Define css type
header('Content-type: text/css');
// Important: Following code is to cache this file to avoid page request by browser at each Dolibarr page access.
// You can use CTRL+F5 to refresh your browser cache.
if (empty($dolibarr_nocache)) header('Cache-Control: max-age=3600, public, must-revalidate');
else header('Cache-Control: no-cache');
?>
.myclasscss {
/* ... */
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 683 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 764 B

View File

@ -0,0 +1,59 @@
<?php
/* Copyright (C) 2018 SuperAdmin
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Library javascript to enable Browser notifications
*/
if (!defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1');
if (!defined('NOREQUIREDB')) define('NOREQUIREDB','1');
if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1');
if (!defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', 1);
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1);
if (!defined('NOLOGIN')) define('NOLOGIN', 1);
if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', 1);
if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', 1);
if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
/**
* \file datapolicies/js/datapolicies.js.php
* \ingroup datapolicies
* \brief JavaScript file for module datapolicies.
*/
// Load Dolibarr environment
$res=0;
// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include($_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php");
// Try main.inc.php into web root detected using web root caluclated from SCRIPT_FILENAME
$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1;
while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; }
if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include(substr($tmp, 0, ($i+1))."/main.inc.php");
if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/../main.inc.php")) $res=@include(substr($tmp, 0, ($i+1))."/../main.inc.php");
// Try main.inc.php using relative path
if (! $res && file_exists("../../main.inc.php")) $res=@include("../../main.inc.php");
if (! $res && file_exists("../../../main.inc.php")) $res=@include("../../../main.inc.php");
if (! $res) die("Include of main fails");
// Define js type
header('Content-Type: application/javascript');
// Important: Following code is to cache this file to avoid page request by browser at each Dolibarr page access.
// You can use CTRL+F5 to refresh your browser cache.
if (empty($dolibarr_nocache)) header('Cache-Control: max-age=3600, public, must-revalidate');
else header('Cache-Control: no-cache');
?>

View File

@ -0,0 +1,92 @@
# Copyright (C) 2018 SuperAdmin
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Module label 'ModulergpdName'
ModulergpdName = GDPR
# Module description 'ModulergpdDesc'
ModulergpdDesc = Conformity with the GDPR
#
# Page d'administration
#
rgpdSetup = Module Setup
Settings_DATAPOLICIES = Settings of DATAPOLICIES module
rgpdSetupPage = According to <a href="http://www.privacy-regulation.eu/en/5.htm" target="_blank">Article 5</a> of the GDPR, personal data must be kept for a period not exceeding that necessary for the purposes for which they were processed, except for archival purposes.
The deletion will be done automatically after a certain duration without event (the duration which you will have indicated below).
NB_MONTHS = %s months
ONE_YEAR = 1 year
NB_YEARS = %s years
DATAPOLICIES_TIERS_CLIENT = Customer
DATAPOLICIES_TIERS_PROSPECT = Prospect
DATAPOLICIES_TIERS_PROSPECT_CLIENT = Prospect/Customer
DATAPOLICIES_TIERS_NIPROSPECT_NICLIENT = Nor prospect/Nor customer
DATAPOLICIES_TIERS_FOURNISSEUR = Supplier
DATAPOLICIES_CONTACT_CLIENT = Customer
DATAPOLICIES_CONTACT_PROSPECT = Prospect
DATAPOLICIES_CONTACT_PROSPECT_CLIENT = Prospect/Customer
DATAPOLICIES_CONTACT_NIPROSPECT_NICLIENT = Nor prospect/Nor customer
DATAPOLICIES_CONTACT_FOURNISSEUR = Supplier
DATAPOLICIES_ADHERENT = Member
DATAPOLICIES_Tooltip_SETUP = Type of contact - Indicate your choices for each type.
DATAPOLICIESMail=Emails Setup
DATAPOLICIESSUBJECTMAIL=Subject of email
DATAPOLICIESCONTENTMAIL=Content of the email
DATAPOLICIESSUBSITUTION=You can use the following variables in your email (LINKACCEPT allows to create a link recording the agreement of the person, LINKREFUSED makes it possible to record the refusal of the person):
DATAPOLICIESACCEPT=Message after agreement
DATAPOLICIESREFUSE=Message after desagreement
SendAgreementText=You can send a GDPR email to all your relevant contacts (who have not yet received an email and for which you have not registered anything about their GDPR agreement). To do this, use the following button.
SendAgreement=Send emails
AllAgreementSend = All emails have been sent
TXTLINKDATAPOLICIESACCEPT= Text for the link "agreement"
TXTLINKDATAPOLICIESREFUSE= Text for the link "desagreement"
#
# Extrafield
#
DATAPOLICIES_BLOCKCHECKBOX = GDPR : Processing of personal data
DATAPOLICIES_consentement = Consent obtained for the processing of personal data
DATAPOLICIES_opposition_traitement = Opposes the processing of his personal data
DATAPOLICIES_opposition_prospection = Opposes the processing of his personal data for the purposes of prospecting
#
# Popup
#
DATAPOLICIES_POPUP_ANONYME_TITLE = Anonymize a thirdparty
DATAPOLICIES_POPUP_ANONYME_TEXTE = You can not delete this contact from Dolibarr because there are related items. In accordance with the GDPR, you will make all this data anonymous to respect your obligations. Would you like to continue ?
#
# Bouton portabilité
#
DATAPOLICIES_PORTABILITE = Portability GDPR
DATAPOLICIES_PORTABILITE_TITLE = Export of personal data
DATAPOLICIES_PORTABILITE_CONFIRMATION = You want to export the personal data of this contact. Are you sure ?
#
# Note ajoutés lors d'une anonymisation
#
ANONYMISER_AT = Anonymised the %s
#V2
DATAPOLICIESReturn=GDPR Validation
DATAPOLICIES_date = Date of agreement/desagreement GDPR
DATAPOLICIES_send = Date sending agreement email
DATAPOLICIESReturn = GDPR Return
DATAPOLICIES_SEND = Send GDPR email
MailSent = Email has been sent
#ERROR
ErrorSubjectIsRequired= Error : The subject of email is required. Indicate it in the module setup
=Due to a technical problem, we were unable to register your choice. We apologize for that. Contact us to send us your choice.

View File

@ -0,0 +1,96 @@
# Copyright (C) 2018 INOVEA CONSEIl info@inovea-conseil.com
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Générique
#
# Module label 'ModulergpdName'
ModulergpdName = DATAPOLICIES
# Module description 'ModulergpdDesc'
Module432452Desc = Module de mise en conformité avec le DATAPOLICIES
#
# Page d'administration
#
rgpdSetup = Configuration du module DATAPOLICIES
Settings_DATAPOLICIES = Paramétrage du module DATAPOLICIES
rgpdSetupPage = Selon <a href="http://www.privacy-regulation.eu/fr/5.htm" target="_blank">larticle 5</a> du DATAPOLICIES, les données à caractère personnel doivent être conservées pendant une durée nexcédant pas celle nécessaire au regard des finalités pour lesquelles elles ont été traitées, à lexception de fins archivistiques. La suppression se fera automatiquement après une certaine durée sans évènement (la durée que vous aurez indiquée ci-dessous).
NB_MONTHS = %s mois
ONE_YEAR = 1 an
NB_YEARS = %s ans
DATAPOLICIES_TIERS_CLIENT = Client
DATAPOLICIES_TIERS_PROSPECT = Prospect
DATAPOLICIES_TIERS_PROSPECT_CLIENT = Prospect/Client
DATAPOLICIES_TIERS_NIPROSPECT_NICLIENT = Ni prospect / Ni client
DATAPOLICIES_TIERS_FOURNISSEUR = Fournisseur
DATAPOLICIES_CONTACT_CLIENT = Client
DATAPOLICIES_CONTACT_PROSPECT = Prospect
DATAPOLICIES_CONTACT_PROSPECT_CLIENT = Prospect/Client
DATAPOLICIES_CONTACT_NIPROSPECT_NICLIENT = Ni prospect / Ni client
DATAPOLICIES_CONTACT_FOURNISSEUR = Fournisseur
DATAPOLICIES_ADHERENT = Adhérent
DATAPOLICIES_Tooltip_SETUP = Type du contact - Indiquez vos choix pour chaque type.
DATAPOLICIESMail=Paramétrage des emails
DATAPOLICIESSUBJECTMAIL=Objet du mail
DATAPOLICIESCONTENTMAIL=Contenu du mail
DATAPOLICIESSUBSITUTION=Vous pouvez utiliser les variables suivantes dans votre email (LINKACCEPT permet de créer un lien enregistrant l'acceptation de la personne, LINKREFUSED permet d'enregistrer le refus de la personne) :
DATAPOLICIESACCEPT=Message suite acceptation
DATAPOLICIESREFUSE=Message suite opposition
SendAgreementText=Vous pouvez envoyer un email DATAPOLICIES à tous vos contacts concernés (qui n'ont pas encore reçus de mail et pour lesquels vous n'avez rien enregistré concernant leur accord/désaccord DATAPOLICIES). Pour cela, utilisez le bouton suivant.
SendAgreement=Envoyer les emails
AllAgreementSend = Tous les e-mails de consentement ont été envoyés
TXTLINKDATAPOLICIESACCEPT= Texte du lien d'acceptation
TXTLINKDATAPOLICIESREFUSE= Texte du lien d'opposition
#
# Extrafield
#
DATAPOLICIES_BLOCKCHECKBOX = DATAPOLICIES : Traitement des données à caractère personnel
DATAPOLICIES_consentement = Consentement recueilli pour le traitement des données à caractère personnel le concernant
DATAPOLICIES_opposition_traitement = Soppose au traitement de ses données à caractère personnel
DATAPOLICIES_opposition_prospection = Soppose au traitement de ses données à caractère personnel à des fins de prospection
#
# Popup
#
DATAPOLICIES_POPUP_ANONYME_TITLE = Anonymiser un tiers
DATAPOLICIES_POPUP_ANONYME_TEXTE = Vous ne pouvez pas supprimer ce contact de Dolibarr car des éléments y sont liés. Conformément au DATAPOLICIES, vous allez rendre toutes ces données anonymes afin de respecter vos obligations. Souhaitez-vous continuer ?
#
# Bouton portabilité
#
DATAPOLICIES_PORTABILITE = Portabilité DATAPOLICIES
DATAPOLICIES_PORTABILITE_TITLE = Export des données à caractère personnel
DATAPOLICIES_PORTABILITE_CONFIRMATION = Vous souhaitez exporter les données à caractère personnel de ce contact. Etes-vous sûr ?
#
# Note ajoutés lors d'une anonymisation
#
ANONYMISER_AT = Anonymisé le %s
#V2
DATAPOLICIESReturn=Validation DATAPOLICIES
DATAPOLICIES_date=Date d'accord/opposition au traitement
DATAPOLICIES_send=Date envoi consentement
DATAPOLICIESReturn=Retour DATAPOLICIES
DATAPOLICIES_SEND=Envoyer l'email de consentement
MailSent=L'email a bien été envoyé
#ERROR
ErrorSubjectIsRequired=Erreur : vous n'avez pas indiqué l'objet de l'email dans la configuration
=Suite à un problème technique, nous n'avons pas pu enregistrer votre choix. Nous nous en excusons. Contactez-nous pour nous transmettre votre choix.

View File

@ -0,0 +1,80 @@
# Copyright (C) 2018 INOVEA CONSEIl info@inovea-conseil.com - Thanks to Claudio Aschieri
#
# # Module label 'ModulergpdName'
ModulergpdName = GDPR
# Module description 'ModulergpdDesc'
ModulergpdDesc = Conformità con GDPR
Module432452Name=GDPR
Module432452Desc=Conformità con GDPR (Regolamento Generale sulla protezione di dati)
#
# Page d'administration
#
rgpdSetup = Module Setup
Settings_DATAPOLICIES = Configurazione modulo GDPR
rgpdSetupPage = In accordo con <a href="http://www.privacy-regulation.eu/it/5.htm" target="_blank">l'art 5 del GDPR </a> i dati personali devono essere conservati per un periodo di tempo che .... ed eliminati se non sono più utili agli scopi per cui sono stati processati.
NB_MONTHS = %s mesi
ONE_YEAR = 1 anno
NB_YEARS = %s anni
DATAPOLICIES_TIERS_CLIENT = Cliente
DATAPOLICIES_TIERS_PROSPECT = Fornitore
DATAPOLICIES_TIERS_PROSPECT_CLIENT = Potenziale Cliente / Cliente
DATAPOLICIES_TIERS_NIPROSPECT_NICLIENT = Nè potenziale cliente / Nè cliente
DATAPOLICIES_TIERS_FOURNISSEUR = Fornitore
DATAPOLICIES_CONTACT_CLIENT = Cliente
DATAPOLICIES_CONTACT_PROSPECT = Potenziale cliente
DATAPOLICIES_CONTACT_PROSPECT_CLIENT = Potenziale Cliente / Cliente
DATAPOLICIES_CONTACT_NIPROSPECT_NICLIENT = Nè potenziale cliente / Nè cliente
DATAPOLICIES_CONTACT_FOURNISSEUR = Fornitore
DATAPOLICIES_ADHERENT = Membri
DATAPOLICIES_Tooltip_SETUP = Tipo di contatto - Indica la scelta per ogni tipologia
DATAPOLICIESMail=Configurazione Email
DATAPOLICIESSUBJECTMAIL=Subject dell'e-mail
DATAPOLICIESCONTENTMAIL=Contenuto dell'e-mail
DATAPOLICIESSUBSITUTION=Puoi utilizzare le seguenti variabili nella tua email (LINKACCEPT consente di creare un link per registrare l'accettazione della persona, LINKREFUSED consente di registrare il rifiuto della persona):
DATAPOLICIESACCEPT= Messaggio dopo il consenso
DATAPOLICIESREFUSE=Messaggio dopo il rifiuto
SendAgreementText=Puoi inviare un'email GDPR a tutti i tuoi contatti rilevanti (che non hanno ancora ricevuto un'e-mail e per i quali non hai registrato nulla sul loro accordo GDPR). Per fare ciò, utilizzare il seguente pulsante.
SendAgreement=Invia emails
AllAgreementSend = Tutte le email sono state inviate
TXTLINKDATAPOLICIESACCEPT= Testo per il link "Consenso"
TXTLINKDATAPOLICIESREFUSE= Testo per il link "Consenso negato"
#
# Extrafield
#
DATAPOLICIES_BLOCKCHECKBOX = GDPR : Trattamento dei dati personali
DATAPOLICIES_consentement = Consenso ottenuto al Trattamento dei dati personali
DATAPOLICIES_opposition_traitement = Consenso negato al trattamento dei dati personali
DATAPOLICIES_opposition_prospection = Consenso negato al trattamento dei dati personali a fini commerciali
#
# Popup
#
DATAPOLICIES_POPUP_ANONYME_TITLE = Anonimizza un soggetto terzo
DATAPOLICIES_POPUP_ANONYME_TEXTE = Impossibile eliminare questo contatto da Dolibarr perchè vi sono elementi collegati. In conformità con il GDPR, renderai tutti questi dati anonimi per rispettare i tuoi obblighi. Vuoi continuare?
#
# Bouton portabilité
#
DATAPOLICIES_PORTABILITE = Portabilità GDPR
DATAPOLICIES_PORTABILITE_TITLE = Esporta i dati personali
DATAPOLICIES_PORTABILITE_CONFIRMATION = Vuoi davvero esportare i dati personali di questo contatto?
#
# Note ajoutée lors d'une anonymisation
#
ANONYMISER_AT = Anonimizzato il %s
#V2
DATAPOLICIESReturn=GDPR Validazione
DATAPOLICIES_date = Data di accordo / disaccordo GDPR
DATAPOLICIES_send = Data di invio del consenso (e-mail)
DATAPOLICIESReturn = GDPR ritorno
DATAPOLICIES_SEND = Inviare GDPR e-mail
MailSent=L'email è stata inviata
#ERROR
ErrorSubjectIsRequired= Errore: L'oggetto della mail è obbligatorio. Inserisci l'oggetto nella configurazione del modulo.
=A causa di un problema tecnico, non siamo stati in grado di registrare la tua scelta. Ci scusiamo per questo. Contattaci per inviarci la tua scelta.

View File

@ -0,0 +1,59 @@
<?php
/* Copyright (C) 2018 SuperAdmin
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file datapolicies/lib/datapolicies.lib.php
* \ingroup datapolicies
* \brief Library files with common functions for datapolicies
*/
/**
* Prepare admin pages header
*
* @return array
*/
function datapoliciesAdminPrepareHead()
{
global $langs, $conf;
$langs->load("datapolicies@datapolicies");
$h = 0;
$head = array();
$head[$h][0] = dol_buildpath("/datapolicies/admin/setup.php", 1);
$head[$h][1] = $langs->trans("Settings_DATAPOLICIES");
$head[$h][2] = 'settings';
$h++;
$head[$h][0] = dol_buildpath("/datapolicies/admin/setupmail.php", 1);
$head[$h][1] = $langs->trans("DATAPOLICIESMail");
$head[$h][2] = 'settings';
$h++;
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
//$this->tabs = array(
// 'entity:+tabname:Title:@datapolicies:/datapolicies/mypage.php?id=__ID__'
//); // to add new tab
//$this->tabs = array(
// 'entity:-tabname:Title:@datapolicies:/datapolicies/mypage.php?id=__ID__'
//); // to remove a tab
complete_head_from_modules($conf, $langs, $object, $head, $h, 'datapolicies');
return $head;
}

View File

@ -0,0 +1,58 @@
<?php
/* Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file datapolicies/mailing.php
* \ingroup datapolicies
* \brief datapolicies mailing page.
*/
// Load Dolibarr environment
$res=0;
// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include($_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php");
// Try main.inc.php into web root detected using web root caluclated from SCRIPT_FILENAME
$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1;
while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; }
if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include(substr($tmp, 0, ($i+1))."/main.inc.php");
if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php");
// Try main.inc.php using relative path
if (! $res && file_exists("../../main.inc.php")) $res=@include("../../main.inc.php");
if (! $res && file_exists("../../../main.inc.php")) $res=@include("../../../main.inc.php");
if (! $res) die("Include of main fails");
global $langs, $user, $db, $conf;
dol_include_once('/contact/class/contact.class.php');
dol_include_once('/datapolicies/class/datapolicies.class.php');
$idcontact = GETPOST('idc');
if(!empty($idcontact)){
$contact = new Contact($db);
$contact->fetch($idcontact);
DataPolicies::sendMailDataPoliciesContact($contact);
}else{
$contacts = new DataPolicies($db);
$contacts->getAllContactNotInformed();
$contacts->getAllCompaniesNotInformed();
$contacts->getAllAdherentsNotInformed();
echo $langs->trans('AllAgreementSend');
}

View File

@ -0,0 +1,3 @@
# DO NOT DELETE THIS FILE MANUALLY
# File to flag module built using official module template.
# When this file is present into a module directory, you can edit it with the module builder tool. Use ModuleBuilder if you want to delete module.

View File

@ -0,0 +1,169 @@
<?php
/* Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file datapolicies/admin/setup.php
* \ingroup datapolicies
* \brief datapolicies setup page.
*/
if (!defined('NOLOGIN'))
define("NOLOGIN", 1); // This means this output page does not require to be logged.
if (!defined('NOCSRFCHECK'))
define('NOCSRFCHECK', '1'); // Do not check anti CSRF attack test
if (!defined('NOREQUIREMENU'))
define('NOREQUIREMENU', '1');
// Load Dolibarr environment
$res = 0;
// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"]))
$res = @include($_SERVER["CONTEXT_DOCUMENT_ROOT"] . "/main.inc.php");
// Try main.inc.php into web root detected using web root caluclated from SCRIPT_FILENAME
$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME'];
$tmp2 = realpath(__FILE__);
$i = strlen($tmp) - 1;
$j = strlen($tmp2) - 1;
while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) {
$i--;
$j--;
}
if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1)) . "/main.inc.php"))
$res = @include(substr($tmp, 0, ($i + 1)) . "/main.inc.php");
if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1))) . "/main.inc.php"))
$res = @include(dirname(substr($tmp, 0, ($i + 1))) . "/main.inc.php");
// Try main.inc.php using relative path
if (!$res && file_exists("../../main.inc.php"))
$res = @include("../../main.inc.php");
if (!$res && file_exists("../../../main.inc.php"))
$res = @include("../../../main.inc.php");
if (!$res)
die("Include of main fails");
global $langs, $user, $db, $conf;
dol_include_once('/contact/class/contact.class.php');
dol_include_once('/societe/class/societe.class.php');
dol_include_once('/adherents/class/adherent.class.php');
dol_include_once('/user/class/user.class.php');
dol_include_once('/datapolicies/class/datapolicies.class.php');
$idc = GETPOST('c');
$ids = GETPOST('s');
$ida = GETPOST('a');
$action = GETPOST('action');
$lang = GETPOST('l');
$code = GETPOST('key');
$acc = "DATAPOLICIESACCEPT_" . $lang;
$ref = "DATAPOLICIESREFUSE_" . $lang;
$langs->load('datapolicies@datapolicies',0,0,$lang);
if (empty($action) || (empty($idc) && empty($ids) && empty($ida))) {
return 0;
} elseif (!empty($idc)) {
$contact = new Contact($db);
$contact->fetch($idc);
$check = md5($contact->email);
if ($check != $code) {
$return = $langs->trans('ErrorEmailDATAPOLICIES');
} elseif ($action == 1) {
$contact->array_options['options_datapolicies_consentement'] = 1;
$contact->array_options['options_datapolicies_opposition_traitement'] = 0;
$contact->array_options['options_datapolicies_opposition_prospection'] = 0;
$contact->array_options['options_datapolicies_date'] = date('Y-m-d', time());
$return = $conf->global->$acc;
} elseif ($action == 2) {
$contact->no_email = 1;
$contact->array_options['options_datapolicies_consentement'] = 0;
$contact->array_options['options_datapolicies_opposition_traitement'] = 1;
$contact->array_options['options_datapolicies_opposition_prospection'] = 1;
$contact->array_options['options_datapolicies_date'] = date('Y-m-d', time());
$return = $conf->global->$ref;
}
$contact->update($idc);
} elseif (!empty($ids)) {
$societe = new Societe($db);
$societe->fetch($ids);
$check = md5($societe->email);
if ($check != $code) {
$return = $langs->trans('ErrorEmailDATAPOLICIES');
} elseif ($action == 1) {
$societe->array_options['options_datapolicies_consentement'] = 1;
$societe->array_options['options_datapolicies_opposition_traitement'] = 0;
$societe->array_options['options_datapolicies_opposition_prospection'] = 0;
$societe->array_options['options_datapolicies_date'] = date('Y-m-d', time());
$return = $conf->global->$acc;
} elseif ($action == 2) {
$societe->array_options['options_datapolicies_consentement'] = 0;
$societe->array_options['options_datapolicies_opposition_traitement'] = 1;
$societe->array_options['options_datapolicies_opposition_prospection'] = 1;
$societe->array_options['options_datapolicies_date'] = date('Y-m-d', time());
$return = $conf->global->$ref;
}
$societe->update($ids);
} elseif (!empty($ida)) {
$adherent = new Adherent($db);
$adherent->fetch($ida);
$check = md5($adherent->email);
if ($check != $code) {
$return = $langs->trans('ErrorEmailDATAPOLICIES');
} elseif ($action == 1) {
$adherent->array_options['options_datapolicies_consentement'] = 1;
$adherent->array_options['options_datapolicies_opposition_traitement'] = 0;
$adherent->array_options['options_datapolicies_opposition_prospection'] = 0;
//$adherent->array_options['options_datapolicies_date'] = date('Y-m-d', time());
$return = $conf->global->$acc;
} elseif ($action == 2) {
$adherent->array_options['options_datapolicies_consentement'] = 0;
$adherent->array_options['options_datapolicies_opposition_traitement'] = 1;
$adherent->array_options['options_datapolicies_opposition_prospection'] = 1;
//$adherent->array_options['options_datapolicies_date'] = date('Y-m-d', time());
$return = $conf->global->$ref;
}
$newuser = new User($db);
$adherent->update($newuser);
}
header("Content-type: text/html; charset=" . $conf->file->character_set_client);
print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">';
print "\n";
print "<html>\n";
print "<head>\n";
print '<meta name="robots" content="noindex,nofollow">' . "\n";
print '<meta name="keywords" content="dolibarr">' . "\n";
print '<meta name="description" content="Dolibarr DATAPOLICIES">' . "\n";
print "<title>" . $langs->trans("DATAPOLICIESReturn") . "</title>\n";
print '<link rel="stylesheet" type="text/css" href="' . DOL_URL_ROOT . $conf->css . '?lang=' . $lang . '">' . "\n";
print '<style type="text/css">';
print '.CTableRow1 { margin: 1px; padding: 3px; font: 12px verdana,arial; background: #e6E6eE; color: #000000; -moz-border-radius-topleft:6px; -moz-border-radius-topright:6px; -moz-border-radius-bottomleft:6px; -moz-border-radius-bottomright:6px;}';
print '.CTableRow2 { margin: 1px; padding: 3px; font: 12px verdana,arial; background: #FFFFFF; color: #000000; -moz-border-radius-topleft:6px; -moz-border-radius-topright:6px; -moz-border-radius-bottomleft:6px; -moz-border-radius-bottomright:6px;}';
print '</style>';
print "</head>\n";
print '<body style="margin: 10% 40%">' . "\n";
print '<table class="CTableRow1" ><tr><td style="text_align:center;">';
print $return . "<br>\n";
print '</td></tr></table>';
print "</body>\n";
print "</html>\n";
$db->close();
?>