protected function _upgradeFrom3dot2(framework\Request $request) { set_time_limit(0); \thebuggenie\core\entities\tables\Milestones::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGMilestone::getB2DBTable()); \thebuggenie\core\entities\tables\Projects::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGProjectsTable::getTable()); \thebuggenie\core\entities\tables\Log::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGLogTable::getTable()); \thebuggenie\core\entities\tables\Users::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGUsersTable::getTable()); \thebuggenie\core\entities\tables\Issues::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGIssuesTable::getTable()); \thebuggenie\core\entities\tables\Workflows::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGWorkflowsTable::getTable()); \thebuggenie\core\entities\tables\IssueSpentTimes::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGIssueSpentTimesTable::getTable()); \thebuggenie\core\entities\tables\Comments::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGCommentsTable::getTable()); \thebuggenie\core\entities\tables\SavedSearches::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGSavedSearchesTable::getTable()); \thebuggenie\core\entities\tables\Settings::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGSettingsTable::getTable()); \thebuggenie\core\entities\tables\Notifications::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGNotificationsTable::getTable()); \thebuggenie\core\entities\tables\Permissions::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGPermissionsTable::getTable()); \thebuggenie\core\entities\Dashboard::getB2DBTable()->create(); \thebuggenie\core\entities\DashboardView::getB2DBTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_32\TBGDashboardViewsTable::getTable()); \thebuggenie\core\entities\ApplicationPassword::getB2DBTable()->create(); \thebuggenie\core\entities\NotificationSetting::getB2DBTable()->create(); $transaction = \b2db\Core::startTransaction(); // Upgrade user passwords switch ($request['upgrade_passwords']) { case 'manual': $password = $request['manual_password']; foreach (\thebuggenie\core\entities\tables\Users::getTable()->selectAll() as $user) { $user->setPassword($password); $user->save(); } break; case 'auto': $field = $request['upgrade_passwords_pick'] == 'username' ? 'username' : 'email'; foreach (\thebuggenie\core\entities\tables\Users::getTable()->selectAll() as $user) { if ($field == 'username' && trim($user->getUsername())) { $user->setPassword(trim($user->getUsername())); $user->save(); } elseif ($field == 'email' && trim($user->getEmail())) { $user->setPassword(trim($user->getEmail())); $user->save(); } } break; } $adminuser = \thebuggenie\core\entities\User::getB2DBTable()->selectById(1); $adminuser->setPassword($request['admin_password']); $adminuser->save(); // Add new settings framework\Settings::saveSetting(framework\Settings::SETTING_SERVER_TIMEZONE, 'core', date_default_timezone_get(), 0, 1); foreach ($request->getParameter('status') as $scope_id => $status_id) { $scope = \thebuggenie\core\entities\tables\Scopes::getTable()->selectById((int) $scope_id); if ($scope instanceof \thebuggenie\core\entities\Scope) { $epic = new \thebuggenie\core\entities\Issuetype(); $epic->setName('Epic'); $epic->setIcon('epic'); $epic->setDescription('Issue type suited for entering epics'); $epic->setScope($scope_id); $epic->save(); framework\Settings::saveSetting('issuetype_epic', $epic->getID(), 'core', $scope_id); foreach (\thebuggenie\core\entities\tables\Workflows::getTable()->getAll((int) $scope_id) as $workflow) { $transition = new \thebuggenie\core\entities\WorkflowTransition(); $steps = $workflow->getSteps(); $step = array_shift($steps); $step->setLinkedStatusID((int) $status_id); $step->save(); $transition->setOutgoingStep($step); $transition->setName('Issue created'); $transition->setWorkflow($workflow); $transition->setScope($scope); $transition->setDescription('This is the initial transition for issues using this workflow'); $transition->save(); $workflow->setInitialTransition($transition); $workflow->save(); } \thebuggenie\core\entities\ActivityType::loadFixtures($scope); } } $transaction->commitAndEnd(); framework\Context::finishUpgrading(); foreach (framework\Context::getModules() as $module) { $module->upgrade(); } $this->upgrade_complete = true; }
public static function loadFixtures(\thebuggenie\core\entities\Scope $scope) { $scope_id = $scope->getID(); $bug_report = new \thebuggenie\core\entities\Issuetype(); $bug_report->setName('Bug report'); $bug_report->setIcon('bug_report'); $bug_report->setScope($scope_id); $bug_report->setDescription('Have you discovered a bug in the application, or is something not working as expected?'); $bug_report->save(); \thebuggenie\core\framework\Settings::saveSetting('defaultissuetypefornewissues', $bug_report->getID(), 'core', $scope_id); \thebuggenie\core\framework\Settings::saveSetting('issuetype_bug_report', $bug_report->getID(), 'core', $scope_id); $feature_request = new \thebuggenie\core\entities\Issuetype(); $feature_request->setName('Feature request'); $feature_request->setIcon('feature_request'); $feature_request->setDescription('Are you missing some specific feature, or is your favourite part of the application a bit lacking?'); $feature_request->setScope($scope_id); $feature_request->save(); \thebuggenie\core\framework\Settings::saveSetting('issuetype_feature_request', $feature_request->getID(), 'core', $scope_id); $enhancement = new \thebuggenie\core\entities\Issuetype(); $enhancement->setName('Enhancement'); $enhancement->setIcon('enhancement'); $enhancement->setDescription('Have you found something that is working in a way that could be improved?'); $enhancement->setScope($scope_id); $enhancement->save(); \thebuggenie\core\framework\Settings::saveSetting('issuetype_enhancement', $enhancement->getID(), 'core', $scope_id); $task = new \thebuggenie\core\entities\Issuetype(); $task->setName('Task'); $task->setIcon('task'); $task->setIsTask(); $task->setScope($scope_id); $task->save(); \thebuggenie\core\framework\Settings::saveSetting('issuetype_task', $task->getID(), 'core', $scope_id); $user_story = new \thebuggenie\core\entities\Issuetype(); $user_story->setName('User story'); $user_story->setIcon('developer_report'); $user_story->setDescription('Doing it Agile-style. Issue type perfectly suited for entering user stories'); $user_story->setScope($scope_id); $user_story->save(); \thebuggenie\core\framework\Settings::saveSetting('issuetype_user_story', $user_story->getID(), 'core', $scope_id); $epic = new \thebuggenie\core\entities\Issuetype(); $epic->setName('Epic'); $epic->setIcon('epic'); $epic->setDescription('Issue type suited for entering epics'); $epic->setScope($scope_id); $epic->save(); \thebuggenie\core\framework\Settings::saveSetting('issuetype_epic', $epic->getID(), 'core', $scope_id); $idea = new \thebuggenie\core\entities\Issuetype(); $idea->setName('Idea'); $idea->setIcon('idea'); $idea->setDescription('Express yourself - share your ideas with the rest of the team!'); $idea->setScope($scope_id); $idea->save(); \thebuggenie\core\framework\Settings::saveSetting('issuetype_idea', $idea->getID(), 'core', $scope_id); return array($bug_report->getID(), $feature_request->getID(), $enhancement->getID(), $task->getID(), $user_story->getID(), $idea->getID(), $epic->getID()); }