diff --git a/ChangeLog b/ChangeLog
index 7a29202d24d..1a1f5fe677a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,7 +3,10 @@ English Dolibarr ChangeLog
***** ChangeLog for 3.1 compared to 3.0 *****
For users:
- New: Can add information on current user on odt generation
+- New: Prefix on third party is not used by default. Hidden option
+ SOCIETE_USEPREFIX can restore old feature.
- New: Standing orders module use bank account from banks module
+- New: Ask password when creating a user from a contact
For developers:
- New: External modules can add their menu manager
diff --git a/htdocs/contact/fiche.php b/htdocs/contact/fiche.php
index 6b9f8a69d44..fce0b1006ea 100644
--- a/htdocs/contact/fiche.php
+++ b/htdocs/contact/fiche.php
@@ -94,13 +94,29 @@ else
if ($result > 0)
{
+ $db->begin();
+
// Creation user
$nuser = new User($db);
$result=$nuser->create_from_contact($object,$_POST["login"]);
- if ($result < 0)
+ if ($result > 0)
+ {
+ $result2=$nuser->setPassword($user,$_POST["password"],0,1,1);
+ if ($result2)
+ {
+ $db->commit();
+ }
+ else
+ {
+ $db->rollback();
+ }
+ }
+ else
{
$msg=$nuser->error;
+
+ $db->rollback();
}
}
else
@@ -772,10 +788,27 @@ else
include_once(DOL_DOCUMENT_ROOT.'/lib/functions2.lib.php');
$login=dol_buildlogin($object->nom,$object->prenom);
- // Create a form array
- $formquestion=array(array('label' => $langs->trans("LoginToCreate"), 'type' => 'text', 'name' => 'login', 'value' => $login));
+ $generated_password='';
+ if (!$ldap_sid)
+ {
+ 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();
+ }
+ }
+ $password=$generated_password;
- $ret=$form->form_confirm($_SERVER["PHP_SELF"]."?id=".$object->id,$langs->trans("CreateDolibarrLogin"),$langs->trans("ConfirmCreateContact"),"confirm_create_user",$formquestion);
+ // Create a form array
+ $formquestion=array(
+ array('label' => $langs->trans("LoginToCreate"), 'type' => 'text', 'name' => 'login', 'value' => $login),
+ array('label' => $langs->trans("Password"), 'type' => 'text', 'name' => 'password', 'value' => $password));
+
+ $ret=$form->form_confirm($_SERVER["PHP_SELF"]."?id=".$object->id,$langs->trans("CreateDolibarrLogin"),$langs->trans("ConfirmCreateContact"),"confirm_create_user",$formquestion,'no');
if ($ret == 'html') print '
';
}
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 27422180287..c47a7a8935b 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -1806,7 +1806,7 @@ class Form
* @param title title
* @param question question
* @param action action
- * @param formquestion an array with forms complementary inputs
+ * @param formquestion an array with complementary inputs to add into forms: array(array('label'=> ,'type'=> , ))
* @param selectedchoice "" or "no" or "yes"
* @param useajax 0=No, 1=Yes, 2=Yes but submit page with &confirm=no if choice is No
* @param height Force height of box
@@ -1831,6 +1831,10 @@ class Form
{
$more.='