diff --git a/ChangeLog b/ChangeLog index f48de97d970..68e9674d0da 100644 --- a/ChangeLog +++ b/ChangeLog @@ -16,6 +16,8 @@ Following changes may create regression for some external modules, but were nece * Removed CommonObject::displayMarginInfos (was deprecated in 3.8). Use same method into html.formmargin.class.php * Removed Societe::set_commnucation_level (was deprecated in 4.0). Was not used. +* Removed the trigger file of PAYPAL module that stored data that was not used by Dolibarr. The trigger event still + exists, but if an external module need action on it, it must provides itself its trigger file. ***** ChangeLog for 5.0.2 compared to 5.0.1 ***** FIX: #6468 + Fix missing translation diff --git a/htdocs/core/triggers/interface_20_modPaypal_PaypalWorkflow.class.php b/htdocs/core/triggers/interface_20_modPaypal_PaypalWorkflow.class.php deleted file mode 100644 index 1d57f598d57..00000000000 --- a/htdocs/core/triggers/interface_20_modPaypal_PaypalWorkflow.class.php +++ /dev/null @@ -1,112 +0,0 @@ - - * Copyright (C) 2014 Marcos García - * - * 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 . - */ - -/** - * \file /htdocs/core/triggers/interface_20_modPaypal_PaypalWorkflow.class.php - * \ingroup paypal - * \brief Trigger file for paypal workflow - */ - -require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php'; - - -/** - * Class of triggers for paypal module - */ -class InterfacePaypalWorkflow extends DolibarrTriggers -{ - public $picto = 'paypal@paypal'; - public $family = 'paypal'; - public $description = "Triggers of this module allows to manage paypal workflow"; - public $version = self::VERSION_DOLIBARR; - - /** - * Function called when a Dolibarrr business event is done. - * All functions "runTrigger" are triggered if file is inside directory htdocs/core/triggers or htdocs/module/code/triggers (and declared) - * - * @param string $action Event action code - * @param Object $object Object - * @param User $user Object user - * @param Translate $langs Object langs - * @param conf $conf Object conf - * @return int <0 if KO, 0 if no triggered ran, >0 if OK - */ - public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) - { - // Mettre ici le code a executer en reaction de l'action - // Les donnees de l'action sont stockees dans $object - - if ($action == 'PAYPAL_PAYMENT_OK') - { - dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". source=".$object->source." ref=".$object->ref); - - if (! empty($object->source)) - { - if ($object->source == 'membersubscription') - { - //require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherents.class.php'; - - // TODO add subscription treatment - } - else - { - require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - - $soc = new Societe($this->db); - - // Parse element/subelement (ex: project_task) - $element = $path = $filename = $object->source; - if (preg_match('/^([^_]+)_([^_]+)/i',$object->source,$regs)) - { - $element = $path = $regs[1]; - $filename = $regs[2]; - } - // For compatibility - if ($element == 'order') { - $path = $filename = 'commande'; - } - if ($element == 'invoice') { - $path = 'compta/facture'; $filename = 'facture'; - } - - dol_include_once('/'.$path.'/class/'.$filename.'.class.php'); - - $classname = ucfirst($filename); - $obj = new $classname($this->db); - - $ret = $obj->fetch('',$object->ref); - if ($ret < 0) return -1; - - // Add payer id - $soc->setValueFrom('ref_int', $object->payerID, 'societe', $obj->socid); - - // Add transaction id - $obj->setValueFrom('ref_int',$object->resArray["TRANSACTIONID"]); - } - } - else - { - // TODO add free tag treatment - } - - } - - return 0; - } - -} diff --git a/htdocs/core/triggers/interface_20_modStripe_StripeWorkflow.class.php b/htdocs/core/triggers/interface_20_modStripe_StripeWorkflow.class.php deleted file mode 100644 index 4fbf29c7b07..00000000000 --- a/htdocs/core/triggers/interface_20_modStripe_StripeWorkflow.class.php +++ /dev/null @@ -1,113 +0,0 @@ - - * Copyright (C) 2014 Marcos García - * Copyright (C) 2017 Alexandre Spangaro - * - * 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 . - */ - -/** - * \file /htdocs/core/triggers/interface_20_modStripe_StripeWorkflow.class.php - * \ingroup stripe - * \brief Trigger file for stripe workflow - */ - -require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php'; - - -/** - * Class of triggers for stripe module - */ -class InterfaceStripeWorkflow extends DolibarrTriggers -{ - public $picto = 'stripe@stripe'; - public $family = 'stripe'; - public $description = "Triggers of this module allows to manage stripe workflow"; - public $version = self::VERSION_DOLIBARR; - - /** - * Function called when a Dolibarrr business event is done. - * All functions "runTrigger" are triggered if file is inside directory htdocs/core/triggers or htdocs/module/code/triggers (and declared) - * - * @param string $action Event action code - * @param Object $object Object - * @param User $user Object user - * @param Translate $langs Object langs - * @param conf $conf Object conf - * @return int <0 if KO, 0 if no triggered ran, >0 if OK - */ - public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf) - { - // Mettre ici le code a executer en reaction de l'action - // Les donnees de l'action sont stockees dans $object - - if ($action == 'STRIPE_PAYMENT_OK') - { - dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". source=".$object->source." ref=".$object->ref); - - if (! empty($object->source)) - { - if ($object->source == 'membersubscription') - { - //require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherents.class.php'; - - // TODO add subscription treatment - } - else - { - require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; - - $soc = new Societe($this->db); - - // Parse element/subelement (ex: project_task) - $element = $path = $filename = $object->source; - if (preg_match('/^([^_]+)_([^_]+)/i',$object->source,$regs)) - { - $element = $path = $regs[1]; - $filename = $regs[2]; - } - // For compatibility - if ($element == 'order') { - $path = $filename = 'commande'; - } - if ($element == 'invoice') { - $path = 'compta/facture'; $filename = 'facture'; - } - - dol_include_once('/'.$path.'/class/'.$filename.'.class.php'); - - $classname = ucfirst($filename); - $obj = new $classname($this->db); - - $ret = $obj->fetch('',$object->ref); - if ($ret < 0) return -1; - - // Add payer id - $soc->setValueFrom('ref_int', $object->payerID, 'societe', $obj->socid); - - // Add transaction id - $obj->setValueFrom('ref_int',$object->resArray["TRANSACTIONID"]); - } - } - else - { - // TODO add free tag treatment - } - - } - - return 0; - } - -} diff --git a/htdocs/paybox/admin/paybox.php b/htdocs/paybox/admin/paybox.php index 1a020ab86bf..ffbc2e41e0c 100644 --- a/htdocs/paybox/admin/paybox.php +++ b/htdocs/paybox/admin/paybox.php @@ -93,16 +93,22 @@ llxHeader(); $linkback=''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("PayBoxSetup"),$linkback,'title_setup'); -print $langs->trans("PayBoxDesc")."
\n"; +$h = 0; +$head = array(); + +$head[$h][0] = DOL_URL_ROOT."/paybox/admin/paybox.php"; +$head[$h][1] = $langs->trans("PayBox"); +$head[$h][2] = 'payboxaccount'; +$h++; -print '
'; print '
'; print ''; print ''; -dol_fiche_head(null, 'payboxaccount', ''); +dol_fiche_head($head, 'payboxaccount', '', -1); -$var=true; +print $langs->trans("PayBoxDesc")."
\n"; +print '
'; print ''; print ''; @@ -131,7 +137,6 @@ print 'trans("Test").')'; print ''; -$var=true; print ''; print ''; print ''; diff --git a/htdocs/paypal/admin/paypal.php b/htdocs/paypal/admin/paypal.php index ef0c40f2813..6d52fea8d99 100644 --- a/htdocs/paypal/admin/paypal.php +++ b/htdocs/paypal/admin/paypal.php @@ -121,7 +121,6 @@ print '
'; print '
'.$langs->trans("UsageParameter").''.$langs->trans("Value").'
'; // Account Parameters -$var=true; print ''; print ''; print ''; @@ -160,7 +159,6 @@ print $form->selectarray("PAYPAL_SSLVERSION",array('1'=> $langs->trans('TLSv1'), print ''; // Usage Parameters -$var=true; print ''; print ''; print ''; @@ -220,7 +218,6 @@ print ''; -$var=true; print ''; print ''; print ''; diff --git a/htdocs/public/paybox/paymentko.php b/htdocs/public/paybox/paymentko.php index 1d450a91af2..e417aad12c7 100644 --- a/htdocs/public/paybox/paymentko.php +++ b/htdocs/public/paybox/paymentko.php @@ -50,6 +50,7 @@ $langs->load("paypal"); $langs->load("stripe"); +$object = new stdClass(); // For triggers /* @@ -71,6 +72,14 @@ foreach($_POST as $k => $v) $tracepost .= "{$k} - {$v}\n"; dol_syslog("POST=".$tracepost, LOG_DEBUG, 0, '_paybox'); +// Appel des triggers +include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; +$interface=new Interfaces($db); +$result=$interface->run_triggers('PAYBOX_PAYMENT_OK',$object,$user,$langs,$conf); +if ($result < 0) { $error++; $errors=$interface->errors; } +// Fin appel triggers + + // Send an email if (! empty($conf->global->PAYBOX_PAYONLINE_SENDEMAIL)) { diff --git a/htdocs/public/paybox/paymentok.php b/htdocs/public/paybox/paymentok.php index 93d93a88cbe..5b88dcb65d7 100644 --- a/htdocs/public/paybox/paymentok.php +++ b/htdocs/public/paybox/paymentok.php @@ -60,6 +60,9 @@ $FULLTAG=GETPOST('FULLTAG'); if (empty($FULLTAG)) $FULLTAG=GETPOST('fulltag'); +$object = new stdClass(); // For triggers + + /* * Actions */ @@ -113,6 +116,7 @@ print $langs->trans("YourPaymentHasBeenRecorded")."

