diff --git a/htdocs/core/ajax/ajaxtooltip.php b/htdocs/core/ajax/ajaxtooltip.php index 84dd613d1b5..d5461b0dc1b 100644 --- a/htdocs/core/ajax/ajaxtooltip.php +++ b/htdocs/core/ajax/ajaxtooltip.php @@ -151,6 +151,10 @@ if ($objecttype == 'facture' || $objecttype == 'invoice') { $classpath = 'product/stock/class'; $module = 'stock'; $myobject = 'productlot'; +} elseif ($objecttype == 'usergroup') { + $classpath = 'user/class'; + $module = 'user'; + $myobject = 'usergroup'; } // Generic case for $classfile and $classname diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 964f4b9a67f..f7ea29d6720 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -50,7 +50,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; -if (!empty($conf->ldap->enabled)) { +if (isModEnabled('ldap')) { require_once DOL_DOCUMENT_ROOT.'/core/class/ldap.class.php'; } if (isModEnabled('adherent')) { @@ -785,7 +785,7 @@ if ($action == 'create' || $action == 'adduserldap') { print "
"; - if (!empty($conf->ldap->enabled) && (isset($conf->global->LDAP_SYNCHRO_ACTIVE) && getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_LDAP_TO_DOLIBARR)) { + if (isModEnabled('ldap')et($conf->global->LDAP_SYNCHRO_ACTIVE) && getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_LDAP_TO_DOLIBARR)) { // Show form to add an account from LDAP if sync LDAP -> Dolibarr is set $ldap = new Ldap(); $result = $ldap->connect_bind(); @@ -1375,7 +1375,7 @@ if ($action == 'create' || $action == 'adduserldap') { // Connexion ldap // pour recuperer passDoNotExpire et userChangePassNextLogon - if (!empty($conf->ldap->enabled) && !empty($object->ldap_sid)) { + if (isModEnabled('ldap') && !empty($object->ldap_sid)) { $ldap = new Ldap(); $result = $ldap->connect_bind(); if ($result > 0) { @@ -2896,7 +2896,7 @@ if ($action == 'create' || $action == 'adduserldap') { print ''; } - if (!empty($conf->ldap->enabled) && !empty($object->ldap_sid)) { + if (isModEnabled('ldap') && !empty($object->ldap_sid)) { $ldap->unbind(); } } diff --git a/htdocs/user/class/usergroup.class.php b/htdocs/user/class/usergroup.class.php index a9884ca59d1..327de8def0b 100644 --- a/htdocs/user/class/usergroup.class.php +++ b/htdocs/user/class/usergroup.class.php @@ -7,6 +7,7 @@ * Copyright (C) 2014 Alexis Algoud * Copyright (C) 2018 Nicolas ZABOURI * Copyright (C) 2019 Abbes Bahfir + * Copyright (C) 2023 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -28,7 +29,7 @@ */ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; -if (!empty($conf->ldap->enabled)) { +if (isModEnabled('ldap')) { require_once DOL_DOCUMENT_ROOT."/core/class/ldap.class.php"; } @@ -706,6 +707,33 @@ class UserGroup extends CommonObject return ''; } + /** + * getTooltipContentArray + * + * @param array $params ex option, infologin + * @since v18 + * @return array + */ + public function getTooltipContentArray($params) + { + global $conf, $langs, $menumanager; + + $option = $params['option'] ?? ''; + + $datas = []; + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { + $langs->load("users"); + return ['optimize' => $langs->trans("ShowGroup")]; + } + $datas['divopen'] = '
'; + $datas['picto'] = img_picto('', 'group').' '.$langs->trans("Group").'
'; + $datas['name'] = ''.$langs->trans('Name').': '.$this->name; + $datas['description'] = '
'.$langs->trans("Description").': '.$this->note; + $datas['divclose'] = '
'; + + return $datas; + } + /** * Return a link to the user card (with optionaly the picto) * Use this->id,this->lastname, this->firstname @@ -759,8 +787,18 @@ class UserGroup extends CommonObject $label = $langs->trans("ShowGroup"); $linkclose .= ' alt="'.dol_escape_htmltag($label, 1, 1).'"'; } - $linkclose .= ' title="'.dol_escape_htmltag($label, 1, 1).'"'; - $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; + if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) { + $params = [ + 'id' => $this->id, + 'objecttype' => $this->element, + 'option' => $option, + ]; + $linkclose .= ' data-params='.json_encode($params).' title="' . $langs->trans('Loading') . '"'; + $linkclose .= ' class="classforajaxtooltip'.($morecss ? ' '.$morecss : '').'"'; + } else { + $linkclose .= ' title="'.dol_escape_htmltag($label, 1, 1).'"'; + $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; + } } $linkstart = 'ldap->enabled)) { +if (isModEnabled('ldap')) { require_once DOL_DOCUMENT_ROOT.'/core/class/ldap.class.php'; } diff --git a/test/phpunit/AllTests.php b/test/phpunit/AllTests.php index 1d57db17ffc..ec419ad9987 100644 --- a/test/phpunit/AllTests.php +++ b/test/phpunit/AllTests.php @@ -41,7 +41,7 @@ if (empty($conf->adherent->enabled)) { print "Error: Module member must be enabled to have significant results.\n"; exit(1); } -if (!empty($conf->ldap->enabled)) { +if (isModEnabled('ldap')) { print "Error: LDAP module should not be enabled.\n"; exit(1); }