From 340d92fcfa474d08354178b58c9fc1880731be8a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Joshua=20R=C3=BCsweg?= Date: Mon, 30 Jul 2018 20:52:12 +0200 Subject: [PATCH] Add reputation for user profiles See #2508 --- com.woltlab.wcf/templates/membersList.tpl | 2 +- com.woltlab.wcf/templates/messageSidebar.tpl | 21 ++++-- .../templates/userInformationStatistics.tpl | 9 ++- com.woltlab.wcf/templates/userSidebar.tpl | 18 +++++ .../files/lib/page/MembersListPage.class.php | 6 +- .../install/files/style/ui/reactions.scss | 68 +++++++++++++++++++ wcfsetup/install/lang/de.xml | 4 +- wcfsetup/install/lang/en.xml | 4 +- 8 files changed, 120 insertions(+), 12 deletions(-) diff --git a/com.woltlab.wcf/templates/membersList.tpl b/com.woltlab.wcf/templates/membersList.tpl index a432e2b77e..b68b6d6143 100644 --- a/com.woltlab.wcf/templates/membersList.tpl +++ b/com.woltlab.wcf/templates/membersList.tpl @@ -57,7 +57,7 @@ - {if MODULE_LIKE}{/if} + {if MODULE_LIKE}{/if} {event name='sortField'} diff --git a/com.woltlab.wcf/templates/messageSidebar.tpl b/com.woltlab.wcf/templates/messageSidebar.tpl index 37dd130a54..d1ef705ef9 100644 --- a/com.woltlab.wcf/templates/messageSidebar.tpl +++ b/com.woltlab.wcf/templates/messageSidebar.tpl @@ -44,6 +44,22 @@
{@$userProfile->getRank()->getImage()}
{/if} {/if} + + {if MODULE_LIKE && MESSAGE_SIDEBAR_ENABLE_LIKES_RECEIVED && !$isReply} +
+ {assign var=overallReactionCount value=$userProfile->positiveReactionsReceived - $userProfile->negativeReactionsReceived} + + {if $overallReactionCount > 0} + {$overallReactionCount|shortUnit} + {elseif $overallReactionCount < 0} + {assign var=overallReactionCount value=$overallReactionCount*-1} + {$overallReactionCount|shortUnit} + {else} + {$overallReactionCount|shortUnit} + {/if} + +
+ {/if} {if !$isReply && MODULE_TROPHY && $__wcf->session->getPermission('user.profile.trophy.canSeeTrophies') && ($userProfile->isAccessible('canViewTrophies') || $userProfile->userID == $__wcf->session->userID) && $userProfile->getSpecialTrophies()|count}
@@ -81,11 +97,6 @@
{content} - {if MODULE_LIKE && MESSAGE_SIDEBAR_ENABLE_LIKES_RECEIVED && $userProfile->likesReceived} -
{lang}wcf.like.likesReceived{/lang}
-
{#$userProfile->likesReceived}
- {/if} - {if MESSAGE_SIDEBAR_ENABLE_ACTIVITY_POINTS && $userProfile->activityPoints}
{lang}wcf.user.activityPoint{/lang}
{#$userProfile->activityPoints}
diff --git a/com.woltlab.wcf/templates/userInformationStatistics.tpl b/com.woltlab.wcf/templates/userInformationStatistics.tpl index 927de4caac..5594c83760 100644 --- a/com.woltlab.wcf/templates/userInformationStatistics.tpl +++ b/com.woltlab.wcf/templates/userInformationStatistics.tpl @@ -1,8 +1,11 @@ {event name='statistics'} -{if MODULE_LIKE && $user->likesReceived} -
{if $__wcf->getSession()->getPermission('user.profile.canViewUserProfile') && !$user->isProtected()}{lang}wcf.like.likesReceived{/lang}{else}{lang}wcf.like.likesReceived{/lang}{/if}
-
{#$user->likesReceived}
+{if MODULE_LIKE} + {assign var=reactionReputation value=$user->positiveReactionsReceived - $user->negativeReactionsReceived} + {if $reactionReputation} +
{if $__wcf->getSession()->getPermission('user.profile.canViewUserProfile') && !$user->isProtected()}{lang}wcf.like.reputation{/lang}{else}{lang}wcf.like.reputation{/lang}{/if}
+
{#$reactionReputation}
+ {/if} {/if} {if $user->activityPoints} diff --git a/com.woltlab.wcf/templates/userSidebar.tpl b/com.woltlab.wcf/templates/userSidebar.tpl index 218b0a9596..a5dd06e4cb 100644 --- a/com.woltlab.wcf/templates/userSidebar.tpl +++ b/com.woltlab.wcf/templates/userSidebar.tpl @@ -1,4 +1,22 @@ {if !$user->isProtected()} + {if MODULE_LIKE} + {assign var=reactionReputation value=$user->positiveReactionsReceived - $user->negativeReactionsReceived} +
+

Reputation

+ +
+ {if $reactionReputation > 0} + {#$reactionReputation} + {elseif $reactionReputation < 0} + {assign var=reactionReputation value=$reactionReputation*-1} + {#$reactionReputation} + {else} + {#$reactionReputation} + {/if} +
+
+ {/if} + {if $followingCount}

{lang}wcf.user.profile.following{/lang} {#$followingCount}

diff --git a/wcfsetup/install/files/lib/page/MembersListPage.class.php b/wcfsetup/install/files/lib/page/MembersListPage.class.php index cb66a96090..a766b7d8cb 100644 --- a/wcfsetup/install/files/lib/page/MembersListPage.class.php +++ b/wcfsetup/install/files/lib/page/MembersListPage.class.php @@ -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 = []; diff --git a/wcfsetup/install/files/style/ui/reactions.scss b/wcfsetup/install/files/style/ui/reactions.scss index 4d4c3ce422..9bc39d384c 100644 --- a/wcfsetup/install/files/style/ui/reactions.scss +++ b/wcfsetup/install/files/style/ui/reactions.scss @@ -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 diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index 6c219ab543..f8ca5596e4 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -3110,7 +3110,7 @@ E-Mail-Adresse: {@$emailAddress} {* this line ends with a space *} - username}]]> + username}]]> @@ -3136,6 +3136,8 @@ E-Mail-Adresse: {@$emailAddress} {* this line ends with a space *} + + diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml index 30a7b24c3d..315fb138f9 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -3055,7 +3055,7 @@ Email: {@$emailAddress} {* this line ends with a space *} - username}]]> + username}]]> @@ -3081,6 +3081,8 @@ Email: {@$emailAddress} {* this line ends with a space *} + + -- 2.20.1