From 732b3ceace29ce4cb98b306e0fab271f4ee9d62e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 22 Oct 2012 00:18:32 +0200 Subject: [PATCH] Fix: Bad error management when validating member --- htdocs/adherents/admin/mailman.php | 2 -- htdocs/adherents/class/adherent.class.php | 4 ++- htdocs/adherents/fiche.php | 31 ++++++++++++++++++----- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/htdocs/adherents/admin/mailman.php b/htdocs/adherents/admin/mailman.php index b3169c721f2..b08fb0bdeb5 100644 --- a/htdocs/adherents/admin/mailman.php +++ b/htdocs/adherents/admin/mailman.php @@ -200,8 +200,6 @@ if (! empty($conf->global->ADHERENT_USE_MAILMAN)) print '*'.$langs->trans("FollowingConstantsWillBeSubstituted").'
'; print '%LISTE%, %MAILMAN_ADMINPW%, %EMAIL%
'; - - print '
'; } else { diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index c9f4a3de738..5709fcb7647 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -1377,6 +1377,7 @@ class Adherent extends CommonObject $result=$mailmanspip->add_to_mailman($this); if ($result < 0) { + $this->error=$mailmanspip->error; $err+=1; } } @@ -1387,7 +1388,8 @@ class Adherent extends CommonObject $result=$mailmanspip->add_to_spip($this); if ($result < 0) { - $err+=1; + $this->error=$mailmanspip->error; + $err+=1; } } if ($err) diff --git a/htdocs/adherents/fiche.php b/htdocs/adherents/fiche.php index c7daca76a6f..4807c408d9b 100644 --- a/htdocs/adherents/fiche.php +++ b/htdocs/adherents/fiche.php @@ -578,36 +578,53 @@ if ($user->rights->adherent->supprimer && $action == 'confirm_delete' && $confir if ($user->rights->adherent->creer && $action == 'confirm_valid' && $confirm == 'yes') { - $result=$object->validate($user); + $error=0; + + $db->begin(); $adht = new AdherentType($db); $adht->fetch($object->typeid); + $result=$object->validate($user); + if ($result >= 0 && ! count($object->errors)) { // Send confirmation Email (selon param du type adherent sinon generique) - if ($object->email && $_POST["send_mail"]) + if ($object->email && ! empty($_POST["send_mail"])) { $result=$object->send_an_email($adht->getMailOnValid(),$conf->global->ADHERENT_MAIL_VALID_SUBJECT,array(),array(),array(),"","",0,2); if ($result < 0) { + $error++; $errmsg.=$object->error; } } - // Rajoute l'utilisateur dans les divers abonnements (mailman, spip, etc...) - if ($object->add_to_abo() < 0) + // Add user to other systems (mailman, spip, etc...) + // TODO Move this into trigger on validate action + if (! $error && $object->add_to_abo() < 0) { - // error - $errmsg.= $langs->trans("ErrorFailedToAddToMailmanList").': '.$object->error."
\n"; + $langs->load("errors"); + $error++; + $errmsg.= $langs->trans("ErrorFailedToAddToMailmanList").': '.$object->error." ".join(',',$object->errors)."
\n"; } } else { + $error++; if ($object->error) $errmsg=$object->error; else $errmsgs=$object->errors; - $action=''; } + + if (! $error) + { + $db->commit(); + } + else + { + $db->rollback(); + } + $action=''; } if ($user->rights->adherent->supprimer && $action == 'confirm_resign')