@@ -2065,6 +2065,24 @@ public static function getTopcoderUser($user) {
2065
2065
return $ topcoderUser ;
2066
2066
}
2067
2067
2068
+ /**
2069
+ * Get Topcoder User Details (PhotoUrl, Rating, IsAdmin and others)
2070
+ * @param $user
2071
+ * @return array|false|mixed|void
2072
+ */
2073
+ public static function hasColorizedRole ($ user ) {
2074
+ $ userModel = new UserModel ();
2075
+ if (is_numeric ($ user )) {
2076
+ $ user = $ userModel ->getID ($ user , DATASET_TYPE_ARRAY );
2077
+ }
2078
+ $ userID = val ('UserID ' , $ user );
2079
+
2080
+ $ userRoleData = $ userModel ->getRoles ($ userID )->resultArray ();
2081
+ $ roleNames = array_column ($ userRoleData , 'Name ' );
2082
+ $ customerRoleName = c ('ColorizedRole ' , null );
2083
+ return count (array_intersect ($ roleNames , [$ customerRoleName ])) > 0 ;
2084
+ }
2085
+
2068
2086
private static function getTopcoderUserFromCache ($ userID ) {
2069
2087
if (!Gdn_Cache::activeEnabled ()) {
2070
2088
return false ;
@@ -2801,6 +2819,10 @@ function userAnchor($user, $cssClass = null, $options = null) {
2801
2819
$ attributes ['class ' ] = $ attributes ['class ' ].' ' . 'disabledLink ' ;
2802
2820
}
2803
2821
2822
+ $ hasRole = TopcoderPlugin::hasColorizedRole ($ userID );
2823
+ if ($ hasRole ) {
2824
+ $ attributes ['class ' ] = $ attributes ['class ' ].' ' . 'purple ' ;
2825
+ }
2804
2826
2805
2827
Gdn::controller ()->EventArguments ['User ' ] = $ user ;
2806
2828
Gdn::controller ()->EventArguments ['IsTopcoderAdmin ' ] =$ isTopcoderAdmin ;
@@ -3042,6 +3064,16 @@ function topcoderMentionAnchor($mention, $cssClass = null, $options = null) {
3042
3064
if ($ isTopcoderAdmin ) {
3043
3065
$ attributes ['class ' ] = $ attributes ['class ' ].' ' . 'topcoderAdmin ' ;
3044
3066
}
3067
+
3068
+ $ userModel = new UserModel ();
3069
+ $ user = $ userModel ->getByUsername ($ handle , false );
3070
+ if ($ user ) {
3071
+ $ userID = val ('UserID ' , $ user );
3072
+ $ hasRole = TopcoderPlugin::hasColorizedRole ($ userID );
3073
+ if ($ hasRole ) {
3074
+ $ attributes ['class ' ] = $ attributes ['class ' ].' ' . 'purple ' ;
3075
+ }
3076
+ }
3045
3077
return '<a href=" ' .htmlspecialchars (url ($ userUrl )).'" ' .attribute ($ attributes ).'>@ ' .$ handle .'</a> ' ;
3046
3078
}
3047
3079
}
0 commit comments