protected function _upgrade()
 {
     switch ($this->_version) {
         case '2.0':
             $table = Settings::getTable();
             $crit = $table->getCriteria();
             $ctn = $crit->returnCriterion(Settings::NAME, 'diff_url_%', Criteria::DB_LIKE);
             $ctn->addOr(Settings::NAME, 'log_url_%', Criteria::DB_LIKE);
             $ctn->addOr(Settings::NAME, 'blob_url_%', Criteria::DB_LIKE);
             $ctn->addOr(Settings::NAME, 'commit_url_%', Criteria::DB_LIKE);
             $crit->addWhere($ctn);
             $crit->addWhere(Settings::MODULE, 'vcs_integration');
             $urls = $table->doSelect($crit);
             if ($urls) {
                 while ($url = $urls->getNextRow()) {
                     $value = str_replace(array('%revno%', '%oldrev%', '%file%'), array('%revno', '%oldrev', '%file'), $url[Settings::VALUE]);
                     $crit = $table->getCriteria();
                     $crit->addUpdate(Settings::VALUE, $value);
                     $table->doUpdateById($crit, $url[Settings::ID]);
                 }
             }
     }
 }
Esempio n. 2
0
 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;
 }
Esempio n. 3
0
 protected function _upgrade()
 {
     switch ($this->_version) {
         case '1.0':
             IncomingEmailAccount::getB2DBTable()->upgrade(\thebuggenie\modules\mailing\upgrade_32\TBGIncomingEmailAccountTable::getTable());
             Settings::getTable()->deleteAllUserModuleSettings('mailing');
             break;
     }
 }
Esempio n. 4
0
 public function getUnattachedFiles()
 {
     $crit = $this->getCriteria();
     $crit->addSelectionColumn(self::ID, 'id');
     $res = $this->doSelect($crit);
     $file_ids = [];
     if ($res) {
         while ($row = $res->getNextRow()) {
             $file_ids[$row['id']] = $row['id'];
         }
     }
     $file_ids = array_diff($file_ids, IssueFiles::getTable()->getLinkedFileIds($file_ids));
     $event = framework\Event::createNew('core', 'thebuggenie\\core\\entities\\tables\\Files::getUnattachedFiles', $this, ['file_ids' => $file_ids], []);
     $event->trigger();
     if ($event->isProcessed()) {
         foreach ($event->getReturnList() as $linked_file_ids) {
             $file_ids = array_diff($file_ids, $linked_file_ids);
         }
     }
     $system_file_ids = Settings::getTable()->getFileIds();
     $file_ids = array_diff($file_ids, $system_file_ids);
     $project_file_ids = Projects::getTable()->getFileIds();
     $file_ids = array_diff($file_ids, $project_file_ids);
     return $file_ids;
 }
Esempio n. 5
0
 private static function _loadSetting($name, $module = 'core', $scope = 0)
 {
     $crit = new \b2db\Criteria();
     $crit->addWhere(tables\Settings::NAME, $name);
     $crit->addWhere(tables\Settings::MODULE, $module);
     if ($scope == 0) {
         throw new \Exception('The Bug Genie has not been correctly installed. Please check that the default scope exists');
     }
     $crit->addWhere(tables\Settings::SCOPE, $scope);
     $res = tables\Settings::getTable()->doSelect($crit);
     if ($res) {
         $retarr = array();
         while ($row = $res->getNextRow()) {
             $retarr[$row->get(tables\Settings::UID)] = $row->get(tables\Settings::VALUE);
         }
         return $retarr;
     } else {
         return null;
     }
 }
Esempio n. 6
0
 public function loadFixtures()
 {
     // Load initial settings
     tables\Settings::getTable()->loadFixtures($this);
     \thebuggenie\core\framework\Settings::loadSettings();
     // Load group, users and permissions fixtures
     Group::loadFixtures($this);
     // Load initial teams
     Team::loadFixtures($this);
     // Set up user states, like "available", "away", etc
     Userstate::loadFixtures($this);
     // Set up data types
     list($b_id, $f_id, $e_id, $t_id, $u_id, $i_id, $ep_id) = Issuetype::loadFixtures($this);
     $scheme = IssuetypeScheme::loadFixtures($this);
     tables\IssueFields::getTable()->loadFixtures($this, $scheme, $b_id, $f_id, $e_id, $t_id, $u_id, $i_id, $ep_id);
     Datatype::loadFixtures($this);
     // Set up workflows
     Workflow::loadFixtures($this);
     WorkflowScheme::loadFixtures($this);
     tables\WorkflowIssuetype::getTable()->loadFixtures($this);
     // Set up left menu links
     tables\Links::getTable()->loadFixtures($this);
 }
 public function upgradeFrom3dot1()
 {
     $wcrit = Settings::getTable()->getCriteria();
     $wcrit->addWhere(Settings::NAME, \thebuggenie\core\framework\Settings::SETTING_DEFAULT_WORKFLOW);
     $workflows = array();
     if ($res = Settings::getTable()->doSelect($wcrit)) {
         while ($row = $res->getNextRow()) {
             $workflow_id = (int) $row->get(Settings::VALUE);
             $workflows[$workflow_id] = $workflow_id;
         }
     }
     if (count($workflows)) {
         $crit = $this->getCriteria();
         $crit->addWhere(self::NAME, '%reject%', \b2db\Criteria::DB_LIKE);
         $crit->addWhere(self::WORKFLOW_ID, $workflows, \b2db\Criteria::DB_IN);
         $crit->addUpdate(self::TEMPLATE, 'main/updateissueproperties');
         $this->doUpdate($crit);
     }
 }