Skip to content

Commit b529f47

Browse files
authored
Merge pull request #212 from topcoder-platform/issues-133
Issues-133, Issues-136, Vanilla bugs
2 parents 8ad1805 + 58637e6 commit b529f47

File tree

5 files changed

+48
-22
lines changed

5 files changed

+48
-22
lines changed

config/vanilla/bootstrap.early.php

Lines changed: 41 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,58 @@
22

33
if (c('Garden.Installed')) {
44

5-
$Database = Gdn::database();
6-
$SQL = $Database->sql();
7-
8-
$Construct = $Database->structure();
9-
105
// Update Vanilla Role Names
116
Gdn::sql()->update('Role')->set('Name', 'Vanilla Member')->where('RoleID', 8)->put();
127
Gdn::sql()->update('Role')->set('Name', 'Vanilla Admin')->where('RoleID', 16)->put();
138
Gdn::sql()->update('Role')->set('Name', 'Vanilla Moderator')->where('RoleID', 32)->put();
149

1510

1611
//
17-
// Update Vanilla tables
12+
// Update Vanilla tables and data
1813
//
1914

2015
//Add extra columns in Category : https://github.com/topcoder-platform/forums/issues/178
21-
$Construct->table('Category');
22-
$GroupIDExists = $Construct->columnExists('GroupID');
23-
if(!$GroupIDExists) {
24-
$Construct->column('GroupID', 'int', true, 'key');
25-
$Construct->set(false, false);
26-
}
27-
28-
// Update data after adding GroupID column: https://github.com/topcoder-platform/forums/issues/178
29-
Gdn::sql()->query("UPDATE GDN_Category c
30-
INNER JOIN (select c.CategoryID, g.GroupID from GDN_Category c , GDN_Group g where c.UrlCode like concat(g.ChallengeID,'%')) as src
16+
if(!Gdn::structure()->table('Category')->columnExists('GroupID')) {
17+
Gdn::structure()->table('Category')
18+
->column('GroupID', 'int', true, 'key')
19+
->set(false, false);
20+
21+
// Update data after adding GroupID column: https://github.com/topcoder-platform/forums/issues/178
22+
Gdn::sql()->query("UPDATE GDN_Category c
23+
INNER JOIN (SELECT c.CategoryID, g.GroupID FROM GDN_Category c , GDN_Group g WHERE c.UrlCode LIKE concat(g.ChallengeID,'%')) AS src
3124
ON src.CategoryID = c.CategoryID
3225
SET c.GroupID = src.GroupID
33-
WHERE c.GroupID is null");
26+
WHERE c.GroupID IS NULL");
27+
}
28+
29+
3430

31+
// Add the column Type in Group : https://github.com/topcoder-platform/forums/issues/133
32+
if(! Gdn::structure()->table('Group')->columnExists('Privacy')) {
33+
if(Gdn::structure()->table('Group')->renameColumn('Type', 'Privacy')) {
34+
35+
// Reset the internal state of this object so that it can be reused.
36+
Gdn::structure()->reset();
37+
38+
Gdn::structure()->table('Group')
39+
->column('Type', ['challenge', 'regular'], true)
40+
->set(false, false);
41+
42+
// Update existing data, all groups with ChallengeID will have the type 'challenge'
43+
Gdn::sql()->query("UPDATE GDN_Group g
44+
SET g.Type = CASE WHEN g.ChallengeID IS NOT NULL THEN 'challenge'
45+
ELSE 'regular' END");
46+
47+
Gdn::structure()->table('Group')
48+
->column('Type', ['challenge', 'regular'], false)
49+
->set(false, false);
50+
}
51+
}
52+
53+
// Add the column Archived in Group : https://github.com/topcoder-platform/forums/issues/136
54+
if(!Gdn::structure()->table('Group')->columnExists('Archived')) {
55+
Gdn::structure()->table('Group')
56+
->column('Archived', 'tinyint(1)', '0')
57+
->set(false, false);
58+
}
3559
}

config/vanilla/bootstrap.late.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@
1919
'Groups.Group.Edit',
2020
'Groups.Category.Manage',
2121
'Groups.Moderation.Manage',
22-
'Groups.EmailInvitations.Add']);
23-
22+
'Groups.EmailInvitations.Add',
23+
'Groups.Group.Archive']);
2424

25+
// TODO: need to be sure that all roles and permissions haven't be changed manually in prod/dev
2526
updateTopcoderRolePermissions(RoleModel::TOPCODER_ROLES);
26-
updateTopcoderRolePermissions(RoleModel::TOPCODER_PROJECT_ROLES);
27+
// updateTopcoderRolePermissions(RoleModel::TOPCODER_PROJECT_ROLES);
2728
}

vanilla/applications/dashboard/models/class.rolemodel.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ class RoleModel extends Gdn_Model {
8383
'Vanilla.Comments.Edit' => 1,
8484
'Vanilla.Comments.Delete' => 1,
8585
'Plugins.Attachments.Upload.Allow' => 1,
86+
'Groups.Group.Archive' => 1
8687

8788
];
8889
const TOPCODER_ROLES = [

vanilla/applications/vanilla/views/discussions/helper_functions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ function writeFilterTabs($sender) {
450450
}
451451
if (($countDiscussions > 0 || $sender->RequestMethod == 'mine') && c('Vanilla.Discussions.ShowMineTab', true)) {
452452
?>
453-
<li<?php echo $sender->RequestMethod == 'mine' ? ' class="Active"' : ''; ?>><?php echo anchor($myDiscussions, '/discussions/mine', 'MyDiscussions TabLink'); ?></li>
453+
<li<?php echo $sender->RequestMethod == 'mine' && $sender->ControllerName == 'discussionscontroller' ? ' class="Active"' : ''; ?>><?php echo anchor($myDiscussions, '/discussions/mine', 'MyDiscussions TabLink'); ?></li>
454454
<?php
455455
}
456456
if ($countDrafts > 0 || $sender->ControllerName == 'draftscontroller') {

vanilla/applications/vanilla/views/modules/discussionfilter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function filterCountString($count, $url = '') {
5757
}
5858
if (($CountDiscussions > 0 || $Controller->RequestMethod == 'mine') && c('Vanilla.Discussions.ShowMineTab', true)) {
5959
?>
60-
<li class="MyDiscussions<?php echo $Controller->RequestMethod == 'mine' ? ' Active' : ''; ?>"><?php echo anchor(sprite('SpMyDiscussions').' '.$MyDiscussions, '/discussions/mine'); ?></li>
60+
<li class="MyDiscussions<?php echo $Controller->ControllerName == 'discussionscontroller' && $Controller->RequestMethod == 'mine' ? ' Active' : ''; ?>"><?php echo anchor(sprite('SpMyDiscussions').' '.$MyDiscussions, '/discussions/mine'); ?></li>
6161
<?php
6262
}
6363
if ($CountDrafts > 0 || $Controller->ControllerName == 'draftscontroller') {

0 commit comments

Comments
 (0)