* for the specific language governing rights and limitations under the * License. * * The Original Code is: CalemEAM Open Source * * The Initial Developer of the Original Code is CalemEAM Inc. * Portions created by CalemEAM are Copyright (C) 2007 CalemEAM Inc.; * All Rights Reserved. * Contributor(s): */ /** * To run Calem test one must set up the following: * - _CALEM_DIR_ * - _CALEM_DIR_ . 'config/calem.php' is included already. */ /** * Must define _CALEM_DIR_ and _LOG4PHP_CONFIGURATION * */ if (!defined('_CALEM_DIR_')) { chdir('../..'); define('_CALEM_DIR_', getcwd() . '/'); define('LOG4PHP_CONFIGURATION', _CALEM_DIR_ . 'etc/log4php.properties'); } require_once _CALEM_DIR_ . 'server/setup/CalemLoadSampleData.php'; //Starting off loading sample data. echo date("F j, Y, g:i:s a") . " - Loading sample data...<br>\n"; $loader = new CalemLoadSampleData(); $result = $loader->load(); echo $result . "<br>\n"; echo date("F j, Y, g:i:s a") . " - DONE<br>\n";
public function validateInput() { $this->setLoadSample($_REQUEST['fi_load_sample']); $this->setUpgrade($_REQUEST['fi_upgrade']); $this->setVerifyDb($_REQUEST['fi_verifydb']); //Allow sufficient time set_time_limit(0); //Now creating DB first $rtn = true; try { /** * Creating database tables first */ require_once _CALEM_DIR_ . 'server/include/core/database/CalemDbSetup.php'; $dbSetup = new CalemDbSetup(); $dbHandler = CalemFactory::getDbHandler(); $conn = $dbHandler->getCalemConnection(); $dbSetup->setupSchema($dbHandler, $conn); //Verify db setup if ($this->getVerifyDb()) { $dbSetup->validate(); } //What about upgrade if ($this->upgradeHdlr) { $GLOBALS['logger']->debug('DbSetupModel: doing an upgrade; hdlr=' . get_class($this->upgradeHdlr)); $results = $this->upgradeHdlr->upgrade(); $GLOBALS['logger']->info("upgrade results: " . var_export($results, true)); } //Load Init data require_once _CALEM_DIR_ . 'server/setup/CalemLoadInitData.php'; $loader = new CalemLoadInitData(); $loader->load(); //Load sample data if set if ($this->getLoadSample()) { require_once _CALEM_DIR_ . 'server/setup/CalemLoadSampleData.php'; $loader = new CalemLoadSampleData(); $loader->load(); } } catch (Exception $e) { $msg = $this->calemLang->getMsg('db_conf_exception') . " <br /> " . $e->getMessage(); $GLOBALS['logger']->error("Error at CalemInstDbSetupController.validateInput: " . $e->getMessage()); $this->setErrorMsg($msg); $rtn = false; } return $rtn; }
public function validateInput() { $this->setDbType($_REQUEST['fi_dbtype']); $this->setDbHost($_REQUEST['fi_dbhost']); $this->setAdminUser($_REQUEST['fi_admin_user']); $this->setAdminPassword($_REQUEST['fi_admin_password']); $this->setDbHost($_REQUEST['fi_dbhost']); $this->setUsername($_REQUEST['fi_username']); $this->setPassword($_REQUEST['fi_password']); $this->setDbName($_REQUEST['fi_dbname']); $this->setLoadSample($_REQUEST['fi_load_sample']); //Now validate the info to see if we can load it. $rtn = $this->getDbType() && $this->getDbHost() && $this->getUsername() && $this->getDbName() && $this->getAdminUser(); if (!$rtn) { $this->setErrorMsg($this->calemLang->getMsg('db_info_required')); return false; } //Allow sufficient time set_time_limit(0); //Start DB setup $rtn = true; try { //Connecting as Admin first $this->controller->setupDbAdminInfo(); $dbHandler = CalemFactory::getDbHandler(); $conn = $dbHandler->getDatabaseAdminConnection(); //Get database setup class. require_once _CALEM_DIR_ . 'server/include/core/database/CalemDbSetup.php'; $dbSetup = new CalemDbSetup(); //Prepare db info for setup. $this->controller->setupDbInfo(); /** * First let's create user and database */ $dbSetup->setupDatabaseAndUser($dbHandler, $conn); //Release the connection for admin $dbHandler->releaseDatabaseAdminConnection(); /** * Next, creating database tables first */ $conn = $dbHandler->getCalemConnection(); $dbSetup->setupSchema($dbHandler, $conn); $dbSetup->validate(); //Upgrade if applicable $upgradeHdlr = $this->getUpgradeHdlr(); if ($upgradeHdlr) { $GLOBALS['logger']->debug('DbExpressSetupModel: doing an upgrade; hdlr=' . get_class($upgradeHdlr)); $upgradeHdlr->upgrade(); } //Load Init data require_once _CALEM_DIR_ . 'server/setup/CalemLoadInitData.php'; $loader = new CalemLoadInitData(); $loader->load(); //Load sample data if set if ($this->getLoadSample()) { require_once _CALEM_DIR_ . 'server/setup/CalemLoadSampleData.php'; $loader = new CalemLoadSampleData(); $loader->load(); } } catch (Exception $e) { $msg = $this->calemLang->getMsg('db_conf_exception') . " <br /> " . $e->getMessage(); $GLOBALS['logger']->error("Error at CalemInstDbSetupController.validateInput: " . $e->getMessage()); $this->setErrorMsg($msg); $rtn = false; } return $rtn; }