From a665ff5bdacc55e52434d830e5d37d8c57abf81d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 12 May 2021 11:51:39 +0200 Subject: [PATCH] Copy-Paste works also for hidden fields --- htdocs/core/lib/functions.lib.php | 22 ++++++++++++------- htdocs/theme/eldy/global.inc.php | 10 +++++++-- htdocs/theme/md/style.css.php | 17 ++++++++++++++- htdocs/user/card.php | 36 +++++++++++++++++-------------- 4 files changed, 58 insertions(+), 27 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index ba953282d2d..970ec73e373 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3505,7 +3505,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'margin', 'map-marker-alt', 'member', 'meeting', 'money-bill-alt', 'movement', 'mrp', 'note', 'next', 'off', 'on', 'order', 'paiment', 'paragraph', 'play', 'pdf', 'phone', 'playdisabled', 'previous', 'poll', 'pos', 'printer', 'product', 'propal', 'stock', 'resize', 'service', 'stats', 'trip', - 'setup', 'share-alt', 'sign-out', 'split', 'stripe', 'stripe-s', 'switch_off', 'switch_on', 'tools', 'unlink', 'uparrow', 'user', 'vcard', 'wrench', + 'security', 'setup', 'share-alt', 'sign-out', 'split', 'stripe', 'stripe-s', 'switch_off', 'switch_on', 'tools', 'unlink', 'uparrow', 'user', 'vcard', 'wrench', 'github', 'jabber', 'skype', 'twitter', 'facebook', 'linkedin', 'instagram', 'snapchat', 'youtube', 'google-plus-g', 'whatsapp', 'chevron-left', 'chevron-right', 'chevron-down', 'chevron-top', 'commercial', 'companies', 'generic', 'home', 'hrm', 'members', 'products', 'invoicing', @@ -3556,7 +3556,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'reception'=>'dolly', 'recruitmentjobposition'=>'id-card-alt', 'recruitmentcandidature'=>'id-badge', 'resize'=>'crop', 'supplier_order'=>'dol-order_supplier', 'supplier_proposal'=>'file-signature', 'refresh'=>'redo', 'resource'=>'laptop-house', - 'salary'=>'wallet', 'shipment'=>'dolly', 'stock'=>'box-open', 'stats' => 'chart-bar', 'split'=>'code-branch', 'stripe'=>'stripe-s', + 'security'=>'key', 'salary'=>'wallet', 'shipment'=>'dolly', 'stock'=>'box-open', 'stats' => 'chart-bar', 'split'=>'code-branch', 'stripe'=>'stripe-s', 'supplier'=>'building', 'supplier_invoice'=>'file-invoice-dollar', 'technic'=>'cogs', 'ticket'=>'ticket-alt', 'timespent'=>'clock', 'title_setup'=>'tools', 'title_accountancy'=>'money-check-alt', 'title_bank'=>'university', 'title_hrm'=>'umbrella-beach', 'title_agenda'=>'calendar-alt', @@ -3656,7 +3656,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'other'=>'#ddd', 'partnership'=>'#6c6aa8', 'playdisabled'=>'#ccc', 'printer'=>'#444', 'projectpub'=>'#986c6a', 'reception'=>'#a69944', 'resize'=>'#444', 'rss'=>'#cba', //'shipment'=>'#a69944', - 'stats'=>'#444', 'switch_off'=>'#999', 'technic'=>'#999', 'timespent'=>'#555', + 'security'=>'#999', 'stats'=>'#444', 'switch_off'=>'#999', 'technic'=>'#999', 'timespent'=>'#555', 'uncheck'=>'#800', 'uparrow'=>'#555', 'user-cog'=>'#999', 'country'=>'#aaa', 'globe-americas'=>'#aaa', 'website'=>'#304', 'workstation'=>'#a69944' ); @@ -10232,14 +10232,20 @@ function readfileLowMemory($fullpath_original_file_osencoded, $method = -1) } /** - * Create a button to copy $valuetoprint in the clipboard + * Create a button to copy $valuetocopy in the clipboard * - * @param string $valuetoprint The value to print - * @param int $showonlyonhover Show the copypaste button only on hover + * @param string $valuetocopy The value to print + * @param int $showonlyonhover Show the copy-paste button only on hover + * @param string $texttoshow Replace the value to show with this text * @return string The string to print for the button */ -function showValueWithClipboardCPButton($valuetoprint, $showonlyonhover = 1) +function showValueWithClipboardCPButton($valuetocopy, $showonlyonhover = 1, $texttoshow = '') { - $result = ''.$valuetoprint.''; + if ($texttoshow) { + $result = ''.$valuetocopy.''.$texttoshow.''; + } else { + $result = ''.$valuetocopy.''; + } + return $result; } diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index e9a646d751f..912cf21a1de 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -4674,7 +4674,7 @@ table.dp { /* ============================================================================== */ -/* Afficher/cacher */ +/* Show/Hide */ /* ============================================================================== */ div.visible { @@ -6763,9 +6763,15 @@ div.phpdebugbar-widgets-templates a.phpdebugbar-widgets-editor-link:before /* ============================================================================== */ -/* For copypaste feature */ +/* For copy-paste feature */ /* ============================================================================== */ +span.clipboardCPValue.hidewithsize { + width: 0 !important; + display: inline-block; + color: transparent; +} + .clipboardCPShowOnHover .clipboardCPButton { display: none; } diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 0b09b141258..8152e56e945 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -4583,7 +4583,7 @@ table.dp { /* ============================================================================== */ -/* Afficher/cacher */ +/* Show/Hide */ /* ============================================================================== */ div.visible { @@ -6606,6 +6606,21 @@ div.phpdebugbar-widgets-templates a.phpdebugbar-widgets-editor-link:before } +/* ============================================================================== */ +/* For copy-paste feature */ +/* ============================================================================== */ + +span.clipboardCPValue.hidewithsize { + width: 0 !important; + display: inline-block; + color: transparent; +} + +.clipboardCPShowOnHover .clipboardCPButton { + display: none; +} + + /* ============================================================================== */ /* CSS style used for small screen */ /* ============================================================================== */ diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 8b31f8b544b..332c98f56da 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -1573,7 +1573,7 @@ if ($action == 'create' || $action == 'adduserldap') { // Color user if (!empty($conf->agenda->enabled)) { - print ''.$langs->trans("ColorUser").''; + print ''.$langs->trans("ColorUser").''; print ''; print $formother->showColor($object->color, ''); print ''; @@ -1582,7 +1582,7 @@ if ($action == 'create' || $action == 'adduserldap') { // Categories if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) { - print ''.$langs->trans("Categories").''; + print ''.$langs->trans("Categories").''; print ''; print $form->showCategories($object->id, Categorie::TYPE_USER, 1); print ''; @@ -1591,7 +1591,7 @@ if ($action == 'create' || $action == 'adduserldap') { // Default language if (!empty($conf->global->MAIN_MULTILANGS)) { require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - print ''.$langs->trans("DefaultLang").''; + print ''.$langs->trans("DefaultLang").''; //$s=picto_from_langcode($object->default_lang); //print ($s?$s.' ':''); $langs->load("languages"); @@ -1606,14 +1606,6 @@ if ($action == 'create' || $action == 'adduserldap') { print "\n"; } - print ''.$langs->trans("LastConnexion").''; - print ''.dol_print_date($object->datelastlogin, "dayhour").''; - print "\n"; - - print ''.$langs->trans("PreviousConnexion").''; - print ''.dol_print_date($object->datepreviouslogin, "dayhour").''; - print "\n"; - // Multicompany if (!empty($conf->multicompany->enabled) && is_object($mc)) { // This is now done with hook formObjectOptions. Keep this code for backward compatibility with old multicompany module @@ -1698,13 +1690,13 @@ if ($action == 'create' || $action == 'adduserldap') { print "\n"; - + // Credentials print '
'; - print ''; + print '
'; print ''; - print ''; + print ''; print ''; // Date login validity @@ -1779,13 +1771,25 @@ if ($action == 'create' || $action == 'adduserldap') { print ''; print ''; } + + print ''; + print ''; + print "\n"; + print '
'; - print $langs->trans("Credentials"); + print img_picto('', 'security', 'class="paddingleft pictofixedwidth"').$langs->trans("Credentials"); print '
'.$langs->trans("ApiKey").''; if (!empty($object->api_key)) { - print ''.preg_replace('/./', '*', $object->api_key).''; + print ''; + print showValueWithClipboardCPButton($object->api_key, 1, $langs->trans("Hidden")); + print ''; } if ($user->admin || $user->id == $object->id) { // TODO Add a feature to reveal the hash } print '
'.$langs->trans("LastConnexion").''; + if ($object->datepreviouslogin) { + print dol_print_date($object->datepreviouslogin, "dayhour").' ('.$langs->trans("Previous").'), '; + } + print dol_print_date($object->datelastlogin, "dayhour").' ('.$langs->trans("Current").')'; + print '
'; print '';