From 26e23219e6b2b2c378ac4e82f24d30327348719f Mon Sep 17 00:00:00 2001 From: Steve Date: Wed, 23 Feb 2022 10:34:54 +0100 Subject: [PATCH] feat: dolGetButtonAction --- htdocs/user/card.php | 66 ++++++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 3b3d4324323..f4ac28b7262 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -1843,21 +1843,16 @@ if ($action == 'create' || $action == 'adduserldap') { } if ($caneditfield && (empty($conf->multicompany->enabled) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) { + $params = array( + 'attr' => array( + 'title' => '', + 'class' => 'classfortooltip' + ) + ); if (!empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED)) { - $params = array( - 'attr' => array( - 'title' => $langs->trans('DisabledInMonoUserMode'), - 'class' => 'classfortooltip' - ) - ); + $params['attr']['title'] = $langs->trans('DisabledInMonoUserMode'); print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER['PHP_SELF'].'#', '', false, $params); } else { - $params = array( - 'attr' => array( - 'title' => '', - 'class' => 'classfortooltip' - ) - ); print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=edit', '', true, $params); } } elseif ($caneditpassword && !$object->ldap_sid && @@ -1872,43 +1867,53 @@ if ($action == 'create' || $action == 'adduserldap') { } // Si on a un gestionnaire de generation de mot de passe actif + $params = array( + 'attr' => array( + 'title' => '', + 'class' => 'classfortooltip' + ) + ); if ($conf->global->USER_PASSWORD_GENERATED != 'none') { if ($object->statut == 0) { - print '
'.$langs->trans("ReinitPassword").'
'; + $params['attr']['title'] = $langs->trans('UserDisabled'); + print dolGetButtonAction($langs->trans('ReinitPassword'), '', 'default', $_SERVER['PHP_SELF'].'#', '', false, $params); } elseif (($user->id != $id && $caneditpassword) && $object->login && !$object->ldap_sid && ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) { - print '
'.$langs->trans("ReinitPassword").'
'; + print dolGetButtonAction($langs->trans('ReinitPassword'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=password', '', true, $params); } if ($object->statut == 0) { - print '
'.$langs->trans("SendNewPassword").'
'; + $params['attr']['title'] = $langs->trans('UserDisabled'); + print dolGetButtonAction($langs->trans('SendNewPassword'), '', 'default', $_SERVER['PHP_SELF'].'#', '', false, $params); } elseif (($user->id != $id && $caneditpassword) && $object->login && !$object->ldap_sid && ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) { if ($object->email) { - print '
'.$langs->trans("SendNewPassword").'
'; + print dolGetButtonAction($langs->trans('SendNewPassword'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=passwordsend', '', true, $params); } else { - print '
'.$langs->trans("SendNewPassword").'
'; + $params['attr']['title'] = $langs->trans('NoEMail'); + print dolGetButtonAction($langs->trans('SendNewPassword'), '', 'default', $_SERVER['PHP_SELF'].'#', '', false, $params); } } } // Enable user + $params = array( + 'attr' => array( + 'title' => '', + 'class' => 'classfortooltip' + ) + ); if ($user->id <> $id && $candisableuser && $object->statut == 0 && ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) { - print dolGetButtonAction($langs->trans('Reactivate'), '', 'default', $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=enable&token='.newToken().$langs->trans("Reactivate"), ''); + print dolGetButtonAction($langs->trans('Reactivate'), '', 'default', $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=enable&token='.newToken().$langs->trans("Reactivate"), '', true, $params); } // Disable user if ($user->id <> $id && $candisableuser && $object->statut == 1 && ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) { - print dolGetButtonAction($langs->trans('DisableUser'), '', 'default', $_SERVER['PHP_SELF'] . '?action=disable&id=' . $object->id . '&token='.newToken().$langs->trans("DisableUser"), ''); + print dolGetButtonAction($langs->trans('DisableUser'), '', 'default', $_SERVER['PHP_SELF'] . '?action=disable&id=' . $object->id . '&token='.newToken().$langs->trans("DisableUser"), '', true, $params); } else { if ($user->id == $id) { - $params = array( - 'attr' => array( - 'title' => $langs->trans('CantDisableYourself'), - 'class' => 'classfortooltip' - ) - ); + $params['attr']['title'] = $langs->trans('CantDisableYourself'); print dolGetButtonAction($langs->trans('DisableUser'), '', 'default', $_SERVER['PHP_SELF'].'#', '', false, $params); } } @@ -1916,15 +1921,10 @@ if ($action == 'create' || $action == 'adduserldap') { if ($user->id <> $id && $candisableuser && ((empty($conf->multicompany->enabled) && $object->entity == $user->entity) || !$user->entity || ($object->entity == $conf->entity) || ($conf->global->MULTICOMPANY_TRANSVERSE_MODE && $conf->entity == 1))) { if ($user->admin || !$object->admin) { // If user edited is admin, delete is possible on for an admin - print dolGetButtonAction($langs->trans('DeleteUser'), '', 'default', $_SERVER['PHP_SELF'].'?action=delete&token='.newToken().'&id='.$object->id, ''); + print dolGetButtonAction($langs->trans('DeleteUser'), '', 'default', $_SERVER['PHP_SELF'].'?action=delete&token='.newToken().'&id='.$object->id, '', true, $params); } else { - $params = array( - 'attr' => array( - 'title' => $langs->trans('MustBeAdminToDeleteOtherAdmin'), - 'class' => 'classfortooltip' - ) - ); - print dolGetButtonAction($langs->trans('DeleteUser'), '', 'default', $_SERVER['PHP_SELF'].'?action=delete&token='.newToken().'&id='.$object->id, '', false); + $params['attr']['title'] = $langs->trans('MustBeAdminToDeleteOtherAdmin'); + print dolGetButtonAction($langs->trans('DeleteUser'), '', 'default', $_SERVER['PHP_SELF'].'?action=delete&token='.newToken().'&id='.$object->id, '', false, $params); } } }