From 072dec5cc93b010beedf91b13052f7a2ccc0e84c Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Tue, 17 Sep 2013 15:43:15 +0200 Subject: [PATCH] nstall step Please enter the commit message for your changes. Lines starting --- core/lib/Thelia/Core/Thelia.php | 39 ++++++++---------- core/lib/Thelia/Install/Database.php | 2 +- core/lib/Thelia/Model/Admin.php | 2 - install/thelia.sqlite | Bin 262144 -> 0 bytes web/install/config.php | 22 +++++------ web/install/end.php | 57 +++++++++++++++++++++++++++ web/install/footer.php | 1 - 7 files changed, 85 insertions(+), 38 deletions(-) delete mode 100644 install/thelia.sqlite create mode 100644 web/install/end.php 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 65d4cb6a9fb8af1ef1ccd4edbb66f4072e3e8d00..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 262144 zcmeI*&u=4F9RTpL_eXw+DE*; zVeaw2gQ@+`f=~bU>2H4im!Hi%{?GnrkAHtzhiSEM%U%Kd3)!$BkjH7k3)_wbtFYI};aEOO>cpjlyc_hpSOI z(K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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; + ?>
@@ -98,13 +96,15 @@ if (!$err) {
-
- - +
+
+ +
+
- -
+ + 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. +

+ +
+ \ No newline at end of file diff --git a/web/install/footer.php b/web/install/footer.php index 2dbe991d4..29e87f2c2 100644 --- a/web/install/footer.php +++ b/web/install/footer.php @@ -37,6 +37,5 @@ - \ No newline at end of file