diff --git a/htdocs/core/lib/ticket.lib.php b/htdocs/core/lib/ticket.lib.php index 81c51ade506..53afbe50dce 100644 --- a/htdocs/core/lib/ticket.lib.php +++ b/htdocs/core/lib/ticket.lib.php @@ -139,6 +139,45 @@ function ticket_prepare_head($object) return $head; } +/** + * Return string with full Url. The file qualified is the one defined by relative path in $object->last_main_doc + * + * @param Object $object Object + * @return string Url string + */ +function showDirectPublicLink($object) +{ + global $conf, $langs; + + require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; + $email = CMailFile::getValidAddress($object->origin_email, 2); + if ($email) + { + $url = dol_buildpath('/public/ticket/view.php', 3).'?track_id='.$object->track_id.'&email='.$email; + } + + $out=''; + if (empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) + { + $out.= ''.$langs->trans("PublicInterfaceNotEnabled").''; + } + else + { + $out.= img_picto('', 'object_globe.png').' '.$langs->trans("TicketPublicAccess").':
'; + if ($url) + { + $out.= ''; + $out.= ajax_autoselect("directpubliclink", 0); + } + else + { + $out.= ''.$langs->trans("TicketNotCreatedFromPublicInterface").''; + } + } + + return $out; +} + /** * Generate a random id * diff --git a/htdocs/langs/en_US/ticket.lang b/htdocs/langs/en_US/ticket.lang index 80dda58ba59..4bc40e19555 100644 --- a/htdocs/langs/en_US/ticket.lang +++ b/htdocs/langs/en_US/ticket.lang @@ -226,6 +226,8 @@ TicketConfirmChangeStatus=Confirm the status change: %s ? TicketLogStatusChanged=Status changed: %s to %s TicketNotNotifyTiersAtCreate=Not notify company at create Unread=Unread +TicketNotCreatedFromPublicInterface=Not available. Ticket was not created from public interface. +PublicInterfaceNotEnabled=Public interface was not enabled # # Logs diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index 8e8add64b38..690c01644e0 100644 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -769,7 +769,7 @@ if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'd } if (!empty($object->origin_email)) { $morehtmlref .= '
' . $langs->trans("CreatedBy") . ' : '; - $morehtmlref .= $object->origin_email . ' (' . $langs->trans("TicketEmailOriginIssuer") . ')'; + $morehtmlref .= dol_escape_htmltag($object->origin_email) . ' (' . $langs->trans("TicketEmailOriginIssuer") . ')'; } // Thirdparty @@ -983,6 +983,7 @@ if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'd } print ''; print ''; + if (GETPOST('set', 'alpha') == 'properties' && $user->rights->ticket->write) { print ''; // Type @@ -1212,6 +1213,10 @@ if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'd $linktoelem = $form->showLinkToObjectBlock($object, null, array('ticket')); $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); + // Show direct link to public interface + print '
'."\n"; + print showDirectPublicLink($object).'
'; + print '
'; // List of actions on element