Fix: Can change password if has only permission change password.

This commit is contained in:
Laurent Destailleur 2010-02-27 16:14:52 +00:00
parent b5acf315b0
commit c001d75785
8 changed files with 132 additions and 116 deletions

View File

@ -9,7 +9,8 @@ For users:
- New: Add default language for third parties and use it when multilang is enabled
to define default language for document generation.
- New: Can reopen a closed supplier invoice.
- Fix: Formant number as wrong for ar_AR language.
- Fix: Format number was wrong for ar_AR language.
- Fix: Can change password if has only permission change password.
For developers:
- More comments in code
@ -56,6 +57,7 @@ For users:
- Fix: Warning should not appears for invoice closed
- Fix: Import for companies works even with prefix empty.
- Fix: bug #28895 : Création d'utilisateur impossible.
- Fix: Can change password if has only permission change password.
For developers:
- Qual: Reorganize /dev directory.

View File

@ -90,6 +90,7 @@ Reactivate=Reactivate
CreateInternalUserDesc=This form allows you to creat an user internal to your company/foundation. To creat an external user (customer, supplier, ...), use button 'Create Dolibarr user' from third party's contact card.
InternalExternalDesc=An <b>internal</b> user is a user that is part of your company/foundation.<br>An <b>external</b> user is a customer, supplier or other.<br><br>In both cases, permissions defines rights on Dolibarr, also external user can have a different menu manager than internal user (See Home - Setup - Display)
PermissionInheritedFromAGroup=Permission granted because inherited from one of a user's group.
Inherited=Inherited
IdPhoneCaller=Id phone caller
UserLogged=User %s connected
NewUserCreated=User %s created

View File

@ -90,6 +90,7 @@ Reactivate=Réactiver
CreateInternalUserDesc=Cet écran permet de créer un utilisateur interne à votre société/institution. Pour créer un utilisateur externe (client, fournisseur, ...), utiliser le bouton 'Créer utilisateur Dolibarr' qui se trouve sur la fiche contact du tiers en question.
InternalExternalDesc=Un utilisateur <b>interne</b> est un utilisateur appartenant à votre société/institution.<br>Un utilisateur <b>externe</b> est un utilisateur client, fournisseur ou autre.<br><br>Dans les 2 cas, les permissions utilisateurs définissent les droits d'accès mais l'utilisateur externe peut en plus avoir un gestionnaire de menu différent de l'utilisateur interne (Voir Accueil - Configuration - Affichage)
PermissionInheritedFromAGroup=La permission est accordée car héritée d'un groupe auquel appartient l'utilisateur.
Inherited=Hérité
IdPhoneCaller=Id appelant (téléphone)
UserLogged=Connexion utilisateur %s
NewUserCreated=Création utilisateur %s

View File

