Fix: Bad error management when validating member

This commit is contained in:
Laurent Destailleur 2012-10-22 00:18:32 +02:00
parent bba5057d5d
commit 732b3ceace
3 changed files with 27 additions and 10 deletions

View File

@ -200,8 +200,6 @@ if (! empty($conf->global->ADHERENT_USE_MAILMAN))
print '*'.$langs->trans("FollowingConstantsWillBeSubstituted").'<br>'; print '*'.$langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
print '%LISTE%, %MAILMAN_ADMINPW%, %EMAIL% <br>'; print '%LISTE%, %MAILMAN_ADMINPW%, %EMAIL% <br>';
print '<br>';
} }
else else
{ {

View File

@ -1377,6 +1377,7 @@ class Adherent extends CommonObject
$result=$mailmanspip->add_to_mailman($this); $result=$mailmanspip->add_to_mailman($this);
if ($result < 0) if ($result < 0)
{ {
$this->error=$mailmanspip->error;
$err+=1; $err+=1;
} }
} }
@ -1387,7 +1388,8 @@ class Adherent extends CommonObject
$result=$mailmanspip->add_to_spip($this); $result=$mailmanspip->add_to_spip($this);
if ($result < 0) if ($result < 0)
{ {
$err+=1; $this->error=$mailmanspip->error;
$err+=1;
} }
} }
if ($err) if ($err)

View File

@ -578,36 +578,53 @@ if ($user->rights->adherent->supprimer && $action == 'confirm_delete' && $confir
if ($user->rights->adherent->creer && $action == 'confirm_valid' && $confirm == 'yes') if ($user->rights->adherent->creer && $action == 'confirm_valid' && $confirm == 'yes')
{ {
$result=$object->validate($user); $error=0;
$db->begin();
$adht = new AdherentType($db); $adht = new AdherentType($db);
$adht->fetch($object->typeid); $adht->fetch($object->typeid);
$result=$object->validate($user);
if ($result >= 0 && ! count($object->errors)) if ($result >= 0 && ! count($object->errors))
{ {
// Send confirmation Email (selon param du type adherent sinon generique) // 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); $result=$object->send_an_email($adht->getMailOnValid(),$conf->global->ADHERENT_MAIL_VALID_SUBJECT,array(),array(),array(),"","",0,2);
if ($result < 0) if ($result < 0)
{ {
$error++;
$errmsg.=$object->error; $errmsg.=$object->error;
} }
} }
// Rajoute l'utilisateur dans les divers abonnements (mailman, spip, etc...) // Add user to other systems (mailman, spip, etc...)
if ($object->add_to_abo() < 0) // TODO Move this into trigger on validate action
if (! $error && $object->add_to_abo() < 0)
{ {
// error $langs->load("errors");
$errmsg.= $langs->trans("ErrorFailedToAddToMailmanList").': '.$object->error."<br>\n"; $error++;
$errmsg.= $langs->trans("ErrorFailedToAddToMailmanList").': '.$object->error." ".join(',',$object->errors)."<br>\n";
} }
} }
else else
{ {
$error++;
if ($object->error) $errmsg=$object->error; if ($object->error) $errmsg=$object->error;
else $errmsgs=$object->errors; else $errmsgs=$object->errors;
$action='';
} }
if (! $error)
{
$db->commit();
}
else
{
$db->rollback();
}
$action='';
} }
if ($user->rights->adherent->supprimer && $action == 'confirm_resign') if ($user->rights->adherent->supprimer && $action == 'confirm_resign')