diff --git a/include/ajax.tickets.php b/include/ajax.tickets.php index 85a0c15165de97cc3fa784ce8b21a4dfe1c7ce29..a23278cd91686dab7ea8700e2c5588db4a3d0726 100644 --- a/include/ajax.tickets.php +++ b/include/ajax.tickets.php @@ -19,6 +19,7 @@ if(!defined('INCLUDE_DIR')) die('403'); include_once(INCLUDE_DIR.'class.ticket.php'); require_once(INCLUDE_DIR.'class.ajax.php'); require_once(INCLUDE_DIR.'class.note.php'); +include_once INCLUDE_DIR . 'class.thread_actions.php'; class TicketsAjaxAPI extends AjaxController { diff --git a/include/class.thread.php b/include/class.thread.php index ff5b1e7078628b8d982520c91437c5c4ac141273..a8b1ab67d15140c085591f113790d841a5ddf789 100644 --- a/include/class.thread.php +++ b/include/class.thread.php @@ -245,6 +245,7 @@ class ThreadEntry { var $thread; var $attachments; + var $_actions; function ThreadEntry($id, $threadId=0, $type='') { $this->load($id, $threadId, $type); @@ -799,7 +800,7 @@ class ThreadEntry { function lookupByEmailHeaders(&$mailinfo, &$seen=false) { // Search for messages using the References header, then the // in-reply-to header - $search = 'SELECT thread_entery_id, mid FROM '.THREAD_ENTRY_EMAIL_TABLE + $search = 'SELECT thread_entry_id, mid FROM '.THREAD_ENTRY_EMAIL_TABLE . ' WHERE mid=%s ' . ' ORDER BY thread_entry_id DESC'; @@ -1673,10 +1674,21 @@ abstract class ThreadEntryAction { */ abstract function getJsStub(); + /** + * getAjaxUrl + * + * Generate a URL to be used as an AJAX callback. The URL can be used to + * trigger this thread entry action via the callback. + * + * Parameters: + * $dialog - (bool) used in conjunction with `$.dialog()` javascript + * function which assumes the `ajax.php/` should be replace a leading + * `#` in the url + */ function getAjaxUrl($dialog=false) { return sprintf('%stickets/%d/thread/%d/%s', $dialog ? '#' : 'ajax.php/', - $this->thread->getTicketId(), + $this->thread->getThread()->getObjectId(), $this->thread->getId(), static::getId() ); diff --git a/include/class.thread_actions.php b/include/class.thread_actions.php new file mode 100644 index 0000000000000000000000000000000000000000..ce6ac82469df253fe5aecb942759de7f4a814252 --- /dev/null +++ b/include/class.thread_actions.php @@ -0,0 +1,55 @@ +<?php +/********************************************************************* + class.thread_actions.php + + Actions for thread entries. This serves as a simple repository for + drop-down actions which can be triggered on the ticket-view page for an + object's thread. + + Jared Hancock <jared@osticket.com> + Peter Rotich <peter@osticket.com> + Copyright (c) 2006-2014 osTicket + http://www.osticket.com + + Released under the GNU General Public License WITHOUT ANY WARRANTY. + See LICENSE.TXT for details. + + vim: expandtab sw=4 ts=4 sts=4: +**********************************************************************/ +include_once(INCLUDE_DIR.'class.thread.php'); + +class TEA_ShowEmailHeaders extends ThreadEntryAction { + static $id = 'view_headers'; + static $name = /* trans */ 'View Email Headers'; + static $icon = 'envelope'; + + function isEnabled() { + global $thisstaff; + + return $thisstaff && $thisstaff->isAdmin(); + } + + function isVisible() { + return (bool) $this->thread->getEmailHeader(); + } + + function getJsStub() { + return sprintf("$.dialog('%s');", + $this->getAjaxUrl() + ); + } + + function trigger() { + switch ($_SERVER['REQUEST_METHOD']) { + case 'GET': + return $this->trigger__get(); + } + } + + private function trigger__get() { + $headers = $this->thread->getEmailHeader(); + + include STAFFINC_DIR . 'templates/thread-email-headers.tmpl.php'; + } +} +ThreadEntry::registerAction(/* trans */ 'E-Mail', 'TEA_ShowEmailHeaders'); diff --git a/include/staff/templates/thread-email-headers.tmpl.php b/include/staff/templates/thread-email-headers.tmpl.php new file mode 100644 index 0000000000000000000000000000000000000000..6e2f45809e0e9dc7d985b92eff1252fcb52ca7a0 --- /dev/null +++ b/include/staff/templates/thread-email-headers.tmpl.php @@ -0,0 +1,15 @@ +<h3><?php echo __('Raw Email Headers'); ?></h3> +<b><a class="close" href="#"><i class="icon-remove-circle"></i></a></b> +<hr/> + +<pre style="max-height: 300px; overflow-y: scroll"> +<?php echo $headers; ?> +</pre> + +<hr> +<p class="full-width"> + <span class="buttons pull-right"> + <input type="button" name="cancel" class="close" + value="<?php echo __('Close'); ?>"> + </span> +</p> diff --git a/include/staff/ticket-view.inc.php b/include/staff/ticket-view.inc.php index 3542a663134e6ec02108d2efc2871d5cd8855c97..9518c6f728b7a8cec8b859467f7b575ac0bf11e4 100644 --- a/include/staff/ticket-view.inc.php +++ b/include/staff/ticket-view.inc.php @@ -1,4 +1,6 @@ <?php +include_once INCLUDE_DIR . 'class.thread_actions.php'; + //Note that ticket obj is initiated in tickets.php. if(!defined('OSTSCPINC') || !$thisstaff || !is_object($ticket) || !$ticket->getId()) die('Invalid path'); @@ -408,7 +410,7 @@ $tcount+= $ticket->getNumNotes(); <?php if ($tentry->hasActions()) { $actions = $tentry->getActions(); ?> <div class="pull-right"> - <span class="action-button" data-dropdown="#entry-action-more-<?php echo $entry['id']; ?>"> + <span class="action-button pull-right" data-dropdown="#entry-action-more-<?php echo $entry['id']; ?>"> <i class="icon-caret-down"></i> <span ><i class="icon-cog"></i></span> </span> @@ -427,7 +429,7 @@ $tcount+= $ticket->getNumNotes(); </ul> </div> <?php } ?> - <span class="pull-right" style="white-space:no-wrap;display:inline-block"> + <span style="vertical-align:middle"> <span style="vertical-align:middle;" class="textra"></span> <span style="vertical-align:middle;" class="tmeta faded title"><?php