Skip to content

Commit

Permalink
Merge pull request #608 from protich/feature/poster-name
Browse files Browse the repository at this point in the history
Use up-to-date user/staff name instead of poster when displaying ticket thread

Reviewed-By: Jared Hancock <jared@osticket.com>
  • Loading branch information
greezybacon committed Feb 25, 2014
2 parents 70401ea + 80acffa commit 6d87b96
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
2 changes: 1 addition & 1 deletion include/class.pdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ function _print() {
$this->WriteCell($w/2, 7, Format::db_datetime($entry['created']), 'LTB', 0, 'L', true);
$this->SetFont('Arial', '', 10);
$this->WriteCell($w, 7, Format::truncate($entry['title'], 50), 'TB', 0, 'L', true);
$this->WriteCell($w/2, 7, $entry['poster'], 'TBR', 1, 'L', true);
$this->WriteCell($w/2, 7, $entry['name'] ?: $entry['poster'], 'TBR', 1, 'L', true);
$this->SetFont('');
$text= $entry['body'];
if($entry['attachments']
Expand Down
15 changes: 11 additions & 4 deletions include/class.staff.php
Original file line number Diff line number Diff line change
Expand Up @@ -569,16 +569,23 @@ function update($vars, &$errors) {
function delete() {
global $thisstaff;

if(!$thisstaff || !($id=$this->getId()) || $id==$thisstaff->getId())
if (!$thisstaff || $this->getId() == $thisstaff->getId())
return 0;

$sql='DELETE FROM '.STAFF_TABLE.' WHERE staff_id='.db_input($id).' LIMIT 1';
$sql='DELETE FROM '.STAFF_TABLE
.' WHERE staff_id = '.db_input($this->getId()).' LIMIT 1';
if(db_query($sql) && ($num=db_affected_rows())) {
// DO SOME HOUSE CLEANING
//Move remove any ticket assignments...TODO: send alert to Dept. manager?
db_query('UPDATE '.TICKET_TABLE.' SET staff_id=0 WHERE status=\'open\' AND staff_id='.db_input($id));
db_query('UPDATE '.TICKET_TABLE.' SET staff_id=0 WHERE staff_id='.db_input($this->getId()));

//Update the poster and clear staff_id on ticket thread table.
db_query('UPDATE '.TICKET_THREAD_TABLE
.' SET staff_id=0, poster= '.db_input($this->getName()->getOriginal())
.' WHERE staff_id='.db_input($this->getId()));

//Cleanup Team membership table.
db_query('DELETE FROM '.TEAM_MEMBER_TABLE.' WHERE staff_id='.db_input($id));
db_query('DELETE FROM '.TEAM_MEMBER_TABLE.' WHERE staff_id='.db_input($this->getId()));
}

Signal::send('model.deleted', $this);
Expand Down
10 changes: 9 additions & 1 deletion include/class.thread.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,17 @@ function getEntries($type, $order='ASC') {
if(!$order || !in_array($order, array('DESC','ASC')))
$order='ASC';

$sql='SELECT thread.* '
$sql='SELECT thread.*
, COALESCE(user.name,
IF(staff.staff_id,
CONCAT_WS(" ", staff.firstname, staff.lastname),
NULL)) as name '
.' ,count(DISTINCT attach.attach_id) as attachments '
.' FROM '.TICKET_THREAD_TABLE.' thread '
.' LEFT JOIN '.USER_TABLE.' user
ON (thread.user_id=user.id) '
.' LEFT JOIN '.STAFF_TABLE.' staff
ON (thread.staff_id=staff.staff_id) '
.' LEFT JOIN '.TICKET_ATTACHMENT_TABLE.' attach
ON (thread.ticket_id=attach.ticket_id
AND thread.id=attach.ref_id) '
Expand Down
2 changes: 1 addition & 1 deletion include/staff/ticket-view.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ function (user) {
<span style="vertical-align:middle;" class="textra"></span>
<span style="vertical-align:middle;"
class="tmeta faded title"><?php
echo Format::htmlchars($entry['poster']); ?></span>
echo Format::htmlchars($entry['name'] ?: $entry['poster']); ?></span>
</span>
</div>
</th>
Expand Down

0 comments on commit 6d87b96

Please sign in to comment.