From 124a76029ecdf541c4eef2428aea7a567f1ec497 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20NASSIET?= Date: Mon, 23 Jan 2023 21:45:28 +0100 Subject: [PATCH] Protection against deletion of ref_employee and national_registration_number while fields are not presents in the user tab --- htdocs/user/card.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index dbe1764f54e..21e18c94e99 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -417,8 +417,18 @@ if (empty($reshook)) { $object->civility_code = GETPOST("civility_code", 'aZ09'); $object->lastname = GETPOST("lastname", 'alphanohtml'); $object->firstname = GETPOST("firstname", 'alphanohtml'); - $object->ref_employee = GETPOST("ref_employee", 'alphanohtml'); - $object->national_registration_number = GETPOST("national_registration_number", 'alphanohtml'); + /* + * Protection against deletion of ref_employee while the field is not present in the user tab + */ + if (GETPOSTISSET("ref_employee")){ + $object->ref_employee = GETPOST("ref_employee", 'alphanohtml'); + } + /* + * Protection against deletion of national_registration_number while the field is not present in the user tab + */ + if (GETPOSTISSET("national_registration_number")){ + $object->national_registration_number = GETPOST("national_registration_number", 'alphanohtml'); + } $object->gender = GETPOST("gender", 'aZ09'); $object->pass = GETPOST("password", 'none'); // We can keep 'none' for password fields $object->api_key = (GETPOST("api_key", 'alphanohtml')) ? GETPOST("api_key", 'alphanohtml') : $object->api_key;