From bad970ff05b204347eebb27434460567b1b5db72 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Thu, 29 Mar 2018 15:04:48 +0200 Subject: [PATCH 1/5] cleaning code --- htdocs/adherents/index.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/htdocs/adherents/index.php b/htdocs/adherents/index.php index fd418756bd6..c9e3d1936c6 100644 --- a/htdocs/adherents/index.php +++ b/htdocs/adherents/index.php @@ -48,9 +48,6 @@ $subscriptionstatic=new Subscription($db); print load_fiche_titre($langs->trans("MembersArea")); - -$var=True; - $Adherents=array(); $AdherentsAValider=array(); $MemberUpToDate=array(); @@ -255,7 +252,6 @@ print ''.$langs->trans("AmountTotal").''; print ''.$langs->trans("AmountAverage").''; print "\n"; -$var=true; krsort($Total); foreach ($Total as $key=>$value) { From c4ce543294990de298ee3107e104b6f8880737ef Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 29 Mar 2018 18:30:31 +0200 Subject: [PATCH 2/5] Fix: backward compatibility --- htdocs/core/class/commonobject.class.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 5bdc58cc61a..5d6ecfd1dfc 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1428,19 +1428,22 @@ abstract class CommonObject if (empty($format)) $format='text'; if (empty($id_field)) $id_field='rowid'; + $fk_user_field = 'fk_user_modif'; + $error=0; $this->db->begin(); // Special case if ($table == 'product' && $field == 'note_private') $field='note'; + if ($table == 'adherent') $fk_user_field = 'fk_user_mod'; $sql = "UPDATE ".MAIN_DB_PREFIX.$table." SET "; if ($format == 'text') $sql.= $field." = '".$this->db->escape($value)."'"; else if ($format == 'int') $sql.= $field." = ".$this->db->escape($value); else if ($format == 'date') $sql.= $field." = ".($value ? "'".$this->db->idate($value)."'" : "null"); - if (! empty($fuser) && is_object($fuser)) $sql.=", fk_user_modif = ".$fuser->id; - elseif (empty($fuser) || $fuser != 'none') $sql.=", fk_user_modif = ".$user->id; + if (! empty($fuser) && is_object($fuser)) $sql.=", ".$fk_user_field." = ".$fuser->id; + elseif (empty($fuser) || $fuser != 'none') $sql.=", ".$fk_user_field." = ".$user->id; $sql.= " WHERE ".$id_field." = ".$id; dol_syslog(get_class($this)."::".__FUNCTION__."", LOG_DEBUG); From 38912d6918a597c3a4b223ca22a2444066425f9c Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 29 Mar 2018 18:36:51 +0200 Subject: [PATCH 3/5] Fix: more complete --- htdocs/core/class/commonobject.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 5d6ecfd1dfc..a438830af17 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1436,7 +1436,9 @@ abstract class CommonObject // Special case if ($table == 'product' && $field == 'note_private') $field='note'; - if ($table == 'adherent') $fk_user_field = 'fk_user_mod'; + if (in_array($table, array('actioncomm', 'adherent', 'advtargetemailing', 'cronjob', 'establishment'))) { + $fk_user_field = 'fk_user_mod'; + } $sql = "UPDATE ".MAIN_DB_PREFIX.$table." SET "; if ($format == 'text') $sql.= $field." = '".$this->db->escape($value)."'"; From 546f3f8b96c79c3aacde02ea752b3ca7510cbe9f Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 30 Mar 2018 07:19:42 +0200 Subject: [PATCH 4/5] Fix: avoid space in email address --- htdocs/adherents/card.php | 6 +++--- htdocs/user/card.php | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index a223d4b35ba..6f215e4ca14 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -2,7 +2,7 @@ /* Copyright (C) 2001-2004 Rodolphe Quiedeville * Copyright (C) 2002-2003 Jean-Louis Bergamo * Copyright (C) 2004-2012 Laurent Destailleur - * Copyright (C) 2005-2017 Regis Houssin + * Copyright (C) 2005-2018 Regis Houssin * Copyright (C) 2012 Marcos GarcĂ­a * Copyright (C) 2012-2016 Philippe Grand * Copyright (C) 2015-2016 Alexandre Spangaro @@ -301,7 +301,7 @@ if (empty($reshook)) $object->phone = trim(GETPOST("phone",'alpha')); $object->phone_perso = trim(GETPOST("phone_perso",'alpha')); $object->phone_mobile= trim(GETPOST("phone_mobile",'alpha')); - $object->email = trim(GETPOST("member_email",'alpha')); + $object->email = trim(str_replace(' ','',GETPOST("member_email",'alpha'))); $object->skype = trim(GETPOST("skype",'alpha')); $object->birth = $birthdate; @@ -445,7 +445,7 @@ if (empty($reshook)) $phone_perso=GETPOST("phone_perso",'alpha'); $phone_mobile=GETPOST("phone_mobile",'alpha'); $skype=GETPOST("member_skype",'alpha'); - $email=GETPOST("member_email",'alpha'); + $email=str_replace(' ','',GETPOST("member_email",'alpha')); $login=GETPOST("member_login",'alpha'); $pass=GETPOST("password",'alpha'); $photo=GETPOST("photo",'alpha'); diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 8eda5d47d97..f4437ddc2c2 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -3,7 +3,7 @@ * Copyright (C) 2002-2003 Jean-Louis Bergamo * Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2005-2017 Regis Houssin + * Copyright (C) 2005-2018 Regis Houssin * Copyright (C) 2005 Lionel Cousteix * Copyright (C) 2011 Herve Prot * Copyright (C) 2012 Juanjo Menent @@ -50,7 +50,7 @@ if (! empty($conf->categorie->enabled)) require_once DOL_DOCUMENT_ROOT.'/categor $id = GETPOST('id','int'); $action = GETPOST('action','aZ09'); $mode = GETPOST('mode','alpha'); -$confirm = GETPOST('confirm','alpha'); +$confirm = GETPOST('confirm','alpha'); $subaction = GETPOST('subaction','alpha'); $group = GETPOST("group","int",3); $cancel = GETPOST('cancel','alpha'); @@ -203,7 +203,7 @@ if (empty($reshook)) { $object->office_fax = GETPOST("office_fax", 'alpha'); $object->user_mobile = GETPOST("user_mobile"); $object->skype = GETPOST("skype", 'alpha'); - $object->email = GETPOST("email", 'alpha'); + $object->email = str_replace(' ','',GETPOST("email", 'alpha')); $object->job = GETPOST("job", 'alpha'); $object->signature = GETPOST("signature"); $object->accountancy_code = GETPOST("accountancy_code"); @@ -347,7 +347,7 @@ if (empty($reshook)) { $object->office_fax = GETPOST("office_fax", 'alpha'); $object->user_mobile = GETPOST("user_mobile"); $object->skype = GETPOST("skype", 'alpha'); - $object->email = GETPOST("email", 'alpha'); + $object->email = str_replace(' ','',GETPOST("email", 'alpha')); $object->job = GETPOST("job", 'alpha'); $object->signature = GETPOST("signature"); $object->accountancy_code = GETPOST("accountancy_code"); From 8c610904acbdf8660a347fdcbe18f0f665a10c78 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 30 Mar 2018 07:36:23 +0200 Subject: [PATCH 5/5] Fix: remove multi spaces --- htdocs/adherents/card.php | 4 ++-- htdocs/user/card.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 6f215e4ca14..0eaa3efff8f 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -301,7 +301,7 @@ if (empty($reshook)) $object->phone = trim(GETPOST("phone",'alpha')); $object->phone_perso = trim(GETPOST("phone_perso",'alpha')); $object->phone_mobile= trim(GETPOST("phone_mobile",'alpha')); - $object->email = trim(str_replace(' ','',GETPOST("member_email",'alpha'))); + $object->email = preg_replace('/\s+/', '', GETPOST("member_email",'alpha')); $object->skype = trim(GETPOST("skype",'alpha')); $object->birth = $birthdate; @@ -445,7 +445,7 @@ if (empty($reshook)) $phone_perso=GETPOST("phone_perso",'alpha'); $phone_mobile=GETPOST("phone_mobile",'alpha'); $skype=GETPOST("member_skype",'alpha'); - $email=str_replace(' ','',GETPOST("member_email",'alpha')); + $email=preg_replace('/\s+/', '', GETPOST("member_email",'alpha')); $login=GETPOST("member_login",'alpha'); $pass=GETPOST("password",'alpha'); $photo=GETPOST("photo",'alpha'); diff --git a/htdocs/user/card.php b/htdocs/user/card.php index f4437ddc2c2..9f713cfb920 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -203,7 +203,7 @@ if (empty($reshook)) { $object->office_fax = GETPOST("office_fax", 'alpha'); $object->user_mobile = GETPOST("user_mobile"); $object->skype = GETPOST("skype", 'alpha'); - $object->email = str_replace(' ','',GETPOST("email", 'alpha')); + $object->email = preg_replace('/\s+/', '', GETPOST("email", 'alpha')); $object->job = GETPOST("job", 'alpha'); $object->signature = GETPOST("signature"); $object->accountancy_code = GETPOST("accountancy_code"); @@ -347,7 +347,7 @@ if (empty($reshook)) { $object->office_fax = GETPOST("office_fax", 'alpha'); $object->user_mobile = GETPOST("user_mobile"); $object->skype = GETPOST("skype", 'alpha'); - $object->email = str_replace(' ','',GETPOST("email", 'alpha')); + $object->email = preg_replace('/\s+/', '', GETPOST("email", 'alpha')); $object->job = GETPOST("job", 'alpha'); $object->signature = GETPOST("signature"); $object->accountancy_code = GETPOST("accountancy_code");