diff --git a/ChangeLog b/ChangeLog index 6a116973007..ab698d84eb8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,7 @@ $Id$ ***** ChangeLog for 3.1 compared to 3.0 ***** For users: +- New: Login is not mandatory in member module. - New: Reduce a step into supplier order workflow to save time (if user has permission to approve, order is approved when order is validated). - New: Add box last members for foundation module. diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 2fe68d1cf7d..42e29522cd4 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -248,7 +248,7 @@ class Adherent extends CommonObject } /** - * Fonction qui cree l'adherent + * Create a member into database * @param user Objet user qui demande la creation * @param notrigger 1 ne declenche pas les triggers, 0 sinon * @return int <0 if KO, >0 if OK @@ -257,6 +257,8 @@ class Adherent extends CommonObject { global $conf,$langs; + $now=dol_now(); + // Check parameters if (! empty($conf->global->ADHERENT_MAIL_REQUIRED) && ! isValidEMail($this->email)) { @@ -264,11 +266,14 @@ class Adherent extends CommonObject $this->error = $langs->trans("ErrorBadEMail",$this->email); return -1; } - if (! $this->datec) $this->datec=gmmktime(); - if (empty($this->login)) + if (! $this->datec) $this->datec=$now; + if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { - $this->error = $langs->trans("ErrorWrongValueForParameterX","Login"); - return -1; + if (empty($this->login)) + { + $this->error = $langs->trans("ErrorWrongValueForParameterX","Login"); + return -1; + } } $this->db->begin(); @@ -278,7 +283,7 @@ class Adherent extends CommonObject $sql.= " (datec,login,fk_user_author,fk_user_mod,fk_user_valid,morphy,fk_adherent_type,entity)"; $sql.= " VALUES ("; $sql.= " '".$this->db->idate($this->datec)."'"; - $sql.= ", '".$this->login."'"; + $sql.= ", ".($this->login?"'".$this->db->escape($this->login)."'":"null"); $sql.= ", ".($user->id>0?$user->id:"null"); // Can be null because member can be create by a guest or a script $sql.= ", null, null, '".$this->morphy."'"; $sql.= ", '".$this->typeid."'"; diff --git a/htdocs/adherents/fiche.php b/htdocs/adherents/fiche.php index 932b81738be..b78299c97df 100644 --- a/htdocs/adherents/fiche.php +++ b/htdocs/adherents/fiche.php @@ -377,36 +377,33 @@ if ($_POST["action"] == 'add' && $user->rights->adherent->creer) $adh->fk_soc = $socid; $adh->public = $public; - foreach($_POST as $key => $value) - { - if (preg_match("/^options_/",$key)) - { - //escape values from POST, at least with $db->escape, to avoid obvious SQL injections - //(array_options is directly input in the DB in adherent.class.php::update()) - $adh->array_options[$key]=$db->escape($_POST[$key]); - } - } - // Check parameters if (empty($morphy) || $morphy == "-1") { $error++; $errmsg .= $langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Nature"))."
\n"; } // Test si le login existe deja - if (empty($login)) { - $error++; - $errmsg .= $langs->trans("ErrorFieldRequired",$langs->trans("Login"))."
\n"; - } - else { - $sql = "SELECT login FROM ".MAIN_DB_PREFIX."adherent WHERE login='".$login."'"; - $result = $db->query($sql); - if ($result) { - $num = $db->num_rows($result); - } - if ($num) { + if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) + { + if (empty($login)) { $error++; - $langs->load("errors"); - $errmsg .= $langs->trans("ErrorLoginAlreadyExists",$login)."
\n"; + $errmsg .= $langs->trans("ErrorFieldRequired",$langs->trans("Login"))."
\n"; + } + else { + $sql = "SELECT login FROM ".MAIN_DB_PREFIX."adherent WHERE login='".$db->escape($login)."'"; + $result = $db->query($sql); + if ($result) { + $num = $db->num_rows($result); + } + if ($num) { + $error++; + $langs->load("errors"); + $errmsg .= $langs->trans("ErrorLoginAlreadyExists",$login)."
\n"; + } + } + if (empty($pass)) { + $error++; + $errmsg .= $langs->trans("ErrorFieldRequired",$langs->transnoentities("Password"))."
\n"; } } if (empty($nom)) { @@ -428,10 +425,6 @@ if ($_POST["action"] == 'add' && $user->rights->adherent->creer) $langs->load("errors"); $errmsg .= $langs->trans("ErrorBadEMail",$email)."
\n"; } - if (empty($pass)) { - $error++; - $errmsg .= $langs->trans("ErrorFieldRequired",$langs->transnoentities("Password"))."
\n"; - } $public=0; if (isset($public)) $public=1; @@ -635,6 +628,12 @@ if ($action == 'create') print ''; + // Login + if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) + { + print ''; + } + // Moral-Physique $morphys["phy"] = $langs->trans("Physical"); $morphys["mor"] = $langs->trans("Moral"); @@ -642,6 +641,17 @@ if ($action == 'create') print $html->selectarray("morphy", $morphys, isset($_POST["morphy"])?$_POST["morphy"]:$adh->morphy, 1); print "\n"; + // Type + print '\n"; + // Company print ''; @@ -658,40 +668,29 @@ if ($action == 'create') print ''; print ''; - // Login - print ''; - - // Mot de passe - $generated_password=''; - if ($conf->global->USER_PASSWORD_GENERATED) + // Password + if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { - $nomclass="modGeneratePass".ucfirst($conf->global->USER_PASSWORD_GENERATED); - $nomfichier=$nomclass.".class.php"; - //print DOL_DOCUMENT_ROOT."/includes/modules/security/generate/".$nomclass; - require_once(DOL_DOCUMENT_ROOT."/includes/modules/security/generate/".$nomfichier); - $genhandler=new $nomclass($db,$conf,$langs,$user); - $generated_password=$genhandler->getNewGeneratedPassword(); + $generated_password=''; + if ($conf->global->USER_PASSWORD_GENERATED) + { + $nomclass="modGeneratePass".ucfirst($conf->global->USER_PASSWORD_GENERATED); + $nomfichier=$nomclass.".class.php"; + //print DOL_DOCUMENT_ROOT."/includes/modules/security/generate/".$nomclass; + require_once(DOL_DOCUMENT_ROOT."/includes/modules/security/generate/".$nomfichier); + $genhandler=new $nomclass($db,$conf,$langs,$user); + $generated_password=$genhandler->getNewGeneratedPassword(); + } + print ''; } - print ''; - - // Type - print '\n"; // Address print ''; - // CP / Ville + // Zip / Town print ''; // Country @@ -824,6 +823,7 @@ if ($action == 'edit') } $rowspan=17; + if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) $rowspan+=1; $rowspan+=sizeof($adho->attribute_label); if ($conf->societe->enabled) $rowspan++; @@ -838,31 +838,49 @@ if ($action == 'edit') // Ref print ''; - // Physique-Moral + // Login + if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) + { + print ''; + } + + // Physique-Moral $morphys["phy"] = $langs->trans("Physical"); $morphys["mor"] = $langs->trans("Morale"); - print '"; - - // Societe - print ''; - - // Civilite - print ''; - - // Photo + print ""; + // Photo print ''; + + // Type + print '"; + + // Company + print ''; + + // Civilite + print ''; print ''; @@ -874,24 +892,11 @@ if ($action == 'edit') print ''; print ''; - // Login - print ''; - // Password - print ''; - - // Type - print ''; } - else - { - print $adht->getNomUrl(1); - print ''; - } - print ""; // Address print '
'.$langs->trans("Login").' / '.$langs->trans("Id").'login).'">
'.$langs->trans("MemberType").''; + $listetype=$adht->liste_array(); + if (sizeof($listetype)) + { + print $html->selectarray("typeid", $listetype, isset($_POST["typeid"])?$_POST["typeid"]:$typeid, 1); + } else { + print ''.$langs->trans("NoTypeDefinedGoToSetup").''; + } + print "
'.$langs->trans("Company").'societe).'">
'.$langs->trans("Firstname").'prenom).'">
'.$langs->trans("Login").'login).'">
'.$langs->trans("Password").''; + print ''; + print '
'.$langs->trans("Password").''; - print ''; - print '
'.$langs->trans("MemberType").''; - $listetype=$adht->liste_array(); - if (sizeof($listetype)) - { - print $html->selectarray("typeid", $listetype, isset($_POST["typeid"])?$_POST["typeid"]:$typeid, 1); - } else { - print ''.$langs->trans("NoTypeDefinedGoToSetup").''; - } - print "
'.$langs->trans("Address").''; print '
'.$langs->trans("Zip").' / '.$langs->trans("Town").'cp).'"> ville).'">
'.$langs->trans("Ref").''.$adh->id.'
'.$langs->trans("Login").' / '.$langs->trans("Id").'login).'">
'.$langs->trans("Nature").''; + print '
'.$langs->trans("Nature").''; print $html->selectarray("morphy", $morphys, isset($_POST["morphy"])?$_POST["morphy"]:$adh->morphy); - print "
'.$langs->trans("Company").'societe).'">
'.$langs->trans("UserTitle").''; - print $htmlcompany->select_civilite(isset($_POST["civilite_id"])?$_POST["civilite_id"]:$adh->civilite_id)."\n"; - print ''; - print $html->showphoto('memberphoto',$adh)."\n"; + print $html->showphoto('memberphoto',$adh)."\n"; if ($caneditfieldmember) { print '

'; print '
'.$langs->trans("PhotoFile").'
'; print ''; print '
'; - } + } + print '
'.$langs->trans("Type").''; + if ($user->rights->adherent->creer) + { + print $html->selectarray("typeid", $adht->liste_array(), (isset($_POST["typeid"])?$_POST["typeid"]:$adh->typeid)); + } + else + { + print $adht->getNomUrl(1); + print ''; + } + print "
'.$langs->trans("Company").'societe).'">
'.$langs->trans("UserTitle").''; + print $htmlcompany->select_civilite(isset($_POST["civilite_id"])?$_POST["civilite_id"]:$adh->civilite_id)."\n"; print '
'.$langs->trans("Firstname").'prenom).'">
'.$langs->trans("Login").'login).'">
'.$langs->trans("Password").'pass).'">
'.$langs->trans("Type").''; - if ($user->rights->adherent->creer) + if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { - print $html->selectarray("typeid", $adht->liste_array(), (isset($_POST["typeid"])?$_POST["typeid"]:$adh->typeid)); + print '
'.$langs->trans("Password").'pass).'">
'.$langs->trans("Address").''; @@ -1143,7 +1148,8 @@ if ($rowid && $action != 'edit') if ($ret == 'html') print '
'; } - $rowspan=15+sizeof($adho->attribute_label); + $rowspan=18+sizeof($adho->attribute_label); + if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) $rowspan+=1; if ($conf->societe->enabled) $rowspan++; print ''; @@ -1154,35 +1160,42 @@ if ($rowid && $action != 'edit') print $html->showrefnav($adh,'rowid'); print ''; - // Morphy - print ''; + // Login + if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) + { + print ''; + print ''; + } + + // Morphy + print ''; + print ''; + print ''; + + // Type + print '\n"; // Company - print ''; + print ''; // Civility - print ''; + print ''; print ''; // Name - print ''; + print ''; print ''; // Firstname - print ''; - - // Login - print ''; - print ''; - print ''; + print ''; // Password - print ''; - - // Type - print '\n"; + if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) + { + print ''; + } // Address print '';
'.$langs->trans("Nature").''.$adh->getmorphylib().'
'.$langs->trans("Login").' / '.$langs->trans("Id").''.$adh->login.' 
'.$langs->trans("Nature").''.$adh->getmorphylib().''; + print $html->showphoto('memberphoto',$adh); + print '
'.$langs->trans("Type").''.$adht->getNomUrl(1)."
'.$langs->trans("Company").''.$adh->societe.'
'.$langs->trans("Company").''.$adh->societe.'
'.$langs->trans("UserTitle").''.$adh->getCivilityLabel().' 
'.$langs->trans("UserTitle").''.$adh->getCivilityLabel().' 
'.$langs->trans("Lastname").''.$adh->nom.' 
'.$langs->trans("Lastname").''.$adh->nom.' 
'.$langs->trans("Firstname").''.$adh->prenom.' 
'.$langs->trans("Login").''.$adh->login.' '; - print $html->showphoto('memberphoto',$adh); - print '
'.$langs->trans("Firstname").''.$adh->prenom.' 
'.$langs->trans("Password").''.preg_replace('/./i','*',$adh->pass).'
'.$langs->trans("Type").''.$adht->getNomUrl(1)."
'.$langs->trans("Password").''.preg_replace('/./i','*',$adh->pass).'
'.$langs->trans("Address").''.nl2br($adh->adresse).'