From 20b9786eba72e131590961161e10e274d0fdd27b Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Mon, 11 May 2015 15:30:00 -0500 Subject: [PATCH] thread-edit: Fix several small issues --- include/class.thread_actions.php | 8 ++++-- .../staff/templates/thread-entries.tmpl.php | 8 +++++- .../templates/thread-entry-view.tmpl.php | 26 +++++++++++++++---- scp/css/scp.css | 1 + 4 files changed, 35 insertions(+), 8 deletions(-) diff --git a/include/class.thread_actions.php b/include/class.thread_actions.php index 30ddc810c..15758498f 100644 --- a/include/class.thread_actions.php +++ b/include/class.thread_actions.php @@ -155,6 +155,8 @@ JS ) { // Replace previous edit -------------------------- $original = $old->getParent(); + // Link the new entry to the old id + $entry->pid = $old->pid; // Drop the previous edit, and base this edit off the original $old->delete(); $old = $original; @@ -221,9 +223,11 @@ class TEA_OrigThreadEntry extends ThreadEntryAction { } private function trigger__get() { - $entry = $this->entry->getParent(); - if (!$entry) + global $thisstaff; + + if (!$this->entry->getParent()) Http::response(404, 'No history for this entry'); + $entry = $this->entry; include STAFFINC_DIR . 'templates/thread-entry-view.tmpl.php'; } } diff --git a/include/staff/templates/thread-entries.tmpl.php b/include/staff/templates/thread-entries.tmpl.php index be49ed35f..2e7da2c38 100644 --- a/include/staff/templates/thread-entries.tmpl.php +++ b/include/staff/templates/thread-entries.tmpl.php @@ -35,7 +35,13 @@ if ($entries) { </div> <?php } ?> <span style="vertical-align:middle"> - <span style="vertical-align:middle;" class="textra"></span> + <span style="vertical-align:middle;" class="textra"> + <?php if ($entry->flags & ThreadEntry::FLAG_EDITED) { ?> + <span class="label label-bare" title="<?php + echo sprintf(__('Edited on %s by %s'), Format::datetime($entry->updated), 'You'); + ?>"><?php echo __('Edited'); ?></span> + <?php } ?> + </span> <span style="vertical-align:middle;" class="tmeta faded title"><?php echo Format::htmlchars($entry->getName()); ?></span> diff --git a/include/staff/templates/thread-entry-view.tmpl.php b/include/staff/templates/thread-entry-view.tmpl.php index 2b76d851f..29f098ca1 100644 --- a/include/staff/templates/thread-entry-view.tmpl.php +++ b/include/staff/templates/thread-entry-view.tmpl.php @@ -6,7 +6,21 @@ <?php $E = $entry; -do { ?> +$i = 0; +$omniscient = $thisstaff->getRole()->hasPerm(ThreadEntry::PERM_EDIT); +do { + $i++; + if (!$omniscient + // The current version is always visible + && $i > 1 + // If you originally posted it, you can see all the edits + && $E->staff_id != $thisstaff->getId() + // You can see your own edits + // && $E->editor != $thisstaff->getId() + ) { + // Skip edits made by other agents + continue; + } ?> <dt> <a href="#"><i class="icon-copy"></i> <strong><?php if ($E->title) @@ -48,11 +62,13 @@ $(function() { var allPanels = $('dd', A).hide().removeClass('hidden'); $('dt > a', A).click(function() { - $('dt', A).removeClass('active'); - allPanels.slideUp(); - $(this).parent().addClass('active').next().slideDown(); + if (!$(this).parent().is('.active')) { + $('dt', A).removeClass('active'); + allPanels.slideUp(); + $(this).parent().addClass('active').next().slideDown(); + } return false; }); - allPanels.last().show(); + allPanels.last().show().prev().addClass('active'); }, 100); }); diff --git a/scp/css/scp.css b/scp/css/scp.css index 59312e8b8..855dd8a03 100644 --- a/scp/css/scp.css +++ b/scp/css/scp.css @@ -2165,6 +2165,7 @@ td.indented { } .accordian dt.active a { color: #184E81; + text-decoration: none; } .accordian dt:not(.active) a i { display: none; -- GitLab