From 257a6a49bf2f438231df38bcbac6638decc6a025 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@users.sourceforge.net>
Date: Thu, 8 Oct 2009 21:49:55 +0000
Subject: [PATCH] Fix: Option to enable mail sending by default works
 correctly.

---
 htdocs/adherents/fiche.php    | 4 ++--
 htdocs/html.form.class.php    | 6 ++++--
 htdocs/langs/en_US/admin.lang | 2 +-
 htdocs/langs/fr_FR/admin.lang | 2 +-
 4 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/htdocs/adherents/fiche.php b/htdocs/adherents/fiche.php
index 6eb64f1eae1..d57b37c57ce 100644
--- a/htdocs/adherents/fiche.php
+++ b/htdocs/adherents/fiche.php
@@ -1003,7 +1003,7 @@ if ($rowid && $action != 'edit')
     {
 		// Cree un tableau formulaire
 		$formquestion=array();
-		if ($adh->email) $formquestion[0]=array('type' => 'checkbox', 'name' => 'send_mail', 'label' => $langs->trans("SendAnEMailToMember",$adh->email),  'value' => 'true');
+		if ($adh->email) $formquestion[0]=array('type' => 'checkbox', 'name' => 'send_mail', 'label' => $langs->trans("SendAnEMailToMember",$adh->email),  'value' => ($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL?true:false));
 
         $ret=$html->form_confirm("fiche.php?rowid=$rowid",$langs->trans("ValidateMember"),$langs->trans("ConfirmValidateMember"),"confirm_valid",$formquestion);
         if ($ret == 'html') print '<br>';
@@ -1209,7 +1209,7 @@ if ($rowid && $action != 'edit')
      */
     print '<div class="tabsAction">';
 
-    if ($action != 'editlogin' && $action != 'editthirdparty')
+    if ($action != 'valid' && $action != 'editlogin' && $action != 'editthirdparty')
     {
 	    // Modify
 		if ($user->rights->adherent->creer)
diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php
index cec34b94e0f..e7d379eb588 100644
--- a/htdocs/html.form.class.php
+++ b/htdocs/html.form.class.php
@@ -184,7 +184,7 @@ class Form
 		{
 			if ($type == 'info' || $type == 'help') return $text;
 		}
-		// Info or help	
+		// Info or help
 		if ($type == 'info') 				$img=img_help(0,$alt);
 		if ($type == 'help' || $type ==1)	$img=img_help(1,$alt);
 		if ($type == 'superadmin') 			$img=img_redstar($alt);
@@ -1641,7 +1641,9 @@ class Form
 					$more.='<tr>';
 					$more.='<td valign="top">'.$input['label'].' &nbsp;';
 					$more.='<input type="checkbox" class="flat" name="'.$input['name'].'"';
-					if ($input['value'] != 'false') $more.=' checked="true"';
+					//print 'xx'.$input['value'].'-'.!empty($input['value']).'-'.($input['value'] != 'false');
+					if (! is_bool($input['value']) && $input['value'] != 'false') $more.=' checked="true"';
+					if (is_bool($input['value']) && $input['value']) $more.=' checked="true"';
 					if ($input['disabled']) $more.=' disabled="true"';
 					$more.='></td>';
 					$more.='<td valign="top" align="left">&nbsp;</td>';
diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang
index f4e210c06f9..de41df9468a 100644
--- a/htdocs/langs/en_US/admin.lang
+++ b/htdocs/langs/en_US/admin.lang
@@ -821,7 +821,7 @@ MembersSetup=Members module setup
 MemberMainOptions=Main options
 AddSubscriptionIntoAccount=Add subscriptions into bank or cash account, of bank module
 AdherentMailRequired=EMail required to create a new member
-MemberSendInformationByMailByDefault=Checkbox to send mail confirmation to members is on by default
+MemberSendInformationByMailByDefault=Checkbox to send mail confirmation to members (validation or new subscription) is on by default
 ##### LDAP setup #####
 LDAPSetup=LDAP Setup
 LDAPGlobalParameters=Global parameters
diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang
index ac12b163622..82549e6a283 100644
--- a/htdocs/langs/fr_FR/admin.lang
+++ b/htdocs/langs/fr_FR/admin.lang
@@ -821,7 +821,7 @@ MembersSetup = Configuration du module Adhérents
 MemberMainOptions = Options principales
 AddSubscriptionIntoAccount = Enregistrer cotisations dans compte bancaire ou caisse, du module banque
 AdherentMailRequired = EMail obligatoire pour créer un nouvel adhérent
-MemberSendInformationByMailByDefault = Case à cocher pour envoyer mail de confirmation aux adhérents est à oui par défaut
+MemberSendInformationByMailByDefault = Case à cocher pour envoyer mail de confirmation (validation ou nouvelle cotisation) aux adhérents est à oui par défaut
 ##### LDAP setup ##### = undefined
 LDAPSetup = Configuration du module LDAP
 LDAPGlobalParameters = Paramètres globals
-- 
GitLab