Skip to content

Commit d1716ec

Browse files
committed
Issues-563: Updated breadcrubms
1 parent 7c08db0 commit d1716ec

File tree

2 files changed

+42
-3
lines changed

2 files changed

+42
-3
lines changed

vanilla/applications/vanilla/controllers/class.categoriescontroller.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -689,8 +689,9 @@ public function all($Category = '', $displayAs = '') {
689689
$this->addModule('BookmarkedModule');
690690
// FIX: https://github.com/topcoder-platform/forums/issues/548
691691
// Show only for 'Public forums'
692-
$isGroupCategory = val('GroupID',$this->data('Category'));
693-
if(gdn::session()->isValid() && $this->data('Category') && !$isGroupCategory) {
692+
$categoryID = val('CategoryID',$this->data('Category'));
693+
$isChallengeForums = $this->checkChallengeForums($categoryID);
694+
if(gdn::session()->isValid() && $this->data('Category') && !$isChallengeForums) {
694695
$this->addModule('CategoriesModule');
695696
}
696697

vanilla/applications/vanilla/controllers/class.vanillacontroller.php

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,20 +72,58 @@ protected function checkPageRange(int $offset, int $totalCount) {
7272
}
7373
}
7474

75+
public function checkChallengeForums($CategoryID) {
76+
$Category = CategoryModel::categories($CategoryID);
77+
$ancestors = CategoryModel::getAncestors($CategoryID);
78+
if(val('GroupID', $Category) > 0) {
79+
return true;
80+
}
81+
82+
foreach ($ancestors as $id => $ancestor) {
83+
if($ancestor['UrlCode'] == self::CHALLENGE_FORUMS_URLCODE) {
84+
return true;
85+
}
86+
if($ancestor['GroupID'] > 0) {
87+
return true;
88+
}
89+
}
90+
91+
return false;
92+
}
93+
7594
protected function buildBreadcrumbs($CategoryID) {
7695
$Category = CategoryModel::categories($CategoryID);
7796
$ancestors = CategoryModel::getAncestors($CategoryID);
7897
$parentCategoryID = val('ParentCategoryID', $Category);
7998
if(val('GroupID', $Category) > 0) {
99+
$challenge = $this->data('Challenge');
100+
$track = $challenge ? $challenge['Track']: false;
80101
$temp = [];
102+
$GroupCategoryID = $this->data('Breadcrumbs.Options.GroupCategoryID');
81103
foreach ($ancestors as $id => $ancestor) {
82104
if($ancestor['GroupID'] > 0) {
83-
$temp[$ancestor['CategoryID']] = $ancestor;
105+
if($GroupCategoryID == $ancestor['CategoryID']) {// root category for a group
106+
array_push($temp, ['Name' => $ancestor['Name'], 'Url'=>'/group/'.$ancestor['GroupID']]);
107+
} else {
108+
$temp[$ancestor['CategoryID']] = $ancestor;
109+
}
84110
} else {
85111
if($ancestor['UrlCode'] == self::CHALLENGE_FORUMS_URLCODE) {
86112
array_push($temp, ['Name' => 'Challenge Forums', 'Url'=>'/groups/mine?filter=challenge']);
87113
}else if($ancestor['UrlCode'] == 'groups') {
88114
array_push($temp, ['Name' => 'Group Forums', 'Url'=>'/groups/mine?filter=regular']);
115+
} else {
116+
if($track) {
117+
switch ($ancestor['UrlCode']) {
118+
case 'development-forums':
119+
case 'data-science-forums':
120+
case 'design-forums':
121+
array_push($temp, ['Name' => $track, 'Url'=>'/groups/mine?filter=challenge']);
122+
break;
123+
default:
124+
$temp[$ancestor['CategoryID']] = $ancestor;
125+
}
126+
}
89127
}
90128
}
91129
}

0 commit comments

Comments
 (0)