@ -222,111 +222,124 @@ if ($_GET["action"] == 'removegroup' && $caneditfield)
}
}
if ($_POST["action"] == 'update' && ! $_POST["cancel"] && $caneditfield)
if ($_POST["action"] == 'update' && ! $_POST["cancel"])
{
$message="";
if (! $_POST["nom"])
if ($caneditfield) // Case we can edit all field
{
$message='<div class="error">'.$langs->trans("NameNotDefined").'</div>';
$action="edit"; // Go back to create page
}
if (! $_POST["login"])
{
$message='<div class="error">'.$langs->trans("LoginNotDefined").'</div>';
$action="edit"; // Go back to create page
}
$message="";
if (! $message)
{
$db->begin();
$edituser = new User($db, $_GET["id"]);
$edituser->fetch();
$edituser->oldcopy=dol_clone($edituser);
$edituser->nom = $_POST["nom"];
$edituser->prenom = $_POST["prenom"];
$edituser->login = $_POST["login"];
$edituser->pass = $_POST["password"];
$edituser->admin = $_POST["admin"];
$edituser->office_phone = $_POST["office_phone"];
$edituser->office_fax = $_POST["office_fax"];
$edituser->user_mobile = $_POST["user_mobile"];
$edituser->email = $_POST["email"];
$edituser->webcal_login = $_POST["webcal_login"];
$edituser->phenix_login = $_POST["phenix_login"];
$edituser->phenix_pass = $_POST["phenix_pass"];
$edituser->entity = $_POST["entity"];
$edituser->photo = $_FILES['photo']['name'];
$ret=$edituser->update($user);
if ($ret < 0)
if (! $_POST["nom"])
{
if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{
$langs->load("errors");
$message.='<div class="error">'.$langs->trans("ErrorLoginAlreadyExists",$edituser->login).'</div>';
}
else
{
$message.='<div class="error">'.$edituser->error.'</div>';
}
$message='<div class="error">'.$langs->trans("NameNotDefined").'</div>';
$action="edit"; // Go back to create page
}
if (! $_POST["login"])
{
$message='<div class="error">'.$langs->trans("LoginNotDefined").'</div>';
$action="edit"; // Go back to create page
}
if ($ret >= 0 && ! sizeof($edituser->errors) && isset($_POST["password"]) && $_POST["password"] !='')
if (! $message)
{
$ret=$edituser->setPassword($user,$_POST["password"]);
$db->begin();
$edituser = new User($db, $_GET["id"]);
$edituser->fetch();
$edituser->oldcopy=dol_clone($edituser);
$edituser->nom = $_POST["nom"];
$edituser->prenom = $_POST["prenom"];
$edituser->login = $_POST["login"];
$edituser->pass = $_POST["password"];
$edituser->admin = $_POST["admin"];
$edituser->office_phone = $_POST["office_phone"];
$edituser->office_fax = $_POST["office_fax"];
$edituser->user_mobile = $_POST["user_mobile"];
$edituser->email = $_POST["email"];
$edituser->webcal_login = $_POST["webcal_login"];
$edituser->phenix_login = $_POST["phenix_login"];
$edituser->phenix_pass = $_POST["phenix_pass"];
$edituser->entity = $_POST["entity"];
$edituser->photo = $_FILES['photo']['name'];
$ret=$edituser->update($user);
if ($ret < 0)
{
$message.='<div class="error">'.$edituser->error.'</div>';
}
}
if ($ret >=0 && ! sizeof($edituser->errors))
{
if (isset($_FILES['photo']['tmp_name']) && trim($_FILES['photo']['tmp_name']))
{
$dir= $conf->user->dir_output . '/' . get_exdir($edituser->id,2,0,1);
create_exdir($dir);
if (@is_dir($dir))
if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{
$newfile=$dir.'/'.$_FILES['photo']['name'];
if (! dol_move_uploaded_file($_FILES['photo']['tmp_name'],$newfile,1) > 0)
{
$message .= '<div class="error">'.$langs->trans("ErrorFailedToSaveFile").'</div>';
}
else
{
// Create small thumbs for company (Ratio is near 16/9)
// Used on logon for example
$imgThumbSmall = vignette($newfile, $maxwidthsmall, $maxheightsmall, '_small', $quality);
$langs->load("errors");
$message.='<div class="error">'.$langs->trans("ErrorLoginAlreadyExists",$edituser->login).'</div>';
}
else
{
$message.='<div class="error">'.$edituser->error.'</div>';
}
}
// Create mini thumbs for company (Ratio is near 16/9)
// Used on menu or for setup page for example
$imgThumbMini = vignette($newfile, $maxwidthmini, $maxheightmini, '_mini', $quality);
if ($ret >= 0 && ! sizeof($edituser->errors) && isset($_POST["password"]) && $_POST["password"] !='')
{
$ret=$edituser->setPassword($user,$_POST["password"]);
if ($ret < 0)
{
$message.='<div class="error">'.$edituser->error.'</div>';
}
}
if ($ret >=0 && ! sizeof($edituser->errors))
{
if (isset($_FILES['photo']['tmp_name']) && trim($_FILES['photo']['tmp_name']))
{
$dir= $conf->user->dir_output . '/' . get_exdir($edituser->id,2,0,1);
create_exdir($dir);
if (@is_dir($dir))
{
$newfile=$dir.'/'.$_FILES['photo']['name'];
if (! dol_move_uploaded_file($_FILES['photo']['tmp_name'],$newfile,1) > 0)
{
$message .= '<div class="error">'.$langs->trans("ErrorFailedToSaveFile").'</div>';
}
else
{
// Create small thumbs for company (Ratio is near 16/9)
// Used on logon for example
$imgThumbSmall = vignette($newfile, $maxwidthsmall, $maxheightsmall, '_small', $quality);
// Create mini thumbs for company (Ratio is near 16/9)
// Used on menu or for setup page for example
$imgThumbMini = vignette($newfile, $maxwidthmini, $maxheightmini, '_mini', $quality);
}
}
}
}
}
if ($ret >= 0 && ! sizeof($edituser->errors))
{
$message.='<div class="ok">'.$langs->trans("UserModified").'</div>';
$db->commit();
if ($ret >= 0 && ! sizeof($edituser->errors))
{
$message.='<div class="ok">'.$langs->trans("UserModified").'</div>';
$db->commit();
}
else
{
$db->rollback();
}
}
else
}
else if ($caneditpassword) // Case we can edit only password
{
$edituser = new User($db, $_GET["id"]);
$edituser->fetch();
$ret=$edituser->setPassword($user,$_POST["password"]);
if ($ret < 0)
{
$db->rollback();
$message.='<div class="error">'.$edituser->error.'</div>';
}
}
}
// Action modif mot de passe
// Change password with a new generated one
if ((($_REQUEST["action"] == 'confirm_password' && $_REQUEST["confirm"] == 'yes')
|| ($_REQUEST["action"] == 'confirm_passwordsend' && $_REQUEST["confirm"] == 'yes')) && $caneditpassword)
{
@ -337,7 +350,7 @@ if ((($_REQUEST["action"] == 'confirm_password' && $_REQUEST["confirm"] == 'yes'
if ($newpassword < 0)
{
// Echec
$message = '<div class="error">'.$langs->trans("ErrorFailedToSaveFile").'</div>';
$message = '<div class="error">'.$langs->trans("ErrorFailedToSetNewPassword").'</div>';
}
else
{
@ -850,12 +863,12 @@ else
print '</tr>';
// Nom
print '<tr><td width="25%" valign="top">'.$langs->trans("Lastname").'</td>';
print '<tr><td valign="top">'.$langs->trans("Lastname").'</td>';
print '<td colspan="2">'.$fuser->nom.'</td>';
print "</tr>\n";
// Prenom
print '<tr><td width="25%" valign="top">'.$langs->trans("Firstname").'</td>';
print '<tr><td valign="top">'.$langs->trans("Firstname").'</td>';
print '<td colspan="2">'.$fuser->prenom.'</td>';
print "</tr>\n";
@ -866,7 +879,7 @@ else
if ($conf->phenix->enabled) $rowspan+=2;
// Login
print '<tr><td width="25%" valign="top">'.$langs->trans("Login").'</td>';
print '<tr><td valign="top">'.$langs->trans("Login").'</td>';
if ($fuser->ldap_sid && $fuser->statut==0)
{
print '<td width="50%" class="error">'.$langs->trans("LoginAccountDisableInDolibarr").'</td>';
@ -882,7 +895,7 @@ else
print '</tr>';
// Password
print '<tr><td width="25%" valign="top">'.$langs->trans("Password").'</td>';
print '<tr><td valign="top">'.$langs->trans("Password").'</td>';
if ($fuser->ldap_sid)
{
if ($passDoNotExpire)
@ -916,7 +929,7 @@ else
print "</tr>\n";
// Administrator
print '<tr><td width="25%" valign="top">'.$langs->trans("Administrator").'</td>';
print '<tr><td valign="top">'.$langs->trans("Administrator").'</td>';
print '<td>'.yn($fuser->admin);
if (! empty($conf->global->MAIN_MODULE_MULTICOMPANY) && $fuser->admin && ! $fuser->entity)
{
@ -930,7 +943,7 @@ else
print "</tr>\n";
// Type
print '<tr><td width="25%" valign="top">'.$langs->trans("Type").'</td>';
print '<tr><td valign="top">'.$langs->trans("Type").'</td>';
print '<td>';
if ($fuser->societe_id)
{
@ -951,19 +964,19 @@ else
print '</td></tr>';
// Tel pro
print '<tr><td width="25%" valign="top">'.$langs->trans("PhonePro").'</td>';
print '<tr><td valign="top">'.$langs->trans("PhonePro").'</td>';
print '<td>'.dol_print_phone($fuser->office_phone,'',0,0,1).'</td>';
// Tel mobile
print '<tr><td width="25%" valign="top">'.$langs->trans("PhoneMobile").'</td>';
print '<tr><td valign="top">'.$langs->trans("PhoneMobile").'</td>';
print '<td>'.dol_print_phone($fuser->user_mobile,'',0,0,1).'</td>';
// Fax
print '<tr><td width="25%" valign="top">'.$langs->trans("Fax").'</td>';
print '<tr><td valign="top">'.$langs->trans("Fax").'</td>';
print '<td>'.dol_print_phone($fuser->office_fax,'',0,0,1).'</td>';
// EMail
print '<tr><td width="25%" valign="top">'.$langs->trans("EMail").($conf->global->USER_MAIL_REQUIRED?'*':'').'</td>';
print '<tr><td valign="top">'.$langs->trans("EMail").($conf->global->USER_MAIL_REQUIRED?'*':'').'</td>';
print '<td>'.dol_print_email($fuser->email,0,0,1).'</td>';
print "</tr>\n";
@ -973,11 +986,11 @@ else
print $fuser->getLibStatut(4);
print '</td></tr>';
print '<tr><td width="25%" valign="top">'.$langs->trans("LastConnexion").'</td>';
print '<tr><td valign="top">'.$langs->trans("LastConnexion").'</td>';
print '<td>'.dol_print_date($fuser->datelastlogin,"dayhour").'</td>';
print "</tr>\n";
print '<tr><td width="25%" valign="top">'.$langs->trans("PreviousConnexion").'</td>';
print '<tr><td valign="top">'.$langs->trans("PreviousConnexion").'</td>';
print '<td>'.dol_print_date($fuser->datepreviouslogin,"dayhour").'</td>';
print "</tr>\n";
@ -987,7 +1000,7 @@ else
if ($conf->webcal->enabled)
{
$langs->load("other");
print '<tr><td width="25%" valign="top">'.$langs->trans("LoginWebcal").'</td>';
print '<tr><td valign="top">'.$langs->trans("LoginWebcal").'</td>';
print '<td>'.$fuser->webcal_login.'&nbsp;</td>';
print "</tr>\n";
}
@ -996,10 +1009,10 @@ else
if ($conf->phenix->enabled)
{
$langs->load("other");
print '<tr><td width="25%" valign="top">'.$langs->trans("LoginPhenix").'</td>';
print '<tr><td valign="top">'.$langs->trans("LoginPhenix").'</td>';
print '<td>'.$fuser->phenix_login.'&nbsp;</td>';
print "</tr>\n";
print '<tr><td width="25%" valign="top">'.$langs->trans("PassPhenix").'</td>';
print '<tr><td valign="top">'.$langs->trans("PassPhenix").'</td>';
print '<td>'.preg_replace('/./i','*',$fuser->phenix_pass_crypted).'&nbsp;</td>';
print "</tr>\n";
}
@ -1007,7 +1020,7 @@ else
// Company / Contact
if ($conf->societe->enabled)
{
print '<tr><td width="25%" valign="top">'.$langs->trans("LinkToCompanyContact").'</td>';
print '<tr><td valign="top">'.$langs->trans("LinkToCompanyContact").'</td>';
print '<td>';
if ($fuser->societe_id > 0)
{
@ -1035,7 +1048,7 @@ else
if ($conf->adherent->enabled)
{
$langs->load("members");
print '<tr><td width="25%" valign="top">'.$langs->trans("LinkedToDolibarrMember").'</td>';
print '<tr><td valign="top">'.$langs->trans("LinkedToDolibarrMember").'</td>';
print '<td>';
if ($fuser->fk_member)
{
@ -1307,7 +1320,7 @@ else
print '</tr>';
// Nom
print "<tr>".'<td valign="top">'.$langs->trans("Name").'</span></td>';
print "<tr>".'<td valign="top" class="fieldrequired">'.$langs->trans("Name").'</span></td>';
print '<td colspan="2">';
if ($caneditfield && !$fuser->ldap_sid)
{
@ -1321,7 +1334,7 @@ else
print '</td></tr>';
// Prenom
print "<tr>".'<td valign="top"><span class="fieldrequired">'.$langs->trans("Firstname").'</td>';
print "<tr>".'<td valign="top">'.$langs->trans("Firstname").'</td>';
print '<td colspan="2">';
if ($caneditfield && !$fuser->ldap_sid)
{

View File

@ -224,7 +224,7 @@ if ($action == 'create')
print '<table class="border" width="100%">';
print "<tr>".'<td valign="top">'.$langs->trans("Name").'</td>';
print "<tr>".'<td valign="top" class="fieldrequired">'.$langs->trans("Name").'</td>';
print '<td class="valeur"><input size="30" type="text" name="nom" value=""></td></tr>';
print "<tr>".'<td valign="top">'.$langs->trans("Note").'</td><td>';
@ -264,7 +264,7 @@ else
*/
$head = group_prepare_head($group);
$title = $langs->trans("Group");
dol_fiche_head($head, 'group', $title);
dol_fiche_head($head, 'group', $title, 0, 'group');
/*
* Confirmation suppression
@ -520,7 +520,7 @@ else
print '<input type="hidden" name="action" value="update">';
print '<table class="border" width="100%">';
print '<tr><td width="25%" valign="top">'.$langs->trans("Name").'</td>';
print '<tr><td width="25%" valign="top" class="fieldrequired">'.$langs->trans("Name").'</td>';
print '<td width="75%" class="valeur"><input size="15" type="text" name="group" value="'.$group->nom.'">';
if (!$group->entity)
{

View File

@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2006-2009 Laurent Destailleur <eldy@users.sourceforge.net>
/* Copyright (C) 2006-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2006 Regis Houssin <regis@dolibarr.fr>
*
* This program is free software; you can redistribute it and/or modify
@ -93,7 +93,7 @@ $form = new Form($db);
$head = group_prepare_head($fgroup);
dol_fiche_head($head, 'ldap', $langs->trans("Group"));
dol_fiche_head($head, 'ldap', $langs->trans("Group"), 0, 'group');
print '<table class="border" width="100%">';

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2002-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
*
@ -74,7 +74,7 @@ if ($_GET["id"])
*/
$head = group_prepare_head($fgroup);
$title = $langs->trans("Group");
dol_fiche_head($head, 'rights', $title);
dol_fiche_head($head, 'rights', $title, 0, 'group');
$db->begin();
@ -212,7 +212,7 @@ if ($_GET["id"])
$oldmod = $obj->module;
$var = !$var;
// Rupture détectée, on récupère objMod
// Rupture d<EFBFBD>tect<EFBFBD>e, on r<>cup<75>re objMod
$objMod = $modules[$obj->module];
$picto=($objMod->picto?$objMod->picto:'generic');

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2002-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
*
@ -318,7 +318,7 @@ if ($result)
if ($caneditperms)
{
print '<td align="center">';
print $form->textwithtooltip($langs->trans("Group"),$langs->trans("PermissionInheritedFromAGroup"));
print $form->textwithtooltip($langs->trans("Inherited"),$langs->trans("PermissionInheritedFromAGroup"));
//print '<a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$fuser->id.'" title="'.$langs->trans("PermissionInheritedFromAGroup").'">';
print '</td>';
}
@ -349,5 +349,4 @@ print '</table>';
$db->close();
llxFooter('$Date$ - $Revision$');
?>