Fix image edition when gravatar module is on

This commit is contained in:
Laurent Destailleur 2020-11-22 01:47:17 +01:00
parent a3faa12753
commit 986f918436
2 changed files with 10 additions and 16 deletions

View File

@ -7493,10 +7493,11 @@ class Form
* @param string $imagesize 'mini', 'small' or '' (original)
* @param int $addlinktofullsize Add link to fullsize image
* @param int $cache 1=Accept to use image in cache
* @param string $forcecapture Force parameter capture on HTML input file element to ask a smartphone to allow to open camera to take photo. Auto if empty.
* @param string $forcecapture '', 'user' or 'environment'. Force parameter capture on HTML input file element to ask a smartphone to allow to open camera to take photo. Auto if ''.
* @param int $noexternsourceoverwrite No overwrite image with extern source (like 'gravatar' or other module)
* @return string HTML code to output photo
*/
public static function showphoto($modulepart, $object, $width = 100, $height = 0, $caneditfield = 0, $cssclass = 'photowithmargin', $imagesize = '', $addlinktofullsize = 1, $cache = 0, $forcecapture = '')
public static function showphoto($modulepart, $object, $width = 100, $height = 0, $caneditfield = 0, $cssclass = 'photowithmargin', $imagesize = '', $addlinktofullsize = 1, $cache = 0, $forcecapture = '', $noexternsourceoverwrite = 0)
{
global $conf, $langs;
@ -7573,18 +7574,15 @@ class Form
{
if ($file && file_exists($dir."/".$file))
{
if ($addlinktofullsize)
{
if ($addlinktofullsize) {
$urladvanced = getAdvancedPreviewUrl($modulepart, $originalfile, 0, '&entity='.$entity);
if ($urladvanced) $ret .= '<a href="'.$urladvanced.'">';
else $ret .= '<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$entity.'&file='.urlencode($originalfile).'&cache='.$cache.'">';
}
$ret .= '<img alt="Photo" class="photo'.$modulepart.($cssclass ? ' '.$cssclass : '').' photologo'.(preg_replace('/[^a-z]/i', '_', $file)).'" '.($width ? ' width="'.$width.'"' : '').($height ? ' height="'.$height.'"' : '').' src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$entity.'&file='.urlencode($file).'&cache='.$cache.'">';
if ($addlinktofullsize) $ret .= '</a>';
} elseif ($altfile && file_exists($dir."/".$altfile))
{
if ($addlinktofullsize)
{
} elseif ($altfile && file_exists($dir."/".$altfile)) {
if ($addlinktofullsize) {
$urladvanced = getAdvancedPreviewUrl($modulepart, $originalfile, 0, '&entity='.$entity);
if ($urladvanced) $ret .= '<a href="'.$urladvanced.'">';
else $ret .= '<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$entity.'&file='.urlencode($originalfile).'&cache='.$cache.'">';
@ -7593,8 +7591,7 @@ class Form
if ($addlinktofullsize) $ret .= '</a>';
} else {
$nophoto = '/public/theme/common/nophoto.png';
if (in_array($modulepart, array('userphoto', 'contact', 'memberphoto'))) // For module that are "physical" users
{
if (in_array($modulepart, array('userphoto', 'contact', 'memberphoto'))) { // For module that are "physical" users
if ($modulepart == 'memberphoto' && strpos($object->morphy, 'mor') !== false) {
$nophoto = '/public/theme/common/company.png';
} else {
@ -7604,11 +7601,8 @@ class Form
}
}
if (!empty($conf->gravatar->enabled) && $email)
{
/**
* @see https://gravatar.com/site/implement/images/php/
*/
if (!empty($conf->gravatar->enabled) && $email && empty($noexternsourceoverwrite)) {
// see https://gravatar.com/site/implement/images/php/
global $dolibarr_main_url_root;
$ret .= '<!-- Put link to gravatar -->';
//$defaultimg=urlencode(dol_buildpath($nophoto,3));

View File

@ -2475,7 +2475,7 @@ if ($action == 'create' || $action == 'adduserldap')
print '<tr>';
print '<td>'.$langs->trans("Photo").'</td>';
print '<td>';
print $form->showphoto('userphoto', $object, 60, 0, $caneditfield, 'photowithmargin', 'small');
print $form->showphoto('userphoto', $object, 60, 0, $caneditfield, 'photowithmargin', 'small', 1, 0, 'user', 1);
print '</td>';
print '</tr>';