Skip to content

Commit

Permalink
NEW Add link to the public interface on the ticket card.
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Oct 5, 2019
1 parent 5c11a0d commit 031c552
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 1 deletion.
39 changes: 39 additions & 0 deletions htdocs/core/lib/ticket.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.= '<span class="opacitymedium">'.$langs->trans("PublicInterfaceNotEnabled").'</span>';
}
else
{
$out.= img_picto('', 'object_globe.png').' '.$langs->trans("TicketPublicAccess").':<br>';
if ($url)
{
$out.= '<input type="text" id="directpubliclink" class="quatrevingtpercent" value="'.$url.'">';
$out.= ajax_autoselect("directpubliclink", 0);
}
else
{
$out.= '<span class="opacitymedium">'.$langs->trans("TicketNotCreatedFromPublicInterface").'</span>';
}
}

return $out;
}

/**
* Generate a random id
*
Expand Down
2 changes: 2 additions & 0 deletions htdocs/langs/en_US/ticket.lang
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion htdocs/ticket/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@
}
if (!empty($object->origin_email)) {
$morehtmlref .= '<br>' . $langs->trans("CreatedBy") . ' : ';
$morehtmlref .= $object->origin_email . ' <small>(' . $langs->trans("TicketEmailOriginIssuer") . ')</small>';
$morehtmlref .= dol_escape_htmltag($object->origin_email) . ' <small>(' . $langs->trans("TicketEmailOriginIssuer") . ')</small>';
}

// Thirdparty
Expand Down Expand Up @@ -983,6 +983,7 @@
}
print '</td>';
print '</tr>';

if (GETPOST('set', 'alpha') == 'properties' && $user->rights->ticket->write) {
print '<tr>';
// Type
Expand Down Expand Up @@ -1212,6 +1213,10 @@
$linktoelem = $form->showLinkToObjectBlock($object, null, array('ticket'));
$somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);

// Show direct link to public interface
print '<br><!-- Link to public interface -->'."\n";
print showDirectPublicLink($object).'<br>';

print '</div><div class="fichehalfright"><div class="ficheaddleft">';

// List of actions on element
Expand Down

0 comments on commit 031c552

Please sign in to comment.