Browse Source

Cleaning installation code see #6420

Julio Montoya 11 years ago
parent
commit
923cf676fb
3 changed files with 165 additions and 977 deletions
  1. 20 14
      main/install/index.php
  2. 133 951
      main/install/install.lib.php
  3. 12 12
      main/install/version.php

+ 20 - 14
main/install/index.php

@@ -9,8 +9,9 @@
  */
 
 require_once __DIR__.'/../../vendor/autoload.php';
-require_once 'install.lib.php';
-require_once '../inc/lib/api.lib.php';
+require_once __DIR__.'/../inc/lib/api.lib.php';
+require_once __DIR__.'/install.lib.php';
+$versionData = require_once __DIR__.'/version.php';
 
 error_reporting(-1);
 ini_set('display_errors', '1');
@@ -19,6 +20,8 @@ set_time_limit(0);
 use Symfony\Component\Console\Output\Output;
 use Symfony\Component\HttpFoundation\Request;
 use ChamiloLMS\Component\Console\Output\BufferedOutput;
+use Chash\Command\Installation\InstallCommand;
+use Chash\Command\Installation\UpgradeCommand;
 
 $app = new Silex\Application();
 
@@ -99,8 +102,8 @@ $console->addCommands(
         new \Doctrine\DBAL\Migrations\Tools\Console\Command\VersionCommand(),
 
         // Chash commands.
-        new Chash\Command\Installation\UpgradeCommand(),
-        new Chash\Command\Installation\InstallCommand(),
+        new UpgradeCommand(),
+        new InstallCommand(),
 
         new Chash\Command\Files\CleanCoursesFilesCommand(),
         new Chash\Command\Files\CleanTempFolderCommand(),
@@ -250,14 +253,13 @@ $app->match('/check-database', function () use ($app) {
         if ($form->isValid()) {
             $parameters = $form->getData();
 
-            /** @var \Chash\Command\Installation\InstallCommand $command */
+            /** @var InstallCommand $command */
             $command = $app['console']->get('chamilo:install');
             $command->setDatabaseSettings($parameters);
 
             $connection = $command->getUserAccessConnectionToHost();
 
             try {
-                //$connect = $connection->connect();
                 $sm = $connection->getSchemaManager();
                 $databases = $sm->listDatabases();
 
@@ -281,7 +283,10 @@ $app->match('/check-database', function () use ($app) {
 
                 return $app->redirect($url);
             } catch (Exception $e) {
-                $app['session']->getFlashBag()->add('success', 'Connection error !'.$e->getMessage());
+                $app['session']->getFlashBag()->add(
+                    'success',
+                    'Connection error !'.$e->getMessage()
+                );
             }
         }
     }
@@ -297,9 +302,9 @@ $app->match('/portal-settings', function () use ($app) {
     /** @var Request $request */
     $request = $app['request'];
 
-    /** @var \Chash\Command\Installation\InstallCommand $command */
+    /** @var InstallCommand $command */
     $command = $app['console']->get('chamilo:install');
-    $builder  = $app['form.factory']->createBuilder('form');
+    $builder = $app['form.factory']->createBuilder('form');
 
     $data = $command->getPortalSettingsParams();
     $data['institution_url']['attributes']['data'] = str_replace('main/install/', '', $request->getUriForPath('/'));
@@ -352,7 +357,7 @@ $app->match('/portal-settings', function () use ($app) {
 $app->match('/admin-settings', function () use ($app) {
     $request = $app['request'];
 
-    /** @var Chash\Command\Installation\InstallCommand $command */
+    /** @var InstallCommand $command */
     $command = $app['console']->get('chamilo:install');
 
     $data = $command->getAdminSettingsParams();
@@ -418,7 +423,6 @@ $app->match('/resume', function () use ($app) {
             )
         );
     } else {
-
         $url = $app['url_generator']->generate('check-database');
 
         return $app->redirect($url);
@@ -427,13 +431,13 @@ $app->match('/resume', function () use ($app) {
 
 // Installation process.
 
-$app->match('/installing', function () use ($app) {
+$app->match('/installing', function () use ($app, $versionData) {
 
     $portalSettings = $app['session']->get('portal_settings');
     $adminSettings = $app['session']->get('admin_settings');
     $databaseSettings = $app['session']->get('database_settings');
 
-    /** @var Chash\Command\Installation\InstallCommand $command */
+    /** @var InstallCommand $command */
     $command = $app['console']->get('chamilo:install');
 
     $def = $command->getDefinition();
@@ -441,7 +445,7 @@ $app->match('/installing', function () use ($app) {
         array(
             'name',
             'path' => realpath(__DIR__.'/../../').'/',
-            'version' => '1.10.0'
+            'version' => $versionData['version']
         ),
         $def
     );
@@ -519,3 +523,5 @@ if (PHP_SAPI == 'cli') {
 } else {
     $app->run();
 }
+
+

File diff suppressed because it is too large
+ 133 - 951
main/install/install.lib.php


+ 12 - 12
main/install/version.php

@@ -2,20 +2,20 @@
 /* For licensing terms, see /license.txt */
 /**
  * This script lists the necessary variables that allow the installation
- * system to know in which version is the current Chamilo install. This 
+ * system to know in which version is the current Chamilo install. This
  * script should be overwritten with each upgrade of Chamilo. It is not
  * required from any other process of Chamilo than the installation or upgrade.
  * It also helps for automatic packaging of unstable versions.
- * 
+ *
  * @package chamilo.install
  */
-/**
- * Variables used from the main/install/index.php
- */
-$new_version            = '1.10.0';
-$new_version_status     = 'Unstable';
-$new_version_last_id	= 2;
-$new_version_stable 	= false;
-$new_version_major      = true;
-$software_name          = 'Chamilo';
-$software_url           = 'http://www.chamilo.org/';
+
+return array(
+    'version' => '10.0.0',
+    'version_status' => 'Unstable',
+    'version_last_id' => 2,
+    'version_stable' => false,
+    'version_major' => true,
+    'software_name' => 'Chamilo',
+    'software_url' => 'http://www.chamilo.org/'
+);

Some files were not shown because too many files changed in this diff