|
29 | 29 | // Check all roles in the env and update all role permissions in RoleModel |
30 | 30 | // updateRolePermissions(RoleModel::TYPE_TOPCODER, RoleModel::TOPCODER_ROLES); |
31 | 31 | // 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 | + } |
32 | 58 | } |
0 commit comments