@@ -1782,10 +1782,13 @@ private static function isTopcoderAdmin($topcoderRoles = false) {
1782
1782
* @param false $topcoderRoles
1783
1783
* @return bool true, if the list of Topcoder roles includes 'Client Manager'
1784
1784
*/
1785
- private static function isTopcoderClientManager ($ topcoderRoles = false ) {
1785
+ public static function isTopcoderClientManager () {
1786
+ if (!Gdn::session ()->isValid ()) {
1787
+ return false ;
1788
+ }
1789
+ $ topcoderRoles = Gdn::controller ()->data ("ChallengeCurrentUserProjectRoles " );
1786
1790
if ($ topcoderRoles ) {
1787
- $ roleNames = array_column ($ topcoderRoles , 'roleName ' );
1788
- $ lowerRoleNames = array_map ('strtolower ' , $ roleNames );
1791
+ $ lowerRoleNames = array_map ('strtolower ' , $ topcoderRoles );
1789
1792
return count (array_intersect ($ lowerRoleNames , ["client manager " ])) > 0 ;
1790
1793
}
1791
1794
@@ -1824,7 +1827,6 @@ private static function loadTopcoderUserDetails($vanillaUser) {
1824
1827
$ topcoderRoles = self ::loadTopcoderRoles ($ topcoderProfile ->userId );
1825
1828
$ cachedUser ['Roles ' ] = self ::getTopcoderRoleNames ($ topcoderRoles );
1826
1829
$ cachedUser ['IsAdmin ' ] = self ::isTopcoderAdmin ($ topcoderRoles );
1827
- $ cachedUser ['IsClientManager ' ] = self ::isTopcoderClientManager ($ topcoderRoles );
1828
1830
$ topcoderRating = self ::loadTopcoderRating ($ username ); //loaded by handle
1829
1831
if ($ topcoderRating ) {
1830
1832
$ cachedUser ['Rating ' ] = $ topcoderRating ;
@@ -1914,7 +1916,7 @@ private function setTopcoderProjectData($sender, $challengeID) {
1914
1916
// if($sender->GroupModel) {
1915
1917
// $sender->GroupModel->setCurrentUserTopcoderProjectRoles($currentProjectRoles);
1916
1918
// }
1917
- self ::log ('setTopcoderProjectData ' , ['ChallengeID ' => $ challengeID , 'currentUser ' => $ currentProjectRoles ,
1919
+ self ::log ('setTopcoderProjectData ' , ['ChallengeID ' => $ challengeID , 'CurrentUserProjectRoles ' => $ currentProjectRoles ,
1918
1920
'Topcoder Resources ' => $ resources , 'Topcoder RoleResources '
1919
1921
=> $ roleResources , 'challenge ' =>$ challenge ]);
1920
1922
}
@@ -2011,7 +2013,7 @@ public function gdn_dispatcher_beforeDispatch_handler($sender, $args) {
2011
2013
'Request(Method) ' => Gdn::request ()->getMethod (),
2012
2014
'Permissions ' => Gdn::session ()->getPermissionsArray (),
2013
2015
);
2014
- logMessage (__FILE__ , __LINE__ , 'TopcoderPlugin ' , "Data " , json_encode ($ data ));
2016
+ // logMessage(__FILE__, __LINE__, 'TopcoderPlugin', "Data", json_encode($data ));
2015
2017
// self::log('gdn_dispatcher_beforeDispatch_handler', $data);
2016
2018
}
2017
2019
@@ -2090,7 +2092,6 @@ private static function loadTopcoderUserDetailsByHandle($topcoderHandle) {
2090
2092
$ topcoderRoles = self ::loadTopcoderRoles ($ topcoderProfile ->userId );
2091
2093
$ cachedUser ['Roles ' ] = self ::getTopcoderRoleNames ($ topcoderRoles );
2092
2094
$ cachedUser ['IsAdmin ' ] = self ::isTopcoderAdmin ($ topcoderRoles );
2093
- $ cachedUser ['IsClientManager ' ] = self ::isTopcoderClientManager ($ topcoderRoles );
2094
2095
$ topcoderRating = self ::loadTopcoderRating ($ topcoderHandle ); //loaded by handle
2095
2096
if ($ topcoderRating ) {
2096
2097
$ cachedUser ['Rating ' ] = $ topcoderRating ;
@@ -2490,7 +2491,7 @@ function userPhoto($user, $options = []) {
2490
2491
}
2491
2492
2492
2493
$ isTopcoderAdmin = val ('IsAdmin ' , $ topcoderProfile );
2493
- $ isTopcoderClientManager = val ( ' IsClientManager ' , $ topcoderProfile );
2494
+ $ isTopcoderClientManager = TopcoderPlugin:: isTopcoderClientManager ( );
2494
2495
$ photoUrl = isset ($ photoUrl ) && !empty (trim ($ photoUrl )) ? $ photoUrl : UserModel::getDefaultAvatarUrl ();
2495
2496
$ isUnlickableUser = TopcoderPlugin::isUnclickableUser ($ name );
2496
2497
$ href = (val ('NoLink ' , $ options )) || $ isUnlickableUser ||
@@ -2586,7 +2587,7 @@ function userAnchor($user, $cssClass = null, $options = null) {
2586
2587
$ topcoderProfile = TopcoderPlugin::getTopcoderUser ($ userID );
2587
2588
2588
2589
// Go to Topcoder user profile link instead of Vanilla profile link
2589
- $ isTopcoderClientManager = val ( ' IsClientManager ' , $ topcoderProfile );
2590
+ $ isTopcoderClientManager = TopcoderPlugin:: isTopcoderClientManager ( );
2590
2591
$ isUnlickableUser = ( $ isTopcoderClientManager && getIncomingValue ('embed_type ' ) == 'mfe ' ) || TopcoderPlugin::isUnclickableUser ($ name );
2591
2592
$ userUrl = $ isUnlickableUser ? '# ' : topcoderUserUrl ($ user , $ px );
2592
2593
@@ -2906,9 +2907,7 @@ function hideInMFE() {
2906
2907
}
2907
2908
//FIX Issues-652: Client Manager - no navigation when embedded
2908
2909
$ isMFE = getIncomingValue ('embed_type ' ) == 'mfe ' ;
2909
- $ user = Gdn::userModel ()->getID (Gdn::session ()->UserID , DATASET_TYPE_ARRAY );
2910
- $ topcoderProfile = TopcoderPlugin::getTopcoderUser ($ user );
2911
- $ isTopcoderClientManager = val ('IsClientManager ' , $ topcoderProfile );
2910
+ $ isTopcoderClientManager = TopcoderPlugin::isTopcoderClientManager ();
2912
2911
2913
2912
if ($ isMFE && $ isTopcoderClientManager ) {
2914
2913
return true ;
0 commit comments