Fix phpcs
This commit is contained in:
parent
d1dde0ffac
commit
c0d45430c4
@ -22,23 +22,7 @@
|
||||
* \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 '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php";
|
||||
require_once '../lib/datapolicies.lib.php';
|
||||
//require_once "../class/myclass.class.php";
|
||||
|
||||
@ -17,40 +17,7 @@
|
||||
* 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 '../../main.inc.php';
|
||||
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';
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/* Copyright (C) 2018 SuperAdmin
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@ -20,15 +19,13 @@
|
||||
* \file datapolicies/class/actions_datapolicies.class.php
|
||||
* \ingroup datapolicies
|
||||
* \brief Example hook overload.
|
||||
*
|
||||
* Put detailed description here.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class Actionsdatapolicies
|
||||
* Class ActionsDatapolicies
|
||||
*/
|
||||
class Actionsdatapolicies {
|
||||
|
||||
class ActionsDatapolicies
|
||||
{
|
||||
/**
|
||||
* @var DoliDB Database handler.
|
||||
*/
|
||||
@ -59,7 +56,8 @@ class Actionsdatapolicies {
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
*/
|
||||
public function __construct($db) {
|
||||
public function __construct($db)
|
||||
{
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
@ -73,7 +71,8 @@ class Actionsdatapolicies {
|
||||
* =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) {
|
||||
function getNomUrl($parameters, &$object, &$action)
|
||||
{
|
||||
global $db, $langs, $conf, $user;
|
||||
$this->resprints = '';
|
||||
return 0;
|
||||
@ -88,7 +87,8 @@ class Actionsdatapolicies {
|
||||
* @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) {
|
||||
public function doActions($parameters, &$object, &$action, $hookmanager)
|
||||
{
|
||||
global $conf, $user, $langs;
|
||||
$langs->load('datapolicies@datapolicies');
|
||||
$error = 0; // Error counter
|
||||
@ -97,6 +97,7 @@ class Actionsdatapolicies {
|
||||
$object->fetch(GETPOST('socid'));
|
||||
}
|
||||
|
||||
// FIXME Removed had coded id, use codes
|
||||
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'))) {
|
||||
@ -237,7 +238,8 @@ class Actionsdatapolicies {
|
||||
* @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) {
|
||||
public function doMassActions($parameters, &$object, &$action, $hookmanager)
|
||||
{
|
||||
global $conf, $user, $langs;
|
||||
|
||||
$error = 0; // Error counter
|
||||
@ -262,13 +264,14 @@ class Actionsdatapolicies {
|
||||
/**
|
||||
* Overloading the addMoreMassActions function : replacing the parent's function with the one below
|
||||
*
|
||||
* @param array $parameter
s Hook metadatas (context, etc...)
|
||||
* @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) {
|
||||
public function addMoreMassActions($parameters, &$object, &$action, $hookmanager)
|
||||
{
|
||||
global $conf, $user, $langs;
|
||||
|
||||
$error = 0; // Error counter
|
||||
@ -296,7 +299,8 @@ class Actionsdatapolicies {
|
||||
* =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) {
|
||||
function beforePDFCreation($parameters, &$object, &$action)
|
||||
{
|
||||
global $conf, $user, $langs;
|
||||
global $hookmanager;
|
||||
|
||||
@ -324,7 +328,8 @@ class Actionsdatapolicies {
|
||||
* =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) {
|
||||
function afterPDFCreation($parameters, &$pdfhandler, &$action)
|
||||
{
|
||||
global $conf, $user, $langs;
|
||||
global $hookmanager;
|
||||
|
||||
@ -342,7 +347,17 @@ class Actionsdatapolicies {
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function addMoreActionsButtons($parameters, &$object, &$action, $hookmanager) {
|
||||
/**
|
||||
* addMoreActionsButtons
|
||||
*
|
||||
* @param array $parameters array of parameters
|
||||
* @param Object $object Object
|
||||
* @param string $action Actions
|
||||
* @param HookManager $hookmanager Hook manager
|
||||
* @return void
|
||||
*/
|
||||
function addMoreActionsButtons($parameters, &$object, &$action, $hookmanager)
|
||||
{
|
||||
global $conf, $user, $langs;
|
||||
$langs->load('datapolicies@datapolicies');
|
||||
|
||||
@ -388,7 +403,17 @@ class Actionsdatapolicies {
|
||||
}
|
||||
}
|
||||
|
||||
function printCommonFooter($parameters, &$object, &$action, $hookmanager) {
|
||||
/**
|
||||
* printCommonFooter
|
||||
*
|
||||
* @param array $parameters array of parameters
|
||||
* @param Object $object Object
|
||||
* @param string $action Actions
|
||||
* @param HookManager $hookmanager Hook manager
|
||||
* @return void
|
||||
*/
|
||||
function printCommonFooter($parameters, &$object, &$action, $hookmanager)
|
||||
{
|
||||
global $conf, $user, $langs;
|
||||
|
||||
$jsscript = '';
|
||||
@ -446,5 +471,4 @@ class Actionsdatapolicies {
|
||||
|
||||
echo $jsscript;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/* Copyright (C) 2018 SuperAdmin
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@ -27,13 +26,19 @@ 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
|
||||
*/
|
||||
Class DataPolicies extends Contact {
|
||||
|
||||
function getAllContactNotInformed() {
|
||||
|
||||
Class DataPolicies extends Contact
|
||||
{
|
||||
/**
|
||||
* getAllContactNotInformed
|
||||
*
|
||||
* @return number
|
||||
*/
|
||||
function getAllContactNotInformed()
|
||||
{
|
||||
global $langs, $conf, $db, $user;
|
||||
|
||||
$langs->load("companies");
|
||||
@ -64,8 +69,13 @@ Class DataPolicies extends Contact {
|
||||
}
|
||||
}
|
||||
|
||||
function getAllCompaniesNotInformed() {
|
||||
|
||||
/**
|
||||
* getAllCompaniesNotInformed
|
||||
*
|
||||
* @return number
|
||||
*/
|
||||
function getAllCompaniesNotInformed()
|
||||
{
|
||||
global $langs, $conf, $db, $user;
|
||||
|
||||
$langs->load("companies");
|
||||
@ -95,8 +105,13 @@ Class DataPolicies extends Contact {
|
||||
}
|
||||
}
|
||||
|
||||
function getAllAdherentsNotInformed() {
|
||||
|
||||
/**
|
||||
* getAllAdherentsNotInformed
|
||||
*
|
||||
* @return number
|
||||
*/
|
||||
function getAllAdherentsNotInformed()
|
||||
{
|
||||
global $langs, $conf, $db, $user;
|
||||
|
||||
$langs->load("adherent");
|
||||
@ -126,195 +141,208 @@ Class DataPolicies extends Contact {
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
/**
|
||||
* sendMailDataPoliciesContact
|
||||
*
|
||||
* @param mixed $contact Contact
|
||||
* @return void
|
||||
*/
|
||||
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;
|
||||
$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);
|
||||
$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);
|
||||
}
|
||||
$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);
|
||||
|
||||
// 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) {
|
||||
|
||||
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);
|
||||
|
||||
$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);
|
||||
} 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;
|
||||
/**
|
||||
* sendMailDataPoliciesCompany
|
||||
*
|
||||
* @param Societe $societe Object societe
|
||||
* @return void
|
||||
*/
|
||||
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;
|
||||
$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;
|
||||
$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);
|
||||
$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);
|
||||
}
|
||||
$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);
|
||||
// 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;
|
||||
/**
|
||||
* sendMailDataPoliciesAdherent
|
||||
*
|
||||
* @param Adherent $adherent Member
|
||||
* @return void
|
||||
*/
|
||||
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;
|
||||
$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;
|
||||
$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);
|
||||
$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);
|
||||
}
|
||||
$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();
|
||||
|
||||
// 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);
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1,12 +1,43 @@
|
||||
<?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/>.
|
||||
*/
|
||||
|
||||
class datapoliciesCron {
|
||||
/**
|
||||
* \file datapolicies/class/datapoliciescron.class.php
|
||||
* \ingroup datapolicies
|
||||
* \brief Example hook overload.
|
||||
*/
|
||||
|
||||
public function exec() {
|
||||
/**
|
||||
* Class DataPoliciesCron
|
||||
*/
|
||||
class DataPoliciesCron
|
||||
{
|
||||
/**
|
||||
* Function exec
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function exec()
|
||||
{
|
||||
global $conf, $db, $langs, $user;
|
||||
|
||||
$langs->load('datapolicies@datapolicies');
|
||||
|
||||
// FIXME Removed hardcoded values of id
|
||||
$arrayofparameters=array(
|
||||
'DATAPOLICIES_TIERS_CLIENT' => array(
|
||||
'sql' => "
|
||||
@ -415,9 +446,9 @@ class datapoliciesCron {
|
||||
);
|
||||
|
||||
foreach ($arrayofparameters as $key => $params) {
|
||||
if ($conf->global->$key != '' && is_numeric($conf->global->$key) && (int)$conf->global->$key > 0) {
|
||||
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);
|
||||
$sql = sprintf($params['sql'], (int) $conf->entity, (int) $conf->global->$key, (int) $conf->global->$key);
|
||||
|
||||
$resql = $db->query($sql);
|
||||
|
||||
@ -466,11 +497,16 @@ class datapoliciesCron {
|
||||
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function sendMailing() {
|
||||
/**
|
||||
* sendMailing
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function sendMailing()
|
||||
{
|
||||
global $conf, $db, $langs, $user;
|
||||
|
||||
$langs->load('datapolicies@datapolicies');
|
||||
@ -482,6 +518,5 @@ class datapoliciesCron {
|
||||
$contacts->getAllCompaniesNotInformed();
|
||||
$contacts->getAllAdherentsNotInformed();
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
||||
@ -32,20 +32,7 @@ if (! defined('NOLOGIN')) define('NOLOGIN',1); // File must be
|
||||
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 '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||
|
||||
session_cache_limiter(false);
|
||||
|
||||
@ -21,22 +21,7 @@
|
||||
* \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;
|
||||
|
||||
require '../../main.inc.php';
|
||||
dol_include_once('/contact/class/contact.class.php');
|
||||
dol_include_once('/datapolicies/class/datapolicies.class.php');
|
||||
|
||||
|
||||
@ -27,39 +27,12 @@ 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;
|
||||
|
||||
require '../../main.inc.php';
|
||||
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');
|
||||
@ -165,5 +138,5 @@ print $return . "<br>\n";
|
||||
print '</td></tr></table>';
|
||||
print "</body>\n";
|
||||
print "</html>\n";
|
||||
|
||||
$db->close();
|
||||
?>
|
||||
Loading…
Reference in New Issue
Block a user