Skip to content

Commit 3e0190e

Browse files
committed
Issues-218
1 parent 514de5d commit 3e0190e

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

config/vanilla/bootstrap.late.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,30 @@
2929
// Check all roles in the env and update all role permissions in RoleModel
3030
// updateRolePermissions(RoleModel::TYPE_TOPCODER, RoleModel::TOPCODER_ROLES);
3131
// updateTopcoderRolePermissions(RoleModel::TYPE_TOPCODER,RoleModel::TOPCODER_PROJECT_ROLES);
32+
33+
// FIX: https://github.com/topcoder-platform/forums/issues/218
34+
// Create a parent category for Groups if it doesn't exist
35+
// Make sure that the UrlCode is unique among categories.
36+
$GroupCategoryExists = Gdn::sql()->select('CategoryID')
37+
->from('Category')
38+
->where('UrlCode', 'groups')
39+
->get()->numRows();
40+
if($GroupCategoryExists == 0) {
41+
$data = [
42+
'Name' => 'Groups',
43+
'UrlCode' => 'groups',
44+
'DisplayAs' => 'categories',
45+
'ParentCategoryID' => -1,
46+
'AllowDiscussions'=> 0,
47+
];
48+
$date = Gdn_Format::toDateTime();
49+
$CategoryModel = CategoryModel::instance();
50+
Gdn::sql()->insert('Category', ['ParentCategoryID' => -1, 'TreeLeft' => 2, 'TreeRight' => 3, 'Depth' => 1, 'InsertUserID' => 1,
51+
'UpdateUserID' => 1, 'DateInserted' => $date, 'DateUpdated' => $date,
52+
'Name' => 'Groups', 'UrlCode' => 'groups', 'Description' => '', 'PermissionCategoryID' => -1, 'DisplayAs' => 'Categories',
53+
'LastDiscussionCommentsDate' => $date]);
54+
$CategoryModel->rebuildTree();
55+
$CategoryModel->recalculateTree();
56+
unset($CategoryModel);
57+
}
3258
}

0 commit comments

Comments
 (0)