Skip to content

Commit 99fd309

Browse files
committed
Support a self-service flag
1 parent d08087a commit 99fd309

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

Topcoder/class.topcoder.plugin.php

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1624,6 +1624,7 @@ public function getChallenge($challengeId) {
16241624
$cachedChallenge['StartDate'] = $startDate;
16251625
$cachedChallenge['EndDate'] = $endDate;
16261626
$cachedChallenge['Track'] = $challenge->track;
1627+
$cachedChallenge['IsSelfService'] = $challenge->legacy->selfService;
16271628
$termIDs = array_column($challenge->terms, 'id');
16281629
$NDA_UUID = c('Plugins.Topcoder.NDA_UUID');
16291630
$cachedChallenge['IsNDA'] = in_array($NDA_UUID, $termIDs);
@@ -1802,7 +1803,6 @@ private static function isTopcoderAdmin($topcoderRoles = false) {
18021803

18031804
/**
18041805
* Check if the list of Topcoder roles includes 'Client Manager' role
1805-
* @param false $topcoderRoles
18061806
* @return bool true, if the list of Topcoder roles includes 'Client Manager'
18071807
*/
18081808
public static function isTopcoderClientManager() {
@@ -1818,6 +1818,22 @@ public static function isTopcoderClientManager() {
18181818
return false;
18191819
}
18201820

1821+
/**
1822+
* Check if the challenge has self-service flag
1823+
* @return bool true, if the challenge has self-service flag
1824+
*/
1825+
public static function isChallengeSelfService() {
1826+
if(!Gdn::session()->isValid()) {
1827+
return false;
1828+
}
1829+
$challenge = Gdn::controller()->data("Challenge");
1830+
if($challenge) {
1831+
return $challenge['IsSelfService'];
1832+
}
1833+
1834+
return false;
1835+
}
1836+
18211837
/**
18221838
* Get Topcoder Role names
18231839
* @param false $topcoderRoles
@@ -2938,3 +2954,12 @@ function hideInMFE() {
29382954
return false;
29392955
}
29402956
}
2957+
2958+
if (!function_exists('isSelfService')) {
2959+
function isSelfService() {
2960+
if (!Gdn::session()->isValid()) {
2961+
return false;
2962+
}
2963+
return TopcoderPlugin::isChallengeSelfService();
2964+
}
2965+
}

0 commit comments

Comments
 (0)