add ajax tooltip on usergroup

This commit is contained in:
Frédéric FRANCE 2023-02-03 09:29:02 +01:00
parent dc33289a10
commit 140a3b462d
5 changed files with 51 additions and 9 deletions

View File

@ -151,6 +151,10 @@ if ($objecttype == 'facture' || $objecttype == 'invoice') {
$classpath = 'product/stock/class'; $classpath = 'product/stock/class';
$module = 'stock'; $module = 'stock';
$myobject = 'productlot'; $myobject = 'productlot';
} elseif ($objecttype == 'usergroup') {
$classpath = 'user/class';
$module = 'user';
$myobject = 'usergroup';
} }
// Generic case for $classfile and $classname // Generic case for $classfile and $classname

View File

@ -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/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.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'; require_once DOL_DOCUMENT_ROOT.'/core/class/ldap.class.php';
} }
if (isModEnabled('adherent')) { if (isModEnabled('adherent')) {
@ -785,7 +785,7 @@ if ($action == 'create' || $action == 'adduserldap') {
print "<br>"; print "<br>";
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 // Show form to add an account from LDAP if sync LDAP -> Dolibarr is set
$ldap = new Ldap(); $ldap = new Ldap();
$result = $ldap->connect_bind(); $result = $ldap->connect_bind();
@ -1375,7 +1375,7 @@ if ($action == 'create' || $action == 'adduserldap') {
// Connexion ldap // Connexion ldap
// pour recuperer passDoNotExpire et userChangePassNextLogon // pour recuperer passDoNotExpire et userChangePassNextLogon
if (!empty($conf->ldap->enabled) && !empty($object->ldap_sid)) { if (isModEnabled('ldap') && !empty($object->ldap_sid)) {
$ldap = new Ldap(); $ldap = new Ldap();
$result = $ldap->connect_bind(); $result = $ldap->connect_bind();
if ($result > 0) { if ($result > 0) {
@ -2896,7 +2896,7 @@ if ($action == 'create' || $action == 'adduserldap') {
print '</div></div>'; print '</div></div>';
} }
if (!empty($conf->ldap->enabled) && !empty($object->ldap_sid)) { if (isModEnabled('ldap') && !empty($object->ldap_sid)) {
$ldap->unbind(); $ldap->unbind();
} }
} }

View File

@ -7,6 +7,7 @@
* Copyright (C) 2014 Alexis Algoud <alexis@atm-consulting.fr> * Copyright (C) 2014 Alexis Algoud <alexis@atm-consulting.fr>
* Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com> * Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
* Copyright (C) 2019 Abbes Bahfir <dolipar@dolipar.org> * Copyright (C) 2019 Abbes Bahfir <dolipar@dolipar.org>
* Copyright (C) 2023 Frédéric France <frederic.france@netlogic.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * 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'; 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"; require_once DOL_DOCUMENT_ROOT."/core/class/ldap.class.php";
} }
@ -706,6 +707,33 @@ class UserGroup extends CommonObject
return ''; 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'] = '<div class="centpercent">';
$datas['picto'] = img_picto('', 'group').' <u>'.$langs->trans("Group").'</u><br>';
$datas['name'] = '<b>'.$langs->trans('Name').':</b> '.$this->name;
$datas['description'] = '<br><b>'.$langs->trans("Description").':</b> '.$this->note;
$datas['divclose'] = '</div>';
return $datas;
}
/** /**
* Return a link to the user card (with optionaly the picto) * Return a link to the user card (with optionaly the picto)
* Use this->id,this->lastname, this->firstname * Use this->id,this->lastname, this->firstname
@ -759,8 +787,18 @@ class UserGroup extends CommonObject
$label = $langs->trans("ShowGroup"); $label = $langs->trans("ShowGroup");
$linkclose .= ' alt="'.dol_escape_htmltag($label, 1, 1).'"'; $linkclose .= ' alt="'.dol_escape_htmltag($label, 1, 1).'"';
} }
$linkclose .= ' title="'.dol_escape_htmltag($label, 1, 1).'"'; if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) {
$linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; $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 = '<a href="'.$url.'"'; $linkstart = '<a href="'.$url.'"';

View File

@ -30,7 +30,7 @@ require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
if (!empty($conf->ldap->enabled)) { if (isModEnabled('ldap')) {
require_once DOL_DOCUMENT_ROOT.'/core/class/ldap.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/ldap.class.php';
} }

View File

@ -41,7 +41,7 @@ if (empty($conf->adherent->enabled)) {
print "Error: Module member must be enabled to have significant results.\n"; print "Error: Module member must be enabled to have significant results.\n";
exit(1); exit(1);
} }
if (!empty($conf->ldap->enabled)) { if (isModEnabled('ldap')) {
print "Error: LDAP module should not be enabled.\n"; print "Error: LDAP module should not be enabled.\n";
exit(1); exit(1);
} }