Skip to content

Different username colors for client admin handles in forums #120

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions Topcoder/class.topcoder.plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -2065,6 +2065,24 @@ public static function getTopcoderUser($user) {
return $topcoderUser;
}

/**
* Get Topcoder User Details (PhotoUrl, Rating, IsAdmin and others)
* @param $user
* @return array|false|mixed|void
*/
public static function hasColorizedRole($user) {
$userModel = new UserModel();
if(is_numeric($user)) {
$user = $userModel->getID($user, DATASET_TYPE_ARRAY);
}
$userID = val('UserID', $user);

$userRoleData = $userModel->getRoles($userID)->resultArray();
$roleNames = array_column($userRoleData, 'Name');
$customerRoleName = c('ColorizedRole', null);
return count(array_intersect($roleNames, [$customerRoleName])) > 0;
}

private static function getTopcoderUserFromCache($userID) {
if(!Gdn_Cache::activeEnabled()) {
return false;
Expand Down Expand Up @@ -2801,6 +2819,10 @@ function userAnchor($user, $cssClass = null, $options = null) {
$attributes['class'] = $attributes['class'].' '. 'disabledLink' ;
}

$hasRole = TopcoderPlugin::hasColorizedRole($userID);
if($hasRole) {
$attributes['class'] = $attributes['class'].' '. 'purple' ;
}

Gdn::controller()->EventArguments['User'] = $user;
Gdn::controller()->EventArguments['IsTopcoderAdmin'] =$isTopcoderAdmin;
Expand Down Expand Up @@ -3042,6 +3064,16 @@ function topcoderMentionAnchor($mention, $cssClass = null, $options = null) {
if($isTopcoderAdmin) {
$attributes['class'] = $attributes['class'].' '. 'topcoderAdmin' ;
}

$userModel = new UserModel();
$user = $userModel->getByUsername($handle, false);
if ($user) {
$userID = val('UserID', $user);
$hasRole = TopcoderPlugin::hasColorizedRole($userID);
if($hasRole) {
$attributes['class'] = $attributes['class'].' '. 'purple' ;
}
}
return '<a href="'.htmlspecialchars(url($userUrl)).'"'.attribute($attributes).'>@'.$handle.'</a>';
}
}
Expand Down
15 changes: 14 additions & 1 deletion Topcoder/design/topcoder.css
Original file line number Diff line number Diff line change
Expand Up @@ -163,4 +163,17 @@ a:hover span.challengeRoles {

.disabledLink {
pointer-events:none
}
}

/* Customer Role */
.purple, .purple:link, .purple:visited, .purple:hover, .purple:active{
color: #652385
}

.DataList .MItem a.purple, .DataList .MItem a.purple:link, .DataList .MItem a.purple:hover, .DataList .MItem a.purple:visited,
.MessageList .ItemDiscussion .Username.purple, .MessageList .ItemDiscussion .Username.purple:hover,
.Content.MainContent .MessageList.DataList.Comments li.Item .Item-Header.CommentHeader .Username.purple,
.Flyout.Flyout a.purple, .Flyout.Flyout a.purple:link,.Flyout.Flyout a.purple:visited, .Flyout.Flyout a.purple:hover, .Flyout.Flyout a.purple:active,
.userContent p a.purple, .userContent p a.purple:link, .userContent p a.purple:visited, .userContent p a.purple:hover, .userContent p a.purple:active,
.InformMessages .InformMessage .purple, .InformMessages .InformMessage .purple:link, .InformMessages .InformMessage .purple:hover, .InformMessages .InformMessage .purple:active, .InformMessages .InformMessage .purple:visited
{ color: #652385 !important; }