diff --git a/htdocs/adherents/adherent.class.php b/htdocs/adherents/adherent.class.php index 0a4d04eb851..10146e85b91 100644 --- a/htdocs/adherents/adherent.class.php +++ b/htdocs/adherents/adherent.class.php @@ -260,12 +260,12 @@ class Adherent extends CommonObject global $conf,$langs; // Check parameters - if ($conf->global->ADHERENT_MAIL_REQUIRED && ! ValidEMail($this->email)) + if ($conf->global->ADHERENT_MAIL_REQUIRED && ! isValidEMail($this->email)) { $this->error = $langs->trans("ErrorBadEMail",$this->email); return -1; } - if (! $this->datec) $this->datec=time(); + if (! $this->datec) $this->datec=gmmktime(); $this->db->begin(); @@ -352,7 +352,7 @@ class Adherent extends CommonObject dol_syslog("Adherent::update notrigger=".$notrigger.", nosyncuser=".$nosyncuser.", email=".$this->email); // Verification parametres - if ($conf->global->ADHERENT_MAIL_REQUIRED && ! ValidEMail($this->email)) + if ($conf->global->ADHERENT_MAIL_REQUIRED && ! isValidEMail($this->email)) { $this->error = $langs->trans("ErrorBadEMail",$this->email); return -1; diff --git a/htdocs/adherents/fiche.php b/htdocs/adherents/fiche.php index d70270b8fcb..42b75bc0d4f 100644 --- a/htdocs/adherents/fiche.php +++ b/htdocs/adherents/fiche.php @@ -320,7 +320,7 @@ if ($user->rights->adherent->creer && $_POST["action"] == 'add') $error++; $errmsg .= $langs->trans("ErrorFieldRequired",$langs->transnoentities("Firstname"))."
\n"; } - if ($conf->global->ADHERENT_MAIL_REQUIRED && ! ValidEMail($email)) { + if ($conf->global->ADHERENT_MAIL_REQUIRED && ! isValidEMail($email)) { $error++; $errmsg .= $langs->trans("ErrorBadEMail",$email)."
\n"; } diff --git a/htdocs/comm/addpropal.php b/htdocs/comm/addpropal.php index 9f3a64216af..dabde8b5310 100644 --- a/htdocs/comm/addpropal.php +++ b/htdocs/comm/addpropal.php @@ -49,7 +49,7 @@ $langs->load("deliveries"); llxHeader(); -print_titre($langs->trans("NewProp")); +print_fiche_titre($langs->trans("NewProp")); $html=new Form($db); @@ -164,7 +164,7 @@ if ($_GET["action"] == 'create') } else { - $datepropal=empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0; + $datepropal=empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0; $html->select_date($datepropal,'liv_','','','',"addprop"); } print ''; @@ -212,40 +212,49 @@ if ($_GET["action"] == 'create') /* * Combobox pour la fonction de copie */ + print ''; - print ''; - print ''; - print ''; - print ''; } else { - dol_print_error($db); + // For backward compatibility + print ''; + print ''; + print ''; + print ''; + + if ($conf->global->PRODUCT_SHOW_WHEN_CREATE) print ''; + + print ''; + print ''; } - print ''; - - if ($conf->global->PRODUCT_SHOW_WHEN_CREATE) print ''; - - print ''; - print ''; if ($conf->global->PRODUCT_SHOW_WHEN_CREATE) { diff --git a/htdocs/includes/modules/mailings/peche.modules.php b/htdocs/includes/modules/mailings/peche.modules.php index 183303db12a..98114d6831f 100644 --- a/htdocs/includes/modules/mailings/peche.modules.php +++ b/htdocs/includes/modules/mailings/peche.modules.php @@ -145,7 +145,7 @@ class mailing_peche extends MailingTargets { //print 'xx'.strlen($buffer).empty($buffer)."
\n"; $id=$cpt; - if (ValidEMail($email)) + if (isValidEMail($email)) { if ($old <> $email) { diff --git a/htdocs/langs/fr_FR/propal.lang b/htdocs/langs/fr_FR/propal.lang index eb357d655ff..0b4fc5ece26 100644 --- a/htdocs/langs/fr_FR/propal.lang +++ b/htdocs/langs/fr_FR/propal.lang @@ -71,7 +71,7 @@ Estimate=Devis : EstimateShort=Devis OtherPropals=Autres propositions CopyPropalFrom=Créer proposition/devis par recopie d'un proposition existante -CreateEmptyPropal=Créer proposition/devis vierge ou depuis liste de produits prédéfinis +CreateEmptyPropal=Créer proposition/devis vierge DefaultProposalDurationValidity=Délai de validité par défaut (en jours) UseCustomerContactAsPropalRecipientIfExist=Utiliser adresse contact suivi client si défini plutot que adresse tiers comme destinataire des propositions ClonePropal=Cloner proposition commerciale diff --git a/htdocs/lib/functions2.lib.php b/htdocs/lib/functions2.lib.php index c5afab7aa3c..12eafbe9659 100644 --- a/htdocs/lib/functions2.lib.php +++ b/htdocs/lib/functions2.lib.php @@ -118,14 +118,15 @@ function dol_print_object_info($object) /** * \brief Return true if email syntax is ok * \param address email (Ex: "toto@titi.com", "John Do ") - * \return boolean true if email ok, false if ko + * \return boolean true if email syntax is OK, false if KO */ -function ValidEmail($address) +function isValidEmail($address) { if (eregi(".*<(.+)>", $address, $regs)) { $address = $regs[1]; } - if (eregi("^[^@ ]+@([a-zA-Z0-9\-]+\.)+([a-zA-Z0-9\-]{2}|asso|aero|biz|com|coop|edu|gov|info|int|mil|name|net|org|pro)\$",$address)) + // 3 letters domains extensions: biz|com|edu|gov|int|mil|net|org|pro + if (eregi("^[^@ ]+@([a-zA-Z0-9\-]+\.)+([a-zA-Z0-9\-]{2,3}|asso|aero|coop|info|name)\$",$address)) { return true; } @@ -136,11 +137,11 @@ function ValidEmail($address) } /** - * \brief Renvoi vrai si l'email a un nom de domaine qui r�soud via dns + * \brief Return true if email has a domain name that can't be resolved * \param mail adresse email (Ex: "toto@titi.com", "John Do ") - * \return boolean true si email valide, false sinon + * \return boolean true if domain email is OK, false if KO */ -function CheckMailDomain($mail) +function isValidMailDomain($mail) { list($user, $domain) = split("@", $mail, 2); if (checkdnsrr($domain, "MX")) @@ -153,6 +154,7 @@ function CheckMailDomain($mail) } } + /** * \brief Return lines of an html table from an array * \remarks Used by array2table function only diff --git a/htdocs/public/paybox/newpayment.php b/htdocs/public/paybox/newpayment.php index ac857c23f67..2383ed051c3 100644 --- a/htdocs/public/paybox/newpayment.php +++ b/htdocs/public/paybox/newpayment.php @@ -83,10 +83,10 @@ if ($_REQUEST["action"] == 'dopayment') $ID=$_REQUEST["id"]; $mesg=''; - if (empty($PRICE)) $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Amount")); - elseif (empty($EMAIL)) $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("YourEMail")); - elseif (! ValidEMail($EMAIL)) $mesg=$langs->trans("ErrorBadEMail",$EMAIL); - elseif (empty($TAG)) $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("PaymentCode")); + if (empty($PRICE)) $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Amount")); + elseif (empty($EMAIL)) $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("YourEMail")); + elseif (! isValidEMail($EMAIL)) $mesg=$langs->trans("ErrorBadEMail",$EMAIL); + elseif (empty($TAG)) $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("PaymentCode")); if (empty($mesg)) { diff --git a/htdocs/soc.php b/htdocs/soc.php index bbd123c01b0..6513b2121bc 100644 --- a/htdocs/soc.php +++ b/htdocs/soc.php @@ -63,9 +63,11 @@ if ($_POST["getsuppliercode"]) $_POST["code_fournisseur"]="aa"; } +// Add new third party if ((! $_POST["getcustomercode"] && ! $_POST["getsuppliercode"]) && ($_POST["action"] == 'add' || $_POST["action"] == 'update') && $user->rights->societe->creer) { + require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php"); $error=0; if ($_REQUEST["private"] == 1) @@ -88,7 +90,7 @@ if ((! $_POST["getcustomercode"] && ! $_POST["getsuppliercode"]) $soc->departement_id = $_POST["departement_id"]; $soc->tel = $_POST["tel"]; $soc->fax = $_POST["fax"]; - $soc->email = $_POST["email"]; + $soc->email = trim($_POST["email"]); $soc->url = $_POST["url"]; $soc->siren = $_POST["idprof1"]; $soc->siret = $_POST["idprof2"]; @@ -109,7 +111,7 @@ if ((! $_POST["getcustomercode"] && ! $_POST["getsuppliercode"]) $soc->effectif_id = $_POST["effectif_id"]; if ($_REQUEST["private"] == 1) { - $soc->typent_id = 8; //todo prévoir autre méthode si le champs "particulier" change de rowid + $soc->typent_id = 8; // TODO prévoir autre méthode si le champs "particulier" change de rowid } else { @@ -121,12 +123,22 @@ if ((! $_POST["getcustomercode"] && ! $_POST["getsuppliercode"]) $soc->commercial_id = $_POST["commercial_id"]; + # A virer +print 'ttt'.$soc->email.isValidEMail($soc->email).$_POST["action"]; +exit; + // Check parameters + if (! empty($soc->email) && ! isValidEMail($soc->email)) + { + $error = 1; + $soc->error = $langs->trans("ErrorBadEMail",$soc->email); + $_GET["action"]= $_POST["action"]=='add'?'add':'edit'; + } if ($soc->fournisseur && ! $conf->fournisseur->enabled) { $error = 1; $soc->error = $langs->trans("ErrorSupplierModuleNotEnabled"); - $_GET["action"]= "create"; + $_GET["action"]= $_POST["action"]=='add'?'add':'edit'; } if (! $error) diff --git a/htdocs/societe.class.php b/htdocs/societe.class.php index 01261d527f5..90d5da7e0b3 100644 --- a/htdocs/societe.class.php +++ b/htdocs/societe.class.php @@ -138,7 +138,7 @@ class Societe extends CommonObject { global $langs,$conf; - // clean parameters + // Clean parameters $this->nom=trim($this->nom); dol_syslog("Societe::create ".$this->nom); diff --git a/htdocs/telephonie/client/new.php b/htdocs/telephonie/client/new.php index bfbd08e8943..8842f9d5887 100644 --- a/htdocs/telephonie/client/new.php +++ b/htdocs/telephonie/client/new.php @@ -133,13 +133,13 @@ if ($_POST["action"] == 'add') $verif = "nok"; } - if (!ValidEmail(trim($contact->email)) && $verif == 'ok') + if (! isValidEmail(trim($contact->email)) && $verif == 'ok') { $mesg = "Email invalide"; $verif = "nok"; } - if (!CheckMailDomain(trim($contact->email)) && $verif == 'ok') + if (! isValidMailDomain(trim($contact->email)) && $verif == 'ok') { $mesg = "Email invalide (domaine invalide)"; $verif = "nok";
'.$langs->trans("CopyPropalFrom").' '; - $liste_propal = array(); - $liste_propal[0] = ''; - $sql ="SELECT p.rowid as id, p.ref, s.nom"; - $sql.=" FROM ".MAIN_DB_PREFIX."propal p, ".MAIN_DB_PREFIX."societe s"; - $sql.=" WHERE s.rowid = p.fk_soc AND fk_statut <> 0 ORDER BY Id"; - $resql = $db->query($sql); - if ($resql) + if (empty($conf->global->PROPAL_CLONE_ON_CREATE_PAGE)) { - $num = $db->num_rows($resql); - $i = 0; - while ($i < $num) - { - $row = $db->fetch_row($resql); - $propalRefAndSocName = $row[1]." - ".$row[2]; - $liste_propal[$row[0]]=$propalRefAndSocName; - $i++; - } - $html->select_array("copie_propal",$liste_propal, 0); + print '
'.$langs->trans("CopyPropalFrom").' '; + $liste_propal = array(); + $liste_propal[0] = ''; + $sql ="SELECT p.rowid as id, p.ref, s.nom"; + $sql.=" FROM ".MAIN_DB_PREFIX."propal p, ".MAIN_DB_PREFIX."societe s"; + $sql.=" WHERE s.rowid = p.fk_soc AND fk_statut <> 0 ORDER BY Id"; + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; + while ($i < $num) + { + $row = $db->fetch_row($resql); + $propalRefAndSocName = $row[1]." - ".$row[2]; + $liste_propal[$row[0]]=$propalRefAndSocName; + $i++; + } + $html->select_array("copie_propal",$liste_propal, 0); + } + else + { + dol_print_error($db); + } + print '
 
'.$langs->trans("CreateEmptyPropal").'
 
'.$langs->trans("CreateEmptyPropal").'