Adds user avatar to user search/suggestions
authorMatthias Schmidt <gravatronics@live.com>
Fri, 28 Jun 2013 08:20:31 +0000 (10:20 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Fri, 28 Jun 2013 08:20:31 +0000 (10:20 +0200)
wcfsetup/install/files/js/WCF.Message.js
wcfsetup/install/files/js/WCF.js
wcfsetup/install/files/lib/data/user/UserAction.class.php
wcfsetup/install/files/style/dropdown.less

index 0ecf4670c181b079b62e57f969646611d179f7ed..2deb9bfe9d35ab49f58d114015f60d07e000842f 100644 (file)
@@ -2991,7 +2991,11 @@ WCF.Message.UserMention = Class.extend({
         * @return      object
         */
        _createListItem: function(listItemData) {
-               $('<li class="box16"><span><span class="icon icon16 icon-user" /> ' + listItemData.label + '</span></li>').data('username', listItemData.label).click($.proxy(this._click, this)).appendTo(this._suggestionList);
+               var $listItem = $('<li />').data('username', listItemData.label).click($.proxy(this._click, this)).appendTo(this._suggestionList);
+               
+               var $box16 = $('<div />').addClass('box16').appendTo($listItem);
+               $box16.append($(listItemData.icon).addClass('framed'));
+               $box16.append($('<div />').append($('<span />').text(listItemData.label)));
        },
        
        /**
index e40cbc54e172a64ebfbf6a56690894b392c84492..de6ff699aaadb1eb0040245a36629935ac7e3610 100755 (executable)
@@ -5671,8 +5671,24 @@ WCF.Search.User = WCF.Search.Base.extend({
        _createListItem: function(item) {
                var $listItem = this._super(item);
                
+               var $icon = null;
+               if (item.icon) {
+                       $icon = $(item.icon);
+               }
+               else if (this._includeUserGroups && item.type === 'group') {
+                       $icon = $('<span class="icon icon16 icon-group" />');
+               }
+               
+               if ($icon) {
+                       var $label = $listItem.find('span').detach();
+                       
+                       var $box16 = $('<div />').addClass('box16').appendTo($listItem);
+                       
+                       $box16.append($icon.addClass('framed'));
+                       $box16.append($('<div />').append($label));
+               }
+               
                // insert item type
-               if (this._includeUserGroups) $('<span class="icon icon16 icon-' + (item.type === 'group' ? 'group' : 'user') + '" style="margin-right: 4px;" />').prependTo($listItem.children('span:eq(0)'));
                $listItem.data('type', item.type);
                
                return $listItem;
index 632b97750db8e000584a9ae1e685a16ede91f229..635b83c967ac06550e41922ba5a4b505bc6bd2f3 100644 (file)
@@ -381,22 +381,20 @@ class UserAction extends AbstractDatabaseObjectAction implements IClipboardActio
                        }
                }
                
-               $conditionBuilder = new PreparedStatementConditionBuilder();
-               $conditionBuilder->add("username LIKE ?", array($searchString.'%'));
+               // find users
+               $userProfileList = new UserProfileList();
+               $userProfileList->getConditionBuilder()->add("username LIKE ?", array($searchString.'%'));
                if (!empty($excludedSearchValues)) {
-                       $conditionBuilder->add("username NOT IN (?)", array($excludedSearchValues));
+                       $userProfileList->getConditionBuilder()->add("username NOT IN (?)", array($excludedSearchValues));
                }
+               $userProfileList->sqlLimit = 10;
+               $userProfileList->readObjects();
                
-               // find users
-               $sql = "SELECT  userID, username
-                       FROM    wcf".WCF_N."_user
-                       ".$conditionBuilder;
-               $statement = WCF::getDB()->prepareStatement($sql, 10);
-               $statement->execute($conditionBuilder->getParameters());
-               while ($row = $statement->fetchArray()) {
+               foreach ($userProfileList as $userProfile) {
                        $list[] = array(
-                               'label' => $row['username'],
-                               'objectID' => $row['userID'],
+                               'icon' => $userProfile->getAvatar()->getImageTag(16),
+                               'label' => $userProfile->username,
+                               'objectID' => $userProfile->userID,
                                'type' => 'user'
                        );
                }
index f8a9cff4f14c7d67f53331ddc5fae14c70a8303f..2929b2b00c41bdd68dc63b76b57b181381fb7ec4 100644 (file)
                        }
                }
                
+               > .box16 {
+                       cursor: pointer;
+                       min-height: auto;
+                       padding: @wcfGapTiny;
+               }
+               
                > label {
                        display: block;
                }