@@ -943,6 +943,14 @@ function gdn_dispatcher_beforeControllerMethod_handler($sender, $args){
943
943
}
944
944
}
945
945
946
+
947
+ public function base_beforeBuildBreadcrumbs_handler ($ sender , $ args ) {
948
+ if (Gdn::session ()->isValid ()) {
949
+ $ showFullBreadcrumbs = & $ args ['ShowFullBreadcrumbs ' ];
950
+ //FIX Issues-652: Client Manager - no navigation when embedded
951
+ $ showFullBreadcrumbs = !hideInMFE ();
952
+ }
953
+ }
946
954
/**
947
955
* Add scripts. Add script to hide iPhone browser bar on pageload.
948
956
*/
@@ -1769,6 +1777,21 @@ private static function isTopcoderAdmin($topcoderRoles = false) {
1769
1777
return false ;
1770
1778
}
1771
1779
1780
+ /**
1781
+ * Check if the list of Topcoder roles includes 'Client Manager' role
1782
+ * @param false $topcoderRoles
1783
+ * @return bool true, if the list of Topcoder roles includes 'Client Manager'
1784
+ */
1785
+ private static function isTopcoderClientManager ($ topcoderRoles = false ) {
1786
+ if ($ topcoderRoles ) {
1787
+ $ roleNames = array_column ($ topcoderRoles , 'roleName ' );
1788
+ $ lowerRoleNames = array_map ('strtolower ' , $ roleNames );
1789
+ return count (array_intersect ($ lowerRoleNames , ["client manager " ])) > 0 ;
1790
+ }
1791
+
1792
+ return false ;
1793
+ }
1794
+
1772
1795
/**
1773
1796
* Get Topcoder Role names
1774
1797
* @param false $topcoderRoles
@@ -1801,6 +1824,7 @@ private static function loadTopcoderUserDetails($vanillaUser) {
1801
1824
$ topcoderRoles = self ::loadTopcoderRoles ($ topcoderProfile ->userId );
1802
1825
$ cachedUser ['Roles ' ] = self ::getTopcoderRoleNames ($ topcoderRoles );
1803
1826
$ cachedUser ['IsAdmin ' ] = self ::isTopcoderAdmin ($ topcoderRoles );
1827
+ $ cachedUser ['IsClientManager ' ] = self ::isTopcoderClientManager ($ topcoderRoles );
1804
1828
$ topcoderRating = self ::loadTopcoderRating ($ username ); //loaded by handle
1805
1829
if ($ topcoderRating ) {
1806
1830
$ cachedUser ['Rating ' ] = $ topcoderRating ;
@@ -2066,6 +2090,7 @@ private static function loadTopcoderUserDetailsByHandle($topcoderHandle) {
2066
2090
$ topcoderRoles = self ::loadTopcoderRoles ($ topcoderProfile ->userId );
2067
2091
$ cachedUser ['Roles ' ] = self ::getTopcoderRoleNames ($ topcoderRoles );
2068
2092
$ cachedUser ['IsAdmin ' ] = self ::isTopcoderAdmin ($ topcoderRoles );
2093
+ $ cachedUser ['IsClientManager ' ] = self ::isTopcoderClientManager ($ topcoderRoles );
2069
2094
$ topcoderRating = self ::loadTopcoderRating ($ topcoderHandle ); //loaded by handle
2070
2095
if ($ topcoderRating ) {
2071
2096
$ cachedUser ['Rating ' ] = $ topcoderRating ;
@@ -2465,9 +2490,11 @@ function userPhoto($user, $options = []) {
2465
2490
}
2466
2491
2467
2492
$ isTopcoderAdmin = val ('IsAdmin ' , $ topcoderProfile );
2493
+ $ isTopcoderClientManager = val ('IsClientManager ' , $ topcoderProfile );
2468
2494
$ photoUrl = isset ($ photoUrl ) && !empty (trim ($ photoUrl )) ? $ photoUrl : UserModel::getDefaultAvatarUrl ();
2469
2495
$ isUnlickableUser = TopcoderPlugin::isUnclickableUser ($ name );
2470
- $ href = (val ('NoLink ' , $ options )) || $ isUnlickableUser || getIncomingValue ('embed_type ' ) == 'mfe ' ? '' : ' href=" ' .url ($ userLink ).'" ' ;
2496
+ $ href = (val ('NoLink ' , $ options )) || $ isUnlickableUser ||
2497
+ ($ isTopcoderClientManager && getIncomingValue ('embed_type ' ) == 'mfe ' ) ? '' : ' href=" ' .url ($ userLink ).'" ' ;
2471
2498
2472
2499
Gdn::controller ()->EventArguments ['User ' ] = $ user ;
2473
2500
Gdn::controller ()->EventArguments ['Title ' ] =& $ title ;
@@ -2556,11 +2583,14 @@ function userAnchor($user, $cssClass = null, $options = null) {
2556
2583
$ attributes ['title ' ] = $ options ['title ' ];
2557
2584
}
2558
2585
2586
+ $ topcoderProfile = TopcoderPlugin::getTopcoderUser ($ userID );
2587
+
2559
2588
// Go to Topcoder user profile link instead of Vanilla profile link
2560
- $ isUnlickableUser = getIncomingValue ('embed_type ' ) == 'mfe ' || TopcoderPlugin::isUnclickableUser ($ name );
2589
+ $ isTopcoderClientManager = val ('IsClientManager ' , $ topcoderProfile );
2590
+ $ isUnlickableUser = ( $ isTopcoderClientManager && getIncomingValue ('embed_type ' ) == 'mfe ' ) || TopcoderPlugin::isUnclickableUser ($ name );
2561
2591
$ userUrl = $ isUnlickableUser ? '# ' : topcoderUserUrl ($ user , $ px );
2562
2592
2563
- $ topcoderProfile = TopcoderPlugin:: getTopcoderUser ( $ userID );
2593
+
2564
2594
$ topcoderRating = val ('Rating ' ,$ topcoderProfile , false );
2565
2595
if ($ topcoderRating != false || $ topcoderRating == null ) {
2566
2596
$ coderStyles = TopcoderPlugin::getRatingCssClass ($ topcoderRating );
@@ -2867,4 +2897,22 @@ function watchingSorts($extraClasses = '') {
2867
2897
'Sort '
2868
2898
);
2869
2899
}
2870
- }
2900
+ }
2901
+
2902
+ if (!function_exists ('hideInMFE ' )) {
2903
+ function hideInMFE () {
2904
+ if (!Gdn::session ()->isValid ()) {
2905
+ return false ;
2906
+ }
2907
+ //FIX Issues-652: Client Manager - no navigation when embedded
2908
+ $ 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 );
2912
+
2913
+ if ($ isMFE && $ isTopcoderClientManager ) {
2914
+ return true ;
2915
+ }
2916
+ return false ;
2917
+ }
2918
+ }
0 commit comments