diff --git a/htdocs/datapolicies/admin/setup.php b/htdocs/datapolicies/admin/setup.php index bcb47489c31..f6edd5b3e90 100644 --- a/htdocs/datapolicies/admin/setup.php +++ b/htdocs/datapolicies/admin/setup.php @@ -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"; diff --git a/htdocs/datapolicies/admin/setupmail.php b/htdocs/datapolicies/admin/setupmail.php index 4420e2203b3..4728298a09e 100644 --- a/htdocs/datapolicies/admin/setupmail.php +++ b/htdocs/datapolicies/admin/setupmail.php @@ -17,40 +17,7 @@ * along with this program. If not, see . */ -/** - * \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'; diff --git a/htdocs/datapolicies/class/actions_datapolicies.class.php b/htdocs/datapolicies/class/actions_datapolicies.class.php index 05958e23ed8..1240b18ebd0 100644 --- a/htdocs/datapolicies/class/actions_datapolicies.class.php +++ b/htdocs/datapolicies/class/actions_datapolicies.class.php @@ -1,5 +1,4 @@ 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; } - } diff --git a/htdocs/datapolicies/class/datapolicies.class.php b/htdocs/datapolicies/class/datapolicies.class.php index 030d5ff475f..d4efc7e6303 100644 --- a/htdocs/datapolicies/class/datapolicies.class.php +++ b/htdocs/datapolicies/class/datapolicies.class.php @@ -1,5 +1,4 @@ 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 "
".print_r($contact,1)."
"; - $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 "
".print_r($contact,1)."
"; + $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__' => ''.$linka.'', - '__LINKREFUSED__' => ''.$linkr.'', - '__FIRSTNAME__' => $contact->firstname, - '__NAME__' => $contact->lastname, - '__CIVILITY__' => $contact->civility, - ); - $subject = make_substitutions($subject, $substitutionarray); - $message = make_substitutions($message, $substitutionarray); + $substitutionarray = array( + '__LINKACCEPT__' => ''.$linka.'', + '__LINKREFUSED__' => ''.$linkr.'', + '__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 .= '
' . $mailfile->error . '
'; + } else { + $result4 = $mailfile->sendfile(); + if (!$error) { - if ($mailfile->error) { - $resultmasssend .= '
' . $mailfile->error . '
'; - } else { - $result4 = $mailfile->sendfile(); - if (!$error) { + $resultmasssend .= $langs->trans("MailSent") . ': ' . $sendto . "
"; + $contact->array_options['options_datapolicies_send'] = date('Y-m-d', time()); + $contact->update($contact->id); - $resultmasssend .= $langs->trans("MailSent") . ': ' . $sendto . "
"; - $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__' => ''.$linka.'', - '__LINKREFUSED__' => ''.$linkr.'', - ); - $subject = make_substitutions($subject, $substitutionarray); - $message = make_substitutions($message, $substitutionarray); + $substitutionarray = array( + '__LINKACCEPT__' => ''.$linka.'', + '__LINKREFUSED__' => ''.$linkr.'', + ); + $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 .= '
' . $mailfile->error . '
'; - } else { - $result4 = $mailfile->sendfile(); - - if (!$error) { - $resultmasssend .= $langs->trans("MailSent") . ': ' . $sendto . "
"; - $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 .= '
' . $mailfile->error . '
'; + } else { + $result4 = $mailfile->sendfile(); + if (!$error) { + $resultmasssend .= $langs->trans("MailSent") . ': ' . $sendto . "
"; + $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__' => ''.$linka.'', - '__LINKREFUSED__' => ''.$linkr.'', - ); - $subject = make_substitutions($subject, $substitutionarray); - $message = make_substitutions($message, $substitutionarray); + $substitutionarray = array( + '__LINKACCEPT__' => ''.$linka.'', + '__LINKREFUSED__' => ''.$linkr.'', + ); + $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 .= '
' . $mailfile->error . '
'; + } 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 .= '
' . $mailfile->error . '
'; - } else { - $result4 = $mailfile->sendfile(); - - if (!$error) { - $resultmasssend .= $langs->trans("MailSent") . ': ' . $sendto . "
"; - $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 . "
"; + $adherent->array_options['options_datapolicies_send'] = date('Y-m-d', time()); + $adherent->update($user); + } else { + dol_print_error($db); + } + } + setEventMessage($resultmasssend); } - - - } diff --git a/htdocs/datapolicies/class/datapoliciescron.class.php b/htdocs/datapolicies/class/datapoliciescron.class.php index 18484d1619d..c02497b9744 100644 --- a/htdocs/datapolicies/class/datapoliciescron.class.php +++ b/htdocs/datapolicies/class/datapoliciescron.class.php @@ -1,12 +1,43 @@ . + */ -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; - } } \ No newline at end of file diff --git a/htdocs/datapolicies/css/datapolicies.css.php b/htdocs/datapolicies/css/datapolicies.css.php index 72a3c09819e..2e573ef92c3 100644 --- a/htdocs/datapolicies/css/datapolicies.css.php +++ b/htdocs/datapolicies/css/datapolicies.css.php @@ -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); diff --git a/htdocs/datapolicies/mailing.php b/htdocs/datapolicies/mailing.php index 4621a270e76..08c24d9aceb 100644 --- a/htdocs/datapolicies/mailing.php +++ b/htdocs/datapolicies/mailing.php @@ -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'); diff --git a/htdocs/datapolicies/public/index.php b/htdocs/datapolicies/public/index.php index 8fb2ef09290..4dd07f2ea2d 100644 --- a/htdocs/datapolicies/public/index.php +++ b/htdocs/datapolicies/public/index.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 . "
\n"; print ''; print "\n"; print "\n"; + $db->close(); -?> \ No newline at end of file