From c5fcd99f6e92f6228cddc3c998c28b758230dbd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20NASSIET?= Date: Mon, 23 Jan 2023 19:51:00 +0100 Subject: [PATCH 1/3] Adding a hook addToLandingPageList in userihm context --- htdocs/user/param_ihm.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/htdocs/user/param_ihm.php b/htdocs/user/param_ihm.php index 3d2e3240ce3..136da34e1bd 100644 --- a/htdocs/user/param_ihm.php +++ b/htdocs/user/param_ihm.php @@ -215,6 +215,16 @@ if (isModEnabled('ticket')) { $tmparray['ticket/list.php?mainmenu=ticket&leftmenu='] = 'Tickets'; } +// Hook for insertion new items in the List of possible landing pages +$reshook = $hookmanager->executeHooks('addToLandingPageList', $tmparray, $object); +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} elseif ($reshook > 0) { + $tmparray=$hookmanager->resArray; +} elseif ($reshook == 0) { + $tmparray=array_merge($tmparray, $hookmanager->resArray); +} + $head = user_prepare_head($object); $title = $langs->trans("User"); 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 2/3] 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; From cade14a80736678fa09c2033581bd1a4cb9c6415 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 23 Jan 2023 21:13:30 +0000 Subject: [PATCH 3/3] Fixing style errors. --- htdocs/user/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 21e18c94e99..688ac6c28ac 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -420,13 +420,13 @@ if (empty($reshook)) { /* * Protection against deletion of ref_employee while the field is not present in the user tab */ - if (GETPOSTISSET("ref_employee")){ + 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")){ + if (GETPOSTISSET("national_registration_number")) { $object->national_registration_number = GETPOST("national_registration_number", 'alphanohtml'); } $object->gender = GETPOST("gender", 'aZ09');