From: Matthias Schmidt Date: Fri, 28 Jun 2013 08:20:31 +0000 (+0200) Subject: Adds user avatar to user search/suggestions X-Git-Tag: 2.0.0_Beta_5~118^2~13^2~4 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=c2d0b2d61078e9d6041ff473d093deeb27169e9f;p=GitHub%2FWoltLab%2FWCF.git Adds user avatar to user search/suggestions --- diff --git a/wcfsetup/install/files/js/WCF.Message.js b/wcfsetup/install/files/js/WCF.Message.js index 0ecf4670c1..2deb9bfe9d 100644 --- a/wcfsetup/install/files/js/WCF.Message.js +++ b/wcfsetup/install/files/js/WCF.Message.js @@ -2991,7 +2991,11 @@ WCF.Message.UserMention = Class.extend({ * @return object */ _createListItem: function(listItemData) { - $('
  • ' + listItemData.label + '
  • ').data('username', listItemData.label).click($.proxy(this._click, this)).appendTo(this._suggestionList); + var $listItem = $('
  • ').data('username', listItemData.label).click($.proxy(this._click, this)).appendTo(this._suggestionList); + + var $box16 = $('
    ').addClass('box16').appendTo($listItem); + $box16.append($(listItemData.icon).addClass('framed')); + $box16.append($('
    ').append($('').text(listItemData.label))); }, /** diff --git a/wcfsetup/install/files/js/WCF.js b/wcfsetup/install/files/js/WCF.js index e40cbc54e1..de6ff699aa 100755 --- a/wcfsetup/install/files/js/WCF.js +++ b/wcfsetup/install/files/js/WCF.js @@ -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 = $(''); + } + + if ($icon) { + var $label = $listItem.find('span').detach(); + + var $box16 = $('
    ').addClass('box16').appendTo($listItem); + + $box16.append($icon.addClass('framed')); + $box16.append($('
    ').append($label)); + } + // insert item type - if (this._includeUserGroups) $('').prependTo($listItem.children('span:eq(0)')); $listItem.data('type', item.type); return $listItem; diff --git a/wcfsetup/install/files/lib/data/user/UserAction.class.php b/wcfsetup/install/files/lib/data/user/UserAction.class.php index 632b97750d..635b83c967 100644 --- a/wcfsetup/install/files/lib/data/user/UserAction.class.php +++ b/wcfsetup/install/files/lib/data/user/UserAction.class.php @@ -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' ); } diff --git a/wcfsetup/install/files/style/dropdown.less b/wcfsetup/install/files/style/dropdown.less index f8a9cff4f1..2929b2b00c 100644 --- a/wcfsetup/install/files/style/dropdown.less +++ b/wcfsetup/install/files/style/dropdown.less @@ -194,6 +194,12 @@ } } + > .box16 { + cursor: pointer; + min-height: auto; + padding: @wcfGapTiny; + } + > label { display: block; }