diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index bc26812bd29..6bb8049f6f6 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -5254,11 +5254,11 @@ class Form
* @param int $height Height of photo (auto if 0)
* @param int $caneditfield Add edit fields
* @param string $cssclass CSS name to use on img for photo
- * @param int $genericifundef Use a generic image if no image avaiable
+ * @param string $imagesize 'mini', 'small' or '' (original)
* @param int $addlinktofullsize Add link to fullsize image
* @return string HTML code to output photo
*/
- static function showphoto($modulepart, $object, $width=100, $height=0, $caneditfield=0, $cssclass='photowithmargin', $genericifundef=0,$addlinktofullsize=1)
+ static function showphoto($modulepart, $object, $width=100, $height=0, $caneditfield=0, $cssclass='photowithmargin', $imagesize='',$addlinktofullsize=1)
{
global $conf,$langs;
@@ -5272,29 +5272,52 @@ class Form
$dir=$conf->societe->multidir_output[$entity];
$smallfile=$object->logo;
$smallfile=preg_replace('/(\.png|\.gif|\.jpg|\.jpeg|\.bmp)/i','_small\\1',$smallfile);
- if (! empty($object->logo)) $file=$id.'/logos/thumbs/'.$smallfile;
+ if (! empty($object->logo))
+ {
+ if ($imagesize == 'mini') $file=$id.'/logos/thumbs/'.getImageFileNameForSize($object->logo, '_mini');
+ else if ($imagesize == 'small') $file=$id.'/logos/thumbs/'.getImageFileNameForSize($object->logo, '_small');
+ else $file=$id.'/logos/thumbs/'.$smallfile;
+ }
}
else if ($modulepart=='contact')
{
$dir=$conf->societe->multidir_output[$entity].'/contact';
- $file=$id.'/photos/'.$object->photo;
+ if (! empty($object->photo))
+ {
+ if ($imagesize == 'mini') $file=$id.'/photos/thumbs/'.getImageFileNameForSize($object->photo, '_mini');
+ else if ($imagesize == 'small') $file=$id.'/photos/thumbs/'.getImageFileNameForSize($object->photo, '_small');
+ else $file=$id.'/photos/'.$object->photo;
+ }
}
else if ($modulepart=='userphoto')
{
$dir=$conf->user->dir_output;
- if (! empty($object->photo)) $file=get_exdir($id, 2, 0, 0, $object, 'user').$object->photo;
+ if (! empty($object->photo))
+ {
+ //var_dump(getImageFileNameForSize($object->photo, '_mini'));
+ if ($imagesize == 'mini') $file=get_exdir($id, 2, 0, 0, $object, 'user').getImageFileNameForSize($object->photo, '_mini');
+ else if ($imagesize == 'small') $file=get_exdir($id, 2, 0, 0, $object, 'user').getImageFileNameForSize($object->photo, '_small');
+ else $file=get_exdir($id, 2, 0, 0, $object, 'user').$object->photo;
+ }
if (! empty($conf->global->MAIN_OLD_IMAGE_LINKS)) $altfile=$object->id.".jpg"; // For backward compatibility
$email=$object->email;
}
else if ($modulepart=='memberphoto')
{
$dir=$conf->adherent->dir_output;
- if (! empty($object->photo)) $file=get_exdir($id, 2, 0, 0, $object, 'invoice_supplier').'photos/'.$object->photo;
+ if (! empty($object->photo))
+ {
+ if ($imagesize == 'mini') $file=get_exdir($id, 2, 0, 0, $object, 'member').'photos/'.getImageFileNameForSize($object->photo, '_mini');
+ else if ($imagesize == 'small') $file=get_exdir($id, 2, 0, 0, $object, 'member').'photos/'.getImageFileNameForSize($object->photo, '_small');
+ else $file=get_exdir($id, 2, 0, 0, $object, 'member').'photos/'.$object->photo;
+ }
if (! empty($conf->global->MAIN_OLD_IMAGE_LINKS)) $altfile=$object->id.".jpg"; // For backward compatibility
$email=$object->email;
- } else {
+ }
+ else
+ {
$dir=$conf->$modulepart->dir_output;
- if (! empty($object->photo)) $file=get_exdir($id, 2, 0, 0, $object, 'member').'photos/'.$object->photo;
+ if (! empty($object->photo)) $file=get_exdir($id, 2, 0, 0, $object, $modulepart).'photos/'.$object->photo;
if (! empty($conf->global->MAIN_OLD_IMAGE_LINKS)) $altfile=$object->id.".jpg"; // For backward compatibility
$email=$object->email;
}
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 896cc0824d0..0750d1d24b0 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -5223,3 +5223,33 @@ function natural_search($fields, $value, $mode=0, $nofirstand=0)
return $res;
}
+
+/**
+ * Return the filename of file to get the thumbs
+ *
+ * @param string $file Original filename
+ * @param string $extName Extension to differenciate thumb file name ('', '_small', '_mini')
+ * @param string $extImgTarget Force image format for thumbs. Use '' to keep same extension than original image.
+ * @return string New file name
+ */
+function getImageFileNameForSize($file, $extName, $extImgTarget='')
+{
+ $dirName = dirname($file);
+ if ($dirName == '.') $dirName='';
+
+ $fileName = preg_replace('/(\.gif|\.jpeg|\.jpg|\.png|\.bmp)$/i','',$file); // On enleve extension quelquesoit la casse
+ $fileName = basename($fileName);
+
+ if (empty($extImgTarget)) $extImgTarget = (preg_match('/\.jpg$/i',$file)?'.jpg':'');
+ if (empty($extImgTarget)) $extImgTarget = (preg_match('/\.jpeg$/i',$file)?'.jpeg':'');
+ if (empty($extImgTarget)) $extImgTarget = (preg_match('/\.gif$/i',$file)?'.gif':'');
+ if (empty($extImgTarget)) $extImgTarget = (preg_match('/\.png$/i',$file)?'.png':'');
+ if (empty($extImgTarget)) $extImgTarget = (preg_match('/\.bmp$/i',$file)?'.bmp':'');
+
+ if (! $extImgTarget) return $file;
+
+ $subdir='';
+ if ($extName) $subdir = 'thumbs/';
+
+ return $dirName.$subdir.$fileName.$extName.$extImgTarget; // New filename for thumb
+}
diff --git a/htdocs/core/lib/images.lib.php b/htdocs/core/lib/images.lib.php
index 7e47f755a7e..e61dc22eeb0 100644
--- a/htdocs/core/lib/images.lib.php
+++ b/htdocs/core/lib/images.lib.php
@@ -483,7 +483,7 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName='_small', $
break;
case IMAGETYPE_JPEG: // 2
$trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 0);
- $extImgTarget = (preg_match('/\.jpeg$/',$file)?'.jpeg':'.jpg');
+ $extImgTarget = (preg_match('/\.jpeg$/i',$file)?'.jpeg':'.jpg');
$newquality=$quality;
break;
case IMAGETYPE_PNG: // 3
@@ -512,7 +512,7 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName='_small', $
$fileName = preg_replace('/(\.gif|\.jpeg|\.jpg|\.png|\.bmp)$/i','',$file); // On enleve extension quelquesoit la casse
$fileName = basename($fileName);
- $imgThumbName = $dirthumb.'/'.$fileName.$extName.$extImgTarget; // Chemin complet du fichier de la vignette
+ $imgThumbName = $dirthumb.'/'.getImageFileNameForSize($file, $extName, $extImgTarget); // Chemin complet du fichier de la vignette
// Check if permission are ok
//$fp = fopen($imgThumbName, "w");
diff --git a/htdocs/theme/eldy/img/object_user.png b/htdocs/theme/eldy/img/object_user.png
index d26d8899ee8..6452b94da68 100644
Binary files a/htdocs/theme/eldy/img/object_user.png and b/htdocs/theme/eldy/img/object_user.png differ
diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php
index a165a735f84..dd63a144226 100644
--- a/htdocs/user/class/user.class.php
+++ b/htdocs/user/class/user.class.php
@@ -1848,7 +1848,7 @@ class User extends CommonObject
* @param integer $notooltip 1=Disable tooltip on picto and name
* @param int $maxlen Max length of visible user name
* @param int $hidethirdpartylogo Hide logo of thirdparty if user is external user
- * @param string $mode 'firstname'=Show only firstname
+ * @param string $mode ''=Show firstname and lastname, 'firstname'=Show only firstname, 'login'=Show login
* @param string $morecss Add more css on link
* @return string String with URL
*/
@@ -1885,7 +1885,7 @@ class User extends CommonObject
if (! empty($this->photo))
{
$label.= '
';
- $label.= Form::showphoto('userphoto', $this, 80, 0, 0, 'photowithmargin photologintooltip');
+ $label.= Form::showphoto('userphoto', $this, 80, 0, 0, 'photowithmargin photologintooltip', 'small');
$label.= '
';
}
@@ -1932,13 +1932,14 @@ class User extends CommonObject
$paddafterimage='';
if (abs($withpictoimg) == 1) $paddafterimage='style="padding-right: 3px;"';
if ($withpictoimg > 0) $picto=''.img_object('', 'user', $paddafterimage.' '.($notooltip?'':'class="classfortooltip"')).'
';
- else $picto=''.Form::showphoto('userphoto', $this, 0, 0, 0, 'loginphoto',0,0).'
';
+ else $picto=''.Form::showphoto('userphoto', $this, 0, 0, 0, 'loginphoto', 0, 0, 'mini').'
';
$result.=$picto;
}
if (abs($withpictoimg) != 2)
{
if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) $result.='';
- $result.=$this->getFullName($langs,'',($mode == 'firstname' ? 2 : -1),$maxlen);
+ if ($mode == 'login') $result.=dol_trunc($this->login, $maxlen);
+ else $result.=$this->getFullName($langs,'',($mode == 'firstname' ? 2 : -1),$maxlen);
if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) $result.='
';
}
$result.=$linkend;
@@ -2398,7 +2399,7 @@ class User extends CommonObject
$this->load_parentof();
// Init $this->users array
- $sql = "SELECT DISTINCT u.rowid, u.firstname, u.lastname, u.fk_user, u.fk_soc, u.login, u.email, u.gender, u.admin, u.statut, u.entity"; // Distinct reduce pb with old tables with duplicates
+ $sql = "SELECT DISTINCT u.rowid, u.firstname, u.lastname, u.fk_user, u.fk_soc, u.login, u.email, u.gender, u.admin, u.statut, u.photo, u.entity"; // Distinct reduce pb with old tables with duplicates
$sql.= " FROM ".MAIN_DB_PREFIX."user as u";
if(! empty($conf->multicompany->enabled) && $conf->entity == 1 && (! empty($conf->multicompany->transverse_mode) || (! empty($user->admin) && empty($user->entity))))
{
@@ -2429,6 +2430,7 @@ class User extends CommonObject
$this->users[$obj->rowid]['email'] = $obj->email;
$this->users[$obj->rowid]['gender'] = $obj->gender;
$this->users[$obj->rowid]['admin'] = $obj->admin;
+ $this->users[$obj->rowid]['photo'] = $obj->photo;
$i++;
}
}
diff --git a/htdocs/user/group/index.php b/htdocs/user/group/index.php
index 058f3ac92e2..f515c8307e7 100644
--- a/htdocs/user/group/index.php
+++ b/htdocs/user/group/index.php
@@ -94,7 +94,7 @@ if ($resql)
print_liste_field_titre($langs->trans("Entity"),$_SERVER["PHP_SELF"],"g.entity",$param,"",'align="center"',$sortfield,$sortorder);
}
print_liste_field_titre($langs->trans("NbOfUsers"),$_SERVER["PHP_SELF"],"nb",$param,"",'align="center"',$sortfield,$sortorder);
- print_liste_field_titre($langs->trans("DateCreation"),$_SERVER["PHP_SELF"],"g.datec",$param,"",'align="right"',$sortfield,$sortorder);
+ print_liste_field_titre($langs->trans("DateCreationShort"),$_SERVER["PHP_SELF"],"g.datec",$param,"",'align="right"',$sortfield,$sortorder);
print "\n";
$var=True;
while ($i < $num)
diff --git a/htdocs/user/hierarchy.php b/htdocs/user/hierarchy.php
index a9aef6ed783..14b8ec4265b 100644
--- a/htdocs/user/hierarchy.php
+++ b/htdocs/user/hierarchy.php
@@ -82,6 +82,7 @@ foreach($fulltree as $key => $val)
{
$userstatic->id=$val['id'];
$userstatic->ref=$val['label'];
+ $userstatic->login=$val['login'];
$userstatic->firstname=$val['firstname'];
$userstatic->lastname=$val['lastname'];
$userstatic->statut=$val['statut'];
@@ -90,6 +91,7 @@ foreach($fulltree as $key => $val)
$userstatic->societe_id=$val['fk_soc'];
$userstatic->admin=$val['admin'];
$userstatic->entity=$val['entity'];
+ $userstatic->photo=$val['photo'];
$entity=$val['entity'];
$entitystring='';
@@ -111,7 +113,7 @@ foreach($fulltree as $key => $val)
}
}
- $li=$userstatic->getNomUrl(1,'',0,1);
+ $li=$userstatic->getNomUrl(-1,'',0,1);
if (! empty($conf->multicompany->enabled) && $userstatic->admin && ! $userstatic->entity)
{
$li.=img_picto($langs->trans("SuperAdministrator"),'redstar');
@@ -121,12 +123,12 @@ foreach($fulltree as $key => $val)
$li.=img_picto($langs->trans("Administrator"),'star');
}
$li.=' ('.$val['login'].($entitystring?' - '.$entitystring:'').')';
-
+
$data[] = array(
'rowid'=>$val['rowid'],
'fk_menu'=>$val['fk_user'],
'statut'=>$val['statut'],
- 'entry'=>'| '.$li.' | '.$userstatic->getLibStatut(5).' |
'
+ 'entry'=>'| '.$li.' | '.$userstatic->getLibStatut(3).' |
'
);
}
diff --git a/htdocs/user/index.php b/htdocs/user/index.php
index 40fe8353093..7688cadbe05 100644
--- a/htdocs/user/index.php
+++ b/htdocs/user/index.php
@@ -124,11 +124,11 @@ $buttonviewhierarchy='