From 0d9530db64686785e8216ff7f95a7311430f57be Mon Sep 17 00:00:00 2001
From: Jared Hancock <jared@osticket.com>
Date: Mon, 4 Jan 2016 15:12:36 -0600
Subject: [PATCH] collabs: Add avatars to the popup mgmt dialog

And, add to the collabs preview popup too
---
 include/class.avatar.php                               | 6 +++++-
 include/staff/templates/collaborators-preview.tmpl.php | 6 ++++--
 include/staff/templates/collaborators.tmpl.php         | 6 +++++-
 include/staff/templates/ticket-preview.tmpl.php        | 6 ++++--
 scp/css/scp.css                                        | 2 ++
 5 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/include/class.avatar.php b/include/class.avatar.php
index 93024d02c..ee55147fc 100644
--- a/include/class.avatar.php
+++ b/include/class.avatar.php
@@ -25,7 +25,11 @@ abstract class Avatar {
     abstract function getUrl($size);
 
     function getImageTag($size=null) {
-        return '<img class="avatar" alt="'.__('Avatar').'" src="'.$this->getUrl($size).'" />';
+        $style = ($size)
+            ? sprintf('style="max-height:%spx"', $size)
+            : '';
+        return "<img {$style} class=\"avatar\" alt=\""
+            .__('Avatar').'" src="'.$this->getUrl($size).'" />';
     }
 
     function __toString() {
diff --git a/include/staff/templates/collaborators-preview.tmpl.php b/include/staff/templates/collaborators-preview.tmpl.php
index e7fb4f598..89b734ac4 100644
--- a/include/staff/templates/collaborators-preview.tmpl.php
+++ b/include/staff/templates/collaborators-preview.tmpl.php
@@ -5,9 +5,11 @@
 if (($users=$thread->getCollaborators())) {?>
 <?php
     foreach($users as $user) {
-        echo sprintf('<tr><td %s><i class="icon-%s"></i> %s <em>&lt;%s&gt;</em></td></tr>',
+        echo sprintf('<tr><td %s>%s%s <em class="faded">&lt;%s&gt;</em></td></tr>',
                 ($user->isActive()? '' : 'class="faded"'),
-                ($user->isActive()? 'comments' :  'comment-alt'),
+                (($U = $user->getUser()) && ($A = $U->getAvatar()))
+                    ? $A->getImageTag(20) : sprintf('<i class="icon-%s"></i>',
+                        ($user->isActive()? 'comments' :  'comment-alt')),
                 Format::htmlchars($user->getName()),
                 $user->getEmail());
     }
diff --git a/include/staff/templates/collaborators.tmpl.php b/include/staff/templates/collaborators.tmpl.php
index c49b1b266..4393ba1f2 100644
--- a/include/staff/templates/collaborators.tmpl.php
+++ b/include/staff/templates/collaborators.tmpl.php
@@ -15,8 +15,10 @@ if(($users=$thread->getCollaborators())) {?>
         $checked = $user->isActive() ? 'checked="checked"' : '';
         echo sprintf('<tr>
                         <td>
+                            <label class="inline checkbox">
                             <input type="checkbox" name="cid[]" id="c%d" value="%d" %s>
-                            <a class="collaborator" href="#thread/%d/collaborators/%d/view">%s</a>
+                            </label>
+                            <a class="collaborator" href="#thread/%d/collaborators/%d/view">%s%s</a>
                             <span class="faded"><em>%s</em></span></td>
                         <td width="10">
                             <input type="hidden" name="del[]" id="d%d" value="">
@@ -28,6 +30,8 @@ if(($users=$thread->getCollaborators())) {?>
                     $checked,
                     $thread->getId(),
                     $user->getId(),
+                    (($U = $user->getUser()) && ($A = $U->getAvatar()))
+                        ? $U->getAvatar()->getImageTag(24) : '',
                     Format::htmlchars($user->getName()),
                     $user->getEmail(),
                     $user->getId(),
diff --git a/include/staff/templates/ticket-preview.tmpl.php b/include/staff/templates/ticket-preview.tmpl.php
index 859bf0a89..3533c8af7 100644
--- a/include/staff/templates/ticket-preview.tmpl.php
+++ b/include/staff/templates/ticket-preview.tmpl.php
@@ -125,10 +125,12 @@ echo '</div>'; // ticket preview content.
         if ($thread && ($collabs=$thread->getCollaborators())) {?>
         <?php
             foreach($collabs as $collab) {
-                echo sprintf('<tr><td %s><i class="icon-%s"></i>
+                echo sprintf('<tr><td %s>%s
                         <a href="users.php?id=%d" class="no-pjax">%s</a> <em>&lt;%s&gt;</em></td></tr>',
                         ($collab->isActive()? '' : 'class="faded"'),
-                        ($collab->isActive()? 'comments' :  'comment-alt'),
+                        (($U = $collab->getUser()) && ($A = $U->getAvatar()))
+                            ? $A->getImageTag(20) : sprintf('<i class="icon-%s"></i>',
+                                $collab->isActive() ? 'comments' :  'comment-alt'),
                         $collab->getUserId(),
                         $collab->getName(),
                         $collab->getEmail());
diff --git a/scp/css/scp.css b/scp/css/scp.css
index 1aa636163..a497ace47 100644
--- a/scp/css/scp.css
+++ b/scp/css/scp.css
@@ -946,6 +946,8 @@ a#post-note:hover {
 }
 img.avatar {
     border-radius: inherit;
+    vertical-align: middle;
+    margin-right: 5px;
 }
 .avatar > img.avatar {
     width: 100%;
-- 
GitLab