From 99fd3095a134f64639e9af722d37c514ce9b8fcd Mon Sep 17 00:00:00 2001 From: Bogdanova Olga Date: Fri, 21 Jan 2022 22:13:56 +0300 Subject: [PATCH] Support a self-service flag --- Topcoder/class.topcoder.plugin.php | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/Topcoder/class.topcoder.plugin.php b/Topcoder/class.topcoder.plugin.php index fdb1542..d96d2b4 100644 --- a/Topcoder/class.topcoder.plugin.php +++ b/Topcoder/class.topcoder.plugin.php @@ -1624,6 +1624,7 @@ public function getChallenge($challengeId) { $cachedChallenge['StartDate'] = $startDate; $cachedChallenge['EndDate'] = $endDate; $cachedChallenge['Track'] = $challenge->track; + $cachedChallenge['IsSelfService'] = $challenge->legacy->selfService; $termIDs = array_column($challenge->terms, 'id'); $NDA_UUID = c('Plugins.Topcoder.NDA_UUID'); $cachedChallenge['IsNDA'] = in_array($NDA_UUID, $termIDs); @@ -1802,7 +1803,6 @@ private static function isTopcoderAdmin($topcoderRoles = false) { /** * Check if the list of Topcoder roles includes 'Client Manager' role - * @param false $topcoderRoles * @return bool true, if the list of Topcoder roles includes 'Client Manager' */ public static function isTopcoderClientManager() { @@ -1818,6 +1818,22 @@ public static function isTopcoderClientManager() { return false; } + /** + * Check if the challenge has self-service flag + * @return bool true, if the challenge has self-service flag + */ + public static function isChallengeSelfService() { + if(!Gdn::session()->isValid()) { + return false; + } + $challenge = Gdn::controller()->data("Challenge"); + if($challenge) { + return $challenge['IsSelfService']; + } + + return false; + } + /** * Get Topcoder Role names * @param false $topcoderRoles @@ -2938,3 +2954,12 @@ function hideInMFE() { return false; } } + +if (!function_exists('isSelfService')) { + function isSelfService() { + if (!Gdn::session()->isValid()) { + return false; + } + return TopcoderPlugin::isChallengeSelfService(); + } +} \ No newline at end of file