diff --git a/ChangeLog b/ChangeLog
index b9a3e0b5794..5eb9570711b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -11,6 +11,7 @@ For users:
- New: Add graph report on number of entities in product statistics page.
- New: Can delete a supplier order whatever is its status.
- New: No limit on free text on PDF generated documents.
+- New: can force login value when creating a user from a member.
- Fix: Failed to go on the future view of bank transaction if there is no
future bank transaction already wrote.
- Fix: Bad ref in supplier list.
diff --git a/htdocs/adherents/fiche.php b/htdocs/adherents/fiche.php
index f4e6dd1509f..7323d4ac3e6 100644
--- a/htdocs/adherents/fiche.php
+++ b/htdocs/adherents/fiche.php
@@ -67,38 +67,36 @@ $typeid=isset($_GET["typeid"])?$_GET["typeid"]:$_POST["typeid"];
* Actions
*/
-// Creation utilisateur depuis adherent
-if ($user->rights->user->user->creer)
+// Create user from a memeber
+if ($_POST["action"] == 'confirm_create_user' && $_POST["confirm"] == 'yes' && $user->rights->user->user->creer)
{
- if ($_GET["action"] == 'create_user')
- {
- // Recuperation contact actuel
- $adh = new Adherent($db);
- $result = $adh->fetch($_GET["rowid"]);
-
- if ($result > 0)
- {
- // Creation user
- $nuser = new User($db);
- $result=$nuser->create_from_member($adh);
+ // Recuperation contact actuel
+ $adh = new Adherent($db);
+ $result = $adh->fetch($_GET["rowid"]);
- if ($result < 0)
- {
- $msg=$nuser->error;
- }
- }
- else
+ if ($result > 0)
+ {
+ // Creation user
+ $nuser = new User($db);
+ $result=$nuser->create_from_member($adh,$_POST["login"]);
+
+ if ($result < 0)
{
- $msg=$adh->error;
+ $langs->load("errors");
+ $msg=$langs->trans($nuser->error);
}
}
+ else
+ {
+ $msg=$adh->error;
+ }
}
if ($_POST["action"] == 'confirm_sendinfo' && $_POST["confirm"] == 'yes')
{
$adh->id = $rowid;
$adh->fetch($rowid);
-
+
if ($adh->email)
{
$result=$adh->send_an_email("Voici le contenu de votre fiche\n\n%INFOS%\n\n","Contenu de votre fiche adherent");
@@ -348,7 +346,7 @@ if ($user->rights->adherent->creer && $_POST["action"] == 'add')
}
}
}
-
+
$db->commit();
Header("Location: liste.php?statut=-1");
@@ -360,12 +358,12 @@ if ($user->rights->adherent->creer && $_POST["action"] == 'add')
if ($adh->error) $errmsg=$adh->error;
else $errmsg=$adh->errors[0];
-
- $action = 'create';
+
+ $action = 'create';
}
}
else {
- $action = 'create';
+ $action = 'create';
}
}
@@ -388,7 +386,7 @@ if ($user->rights->adherent->creer && $_POST["action"] == 'confirm_valid' && $_P
{
$result=$adh->fetch($rowid);
$result=$adh->validate($user);
-
+
$adht = new AdherentType($db);
$adht->fetch($adh->typeid);
@@ -410,13 +408,13 @@ if ($user->rights->adherent->creer && $_POST["action"] == 'confirm_valid' && $_P
$errmsg.=$adh->error;
}
}
-
+
// Rajoute l'utilisateur dans les divers abonnements (mailman, spip, etc...)
if ($adh->add_to_abo($adht) < 0)
{
// error
$errmsg.="Echec du rajout de l'utilisateur aux abonnements mailman: ".$adh->error."
\n";
- }
+ }
}
else
{
@@ -455,7 +453,7 @@ if ($user->rights->adherent->supprimer && $_POST["action"] == 'confirm_resign' &
{
$errmsg.=$adh->error;
}
-
+
// supprime l'utilisateur des divers abonnements ..
if (! $adh->del_to_abo($adht))
{
@@ -540,7 +538,7 @@ if ($action == 'edit')
$adh->fetch_optionals($rowid);
// fetch optionals attributes and labels
$adho->fetch_name_optionals_label();
-
+
$adht = new AdherentType($db);
$adht->fetch($adh->typeid);
@@ -549,7 +547,7 @@ if ($action == 'edit')
* Affichage onglets
*/
$head = member_prepare_head($adh);
-
+
dolibarr_fiche_head($head, 'general', $langs->trans("Member"));
@@ -561,10 +559,10 @@ if ($action == 'edit')
$htmls = new Form($db);
print '
';
-
+
// Ref
print '| '.$langs->trans("Ref").' | '.$adh->id.' |
';
-
+
// Nom
print '| '.$langs->trans("Lastname").'* | | ';
@@ -593,10 +591,10 @@ if ($action == 'edit')
// Prenom
print '
| '.$langs->trans("Firstname").'* | | ';
print '
';
-
+
// Login
print '| '.$langs->trans("Login").'* | |
';
-
+
// Password
print '| '.$langs->trans("Password").'* | |
';
@@ -612,14 +610,14 @@ if ($action == 'edit')
print '';
}
print "";
-
- // Physique-Moral
+
+ // Physique-Moral
$morphys["phy"] = $langs->trans("Physical");
$morphys["mor"] = $langs->trans("Morale");
print "| ".$langs->trans("Person")."* | ";
$htmls->select_array("morphy", $morphys, $adh->morphy);
print " |
";
-
+
// Societe
print '| '.$langs->trans("Company").' | |
';
@@ -629,12 +627,12 @@ if ($action == 'edit')
// Cp
print '| '.$langs->trans("Zip").'/'.$langs->trans("Town").' | |
';
-
+
// Pays
print '| '.$langs->trans("Country").' | ';
$htmls->select_pays($adh->pays_code?$adh->pays_code:$mysoc->pays_code,'pays');
print ' |
';
-
+
// Tel
print '| '.$langs->trans("PhonePro").' | |
';
@@ -646,7 +644,7 @@ if ($action == 'edit')
// EMail
print '| '.$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED?'*':'').' | |
';
-
+
// Date naissance
print "| ".$langs->trans("Birthday")." | \n";
$htmls->select_date(($adh->naiss ? $adh->naiss : -1),'naiss','','',1,'update');
@@ -672,8 +670,8 @@ if ($action == 'edit')
print ' |
';
print '';
-
- print '';
+
+ print '';
}
if ($action == 'create')
@@ -689,7 +687,7 @@ if ($action == 'create')
print_titre($langs->trans("NewMember"));
- print '';
-
+
print "\n";
-
+
/*
* Barre d'actions
*
*/
print '';
-
+
// Modify
if ($user->rights->adherent->creer || ($user->rights->adherent->self->creer && $adh->user_id == $user->id))
{
@@ -992,7 +1003,7 @@ if ($rowid && $action != 'edit')
{
print "".$langs->trans("Modify")."";
}
-
+
// Valider
if ($adh->statut == -1)
{
@@ -1005,7 +1016,7 @@ if ($rowid && $action != 'edit')
print "".$langs->trans("Validate")."";
}
}
-
+
// Reactiver
if ($adh->statut == 0)
{
@@ -1018,7 +1029,7 @@ if ($rowid && $action != 'edit')
print "".$langs->trans("Reenable")."";
}
}
-
+
// Envoi fiche par mail
if ($adh->statut >= 1 && $adh->email)
{
@@ -1031,7 +1042,7 @@ if ($rowid && $action != 'edit')
print "".$langs->trans("SendCardByMail")."";
}
}
-
+
// Resilier
if ($adh->statut >= 1)
{
@@ -1044,7 +1055,7 @@ if ($rowid && $action != 'edit')
print "".$langs->trans("Resiliate")."";
}
}
-
+
// Create user
if (! $user->societe_id && ! $adh->user_id)
{
@@ -1057,7 +1068,7 @@ if ($rowid && $action != 'edit')
print "".$langs->trans("CreateDolibarrLogin")."";
}
}
-
+
// Supprimer
if ($user->rights->adherent->supprimer)
{
@@ -1067,7 +1078,7 @@ if ($rowid && $action != 'edit')
{
print "".$langs->trans("Delete")."";
}
-
+
// Action SPIP
if ($conf->global->ADHERENT_USE_SPIP)
{
@@ -1084,27 +1095,27 @@ if ($rowid && $action != 'edit')
print '
Failed to connect to SPIP: '.$adh->error.'';
}
}
-
+
print '
';
print "
\n";
-
-
-
+
+
+
/*
* Bandeau des cotisations
*
*/
-
+
print '';
-
+
print '';
print '| ';
-
+
print ' | ';
-
+
print ' |
';
print '
';
-
+
}
diff --git a/htdocs/contact/fiche.php b/htdocs/contact/fiche.php
index 384dd7e3c9e..63c738faf93 100644
--- a/htdocs/contact/fiche.php
+++ b/htdocs/contact/fiche.php
@@ -265,7 +265,7 @@ if ($user->rights->societe->contact->creer)
}
else {
print '| '.$langs->trans("Company").' | ';
- print $form->select_societes('','socid','',1);
+ print $form->select_societes('','socid','',1);
//print $form->select_societes('','socid','');
//print $langs->trans("ContactNotLinkedToCompany");
print ' |
';
@@ -313,7 +313,7 @@ if ($user->rights->societe->contact->creer)
$selectarray=array('0'=>$langs->trans("ContactPublic"),'1'=>$langs->trans("ContactPrivate"));
$form->select_array('priv',$selectarray,$contact->priv,0);
print '';
-
+
// Note
print '| '.$langs->trans("Note").' | |
';
@@ -473,7 +473,7 @@ if ($_GET["id"] && $_GET["action"] != 'edit')
* Fiche en mode visualisation
*
*/
- if ($msg)
+ if ($msg)
{
$langs->load("errors");
print ''.$langs->trans($msg).'
';
@@ -482,15 +482,15 @@ if ($_GET["id"] && $_GET["action"] != 'edit')
if ($_GET["action"] == 'create_user')
{
$login=strtolower(substr($contact->prenom, 0, 4)) . strtolower(substr($contact->nom, 0, 4));
-
- // Cr�e un tableau formulaire
+
+ // Create a form array
$formquestion=array(
array('label' => $langs->trans("LoginToCreate"), 'type' => 'text', 'name' => 'login', 'value' => $login));
-
+
$form->form_confirm($_SERVER["PHP_SELF"]."?id=".$contact->id,$langs->trans("CreateDolibarrLogin"),$langs->trans("ConfirmCreateContact"),"confirm_create_user",$formquestion);
print '
';
}
-
+
print '';
// Ref
@@ -558,7 +558,7 @@ if ($_GET["id"] && $_GET["action"] != 'edit')
print '| '.$langs->trans("ContactVisibility").' | ';
print $contact->LibPubPriv($contact->priv);
print ' |
';
-
+
print '| '.$langs->trans("Note").' | ';
print nl2br($contact->note);
print ' |
';
diff --git a/htdocs/user.class.php b/htdocs/user.class.php
index ce054d38520..304e4dec5a1 100644
--- a/htdocs/user.class.php
+++ b/htdocs/user.class.php
@@ -637,7 +637,7 @@ class User extends CommonObject
$sql = "UPDATE ".MAIN_DB_PREFIX."socpeople SET fk_user_creat = null WHERE rowid = ".$this->contact_id;
if ($this->db->query($sql))
{
-
+
}
}
@@ -797,7 +797,6 @@ class User extends CommonObject
if (empty($login)) $login=strtolower(substr($contact->prenom, 0, 4)) . strtolower(substr($contact->nom, 0, 4));
$this->login = $login;
-
$this->db->begin();
// Cree et positionne $this->id
@@ -839,21 +838,22 @@ class User extends CommonObject
/**
* \brief Cree en base un utilisateur depuis l'objet adherent
* \param member Objet adherent source
+ * \param login Login to force
* \return int Si erreur <0, si ok renvoie id compte cree
*/
- function create_from_member($member)
+ function create_from_member($member,$login='')
{
global $conf,$user,$langs;
// Positionne parametres
+ $this->admin = 0;
$this->nom = $member->nom;
$this->prenom = $member->prenom;
-
- $this->login = $member->login;
- $this->pass = $member->pass;
- $this->admin = 0;
-
$this->email = $member->email;
+ $this->pass = $member->pass;
+
+ if (empty($login)) $login=strtolower(substr($member->prenom, 0, 4)) . strtolower(substr($member->nom, 0, 4));
+ $this->login = $login;
$this->db->begin();
@@ -1339,7 +1339,7 @@ class User extends CommonObject
}
$this->clicktodial_loaded = 1; // Data loaded (found or not)
-
+
$this->db->free($resql);
return 1;
}