public function indexAction() { $migration = new Doctrine_Migration(); $this->view->databaseCurrent = Install_Api_Migration::getInstance()->getCurrentVersion(); $this->view->databaseLatest = Install_Api_Migration::getInstance()->getLatestVersion(); $this->view->databaseUpdateNeeded = false; $t = Doctrine::getTable('User_Model_User'); try { $t->count(); $this->view->databaseInitNeeded = false; } catch (Doctrine_Exception $e) { $this->view->databaseInitNeeded = true; } if (!$this->view->databaseInitNeeded && $this->view->databaseCurrent < $this->view->databaseLatest) { $this->view->databaseUpdateNeeded = true; } $status = new stdClass(); if (is_writable(realpath(APPLICATION_PATH . '/data/cache'))) { $status->cache = true; } if (is_writable(realpath(APPLICATION_PATH . '/data/sessions'))) { $status->sessions = true; } if (is_writable(realpath(realpath(getenv('PHP_SELF')) . '/media/common/images/tmp'))) { $status->captcha = true; } if (is_writable(realpath(realpath(getenv('PHP_SELF')) . '/upload'))) { $status->upload = true; } if (is_writable(realpath(APPLICATION_PATH . '/resource/static'))) { $status->resourceStatic = true; } $this->view->requirements = $status; }
/** * check if the cms is already installed or needs update and redirect to installer in one of these cases * @see Zend_Controller_Plugin_Abstract::preDispatch() */ public function preDispatch(Zend_Controller_Request_Abstract $request) { if ($this->getRequest()->getModuleName() == 'install' || $this->getRequest()->getModuleName() == 'devtools') { # we don't need to check while we are in the installer itself return; } # check whether the cms is installed or not $t = Doctrine::getTable('User_Model_User'); try { $t->count(); $installed = true; } catch (Doctrine_Exception $e) { $installed = false; } $redirect = new Zend_Controller_Action_Helper_Redirector(); if ($installed) { # check if update is needed $mig = Install_Api_Migration::getInstance(); if ($mig->getCurrentVersion() < $mig->getLatestVersion()) { # update needed $redirect->gotoSimple('index', 'index', 'install'); } } else { $redirect->gotoSimple('index', 'index', 'install'); } }
public function indexAction() { $t = Doctrine::getTable('User_Model_User'); try { $t->count(); $this->_helper->redirector->gotoSimple('createuser', 'install', 'install'); } catch (Doctrine_Exception $e) { $this->view->form = new FansubCMS_Form_Confirmation(); if ($this->request->isPost()) { $submit = $this->request->getParam('yes'); if (!empty($submit)) { Install_Api_DoctrineTool::getInstance()->createTablesFromArray(); Install_Api_Migration::getInstance()->setCurrentVersion(Install_Api_Migration::getInstance()->getLatestVersion()); // we are on the top atm $this->_helper->redirector->gotoSimple('createuser', 'install', 'install'); } else { $this->_helper->redirector->gotoSimple('index', 'index', 'install'); } } } }
public function migrateAction() { if (Install_Api_Migration::getInstance()->getCurrentVersion() >= Install_Api_Migration::getInstance()->getLatestVersion()) { // nothing to migrate $this->_helper->redirector->gotoSimple('index', 'index', 'install'); return; } $this->view->form = new FansubCMS_Form_Confirmation(); if ($this->request->isPost()) { $submit = $this->request->getParam('yes'); if (!empty($submit)) { try { $success = Install_Api_Migration::getInstance()->migrate(); } catch (Doctrine_Migration_Exception $e) { if (!headers_sent()) { header('Content-Type: text/plain'); } echo "The migration has failed. Please provide the info below if filing in a bug report.\n\n"; echo "Error information:\n"; echo $e->getMessage() . "(Code " . $e->getCode() . ")\n"; echo "File: " . $e->getFile() . ", Line: " . $e->getLine() . "\n\n"; echo "Trace:\n"; echo $e->getTraceAsString(); echo "\n\n"; echo "Extended Trace:\n"; print_r($e->getTrace()); die; } if ($success) { $this->_helper->redirector->gotoSimple('index', 'index', 'install'); } else { $this->view->error = $this->translate('install_migrate_error_in_migrate_run'); } } else { $this->_helper->redirector->gotoSimple('index', 'index', 'install'); } } }
public function testDatabase() { // first migrate database if needed if (Install_Api_Migration::getInstance()->getCurrentVersion() < Install_Api_Migration::getInstance()->getLatestVersion()) { Install_Api_Migration::getInstance()->migrate(); } $api = new Devtools_Api_DoctrineTool(); // truncate all tables or import data if there is some $api->importFixtures(APPLICATION_PATH . '/resource/fixtures'); // create an admin user for unit testing $user = new User_Model_User(); $user->name = 'PHPUnit'; $user->password = '******'; $user->email = '*****@*****.**'; $user->description = 'PHPUnit Testuser'; $user->activated = 'yes'; $user->active = 'no'; $user->show_team = 'no'; $user->save(); $role = new User_Model_Role(); $role->link('User_Model_User', array($user->id)); $role->role_name = 'admin_admin'; $role->save(); }