socialnetworks links

This commit is contained in:
Frédéric FRANCE
2020-12-12 17:00:23 +01:00
parent 5f476e7e7e
commit 4664ac1a1c
3 changed files with 26 additions and 20 deletions

View File

@@ -967,7 +967,7 @@ while ($i < min($num, $limit))
if (!empty($conf->socialnetworks->enabled)) { if (!empty($conf->socialnetworks->enabled)) {
foreach ($socialnetworks as $key => $value) { foreach ($socialnetworks as $key => $value) {
if ($value['active'] && !empty($arrayfields['p.'.$key]['checked'])) { if ($value['active'] && !empty($arrayfields['p.'.$key]['checked'])) {
print '<td>'.dol_print_socialnetworks($arraysocialnetworks[$key], $obj->rowid, $obj->socid, $key).'</td>'; print '<td>'.dol_print_socialnetworks($arraysocialnetworks[$key], $obj->rowid, $obj->socid, $key, $socialnetworks).'</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) $totalarray['nbfield']++;
} }
} }

View File

@@ -816,9 +816,10 @@ abstract class CommonObject
$outsocialnetwork = ''; $outsocialnetwork = '';
if (is_array($this->socialnetworks) && count($this->socialnetworks) > 0) { if (is_array($this->socialnetworks) && count($this->socialnetworks) > 0) {
$socialnetworksdict = getArrayOfSocialNetworks();
foreach ($this->socialnetworks as $key => $value) { foreach ($this->socialnetworks as $key => $value) {
if ($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++; $outdone++;
} }

View File

@@ -2440,13 +2440,14 @@ function getArrayOfSocialNetworks()
/** /**
* Show social network link * Show social network link
* *
* @param string $value Skype to show (only skype, without 'Name of recipient' before) * @param string $value Skype to show (only skype, without 'Name of recipient' before)
* @param int $cid Id of contact if known * @param int $cid Id of contact if known
* @param int $socid Id of third party if known * @param int $socid Id of third party if known
* @param string $type 'skype','facebook',... * @param string $type 'skype','facebook',...
* @return string HTML Link * @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; global $conf, $user, $langs;
@@ -2454,13 +2455,11 @@ function dol_print_socialnetworks($value, $cid, $socid, $type)
if (empty($value)) return '&nbsp;'; if (empty($value)) return '&nbsp;';
if (!empty($type)) if (!empty($type)) {
{
$htmllink = '<div class="divsocialnetwork inline-block valignmiddle">'; $htmllink = '<div class="divsocialnetwork inline-block valignmiddle">';
$htmllink .= img_picto($langs->trans(strtoupper($type)), $type.'.png', '', false, 0, 0, '', 'paddingright', 0); $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 .= '&nbsp;'; $htmllink .= '&nbsp;';
$htmllink .= '<a href="skype:'; $htmllink .= '<a href="skype:';
$htmllink .= $value; $htmllink .= $value;
@@ -2471,13 +2470,19 @@ function dol_print_socialnetworks($value, $cid, $socid, $type)
$htmllink .= '?chat" alt="'.$langs->trans("Chat").'&nbsp;'.$value.'" title="'.$langs->trans("Chat").'&nbsp;'.$value.'">'; $htmllink .= '?chat" alt="'.$langs->trans("Chat").'&nbsp;'.$value.'" title="'.$langs->trans("Chat").'&nbsp;'.$value.'">';
$htmllink .= '<img class="paddingleft" src="'.DOL_URL_ROOT.'/theme/common/skype_chatbutton.png" border="0">'; $htmllink .= '<img class="paddingleft" src="'.DOL_URL_ROOT.'/theme/common/skype_chatbutton.png" border="0">';
$htmllink .= '</a>'; $htmllink .= '</a>';
} if (($cid || $socid) && !empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create) {
if (($cid || $socid) && !empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create && $type == 'skype') $addlink = 'AC_SKYPE';
{ $link = '';
$addlink = 'AC_SKYPE'; if (!empty($conf->global->AGENDA_ADDACTIONFORSKYPE)) $link = '<a href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&amp;backtopage=1&amp;actioncode='.$addlink.'&amp;contactid='.$cid.'&amp;socid='.$socid.'">'.img_object($langs->trans("AddAction"), "calendar").'</a>';
$link = ''; $htmllink .= ($link ? ' '.$link : '');
if (!empty($conf->global->AGENDA_ADDACTIONFORSKYPE)) $link = '<a href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&amp;backtopage=1&amp;actioncode='.$addlink.'&amp;contactid='.$cid.'&amp;socid='.$socid.'">'.img_object($langs->trans("AddAction"), "calendar").'</a>'; }
$htmllink .= ($link ? ' '.$link : ''); } else {
if (!empty($dictsocialnetworks[$type]['url'])) {
$link = str_replace('{socialid}', $value, $dictsocialnetworks[$type]['url']);
$htmllink .= '&nbsp;<a href="'.$link.'">'.$value.'</a>';
} else {
$htmllink .= $value;
}
} }
$htmllink .= '</div>'; $htmllink .= '</div>';
} else { } else {