Added Airtime255 class in Upgrades
This commit is contained in:
parent
5e18e1881f
commit
5af735654c
|
@ -16,6 +16,7 @@ class UpgradeController extends Zend_Controller_Action
|
|||
$upgraders = array();
|
||||
array_push($upgraders, new AirtimeUpgrader253());
|
||||
array_push($upgraders, new AirtimeUpgrader254());
|
||||
array_push($upgraders, new AirtimeUpgrader255());
|
||||
|
||||
$didWePerformAnUpgrade = false;
|
||||
try
|
||||
|
|
|
@ -225,48 +225,23 @@ class AirtimeUpgrader255 extends AirtimeUpgrader {
|
|||
|
||||
$newVersion = $this->getNewVersion();
|
||||
|
||||
$con = Propel::getConnection ();
|
||||
// $con->beginTransaction();
|
||||
try {
|
||||
$this->toggleMaintenanceScreen(true);
|
||||
Cache::clear();
|
||||
|
||||
// Begin upgrade
|
||||
$airtimeConf = isset($_SERVER['AIRTIME_CONF']) ? $_SERVER['AIRTIME_CONF'] : "/etc/airtime/airtime.conf";
|
||||
$values = parse_ini_file($airtimeConf, true);
|
||||
|
||||
// First, ensure there are no superadmins already.
|
||||
$numberOfSuperAdmins = CcSubjsQuery::create ()->filterByDbType ( UTYPE_SUPERADMIN )->filterByDbLogin ( "sourcefabric_admin", Criteria::NOT_EQUAL )-> // Ignore sourcefabric_admin users
|
||||
count ();
|
||||
$username = $values['database']['dbuser'];
|
||||
$password = $values['database']['dbpass'];
|
||||
$host = $values['database']['host'];
|
||||
$database = $values['database']['dbname'];
|
||||
$dir = __DIR__;
|
||||
|
||||
// Only create a super admin if there isn't one already.
|
||||
if ($numberOfSuperAdmins == 0) {
|
||||
// Find the "admin" user and promote them to superadmin.
|
||||
$adminUser = CcSubjsQuery::create ()->filterByDbLogin ( 'admin' )->findOne ();
|
||||
if (! $adminUser) {
|
||||
// TODO: Otherwise get the user with the lowest ID that is of type administrator:
|
||||
//
|
||||
$adminUser = CcSubjsQuery::create ()->filterByDbType ( UTYPE_ADMIN )->orderByDbId ( Criteria::ASC )->findOne ();
|
||||
passthru("export PGPASSWORD=$password && psql -h $host -U $username -q -f $dir/upgrade_sql/airtime_"
|
||||
.$this->getNewVersion()."/upgrade.sql $database 2>&1 | grep -v \"will create implicit index\"");
|
||||
|
||||
if (! $adminUser) {
|
||||
throw new Exception ( "Failed to find any users of type 'admin' ('A')." );
|
||||
}
|
||||
}
|
||||
|
||||
$adminUser = new Application_Model_User ( $adminUser->getDbId () );
|
||||
$adminUser->setType ( UTYPE_SUPERADMIN );
|
||||
$adminUser->save ();
|
||||
Logging::info ( $_SERVER ['HTTP_HOST'] . ': ' . $newVersion . " Upgrade: Promoted user " . $adminUser->getLogin () . " to be a Super Admin." );
|
||||
|
||||
// Also try to promote the sourcefabric_admin user
|
||||
$sofabAdminUser = CcSubjsQuery::create ()->filterByDbLogin ( 'sourcefabric_admin' )->findOne ();
|
||||
if ($sofabAdminUser) {
|
||||
$sofabAdminUser = new Application_Model_User ( $sofabAdminUser->getDbId () );
|
||||
$sofabAdminUser->setType ( UTYPE_SUPERADMIN );
|
||||
$sofabAdminUser->save ();
|
||||
Logging::info ( $_SERVER ['HTTP_HOST'] . ': ' . $newVersion . " Upgrade: Promoted user " . $sofabAdminUser->getLogin () . " to be a Super Admin." );
|
||||
}
|
||||
}
|
||||
|
||||
// $con->commit();
|
||||
Application_Model_Preference::SetAirtimeVersion($newVersion);
|
||||
Cache::clear();
|
||||
|
||||
|
@ -274,7 +249,6 @@ class AirtimeUpgrader255 extends AirtimeUpgrader {
|
|||
|
||||
return true;
|
||||
} catch(Exception $e) {
|
||||
// $con->rollback();
|
||||
$this->toggleMaintenanceScreen(false);
|
||||
throw $e;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue