clean code

This commit is contained in:
Frédéric FRANCE 2023-02-06 23:00:42 +01:00
parent 3238d82386
commit ff94600d8f
2 changed files with 36 additions and 101 deletions

View File

@ -2849,82 +2849,30 @@ class User extends CommonObject
$withpictoimg = 0; $withpictoimg = 0;
} }
$result = ''; $label = ''; $companylink = ''; $result = '';
$params = [
if (!empty($this->photo)) { 'id' => $this->id,
$label .= '<div class="photointooltip floatright">'; 'objecttype' => $this->element,
$label .= Form::showphoto('userphoto', $this, 0, 60, 0, 'photoref photowithmargin photologintooltip', 'small', 0, 1); // Force height to 60 so we total height of tooltip can be calculated and collision can be managed 'infologin' => $infologin,
$label .= '</div>'; 'option' => $option,
//$label .= '<div style="clear: both;"></div>'; ];
$classfortooltip = 'classfortooltip';
$dataparams = '';
if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) {
$classfortooltip = 'classforajaxtooltip';
$dataparams = ' data-params='.json_encode($params);
// $label = $langs->trans('Loading');
} }
$label = implode($this->getTooltipContentArray($params));
// Info Login $companylink = '';
$label .= '<div class="centpercent">';
$label .= img_picto('', $this->picto).' <u class="paddingrightonly">'.$langs->trans("User").'</u>';
$label .= ' '.$this->getLibStatut(4);
$label .= '<br><b>'.$langs->trans('Name').':</b> '.dol_string_nohtmltag($this->getFullName($langs, ''));
if (!empty($this->login)) {
$label .= '<br><b>'.$langs->trans('Login').':</b> '.dol_string_nohtmltag($this->login);
}
if (!empty($this->job)) {
$label .= '<br><b>'.$langs->trans("Job").':</b> '.dol_string_nohtmltag($this->job);
}
$label .= '<br><b>'.$langs->trans("Email").':</b> '.dol_string_nohtmltag($this->email);
if (!empty($this->office_phone) || !empty($this->office_fax) || !empty($this->fax)) {
$phonelist = array();
if ($this->office_phone) {
$phonelist[] = dol_print_phone($this->office_phone, $this->country_code, $this->id, 0, '', '&nbsp', 'phone');
}
if ($this->office_fax) {
$phonelist[] = dol_print_phone($this->office_fax, $this->country_code, $this->id, 0, '', '&nbsp', 'fax');
}
if ($this->user_mobile) {
$phonelist[] = dol_print_phone($this->user_mobile, $this->country_code, $this->id, 0, '', '&nbsp', 'mobile');
}
$label .= '<br><b>'.$langs->trans('Phone').':</b> '.implode('&nbsp;', $phonelist);
}
if (!empty($this->admin)) {
$label .= '<br><b>'.$langs->trans("Administrator").'</b>: '.yn($this->admin);
}
if (!empty($this->accountancy_code) || $option == 'accountancy') {
$label .= '<br><b>'.$langs->trans("AccountancyCode").'</b>: '.$this->accountancy_code;
}
$company = '';
if (!empty($this->socid)) { // Add thirdparty for external users if (!empty($this->socid)) { // Add thirdparty for external users
$thirdpartystatic = new Societe($db); $thirdpartystatic = new Societe($this->db);
$thirdpartystatic->fetch($this->socid); $thirdpartystatic->fetch($this->socid);
if (empty($hidethirdpartylogo)) { if (empty($hidethirdpartylogo)) {
$companylink = ' '.$thirdpartystatic->getNomUrl(2, (($option == 'nolink') ? 'nolink' : '')); // picto only of company $companylink = ' '.$thirdpartystatic->getNomUrl(2, (($option == 'nolink') ? 'nolink' : '')); // picto only of company
} }
$company = ' ('.$langs->trans("Company").': '.img_picto('', 'company').' '.dol_string_nohtmltag($thirdpartystatic->name).')';
}
$type = ($this->socid ? $langs->trans("ExternalUser").$company : $langs->trans("InternalUser"));
$label .= '<br><b>'.$langs->trans("Type").':</b> '.$type;
$label .= '</div>';
if ($infologin > 0) {
$label .= '<br>';
$label .= '<br><u>'.$langs->trans("Session").'</u>';
$label .= '<br><b>'.$langs->trans("IPAddress").'</b>: '.dol_string_nohtmltag(getUserRemoteIP());
if (!empty($conf->global->MAIN_MODULE_MULTICOMPANY)) {
$label .= '<br><b>'.$langs->trans("ConnectedOnMultiCompany").':</b> '.$conf->entity.' (User entity '.$this->entity.')';
}
$label .= '<br><b>'.$langs->trans("AuthenticationMode").':</b> '.dol_string_nohtmltag($_SESSION["dol_authmode"].(empty($dolibarr_main_demo) ? '' : ' (demo)'));
$label .= '<br><b>'.$langs->trans("ConnectedSince").':</b> '.dol_print_date($this->datelastlogin, "dayhour", 'tzuser');
$label .= '<br><b>'.$langs->trans("PreviousConnexion").':</b> '.dol_print_date($this->datepreviouslogin, "dayhour", 'tzuser');
$label .= '<br><b>'.$langs->trans("CurrentTheme").':</b> '.dol_string_nohtmltag($conf->theme);
$label .= '<br><b>'.$langs->trans("CurrentMenuManager").':</b> '.dol_string_nohtmltag($menumanager->name);
$s = picto_from_langcode($langs->getDefaultLang());
$label .= '<br><b>'.$langs->trans("CurrentUserLanguage").':</b> '.dol_string_nohtmltag(($s ? $s.' ' : '').$langs->getDefaultLang());
$label .= '<br><b>'.$langs->trans("Browser").':</b> '.dol_string_nohtmltag($conf->browser->name.($conf->browser->version ? ' '.$conf->browser->version : '').' ('.$_SERVER['HTTP_USER_AGENT'].')');
$label .= '<br><b>'.$langs->trans("Layout").':</b> '.dol_string_nohtmltag($conf->browser->layout);
$label .= '<br><b>'.$langs->trans("Screen").':</b> '.dol_string_nohtmltag($_SESSION['dol_screenwidth'].' x '.$_SESSION['dol_screenheight']);
if ($conf->browser->layout == 'phone') {
$label .= '<br><b>'.$langs->trans("Phone").':</b> '.$langs->trans("Yes");
}
if (!empty($_SESSION["disablemodules"])) {
$label .= '<br><b>'.$langs->trans("DisabledModules").':</b> <br>'.dol_string_nohtmltag(join(', ', explode(',', $_SESSION["disablemodules"])));
}
} }
if ($infologin < 0) { if ($infologin < 0) {
$label = ''; $label = '';
} }
@ -2947,19 +2895,6 @@ class User extends CommonObject
$linkstart = '<a href="'.$url.'"'; $linkstart = '<a href="'.$url.'"';
$linkclose = ""; $linkclose = "";
$classfortooltip = 'classfortooltip';
$dataparams = '';
if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) {
$params = [
'id' => $this->id,
'objecttype' => $this->element,
'infologin' => $infologin,
'option' => $option,
];
$classfortooltip = 'classforajaxtooltip';
$dataparams = ' data-params='.json_encode($params);
// $label = $langs->trans('Loading');
}
if (empty($notooltip)) { if (empty($notooltip)) {
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
$langs->load("users"); $langs->load("users");

View File

@ -105,6 +105,11 @@ class UserGroup extends CommonObject
private $_tab_loaded = array(); // Array of cache of already loaded permissions private $_tab_loaded = array(); // Array of cache of already loaded permissions
/**
* @var int all_permissions_are_loaded
*/
public $all_permissions_are_loaded;
public $oldcopy; // To contains a clone of this when we need to save old properties of object public $oldcopy; // To contains a clone of this when we need to save old properties of object
public $fields = array( public $fields = array(
@ -767,13 +772,20 @@ class UserGroup extends CommonObject
$withpicto = 0; $withpicto = 0;
} }
$result = ''; $label = ''; $result = '';
$params = [
$label .= '<div class="centpercent">'; 'id' => $this->id,
$label .= img_picto('', 'group').' <u>'.$langs->trans("Group").'</u><br>'; 'objecttype' => $this->element,
$label .= '<b>'.$langs->trans('Name').':</b> '.$this->name; 'option' => $option,
$label .= '<br><b>'.$langs->trans("Description").':</b> '.$this->note; ];
$label .= '</div>'; $classfortooltip = 'classfortooltip';
$dataparams = '';
if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) {
$classfortooltip = 'classforajaxtooltip';
$dataparams = ' data-params='.json_encode($params);
// $label = $langs->trans('Loading');
}
$label = implode($this->getTooltipContentArray($params));
if ($option == 'permissions') { if ($option == 'permissions') {
$url = DOL_URL_ROOT.'/user/group/perms.php?id='.$this->id; $url = DOL_URL_ROOT.'/user/group/perms.php?id='.$this->id;
@ -793,18 +805,6 @@ class UserGroup extends CommonObject
} }
$linkclose = ""; $linkclose = "";
$classfortooltip = 'classfortooltip';
$dataparams = '';
if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) {
$params = [
'id' => $this->id,
'objecttype' => $this->element,
'option' => $option,
];
$classfortooltip = 'classforajaxtooltip';
$dataparams = ' data-params='.json_encode($params);
// $label = $langs->trans('Loading');
}
if (empty($notooltip)) { if (empty($notooltip)) {
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
$langs->load("users"); $langs->load("users");