\n"; if (! empty($conf->global->PAYBOX_MESSAGE_OK)) print $conf->global->PAYBOX_MESSAGE_OK; + // Appel des triggers include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; $interface=new Interfaces($db); diff --git a/htdocs/public/payment/paymentko.php b/htdocs/public/payment/paymentko.php index ceface2a9c0..6ce1c3badfa 100644 --- a/htdocs/public/payment/paymentko.php +++ b/htdocs/public/payment/paymentko.php @@ -69,6 +69,9 @@ if (! empty($conf->paybox->enabled)) $validpaymentmethod['paybox']='paybox'; if (empty($validpaymentmethod)) accessforbidden('', 0, 0, 1); +$object = new stdClass(); // For triggers + + /* * Actions */ @@ -87,6 +90,14 @@ foreach($_POST as $k => $v) $tracepost .= "{$k} - {$v}\n"; dol_syslog("POST=".$tracepost, LOG_DEBUG, 0, '_payment'); +// Appel des triggers +include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; +$interface=new Interfaces($db); +$result=$interface->run_triggers('PAYMENTONLINE_PAYMENT_KO',$object,$user,$langs,$conf); +if ($result < 0) { $error++; $errors=$interface->errors; } +// Fin appel triggers + + // Send an email if (! empty($conf->paypal->enabled)) { diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index c138cc29267..c1b4329c7be 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -128,6 +128,9 @@ $PAYMENTSTATUS=$TRANSACTIONID=$TAXAMT=$NOTE=''; $ErrorCode=$ErrorShortMsg=$ErrorLongMsg=$ErrorSeverityCode=''; +$object = new stdClass(); // For triggers + + /* @@ -191,8 +194,6 @@ if (! empty($conf->paypal->enabled)) $ack = strtoupper($resArray["ACK"]); if ($ack=="SUCCESS" || $ack=="SUCCESSWITHWARNING") { - $object = new stdClass(); - $object->source = $source; $object->ref = $ref; $object->payerID = $payerID; @@ -244,11 +245,16 @@ if ($ispaymentok) print $langs->trans("ThisIsTransactionId",$TRANSACTIONID)."

