reduce complexity of user class

This commit is contained in:
Frédéric FRANCE 2018-09-16 13:49:22 +02:00 committed by GitHub
parent ab0f842db6
commit 4120d0f92c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2169,9 +2169,7 @@ class User extends CommonObject
*/
function getPhotoUrl($width, $height, $cssclass='', $imagesize='')
{
$result='';
$result.='<a href="'.DOL_URL_ROOT.'/user/card.php?id='.$this->id.'">';
$result ='<a href="'.DOL_URL_ROOT.'/user/card.php?id='.$this->id.'">';
$result.=Form::showphoto('userphoto', $this, $width, $height, 0, $cssclass, $imagesize);
$result.='</a>';
@ -2388,34 +2386,33 @@ class User extends CommonObject
if ($mode == 0)
{
$prefix='';
if ($statut == 1) return $langs->trans('Enabled');
if ($statut == 0) return $langs->trans('Disabled');
elseif ($statut == 0) return $langs->trans('Disabled');
}
if ($mode == 1)
elseif ($mode == 1)
{
if ($statut == 1) return $langs->trans('Enabled');
if ($statut == 0) return $langs->trans('Disabled');
elseif ($statut == 0) return $langs->trans('Disabled');
}
if ($mode == 2)
elseif ($mode == 2)
{
if ($statut == 1) return img_picto($langs->trans('Enabled'),'statut4','class="pictostatus"').' '.$langs->trans('Enabled');
if ($statut == 0) return img_picto($langs->trans('Disabled'),'statut5','class="pictostatus"').' '.$langs->trans('Disabled');
elseif ($statut == 0) return img_picto($langs->trans('Disabled'),'statut5','class="pictostatus"').' '.$langs->trans('Disabled');
}
if ($mode == 3)
elseif ($mode == 3)
{
if ($statut == 1) return img_picto($langs->trans('Enabled'),'statut4','class="pictostatus"');
if ($statut == 0) return img_picto($langs->trans('Disabled'),'statut5','class="pictostatus"');
elseif ($statut == 0) return img_picto($langs->trans('Disabled'),'statut5','class="pictostatus"');
}
if ($mode == 4)
elseif ($mode == 4)
{
if ($statut == 1) return img_picto($langs->trans('Enabled'),'statut4','class="pictostatus"').' '.$langs->trans('Enabled');
if ($statut == 0) return img_picto($langs->trans('Disabled'),'statut5','class="pictostatus"').' '.$langs->trans('Disabled');
elseif ($statut == 0) return img_picto($langs->trans('Disabled'),'statut5','class="pictostatus"').' '.$langs->trans('Disabled');
}
if ($mode == 5)
elseif ($mode == 5)
{
if ($statut == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4','class="pictostatus"');
if ($statut == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5','class="pictostatus"');
elseif ($statut == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5','class="pictostatus"');
}
}
@ -2436,8 +2433,8 @@ class User extends CommonObject
global $conf;
$dn='';
if ($mode==0) $dn=$conf->global->LDAP_KEY_USERS."=".$info[$conf->global->LDAP_KEY_USERS].",".$conf->global->LDAP_USER_DN;
if ($mode==1) $dn=$conf->global->LDAP_USER_DN;
if ($mode==2) $dn=$conf->global->LDAP_KEY_USERS."=".$info[$conf->global->LDAP_KEY_USERS];
elseif ($mode==1) $dn=$conf->global->LDAP_USER_DN;
elseif ($mode==2) $dn=$conf->global->LDAP_KEY_USERS."=".$info[$conf->global->LDAP_KEY_USERS];
return $dn;
}
@ -3020,7 +3017,7 @@ class User extends CommonObject
public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id)
{
$tables = array(
'user'
'user',
);
return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables);