Add reputation for user profiles
authorJoshua Rüsweg <josh@bastelstu.be>
Mon, 30 Jul 2018 18:52:12 +0000 (20:52 +0200)
committerJoshua Rüsweg <josh@bastelstu.be>
Mon, 30 Jul 2018 18:52:12 +0000 (20:52 +0200)
See #2508

com.woltlab.wcf/templates/membersList.tpl
com.woltlab.wcf/templates/messageSidebar.tpl
com.woltlab.wcf/templates/userInformationStatistics.tpl
com.woltlab.wcf/templates/userSidebar.tpl
wcfsetup/install/files/lib/page/MembersListPage.class.php
wcfsetup/install/files/style/ui/reactions.scss
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index a432e2b77ea479ce52b2baa4be49fef1b42e48e9..b68b6d6143a954f472f9f09d3bce9be254ea488a 100644 (file)
@@ -57,7 +57,7 @@
                                                        <option value="username"{if $sortField == 'username'} selected{/if}>{lang}wcf.user.username{/lang}</option>
                                                        <option value="registrationDate"{if $sortField == 'registrationDate'} selected{/if}>{lang}wcf.user.registrationDate{/lang}</option>
                                                        <option value="activityPoints"{if $sortField == 'activityPoints'} selected{/if}>{lang}wcf.user.activityPoint{/lang}</option>
-                                                       {if MODULE_LIKE}<option value="likesReceived"{if $sortField == 'likesReceived'} selected{/if}>{lang}wcf.like.likesReceived{/lang}</option>{/if}
+                                                       {if MODULE_LIKE}<option value="reactionReputation"{if $sortField == 'reactionReputation'} selected{/if}>{lang}wcf.like.reactionReputation{/lang}</option>{/if}
                                                        <option value="lastActivityTime"{if $sortField == 'lastActivityTime'} selected{/if}>{lang}wcf.user.usersOnline.lastActivity{/lang}</option>
                                                        {event name='sortField'}
                                                </select>
index 37dd130a541e883a197d09d8f9dfdf373cdd0e5f..d1ef705ef9d940ee10e4c183b1df0f051942a3a2 100644 (file)
                                        <div class="userRank">{@$userProfile->getRank()->getImage()}</div>
                                {/if}
                        {/if}
+                       
+                       {if MODULE_LIKE && MESSAGE_SIDEBAR_ENABLE_LIKES_RECEIVED && !$isReply}
+                               <div class="reactionStatusContainer">
+                                       {assign var=overallReactionCount value=$userProfile->positiveReactionsReceived - $userProfile->negativeReactionsReceived}
+                                       <a href="{link controller='User' object=$userProfile}{/link}#likes" class="jsTooltip" title="{lang user=$userProfile}wcf.like.showLikesReceived{/lang}">
+                                               {if $overallReactionCount > 0}
+                                                       <span class="positiveReactionCount"><span class="fa fa-plus-circle icon16"></span> {$overallReactionCount|shortUnit}</span>
+                                               {elseif $overallReactionCount < 0}
+                                                       {assign var=overallReactionCount value=$overallReactionCount*-1}
+                                                       <span class="negativeReactionCount"><span class="fa fa-minus-circle icon16"></span> {$overallReactionCount|shortUnit}</span>
+                                               {else}
+                                                       <span class="neutralReactionCount"><span class="fa fa-plus-circle icon16"></span> {$overallReactionCount|shortUnit}</span>
+                                               {/if}
+                                       </a>
+                               </div>
+                       {/if}
 
                        {if !$isReply && MODULE_TROPHY && $__wcf->session->getPermission('user.profile.trophy.canSeeTrophies') && ($userProfile->isAccessible('canViewTrophies') || $userProfile->userID == $__wcf->session->userID) && $userProfile->getSpecialTrophies()|count}
                                <div class="specialTrophyContainer">
                                <div class="userCredits">
                                        <dl class="plain dataList">
                                                {content}