\n"; if (! empty($conf->global->PAYMENT_MESSAGE_OK)) print $conf->global->PAYMENT_MESSAGE_OK; + $sendemail = ''; + if (! empty($conf->global->PAYMENTONLINE_SENDEMAIL)) $sendemail=$conf->global->PAYMENTONLINE_SENDEMAIL; + // TODO Remove local option to keep only the generic one ? + if ($paymentmethod == 'paypal' && ! empty($conf->global->PAYPAL_PAYONLINE_SENDEMAIL)) $sendemail=$conf->global->PAYPAL_PAYONLINE_SENDEMAIL; + if ($paymentmethod == 'paybox' && ! empty($conf->global->PAYBOX_PAYONLINE_SENDEMAIL)) $sendemail=$conf->global->PAYBOX_PAYONLINE_SENDEMAIL; // Send an email - if (! empty($conf->global->PAYMENTONLINE_SENDEMAIL)) + if ($sendemail) { - $sendto=$conf->global->PAYMENTONLINE_SENDEMAIL; + $sendto=$sendemail; $from=$conf->global->MAILING_EMAIL_FROM; // Define $urlwithroot $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); @@ -269,10 +275,11 @@ if ($ispaymentok) } else { - $content.=$langs->transnoentitiesnoconv("NewPaypalPaymentReceived")."
\n"; + $content.=$langs->transnoentitiesnoconv("NewOnlinePaymentReceived")."
\n"; } $content.="
\n"; $content.=$langs->transnoentitiesnoconv("TechnicalInformation").":
\n"; + $content.=$langs->transnoentitiesnoconv("PaymentSystem").': '.$paymentmethod."
\n"; $content.=$langs->transnoentitiesnoconv("ReturnURLAfterPayment").': '.$urlback."
\n"; $content.="tag=".$fulltag." token=".$token." paymentType=".$paymentType." currencycodeType=".$currencyCodeType." payerId=".$payerID." ipaddress=".$ipaddress." FinalPaymentAmt=".$FinalPaymentAmt; @@ -310,11 +317,16 @@ else if ($mysoc->email) print "\nPlease, send a screenshot of this page to ".$mysoc->email."
\n"; + $sendemail = ''; + if (! empty($conf->global->PAYMENTONLINE_SENDEMAIL)) $sendemail=$conf->global->PAYMENTONLINE_SENDEMAIL; + // TODO Remove local option to keep only the generic one ? + if ($paymentmethod == 'paypal' && ! empty($conf->global->PAYPAL_PAYONLINE_SENDEMAIL)) $sendemail=$conf->global->PAYPAL_PAYONLINE_SENDEMAIL; + if ($paymentmethod == 'paybox' && ! empty($conf->global->PAYBOX_PAYONLINE_SENDEMAIL)) $sendemail=$conf->global->PAYBOX_PAYONLINE_SENDEMAIL; // Send an email - if (! empty($conf->global->PAYMENTONLINE_SENDEMAIL)) + if ($sendemail) { - $sendto=$conf->global->PAYMENTONLINE_SENDEMAIL; + $sendto=$sendemail; $from=$conf->global->MAILING_EMAIL_FROM; // Define $urlwithroot $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); @@ -327,6 +339,7 @@ else $content.=$langs->transnoentitiesnoconv("PaypalConfirmPaymentPageWasCalledButFailed")."\n"; $content.="\n"; $content.=$langs->transnoentitiesnoconv("TechnicalInformation").":\n"; + $content.=$langs->transnoentitiesnoconv("PaymentSystem").': '.$paymentmethod."
\n"; $content.=$langs->transnoentitiesnoconv("ReturnURLAfterPayment").': '.$urlback."\n"; $content.="tag=".$fulltag."\ntoken=".$token." paymentType=".$paymentType." currencycodeType=".$currencyCodeType." payerId=".$payerID." ipaddress=".$ipaddress." FinalPaymentAmt=".$FinalPaymentAmt; diff --git a/htdocs/public/paypal/paymentko.php b/htdocs/public/paypal/paymentko.php index 0bc3c9ca9e6..2d3c67beecb 100644 --- a/htdocs/public/paypal/paymentko.php +++ b/htdocs/public/paypal/paymentko.php @@ -61,6 +61,9 @@ $FULLTAG=GETPOST('FULLTAG'); if (empty($FULLTAG)) $FULLTAG=GETPOST('fulltag'); +$object = new stdClass(); // For triggers + + /* * Actions */ @@ -79,6 +82,14 @@ foreach($_POST as $k => $v) $tracepost .= "{$k} - {$v}\n"; dol_syslog("POST=".$tracepost, LOG_DEBUG, 0, '_paypal'); +// Appel des triggers +include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; +$interface=new Interfaces($db); +$result=$interface->run_triggers('PAYPAL_PAYMENT_KO',$object,$user,$langs,$conf); +if ($result < 0) { $error++; $errors=$interface->errors; } +// Fin appel triggers + + // Send an email if (! empty($conf->global->PAYPAL_PAYONLINE_SENDEMAIL)) { diff --git a/htdocs/public/paypal/paymentok.php b/htdocs/public/paypal/paymentok.php index ca6a376e60d..ddb779d621e 100644 --- a/htdocs/public/paypal/paymentok.php +++ b/htdocs/public/paypal/paymentok.php @@ -92,6 +92,9 @@ $FULLTAG=GETPOST('FULLTAG'); if (empty($FULLTAG)) $FULLTAG=GETPOST('fulltag'); +$object = new stdClass(); // For triggers + + /* * Actions */ @@ -151,8 +154,6 @@ if ($PAYPALTOKEN) $ack = strtoupper($resArray["ACK"]); if($ack=="SUCCESS" || $ack=="SUCCESSWITHWARNING") { - $object = new stdClass(); - $object->source = $source; $object->ref = $ref; $object->payerID = $payerID; @@ -226,7 +227,14 @@ if ($PAYPALTOKEN) } else { - //Display a user friendly Error on the page using any of the following error information returned by PayPal + // Appel des triggers + include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; + $interface=new Interfaces($db); + $result=$interface->run_triggers('PAYPAL_PAYMENT_KO',$object,$user,$langs,$conf); + if ($result < 0) { $error++; $errors=$interface->errors; } + // Fin appel triggers + + //Display a user friendly Error on the page using any of the following error information returned by PayPal $ErrorCode = urldecode($resArray["L_ERRORCODE0"]); $ErrorShortMsg = urldecode($resArray["L_SHORTMESSAGE0"]); $ErrorLongMsg = urldecode($resArray["L_LONGMESSAGE0"]);
'.$langs->trans("AccountParameter").''.$langs->trans("Value").'
'.$langs->trans("UsageParameter").''.$langs->trans("Value").'
'.$langs->trans("UrlGenerationParameters").''.$langs->trans("Value").'