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 ''.$langs->trans("Gender").''; print ''; $arraygender = array('man'=>$langs->trans("Genderman"), 'woman'=>$langs->trans("Genderwoman")); - print $form->selectarray('gender', $arraygender, GETPOST('gender') ?GETPOST('gender') : $object->gender, 1); + if ($caneditfield) { + print $form->selectarray('gender', $arraygender, GETPOSTISSET('gender') ?GETPOST('gender') : $object->gender, 1); + } else { + print $arraygender[$object->gender]; + } print ''; // Employee @@ -2387,31 +2393,50 @@ else // Address print ''.$form->editfieldkey('Address', 'address', '', $object, 0).''; - print ''; + if ($caneditfield) print ''; + print ''; // Zip print ''.$form->editfieldkey('Zip', 'zipcode', '', $object, 0).''; - print $formcompany->select_ziptown($object->zip, 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6); + if ($caneditfield) { + print $formcompany->select_ziptown($object->zip, 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6); + } else { + print $object->zip; + } print ''; // Town print ''.$form->editfieldkey('Town', 'town', '', $object, 0).''; - print $formcompany->select_ziptown($object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id')); + if ($caneditfield) { + print $formcompany->select_ziptown($object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id')); + } else { + print $object->town; + } print ''; // Country print ''.$form->editfieldkey('Country', 'selectcounty_id', '', $object, 0).''; - print $form->select_country((GETPOST('country_id') != '' ?GETPOST('country_id') : $object->country_id), 'country_id'); - if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + if ($caneditfield) { + print $form->select_country((GETPOST('country_id') != '' ?GETPOST('country_id') : $object->country_id), 'country_id'); + if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + } else { + $countrylabel = getCountry($object->country_id, '0'); + print $countrylabel; + } print ''; // State if (empty($conf->global->USER_DISABLE_STATE)) { print ''.$form->editfieldkey('State', 'state_id', '', $object, 0).''; - print $formcompany->select_state($object->state_id, $object->country_code, 'state_id'); + if ($caneditfield) { + print $formcompany->select_state($object->state_id, $object->country_code, 'state_id'); + } else { + print $object->state_label; + } print ''; }