-                                                       {if MODULE_LIKE && MESSAGE_SIDEBAR_ENABLE_LIKES_RECEIVED && $userProfile->likesReceived}
-                                                               <dt><a href="{link controller='User' object=$userProfile}{/link}#likes" class="jsTooltip" title="{lang user=$userProfile}wcf.like.showLikesReceived{/lang}">{lang}wcf.like.likesReceived{/lang}</a></dt>
-                                                               <dd>{#$userProfile->likesReceived}</dd>
-                                                       {/if}
-                                                       
                                                        {if MESSAGE_SIDEBAR_ENABLE_ACTIVITY_POINTS && $userProfile->activityPoints}
                                                                <dt><a href="#" class="activityPointsDisplay jsTooltip" title="{lang user=$userProfile}wcf.user.activityPoint.showActivityPoints{/lang}" data-user-id="{@$userProfile->userID}">{lang}wcf.user.activityPoint{/lang}</a></dt>
                                                                <dd>{#$userProfile->activityPoints}</dd>
index 927de4caacaeeade185553ac01c2b423978eb751..5594c83760c0e5c97de20f2918797ac4e9341737 100644 (file)
@@ -1,8 +1,11 @@
 {event name='statistics'}
 
-{if MODULE_LIKE && $user->likesReceived}
-       <dt>{if $__wcf->getSession()->getPermission('user.profile.canViewUserProfile') && !$user->isProtected()}<a href="{link controller='User' object=$user}{/link}#likes" class="jsTooltip" title="{lang}wcf.like.showLikesReceived{/lang}">{lang}wcf.like.likesReceived{/lang}</a>{else}{lang}wcf.like.likesReceived{/lang}{/if}</dt>
-       <dd>{#$user->likesReceived}</dd>
+{if MODULE_LIKE}
+       {assign var=reactionReputation value=$user->positiveReactionsReceived - $user->negativeReactionsReceived}
+       {if $reactionReputation}
+               <dt>{if $__wcf->getSession()->getPermission('user.profile.canViewUserProfile') && !$user->isProtected()}<a href="{link controller='User' object=$user}{/link}#likes" class="jsTooltip" title="{lang}wcf.like.showLikesReceived{/lang}">{lang}wcf.like.reputation{/lang}</a>{else}{lang}wcf.like.reputation{/lang}{/if}</dt>
+               <dd>{#$reactionReputation}</dd>
+       {/if}
 {/if}
 
 {if $user->activityPoints}
index 218b0a959680100808c475c3e080f738b03222bf..a5dd06e4cbc8a847e42290cc32f462c8a9ae1904 100644 (file)
@@ -1,4 +1,22 @@
 {if !$user->isProtected()}
+       {if MODULE_LIKE}
+               {assign var=reactionReputation value=$user->positiveReactionsReceived - $user->negativeReactionsReceived}
+               <section class="box reactionReputationBox {if $reactionReputation >= 0}positiveReactionReputationBox{else}negativeReactionReputationBox{/if}" data-static-box-identifier="com.woltlab.wcf.ReactionReputation">
+                       <h2 class="boxTitle"><a href="{link controller='User' object=$user}{/link}#likes">Reputation</a></h2>
+                       
+                       <div class="boxContent">
+                               {if $reactionReputation > 0}
+                                       <span class="positiveReactionCount"><span class="fa fa-plus-circle icon32"></span> {#$reactionReputation}</span>
+                               {elseif $reactionReputation < 0}
+                                       {assign var=reactionReputation value=$reactionReputation*-1}
+                                       <span class="negativeReactionCount"><span class="fa fa-minus-circle icon32"></span> {#$reactionReputation}</span>
+                               {else}
+                                       <span class="neutralReactionCount"><span class="fa fa-plus-circle icon32"></span> {#$reactionReputation}</span>
+                               {/if}
+                       </div>
+               </section>
+       {/if}
+       
        {if $followingCount}
                <section class="box" data-static-box-identifier="com.woltlab.wcf.UserProfileFollowing">
                        <h2 class="boxTitle">{lang}wcf.user.profile.following{/lang} <span class="badge">{#$followingCount}</span></h2>
index cb66a960900a02fe161cf5caf73f05281cd01b37..a766b7d8cbabaada5c6bd86d22a3465da9affa55 100644 (file)
@@ -54,7 +54,7 @@ class MembersListPage extends SortablePage {
        /**
         * @inheritDoc
         */
-       public $validSortFields = ['username', 'registrationDate', 'activityPoints', 'likesReceived', 'lastActivityTime'];
+       public $validSortFields = ['username', 'registrationDate', 'activityPoints', 'reactionReputation', 'lastActivityTime'];
        
        /**
         * @inheritDoc
@@ -131,6 +131,10 @@ class MembersListPage extends SortablePage {
         * @inheritDoc
         */
        protected function readObjects() {
+               if ($this->sortField === 'reactionReputation') {
+                       $this->sqlOrderBy = '(user_table.positiveReactionsReceived - user_table.negativeReactionsReceived) '. $this->sortOrder;
+               }
+               
                parent::readObjects();
                
                $userIDs = [];
index 4d4c3ce422b70fcbc6ee5a77b9d8f29bf8301476..9bc39d384c4ff4f16f80b3bfce166e7009d2ce54 100644 (file)
@@ -113,3 +113,71 @@ li.reactCountButton:hover {
                padding: 0px;
        }
 }
+
+.reactionStatusContainer {
+       margin-top: 10px;
+       
+       .positiveReactionCount {
+               color: $wcfStatusSuccessText;
+               
+               .fa {
+                       color: $wcfStatusSuccessText;
+               }
+       }
+       
+       .negativeReactionCount {
+               color: $wcfStatusErrorText;
+               
+               .fa {
+                       color: $wcfStatusErrorText;
+               }
+       }
+       
+       .neutralReactionCount {
+               color: $wcfStatusSuccessText;
+               
+               .fa {
+                       color: $wcfStatusSuccessText;
+               }
+       }
+}
+
+.box.reactionReputationBox {
+       &.positiveReactionReputationBox {
+               background-color: $wcfStatusSuccessBackground;
+               color: $wcfStatusSuccessText;
+               
+               .fa {
+                       color: $wcfStatusSuccessText;
+               }
+               
+               .boxTitle > a {
+                       color: $wcfStatusSuccessText;
+               }
+       }
+       
+       &.negativeReactionReputationBox {
+               background-color: $wcfStatusErrorBackground;
+               color: $wcfStatusErrorText;
+               
+               .fa {
+                       color: $wcfStatusErrorText;
+               }
+               
+               .boxTitle > a {
+                       color: $wcfStatusErrorText;
+               }
+       }
+       
+       .boxContent {
+               @include wcfFontHeadline;
+               
+               text-align: center;
+       }
+}
+
+@include screen-sm-down {
+       .reactionStatusContainer {
+               display: none;
+       }
+}
\ No newline at end of file
index 6c219ab54352a2a4d079447cc03ffa8453bd38b8..f8ca5596e473837f7849f7968c74b39868f0408e 100644 (file)
@@ -3110,7 +3110,7 @@ E-Mail-Adresse: {@$emailAddress} {* this line ends with a space *}
                <item name="wcf.like.button.like"><![CDATA[Gefällt mir]]></item>
                <item name="wcf.like.button.dislike"><![CDATA[Gefällt mir nicht]]></item>
                <item name="wcf.like.likesReceived"><![CDATA[Erhaltene Likes]]></item>
-               <item name="wcf.like.showLikesReceived"><![CDATA[Erhaltene Likes von {$user->username}]]></item>
+               <item name="wcf.like.showLikesReceived"><![CDATA[Erhaltene Reaktionen von {$user->username}]]></item>
                <item name="wcf.like.likesGiven"><![CDATA[Vergebene Likes]]></item>
                <item name="wcf.like.dislikesReceived"><![CDATA[Erhaltene Dislikes]]></item>
                <item name="wcf.like.dislikesGiven"><![CDATA[Vergebene Dislikes]]></item>
@@ -3136,6 +3136,8 @@ E-Mail-Adresse: {@$emailAddress} {* this line ends with a space *}
                <item name="wcf.like.reaction.more"><![CDATA[Weitere Reaktionen]]></item>
                <item name="wcf.like.reactionsReceived"><![CDATA[Erhaltene Reaktionen]]></item>
                <item name="wcf.like.reactionsGiven"><![CDATA[Vergebene Reaktionen]]></item>
+               <item name="wcf.like.reactionReputation"><![CDATA[Reputation aus Raktionen]]></item>
+               <item name="wcf.like.reputation"><![CDATA[Reputation]]></item>
        </category>
        
        <category name="wcf.map">
index 30a7b24c3db628750eb06a69094cb66acc9a2f21..315fb138f9fa4384a75e24d80d9b1c7755c7ab62 100644 (file)
@@ -3055,7 +3055,7 @@ Email: {@$emailAddress} {* this line ends with a space *}
                <item name="wcf.like.button.like"><![CDATA[Like]]></item>
                <item name="wcf.like.button.dislike"><![CDATA[Dislike]]></item>
                <item name="wcf.like.likesReceived"><![CDATA[Likes Received]]></item>
-               <item name="wcf.like.showLikesReceived"><![CDATA[Likes Received by {$user->username}]]></item>
+               <item name="wcf.like.showLikesReceived"><![CDATA[Reactions Received by {$user->username}]]></item>
                <item name="wcf.like.likesGiven"><![CDATA[Likes Given]]></item>
                <item name="wcf.like.dislikesReceived"><![CDATA[Dislikes Received]]></item>
                <item name="wcf.like.dislikesGiven"><![CDATA[Dislikes Given]]></item>
@@ -3081,6 +3081,8 @@ Email: {@$emailAddress} {* this line ends with a space *}
                <item name="wcf.like.reaction.more"><![CDATA[More Reactions]]></item>
                <item name="wcf.like.reactionsReceived"><![CDATA[Reactions Received]]></item>
                <item name="wcf.like.reactionsGiven"><![CDATA[Reactions Given]]></item>
+               <item name="wcf.like.reactionReputation"><![CDATA[Reputation from Reactions]]></item>
+               <item name="wcf.like.reputation"><![CDATA[Reputation]]></item>
        </category>
        
        <category name="wcf.map">