diff --git a/core/lib/Thelia/Core/Thelia.php b/core/lib/Thelia/Core/Thelia.php index b446af221..dbfe48e17 100755 --- a/core/lib/Thelia/Core/Thelia.php +++ b/core/lib/Thelia/Core/Thelia.php @@ -69,29 +69,22 @@ class Thelia extends Kernel protected function initPropel() { - if (defined('THELIA_INSTALL_MODE') === true) { - $serviceContainer = Propel::getServiceContainer(); - $serviceContainer->setAdapterClass('thelia', 'sqlite'); - $manager = new ConnectionManagerSingle(); - $manager->setConfiguration(array( - "classname" => "\Propel\Runtime\Connection\PropelPDO", - "dsn" => "sqlite:".THELIA_ROOT . "/install/thelia.sqlite" - )); - $serviceContainer->setConnectionManager('thelia', $manager); - } else { - $definePropel = new DefinePropel(new DatabaseConfiguration(), - Yaml::parse(THELIA_ROOT . '/local/config/database.yml')); - $serviceContainer = Propel::getServiceContainer(); - $serviceContainer->setAdapterClass('thelia', 'mysql'); - $manager = new ConnectionManagerSingle(); - $manager->setConfiguration($definePropel->getConfig()); - $serviceContainer->setConnectionManager('thelia', $manager); - $con = Propel::getConnection(\Thelia\Model\Map\ProductTableMap::DATABASE_NAME); - $con->setAttribute(ConnectionWrapper::PROPEL_ATTR_CACHE_PREPARES, true); - if ($this->isDebug()) { - $serviceContainer->setLogger('defaultLogger', \Thelia\Log\Tlog::getInstance()); - $con->useDebug(true); - } + if (file_exists(THELIA_ROOT . '/local/config/database.yml') === false) { + return ; + } + + $definePropel = new DefinePropel(new DatabaseConfiguration(), + Yaml::parse(THELIA_ROOT . '/local/config/database.yml')); + $serviceContainer = Propel::getServiceContainer(); + $serviceContainer->setAdapterClass('thelia', 'mysql'); + $manager = new ConnectionManagerSingle(); + $manager->setConfiguration($definePropel->getConfig()); + $serviceContainer->setConnectionManager('thelia', $manager); + $con = Propel::getConnection(\Thelia\Model\Map\ProductTableMap::DATABASE_NAME); + $con->setAttribute(ConnectionWrapper::PROPEL_ATTR_CACHE_PREPARES, true); + if ($this->isDebug()) { + $serviceContainer->setLogger('defaultLogger', \Thelia\Log\Tlog::getInstance()); + $con->useDebug(true); } diff --git a/core/lib/Thelia/Install/Database.php b/core/lib/Thelia/Install/Database.php index 34ca97dae..648a6431a 100644 --- a/core/lib/Thelia/Install/Database.php +++ b/core/lib/Thelia/Install/Database.php @@ -93,7 +93,7 @@ class Database */ public function createDatabase($dbName) { - $this->connection->query( + $this->connection->exec( sprintf( "CREATE DATABASE IF NOT EXISTS %s CHARACTER SET utf8", $dbName diff --git a/core/lib/Thelia/Model/Admin.php b/core/lib/Thelia/Model/Admin.php index 67f6a5928..2712eb95c 100755 --- a/core/lib/Thelia/Model/Admin.php +++ b/core/lib/Thelia/Model/Admin.php @@ -34,8 +34,6 @@ class Admin extends BaseAdmin implements UserInterface public function setPassword($password) { - \Thelia\Log\Tlog::getInstance()->debug($password); - if ($this->isNew() && ($password === null || trim($password) == "")) { throw new \InvalidArgumentException("customer password is mandatory on creation"); } diff --git a/install/thelia.sqlite b/install/thelia.sqlite deleted file mode 100644 index 65d4cb6a9..000000000 Binary files a/install/thelia.sqlite and /dev/null differ diff --git a/web/install/config.php b/web/install/config.php index 249f7c033..9ba221cdd 100644 --- a/web/install/config.php +++ b/web/install/config.php @@ -21,12 +21,12 @@ /* */ /*************************************************************************************/ -$step = 4; +$step = 5; include("header.php"); global $thelia; $err = isset($_GET['err']) && $_GET['err']; -if (!$err) { +if (!$err && $_SESSION['install']['step'] != $step) { $checkConnection = new \Thelia\Install\CheckDatabaseConnection($_SESSION['install']['host'], $_SESSION['install']['username'], $_SESSION['install']['password'], $_SESSION['install']['port']); $connection = $checkConnection->getConnection(); $connection->exec("SET NAMES UTF8"); @@ -41,10 +41,6 @@ if (!$err) { $database->createDatabase($_SESSION['install']['database']); } - if (!$connection->exec(sprintf('use %s', $_SESSION['install']['database']))) { - header('location: bdd.php?err=1'); - } - $database->insertSql($_SESSION['install']['database']); if(!file_exists(THELIA_ROOT . "/local/config/database.yml")) { @@ -75,6 +71,8 @@ if (!$err) { } } +$_SESSION['install']['step'] = $step; + ?>
+ + diff --git a/web/install/end.php b/web/install/end.php new file mode 100644 index 000000000..a86c2d903 --- /dev/null +++ b/web/install/end.php @@ -0,0 +1,57 @@ +. */ +/* */ +/*************************************************************************************/ +$step=6; +include "header.php"; + +if($_SESSION['install']['step'] != $step && (empty($_POST['admin_login']) || empty($_POST['admin_password']) || ($_POST['admin_password'] != $_POST['admin_password_verif']))) { + header('location: config.php?err=1'); +} + +if($_SESSION['install']['step'] == 5) { + $admin = new \Thelia\Model\Admin(); + $admin->setLogin($_POST['admin_login']) + ->setPassword($_POST['admin_password']) + ->setFirstname('admin') + ->setLastname('admin') + ->save(); + + $config = new \Thelia\Model\Config(); + $config->setName('contact_email') + ->setValue($_POST['email_contact']) + ->save(); + ; +} + +$_SESSION['install']['step'] = $step; +?> + ++ Thank you have installed Thelia +
++ Don't forget to delete the web/install directory. +
+ +