From 4664ac1a1c677025280d68b6596a62d2f5b1e29a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 12 Dec 2020 17:00:23 +0100 Subject: [PATCH 1/4] socialnetworks links --- htdocs/contact/list.php | 2 +- htdocs/core/class/commonobject.class.php | 3 +- htdocs/core/lib/functions.lib.php | 41 +++++++++++++----------- 3 files changed, 26 insertions(+), 20 deletions(-) diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 5b8c708b1b2..00c74544d17 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -967,7 +967,7 @@ while ($i < min($num, $limit)) if (!empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { if ($value['active'] && !empty($arrayfields['p.'.$key]['checked'])) { - print ''.dol_print_socialnetworks($arraysocialnetworks[$key], $obj->rowid, $obj->socid, $key).''; + print ''.dol_print_socialnetworks($arraysocialnetworks[$key], $obj->rowid, $obj->socid, $key, $socialnetworks).''; if (!$i) $totalarray['nbfield']++; } } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index dec15e4db83..f34f39740bd 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -816,9 +816,10 @@ abstract class CommonObject $outsocialnetwork = ''; if (is_array($this->socialnetworks) && count($this->socialnetworks) > 0) { + $socialnetworksdict = getArrayOfSocialNetworks(); foreach ($this->socialnetworks as $key => $value) { if ($value) { - $outsocialnetwork .= dol_print_socialnetworks($value, $this->id, $object->id, $key); + $outsocialnetwork .= dol_print_socialnetworks($value, $this->id, $object->id, $key, $socialnetworksdict); } $outdone++; } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 8b9edcd89ba..8a48cdf0906 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2440,13 +2440,14 @@ function getArrayOfSocialNetworks() /** * Show social network link * - * @param string $value Skype to show (only skype, without 'Name of recipient' before) - * @param int $cid Id of contact if known - * @param int $socid Id of third party if known - * @param string $type 'skype','facebook',... - * @return string HTML Link + * @param string $value Skype to show (only skype, without 'Name of recipient' before) + * @param int $cid Id of contact if known + * @param int $socid Id of third party if known + * @param string $type 'skype','facebook',... + * @param array $dictsocialnetworks socialnetworks availables + * @return string HTML Link */ -function dol_print_socialnetworks($value, $cid, $socid, $type) +function dol_print_socialnetworks($value, $cid, $socid, $type, $dictsocialnetworks = array()) { global $conf, $user, $langs; @@ -2454,13 +2455,11 @@ function dol_print_socialnetworks($value, $cid, $socid, $type) if (empty($value)) return ' '; - if (!empty($type)) - { + if (!empty($type)) { $htmllink = '
'; $htmllink .= img_picto($langs->trans(strtoupper($type)), $type.'.png', '', false, 0, 0, '', 'paddingright', 0); - $htmllink .= $value; - if ($type == 'skype') - { + if ($type == 'skype') { + $htmllink .= $value; $htmllink .= ' '; $htmllink .= ''; $htmllink .= ''; $htmllink .= ''; - } - if (($cid || $socid) && !empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create && $type == 'skype') - { - $addlink = 'AC_SKYPE'; - $link = ''; - if (!empty($conf->global->AGENDA_ADDACTIONFORSKYPE)) $link = ''.img_object($langs->trans("AddAction"), "calendar").''; - $htmllink .= ($link ? ' '.$link : ''); + if (($cid || $socid) && !empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create) { + $addlink = 'AC_SKYPE'; + $link = ''; + if (!empty($conf->global->AGENDA_ADDACTIONFORSKYPE)) $link = ''.img_object($langs->trans("AddAction"), "calendar").''; + $htmllink .= ($link ? ' '.$link : ''); + } + } else { + if (!empty($dictsocialnetworks[$type]['url'])) { + $link = str_replace('{socialid}', $value, $dictsocialnetworks[$type]['url']); + $htmllink .= ' '.$value.''; + } else { + $htmllink .= $value; + } } $htmllink .= '
'; } else { From d523ed9f85fc2f5a9d203619a018c6686b42fa29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 12 Dec 2020 17:01:25 +0100 Subject: [PATCH 2/4] socialnetworks links --- htdocs/core/boxes/box_scheduled_jobs.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/core/boxes/box_scheduled_jobs.php b/htdocs/core/boxes/box_scheduled_jobs.php index 17c62ab7c7d..d8efa1b9dbc 100644 --- a/htdocs/core/boxes/box_scheduled_jobs.php +++ b/htdocs/core/boxes/box_scheduled_jobs.php @@ -100,7 +100,6 @@ class box_scheduled_jobs extends ModeleBoxes $objp = $this->db->fetch_object($result); if (dol_eval($objp->test, 1, 1)) { - $nextrun = $this->db->jdate($objp->datenextrun); if (empty($nextrun)) $nextrun = $this->db->jdate($objp->datestart); @@ -140,7 +139,7 @@ class box_scheduled_jobs extends ModeleBoxes ); } - foreach($resultarray as $line => $value) { + foreach ($resultarray as $line => $value) { $this->info_box_contents[$line][] = array( 'td' => 'class="left"', 'text' => $resultarray[$line][0] From 46bf871127ffe2d06e558ff60b1bda3b3e90efa0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 12 Dec 2020 17:23:42 +0100 Subject: [PATCH 3/4] target --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 8a48cdf0906..a14ddbde754 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2479,7 +2479,7 @@ function dol_print_socialnetworks($value, $cid, $socid, $type, $dictsocialnetwor } else { if (!empty($dictsocialnetworks[$type]['url'])) { $link = str_replace('{socialid}', $value, $dictsocialnetworks[$type]['url']); - $htmllink .= ' '.$value.''; + $htmllink .= ' '.$value.''; } else { $htmllink .= $value; } From 643b507a96fbe766f29a05be77c1da832b64767e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 12 Dec 2020 17:31:10 +0100 Subject: [PATCH 4/4] ucfirst --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index a14ddbde754..23c8d559e8a 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2457,7 +2457,7 @@ function dol_print_socialnetworks($value, $cid, $socid, $type, $dictsocialnetwor if (!empty($type)) { $htmllink = '
'; - $htmllink .= img_picto($langs->trans(strtoupper($type)), $type.'.png', '', false, 0, 0, '', 'paddingright', 0); + $htmllink .= img_picto($langs->trans(dol_ucfirst($type)), $type.'.png', '', false, 0, 0, '', 'paddingright', 0); if ($type == 'skype') { $htmllink .= $value; $htmllink .= ' ';