Skip to content
This repository has been archived by the owner on Apr 24, 2024. It is now read-only.

Commit

Permalink
Fix issue with saving notification settings, remove support for upgra…
Browse files Browse the repository at this point in the history
…ding from 3.2
  • Loading branch information
zegenie committed Dec 8, 2016
1 parent 55fe1d2 commit 81bd311
Show file tree
Hide file tree
Showing 7 changed files with 114 additions and 233 deletions.
2 changes: 1 addition & 1 deletion core/entities/NotificationSetting.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class NotificationSetting extends Identifiable
* The setting name
*
* @var string
* @Column(type="string", length=50)
* @Column(type="string", length=255)
*/
protected $_name;

Expand Down
2 changes: 1 addition & 1 deletion core/entities/tables/NotificationSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@
class NotificationSettings extends ScopedTable
{

const B2DB_TABLE_VERSION = 1;
const B2DB_TABLE_VERSION = 2;

}
4 changes: 2 additions & 2 deletions core/framework/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ final class Settings

protected static $_ver_mj = 4;
protected static $_ver_mn = 1;
protected static $_ver_rev = 9;
protected static $_ver_name = "Abstract Apricot";
protected static $_ver_rev = 10;
protected static $_ver_name = "Blissful Banana";
protected static $_defaultscope = null;
protected static $_settings = null;

Expand Down
16 changes: 16 additions & 0 deletions core/modules/installation/Upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,20 @@ protected function _upgradeFrom4dot1dot7()
}
}

protected function _upgradeFrom4dot1dot9()
{
set_time_limit(0);

\thebuggenie\core\entities\tables\NotificationSettings::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_419\NotificationSetting::getB2DBTable());

$this->upgrade_complete = true;
$this->current_version = '4.1.10';

if (defined('TBG_CLI')) {
framework\cli\Command::cli_echo("Successfully upgraded to version {$this->current_version}\n");
}
}

public function upgrade()
{
list ($this->current_version, $this->upgrade_available) = framework\Settings::getUpgradeStatus();
Expand Down Expand Up @@ -159,6 +173,8 @@ public function upgrade()
$this->_upgradeFrom4dot1dot6();
case '4.1.7':
$this->_upgradeFrom4dot1dot7();
case '4.1.9':
$this->_upgradeFrom4dot1dot9();
default:
$this->upgrade_complete = true;
break;
Expand Down
231 changes: 2 additions & 229 deletions core/modules/installation/controllers/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -458,245 +458,18 @@ public function runInstallStep6(framework\Request $request)
framework\Context::clearRoutingCache();
}

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;
$this->current_version = '4.1.0';
}

protected function _upgradeFrom4dot1(framework\Request $request)
{
set_time_limit(0);

\thebuggenie\core\entities\tables\Milestones::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_41\Milestone::getB2DBTable());

$this->upgrade_complete = true;
$this->current_version = '4.1.1';
}

protected function _upgradeFrom4dot1dot1(framework\Request $request)
{
set_time_limit(0);

\thebuggenie\core\modules\installation\upgrade_415\Issue::getB2DBTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_411\Issue::getB2DBTable());
\thebuggenie\core\modules\installation\upgrade_416\Project::getB2DBTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_411\Project::getB2DBTable());

$this->upgrade_complete = true;
$this->current_version = '4.1.2';
}

protected function _upgradeFrom4dot1dot2(framework\Request $request)
{
set_time_limit(0);

\thebuggenie\modules\mailing\entities\tables\MailQueueTable::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_412\MailQueueTable::getTable());

$this->upgrade_complete = true;
$this->current_version = '4.1.3';
}

protected function _upgradeFrom4dot1dot3(framework\Request $request)
{
set_time_limit(0);

\thebuggenie\modules\agile\entities\tables\AgileBoards::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_413\AgileBoard::getB2DBTable());

$this->upgrade_complete = true;
$this->current_version = '4.1.4';
}

protected function _upgradeFrom4dot1dot4(framework\Request $request)
{
set_time_limit(0);

\thebuggenie\core\entities\tables\Files::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_414\File::getB2DBTable());

$this->upgrade_complete = true;
$this->current_version = '4.1.5';
}

protected function _upgradeFrom4dot1dot5(framework\Request $request)
{
set_time_limit(0);

\thebuggenie\core\entities\tables\Issues::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_415\Issue::getB2DBTable());
\thebuggenie\core\entities\tables\IssueSpentTimes::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_415\IssueSpentTime::getB2DBTable());
\thebuggenie\core\entities\tables\IssueEstimates::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_415\IssueEstimatesTable::getTable());

$this->upgrade_complete = true;
$this->current_version = '4.1.6';
}

protected function _upgradeFrom4dot1dot6(framework\Request $request)
{
set_time_limit(0);

\thebuggenie\core\entities\tables\Projects::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_416\Project::getB2DBTable());

