From 986f918436b9da92949dc3bb11a8965057552004 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 22 Nov 2020 01:47:17 +0100 Subject: [PATCH] Fix image edition when gravatar module is on --- htdocs/core/class/html.form.class.php | 24 +++++++++--------------- htdocs/user/card.php | 2 +- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index a7bcc562a9b..15cfa9e5771 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -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 .= ''; else $ret .= ''; } $ret .= 'Photo'; if ($addlinktofullsize) $ret .= ''; - } 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 .= ''; else $ret .= ''; @@ -7593,8 +7591,7 @@ class Form if ($addlinktofullsize) $ret .= ''; } 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 .= ''; //$defaultimg=urlencode(dol_buildpath($nophoto,3)); diff --git a/htdocs/user/card.php b/htdocs/user/card.php index b767be807ff..0885809de78 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -2475,7 +2475,7 @@ if ($action == 'create' || $action == 'adduserldap') print ''; print ''.$langs->trans("Photo").''; print ''; - 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 ''; print '';