diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 5a7b8342bd6..b811fe70abf 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -311,6 +311,9 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f { foreach ($feature2 as $subfeature) { + if ($subfeature == 'user' && $user->id == $objectid && $user->rights->user->self->creer) continue; // User can edit its own card + if ($subfeature == 'user' && $user->id == $objectid && $user->rights->user->self->password) continue; // User can edit its own password + if (empty($user->rights->$feature->$subfeature->creer) && empty($user->rights->$feature->$subfeature->write) && empty($user->rights->$feature->$subfeature->create)) { diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 7feaf2911fa..d12f6064131 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -40,6 +40,7 @@ require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; @@ -85,8 +86,7 @@ if ($id) $socid = 0; if ($user->socid > 0) $socid = $user->socid; $feature2 = 'user'; - -$result = restrictedArea($user, 'user', $id, 'user&user', $feature2); +$result = restrictedArea($user, 'user', $id, 'user', $feature2); if ($user->id <> $id && !$canreaduser) accessforbidden(); @@ -567,12 +567,14 @@ if (empty($reshook)) { $object->fetch($id); - $object->oldcopy = clone $object; + if (GETPOST("password", "none")) { // If pass is empty, we do not change it. + $object->oldcopy = clone $object; - $ret = $object->setPassword($user, GETPOST("password")); - if ($ret < 0) - { - setEventMessages($object->error, $object->errors, 'errors'); + $ret = $object->setPassword($user, GETPOST("password", "none")); + if ($ret < 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + } } } } @@ -1551,7 +1553,7 @@ else else { if ($user->admin) $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').$langs->trans("Crypted").': '.$object->pass_indatabase_crypted; - else $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').$langs->trans("Hidden"); + else $valuetoshow .= ($valuetoshow ? (' '.$langs->trans("or").' ') : '').''.$langs->trans("Hidden").''; } } @@ -2307,7 +2309,11 @@ else print '