$this->upgrade_complete = true;
$this->current_version = '4.1.7';
}

protected function _upgradeFrom4dot1dot7(framework\Request $request)
{
set_time_limit(0);

\thebuggenie\core\entities\tables\Notifications::getTable()->upgrade(\thebuggenie\core\modules\installation\upgrade_417\Notification::getB2DBTable());

$this->upgrade_complete = true;
$this->current_version = '4.1.8';
}

public function runUpgrade(framework\Request $request)
{
list ($this->current_version, $this->upgrade_available) = framework\Settings::getUpgradeStatus();

if ($this->upgrade_available)
{
$scope = new \thebuggenie\core\entities\Scope();
$scope->setID(1);
$scope->setEnabled();
framework\Context::setScope($scope);

if (in_array($this->current_version, array('3.2.0', '3.2'))) {
$this->statuses = \thebuggenie\core\entities\tables\ListTypes::getTable()->getStatusListForUpgrade();
$this->adminusername = \thebuggenie\core\modules\installation\upgrade_32\TBGUsersTable::getTable()->getAdminUsername();
}
}
$this->upgrade_complete = false;

if ($this->upgrade_available && $request->isPost())
{
$this->upgrade_complete = false;

switch ($this->current_version) {
case '3.2.0':
case '3.2':
$this->_upgradeFrom3dot2($request);
case '4.0':
case '4.1':
case '4.1.0':
$this->_upgradeFrom4dot1($request);
case '4.1.1':
$this->_upgradeFrom4dot1dot1($request);
case '4.1.2':
$this->_upgradeFrom4dot1dot2($request);
case '4.1.3':
$this->_upgradeFrom4dot1dot3($request);
case '4.1.4':
$this->_upgradeFrom4dot1dot4($request);
case '4.1.5':
$this->_upgradeFrom4dot1dot5($request);
case '4.1.6':
$this->_upgradeFrom4dot1dot6($request);
case '4.1.7':
$this->_upgradeFrom4dot1dot7($request);
default:
$this->upgrade_complete = true;
break;
}
$upgrader = new \thebuggenie\core\modules\installation\Upgrade();
$this->upgrade_complete = $upgrader->upgrade();

if ($this->upgrade_complete)
{
$existing_installed_content = file_get_contents(THEBUGGENIE_PATH . 'installed');
file_put_contents(THEBUGGENIE_PATH . 'installed', framework\Settings::getVersion(false, true) . ', upgraded ' . date('d.m.Y H:i') . "\n" . $existing_installed_content);
$this->current_version = framework\Settings::getVersion(false, false);
$this->upgrade_available = false;
}
Expand Down
61 changes: 61 additions & 0 deletions core/modules/installation/upgrade_419/NotificationSetting.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php

namespace thebuggenie\core\modules\installation\upgrade_419;

use thebuggenie\core\entities\common\Identifiable;

/**
* Notification setting class
*
* @author Daniel Andre Eikeland <zegenie@zegeniestudios.net>
* @version 3.3
* @license http://opensource.org/licenses/MPL-2.0 Mozilla Public License 2.0 (MPL 2.0)
* @package thebuggenie
* @subpackage main
*/

/**
* Notification setting class
*
* @package thebuggenie
* @subpackage main
*
* @Table(name="\thebuggenie\core\modules\installation\upgrade_419\NotificationSettingsTable")
*/
class NotificationSetting extends Identifiable
{

/**
* The module name
*
* @var string
* @Column(type="string", length=50)
*/
protected $_module_name;

/**
* The setting name
*
* @var string
* @Column(type="string", length=50)
*/
protected $_name;

/**
* Setting value
*
* @var string
* @Column(type="string", length=100)
*/
protected $_value = '';

/**
* Who the notification is for
*
* @var \thebuggenie\core\entities\User
* @Column(type="integer", length=10)
* @Relates(class="\thebuggenie\core\entities\User")
*/
protected $_user_id;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace thebuggenie\core\modules\installation\upgrade_419;

use thebuggenie\core\entities\tables\ScopedTable;

/**
* User notification settings table
*
* @author Daniel Andre Eikeland <zegenie@zegeniestudios.net>
* @version 3.3
* @license http://opensource.org/licenses/MPL-2.0 Mozilla Public License 2.0 (MPL 2.0)
* @package thebuggenie
* @subpackage tables
*/

/**
* User notification settings table
*
* @package thebuggenie
* @subpackage tables
*
* @Table(name="notificationsettings")
* @Entity(class="\thebuggenie\core\modules\installation\upgrade_419\NotificationSetting")
*/
class NotificationSettingsTable extends ScopedTable
{

const B2DB_TABLE_VERSION = 1;

}

0 comments on commit 81bd311

Please sign in to comment.