Skip to content

Support a self-service flag #111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 21, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion Topcoder/class.topcoder.plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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() {
Expand All @@ -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
Expand Down Expand Up @@ -2938,3 +2954,12 @@ function hideInMFE() {
return false;
}
}

if (!function_exists('isSelfService')) {
function isSelfService() {
if (!Gdn::session()->isValid()) {
return false;
}
return TopcoderPlugin::isChallengeSelfService();
}
}