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 '| '.$langs->trans("Login").' / '.$langs->trans("Id").' | login).'"> |
';
+ }
+
// 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 '| '.$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 " | \n";
+
// Company
print '
| '.$langs->trans("Company").' | societe).'"> |
';
@@ -658,40 +668,29 @@ if ($action == 'create')
print '| '.$langs->trans("Firstname").' | prenom).'"> | ';
print '
';
- // Login
- print '| '.$langs->trans("Login").' | login).'"> |
';
-
- // 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 '| '.$langs->trans("Password").' | ';
+ print '';
+ print ' |
';
}
- print '| '.$langs->trans("Password").' | ';
- print '';
- print ' |
';
-
- // Type
- 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 " | \n";
// Address
print '
| '.$langs->trans("Address").' | ';
print ' |
';
- // CP / Ville
+ // Zip / Town
print '| '.$langs->trans("Zip").' / '.$langs->trans("Town").' | cp).'"> ville).'"> |
';
// 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 '| '.$langs->trans("Ref").' | '.$adh->id.' |
';
- // Physique-Moral
+ // Login
+ if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
+ {
+ print '| '.$langs->trans("Login").' / '.$langs->trans("Id").' | login).'"> |
';
+ }
+
+ // Physique-Moral
$morphys["phy"] = $langs->trans("Physical");
$morphys["mor"] = $langs->trans("Morale");
- print '| '.$langs->trans("Nature").' | ';
+ print ' |
| '.$langs->trans("Nature").' | ';
print $html->selectarray("morphy", $morphys, isset($_POST["morphy"])?$_POST["morphy"]:$adh->morphy);
- print " |
";
-
- // Societe
- print '| '.$langs->trans("Company").' | societe).'"> |
';
-
- // Civilite
- print '| '.$langs->trans("UserTitle").' | ';
- print $htmlcompany->select_civilite(isset($_POST["civilite_id"])?$_POST["civilite_id"]:$adh->civilite_id)."\n";
- print ' | ';
-
- // Photo
+ print "";
+ // Photo
print '';
- print $html->showphoto('memberphoto',$adh)."\n";
+ print $html->showphoto('memberphoto',$adh)."\n";
if ($caneditfieldmember)
{
print '
';
- }
+ }
+ print ' | ';
+
+ // Type
+ 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 " |
";
+
+ // Company
+ print '| '.$langs->trans("Company").' | societe).'"> |
';
+
+ // Civilite
+ print '| '.$langs->trans("UserTitle").' | ';
+ print $htmlcompany->select_civilite(isset($_POST["civilite_id"])?$_POST["civilite_id"]:$adh->civilite_id)."\n";
print ' | ';
print '
';
@@ -874,24 +892,11 @@ if ($action == 'edit')
print '| '.$langs->trans("Firstname").' | prenom).'"> | ';
print '
';
- // Login
- print '| '.$langs->trans("Login").' | login).'"> |
';
-
// Password
- print '| '.$langs->trans("Password").' | pass).'"> |
';
-
- // Type
- print '| '.$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).'"> |
';
}
- else
- {
- print $adht->getNomUrl(1);
- print '';
- }
- print "";
// Address
print '| '.$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 '| '.$langs->trans("Nature").' | '.$adh->getmorphylib().' | ';
+ // Login
+ if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
+ {
+ print '| '.$langs->trans("Login").' / '.$langs->trans("Id").' | '.$adh->login.' | ';
+ print ' ';
+ }
+
+ // Morphy
+ print '| '.$langs->trans("Nature").' | '.$adh->getmorphylib().' | ';
+ print '';
+ print $html->showphoto('memberphoto',$adh);
+ print ' | ';
+ print ' ';
+
+ // Type
+ print '| '.$langs->trans("Type").' | '.$adht->getNomUrl(1)." | \n";
// Company
- print '| '.$langs->trans("Company").' | '.$adh->societe.' | ';
+ print '| '.$langs->trans("Company").' | '.$adh->societe.' | ';
// Civility
- print '| '.$langs->trans("UserTitle").' | '.$adh->getCivilityLabel().' | ';
+ print ' | '.$langs->trans("UserTitle").' | '.$adh->getCivilityLabel().' | ';
print ' ';
// Name
- print '| '.$langs->trans("Lastname").' | '.$adh->nom.' | ';
+ print ' | '.$langs->trans("Lastname").' | '.$adh->nom.' | ';
print ' ';
// Firstname
- print '| '.$langs->trans("Firstname").' | '.$adh->prenom.' | ';
-
- // Login
- print '| '.$langs->trans("Login").' | '.$adh->login.' | ';
- print '';
- print $html->showphoto('memberphoto',$adh);
- print ' | ';
- print ' ';
+ print '| '.$langs->trans("Firstname").' | '.$adh->prenom.' | ';
// Password
- print '| '.$langs->trans("Password").' | '.preg_replace('/./i','*',$adh->pass).' | ';
-
- // Type
- print '| '.$langs->trans("Type").' | '.$adht->getNomUrl(1)." | \n";
+ if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
+ {
+ print '| '.$langs->trans("Password").' | '.preg_replace('/./i','*',$adh->pass).' | ';
+ }
// Address
print '| '.$langs->trans("Address").' | '.nl2br($adh->adresse).' | ';
|