Create .env file and use it to load DB settings using symfongy container

pull/2487/head
jmontoyaa 7 years ago
parent 30f31e6321
commit 3dfa340397
  1. 14
      .env.dist
  2. 24
      main/inc/global.inc.php
  3. 10
      main/inc/lib/database.lib.php
  4. 3
      main/install/ajax.php
  5. 252
      main/install/index.php
  6. 9
      main/install/install.lib.php
  7. 28
      src/UserBundle/Entity/User.php

@ -6,11 +6,11 @@
# Format described at http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
# For a sqlite database, use: "sqlite:///%kernel.project_dir%/var/data.db"
# Set "serverVersion" to your server version to avoid edge-case exceptions and extra database calls
DATABASE_HOST="localhost"
DATABASE_PORT="3306"
DATABASE_NAME="master"
DATABASE_USER="root"
DATABASE_PASSWORD="root"
DATABASE_HOST="{{DATABASE_HOST}}"
DATABASE_PORT="{{DATABASE_PORT}}"
DATABASE_NAME="{{DATABASE_NAME}}"
DATABASE_USER="{{DATABASE_USER}}"
DATABASE_PASSWORD="{{DATABASE_PASSWORD}}"
###< doctrine/doctrine-bundle ###
###> symfony/swiftmailer-bundle ###
@ -28,8 +28,8 @@ APP_SECRET=141af65f23c7935a37b504c422f113b0
###< symfony/framework-bundle ###
###> chamilo ###
APP_INSTALLED=0
APP_ENCRYPT_METHOD=bcrypt
APP_INSTALLED={{APP_INSTALLED}}
APP_ENCRYPT_METHOD={{APP_ENCRYPT_METHOD}}
APP_LOCALE=en
APP_URL_APPEND=''
APP_MULTIPLE_ACCESS_URL=''

@ -1,6 +1,8 @@
<?php
/* For licensing terms, see /license.txt */
use Symfony\Component\Dotenv\Dotenv;
/**
* It is recommended that ALL Chamilo scripts include this important file.
* This script manages
@ -21,14 +23,13 @@ define('SHOW_ERROR_CODES', false);
// Include the libraries that are necessary everywhere
require_once __DIR__.'/../../vendor/autoload.php';
$kernel = new Chamilo\Kernel('', '');
$kernel = new Chamilo\Kernel('dev', true);
// Determine the directory path where this current file lies.
// This path will be useful to include the other initialisation files.
$includePath = __DIR__;
// Include the main Chamilo platform configuration file.
$alreadyInstalled = false;
if (file_exists($kernel->getConfigurationFile())) {
require_once $kernel->getConfigurationFile();
@ -102,6 +103,21 @@ if (!is_dir(_MPDF_TEMP_PATH)) {
mkdir(_MPDF_TEMP_PATH, api_get_permissions_for_new_directories(), true);
}
if (file_exists(api_get_path(SYS_PATH).'.env')) {
(new Dotenv())->load(api_get_path(SYS_PATH).'.env');
$kernel->boot();
$doctrine = $kernel->getContainer()->get('doctrine');
$database = new \Database();
$database->setManager($doctrine->getManager());
$database->setConnection($doctrine->getConnection());
} else {
$global_error_code = 3;
// The database server is not available or credentials are invalid.
require $includePath.'/global_error_message.inc.php';
die();
}
// Connect to the server database and select the main chamilo database.
// When $_configuration['db_persistent_connection'] is set, it is expected to be a boolean type.
/*$dbPersistConnection = api_get_configuration_value('db_persistent_connection');
@ -118,7 +134,7 @@ $params = array(
);*/
// Doctrine ORM configuration
/*
$dbParams = [
'driver' => 'pdo_mysql',
'host' => $_configuration['db_host'],
@ -139,7 +155,7 @@ try {
// The database server is not available or credentials are invalid.
require $includePath.'/global_error_message.inc.php';
die();
}
}*/
/* RETRIEVING ALL THE CHAMILO CONFIG SETTINGS FOR MULTIPLE URLs FEATURE*/
if (!empty($_configuration['multiple_access_urls'])) {

@ -22,7 +22,7 @@ class Database
/**
* @param EntityManager $em
*/
public function setManager($em)
public static function setManager($em)
{
self::$em = $em;
}
@ -30,7 +30,7 @@ class Database
/**
* @param Connection $connection
*/
public function setConnection(Connection $connection)
public static function setConnection(Connection $connection)
{
self::$connection = $connection;
}
@ -143,13 +143,13 @@ class Database
$config->setEntityNamespaces(
[
'ChamiloPageBundle' => 'Chamilo\PageBundle\Entity',
'ChamiloUserBundle' => 'Chamilo\UserBundle\Entity',
'ChamiloCoreBundle' => 'Chamilo\CoreBundle\Entity',
'ChamiloCourseBundle' => 'Chamilo\CourseBundle\Entity',
'ChamiloPageBundle' => 'Chamilo\PageBundle\Entity',
'ChamiloPluginBundle' => 'Chamilo\PluginBundle\Entity',
'ChamiloSkillBundle' => 'Chamilo\SkillBundle\Entity',
'ChamiloTicketBundle' => 'Chamilo\TicketBundle\Entity',
'ChamiloPluginBundle' => 'Chamilo\PluginBundle\Entity'
'ChamiloUserBundle' => 'Chamilo\UserBundle\Entity'
]
);

@ -41,7 +41,8 @@ if ($installType === 'new') {
$dbPort = isset($_POST['db_port']) ? $_POST['db_port'] : 3306;
$manager = connectToDatabase($dbHost, $dbUsername, $dbPass, $dbName, $dbPort);
$database = connectToDatabase($dbHost, $dbUsername, $dbPass, $dbName, $dbPort);
$manager = $database->getManager();
$db_prefix = api_get_configuration_value('db_prefix') ? api_get_configuration_value('db_prefix') : 'chamilo_';
$db_c_prefix = api_get_configuration_value('table_prefix') ? api_get_configuration_value('table_prefix') : 'crs_';

@ -2,6 +2,10 @@
/* For licensing terms, see /license.txt */
use ChamiloSession as Session;
use Chamilo\Kernel;
use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Dotenv\Dotenv;
/**
* Chamilo installation
@ -493,13 +497,14 @@ if (@$_POST['step2']) {
if ($installType == 'update') {
$db_name = $dbNameForm;
$manager = connectToDatabase(
$database = connectToDatabase(
$dbHostForm,
$dbUsernameForm,
$dbPassForm,
$dbNameForm,
$dbPortForm
);
$manager = $database->getManager();
$tmp = get_config_param_from_db('platformLanguage');
if (!empty($tmp)) {
@ -736,13 +741,14 @@ if (@$_POST['step2']) {
}
if ($installType == 'update') {
$manager = connectToDatabase(
$dbHostForm,
$dbUsernameForm,
$dbPassForm,
$dbNameForm,
$dbPortForm
);
$database = connectToDatabase(
$dbHostForm,
$dbUsernameForm,
$dbPassForm,
$dbNameForm,
$dbPortForm
);
$manager = $database->getManager();
$perm = api_get_permissions_for_new_directories();
$perm_file = api_get_permissions_for_new_files();
@ -750,178 +756,82 @@ if (@$_POST['step2']) {
migrateSwitch($my_old_version, $manager);
} else {
set_file_folder_permissions();
$manager = connectToDatabase(
$dbHostForm,
$dbUsernameForm,
$dbPassForm,
null,
$dbPortForm
);
$database = connectToDatabase(
$dbHostForm,
$dbUsernameForm,
$dbPassForm,
null,
$dbPortForm
);
$manager = $database->getManager();
$dbNameForm = preg_replace('/[^a-zA-Z0-9_\-]/', '', $dbNameForm);
// Drop and create the database anyways
$manager->getConnection()->getSchemaManager()->dropAndCreateDatabase($dbNameForm);
$manager = connectToDatabase(
$dbHostForm,
$dbUsernameForm,
$dbPassForm,
$dbNameForm,
$dbPortForm
);
$database = connectToDatabase(
$dbHostForm,
$dbUsernameForm,
$dbPassForm,
$dbNameForm,
$dbPortForm
);
$manager = $database->getManager();
$sql = getVersionTable();
$manager->getConnection()->executeQuery($sql);
$metadataList = $manager->getMetadataFactory()->getAllMetadata();
$schema = $manager->getConnection()->getSchemaManager()->createSchema();
// Create database schema
$tool = new \Doctrine\ORM\Tools\SchemaTool($manager);
$tool->createSchema($metadataList);
$connection = $manager->getConnection();
$connection->executeQuery(
'CREATE TABLE page__site (id INT AUTO_INCREMENT NOT NULL, enabled TINYINT(1) NOT NULL, name VARCHAR(255) NOT NULL, relative_path VARCHAR(255) DEFAULT NULL, host VARCHAR(255) NOT NULL, enabled_from DATETIME DEFAULT NULL, enabled_to DATETIME DEFAULT NULL, is_default TINYINT(1) NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, locale VARCHAR(6) DEFAULT NULL, title VARCHAR(64) DEFAULT NULL, meta_keywords VARCHAR(255) DEFAULT NULL, meta_description VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'
);
$connection->executeQuery(
'CREATE TABLE page__page (id INT AUTO_INCREMENT NOT NULL, site_id INT DEFAULT NULL, parent_id INT DEFAULT NULL, target_id INT DEFAULT NULL, route_name VARCHAR(255) NOT NULL, page_alias VARCHAR(255) DEFAULT NULL, type VARCHAR(255) DEFAULT NULL, position INT NOT NULL, enabled TINYINT(1) NOT NULL, decorate TINYINT(1) NOT NULL, edited TINYINT(1) NOT NULL, name VARCHAR(255) NOT NULL, slug LONGTEXT DEFAULT NULL, url LONGTEXT DEFAULT NULL, custom_url LONGTEXT DEFAULT NULL, request_method VARCHAR(255) DEFAULT NULL, title VARCHAR(255) DEFAULT NULL, meta_keyword VARCHAR(255) DEFAULT NULL, meta_description VARCHAR(255) DEFAULT NULL, javascript LONGTEXT DEFAULT NULL, stylesheet LONGTEXT DEFAULT NULL, raw_headers LONGTEXT DEFAULT NULL, template VARCHAR(255) NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX IDX_2FAE39EDF6BD1646 (site_id), INDEX IDX_2FAE39ED727ACA70 (parent_id), INDEX IDX_2FAE39ED158E0B66 (target_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'
);
$connection->executeQuery(
'CREATE TABLE page__snapshot (id INT AUTO_INCREMENT NOT NULL, site_id INT DEFAULT NULL, page_id INT DEFAULT NULL, route_name VARCHAR(255) NOT NULL, page_alias VARCHAR(255) DEFAULT NULL, type VARCHAR(255) DEFAULT NULL, position INT NOT NULL, enabled TINYINT(1) NOT NULL, decorate TINYINT(1) NOT NULL, name VARCHAR(255) NOT NULL, url LONGTEXT DEFAULT NULL, parent_id INT DEFAULT NULL, target_id INT DEFAULT NULL, content LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:json)\', publication_date_start DATETIME DEFAULT NULL, publication_date_end DATETIME DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX IDX_3963EF9AF6BD1646 (site_id), INDEX IDX_3963EF9AC4663E4 (page_id), INDEX idx_snapshot_dates_enabled (publication_date_start, publication_date_end, enabled), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'
);
$connection->executeQuery(
'CREATE TABLE page__bloc (id INT AUTO_INCREMENT NOT NULL, parent_id INT DEFAULT NULL, page_id INT DEFAULT NULL, name VARCHAR(255) DEFAULT NULL, type VARCHAR(64) NOT NULL, settings LONGTEXT NOT NULL COMMENT \'(DC2Type:json)\', enabled TINYINT(1) DEFAULT NULL, position INT DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX IDX_FCDC1A97727ACA70 (parent_id), INDEX IDX_FCDC1A97C4663E4 (page_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'
);
$connection->executeQuery(
'CREATE TABLE classification__category (id INT AUTO_INCREMENT NOT NULL, parent_id INT DEFAULT NULL, context VARCHAR(255) DEFAULT NULL, media_id INT DEFAULT NULL, name VARCHAR(255) NOT NULL, enabled TINYINT(1) NOT NULL, slug VARCHAR(255) NOT NULL, description VARCHAR(255) DEFAULT NULL, position INT DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX IDX_43629B36727ACA70 (parent_id), INDEX IDX_43629B36E25D857E (context), INDEX IDX_43629B36EA9FDD75 (media_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'
);
$connection->executeQuery(
'CREATE TABLE classification__context (id VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, enabled TINYINT(1) NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'
);
$connection->executeQuery(
'CREATE TABLE classification__tag (id INT AUTO_INCREMENT NOT NULL, context VARCHAR(255) DEFAULT NULL, name VARCHAR(255) NOT NULL, enabled TINYINT(1) NOT NULL, slug VARCHAR(255) NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX IDX_CA57A1C7E25D857E (context), UNIQUE INDEX tag_context (slug, context), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'
);
$connection->executeQuery(
'CREATE TABLE classification__collection (id INT AUTO_INCREMENT NOT NULL, context VARCHAR(255) DEFAULT NULL, media_id INT DEFAULT NULL, name VARCHAR(255) NOT NULL, enabled TINYINT(1) NOT NULL, slug VARCHAR(255) NOT NULL, description VARCHAR(255) DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX IDX_A406B56AE25D857E (context), INDEX IDX_A406B56AEA9FDD75 (media_id), UNIQUE INDEX tag_collection (slug, context), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'
);
$connection->executeQuery(
'CREATE TABLE media__gallery (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, context VARCHAR(64) NOT NULL, default_format VARCHAR(255) NOT NULL, enabled TINYINT(1) NOT NULL, updated_at DATETIME NOT NULL, created_at DATETIME NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'
);
$connection->executeQuery(
'CREATE TABLE media__media (id INT AUTO_INCREMENT NOT NULL, category_id INT DEFAULT NULL, name VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, enabled TINYINT(1) NOT NULL, provider_name VARCHAR(255) NOT NULL, provider_status INT NOT NULL, provider_reference VARCHAR(255) NOT NULL, provider_metadata LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:json)\', width INT DEFAULT NULL, height INT DEFAULT NULL, length NUMERIC(10, 0) DEFAULT NULL, content_type VARCHAR(255) DEFAULT NULL, content_size INT DEFAULT NULL, copyright VARCHAR(255) DEFAULT NULL, author_name VARCHAR(255) DEFAULT NULL, context VARCHAR(64) DEFAULT NULL, cdn_is_flushable TINYINT(1) DEFAULT NULL, cdn_flush_identifier VARCHAR(64) DEFAULT NULL, cdn_flush_at DATETIME DEFAULT NULL, cdn_status INT DEFAULT NULL, updated_at DATETIME NOT NULL, created_at DATETIME NOT NULL, INDEX IDX_5C6DD74E12469DE2 (category_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'
);
$connection->executeQuery(
'CREATE TABLE media__gallery_media (id INT AUTO_INCREMENT NOT NULL, gallery_id INT DEFAULT NULL, media_id INT DEFAULT NULL, position INT NOT NULL, enabled TINYINT(1) NOT NULL, updated_at DATETIME NOT NULL, created_at DATETIME NOT NULL, INDEX IDX_80D4C5414E7AF8F (gallery_id), INDEX IDX_80D4C541EA9FDD75 (media_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'
);
$connection->executeQuery(
'ALTER TABLE page__page ADD CONSTRAINT FK_2FAE39EDF6BD1646 FOREIGN KEY (site_id) REFERENCES page__site (id) ON DELETE CASCADE'
);
$connection->executeQuery(
'ALTER TABLE page__page ADD CONSTRAINT FK_2FAE39ED727ACA70 FOREIGN KEY (parent_id) REFERENCES page__page (id) ON DELETE CASCADE'
);
$connection->executeQuery(
'ALTER TABLE page__page ADD CONSTRAINT FK_2FAE39ED158E0B66 FOREIGN KEY (target_id) REFERENCES page__page (id) ON DELETE CASCADE'
);
$connection->executeQuery(
'ALTER TABLE page__snapshot ADD CONSTRAINT FK_3963EF9AF6BD1646 FOREIGN KEY (site_id) REFERENCES page__site (id) ON DELETE CASCADE'
);
$connection->executeQuery(
'ALTER TABLE page__snapshot ADD CONSTRAINT FK_3963EF9AC4663E4 FOREIGN KEY (page_id) REFERENCES page__page (id) ON DELETE CASCADE'
);
$connection->executeQuery(
'ALTER TABLE page__bloc ADD CONSTRAINT FK_FCDC1A97727ACA70 FOREIGN KEY (parent_id) REFERENCES page__bloc (id) ON DELETE CASCADE'
);
$connection->executeQuery(
'ALTER TABLE page__bloc ADD CONSTRAINT FK_FCDC1A97C4663E4 FOREIGN KEY (page_id) REFERENCES page__page (id) ON DELETE CASCADE'
);
$connection->executeQuery(
'ALTER TABLE classification__category ADD CONSTRAINT FK_43629B36727ACA70 FOREIGN KEY (parent_id) REFERENCES classification__category (id) ON DELETE CASCADE'
);
$connection->executeQuery(
'ALTER TABLE classification__category ADD CONSTRAINT FK_43629B36E25D857E FOREIGN KEY (context) REFERENCES classification__context (id)'
);
$connection->executeQuery(
'ALTER TABLE classification__category ADD CONSTRAINT FK_43629B36EA9FDD75 FOREIGN KEY (media_id) REFERENCES media__media (id) ON DELETE SET NULL'
);
$connection->executeQuery(
'ALTER TABLE classification__tag ADD CONSTRAINT FK_CA57A1C7E25D857E FOREIGN KEY (context) REFERENCES classification__context (id)'
);
$connection->executeQuery(
'ALTER TABLE classification__collection ADD CONSTRAINT FK_A406B56AE25D857E FOREIGN KEY (context) REFERENCES classification__context (id)'
);
$connection->executeQuery(
'ALTER TABLE classification__collection ADD CONSTRAINT FK_A406B56AEA9FDD75 FOREIGN KEY (media_id) REFERENCES media__media (id) ON DELETE SET NULL'
);
$connection->executeQuery(
'ALTER TABLE media__media ADD CONSTRAINT FK_5C6DD74E12469DE2 FOREIGN KEY (category_id) REFERENCES classification__category (id) ON DELETE SET NULL'
);
$connection->executeQuery("CREATE TABLE timeline__timeline (id INT AUTO_INCREMENT NOT NULL, action_id INT DEFAULT NULL, subject_id INT DEFAULT NULL, context VARCHAR(255) NOT NULL, type VARCHAR(255) NOT NULL, created_at DATETIME NOT NULL, INDEX IDX_FFBC6AD59D32F035 (action_id), INDEX IDX_FFBC6AD523EDC87 (subject_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;");
$connection->executeQuery("CREATE TABLE timeline__component (id INT AUTO_INCREMENT NOT NULL, model VARCHAR(255) NOT NULL, identifier LONGTEXT NOT NULL COMMENT '(DC2Type:array)', hash VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_1B2F01CDD1B862B8 (hash), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;");
$connection->executeQuery("CREATE TABLE timeline__action (id INT AUTO_INCREMENT NOT NULL, verb VARCHAR(255) NOT NULL, status_current VARCHAR(255) NOT NULL, status_wanted VARCHAR(255) NOT NULL, duplicate_key VARCHAR(255) DEFAULT NULL, duplicate_priority INT DEFAULT NULL, created_at DATETIME NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;");
$connection->executeQuery("CREATE TABLE timeline__action_component (id INT AUTO_INCREMENT NOT NULL, action_id INT DEFAULT NULL, component_id INT DEFAULT NULL, type VARCHAR(255) NOT NULL, text VARCHAR(255) DEFAULT NULL, INDEX IDX_6ACD1B169D32F035 (action_id), INDEX IDX_6ACD1B16E2ABAFFF (component_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;");
$connection->executeQuery("ALTER TABLE timeline__timeline ADD CONSTRAINT FK_FFBC6AD59D32F035 FOREIGN KEY (action_id) REFERENCES timeline__action (id);");
$connection->executeQuery("ALTER TABLE timeline__timeline ADD CONSTRAINT FK_FFBC6AD523EDC87 FOREIGN KEY (subject_id) REFERENCES timeline__component (id) ON DELETE CASCADE;");
$connection->executeQuery("ALTER TABLE timeline__action_component ADD CONSTRAINT FK_6ACD1B169D32F035 FOREIGN KEY (action_id) REFERENCES timeline__action (id) ON DELETE CASCADE;");
$connection->executeQuery("ALTER TABLE timeline__action_component ADD CONSTRAINT FK_6ACD1B16E2ABAFFF FOREIGN KEY (component_id) REFERENCES timeline__component (id) ON DELETE CASCADE;");
//$connection->executeQuery("CREATE UNIQUE INDEX UNIQ_8D93D649A0D96FBF ON user (email_canonical);");
$connection->executeQuery("ALTER TABLE fos_group ADD name VARCHAR(255) NOT NULL;");
$connection->executeQuery("ALTER TABLE fos_group ADD roles LONGTEXT NOT NULL COMMENT '(DC2Type:array)'");
$connection->executeQuery("CREATE TABLE faq_question_translation (id INT AUTO_INCREMENT NOT NULL, translatable_id INT DEFAULT NULL, headline VARCHAR(255) NOT NULL, body LONGTEXT DEFAULT NULL, slug VARCHAR(50) NOT NULL, locale VARCHAR(255) NOT NULL, INDEX IDX_C2D1A2C2AC5D3 (translatable_id), UNIQUE INDEX faq_question_translation_unique_translation (translatable_id, locale), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;");
$connection->executeQuery("CREATE TABLE faq_category_translation (id INT AUTO_INCREMENT NOT NULL, translatable_id INT DEFAULT NULL, headline VARCHAR(255) NOT NULL, body LONGTEXT DEFAULT NULL, slug VARCHAR(50) NOT NULL, locale VARCHAR(255) NOT NULL, INDEX IDX_5493B0FC2C2AC5D3 (translatable_id), UNIQUE INDEX faq_category_translation_unique_translation (translatable_id, locale), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;");
$connection->executeQuery("CREATE TABLE faq_category (id INT AUTO_INCREMENT NOT NULL, rank INT NOT NULL, is_active TINYINT(1) NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX is_active_idx (is_active), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;");
$connection->executeQuery("CREATE TABLE faq_question (id INT AUTO_INCREMENT NOT NULL, category_id INT DEFAULT NULL, is_active TINYINT(1) NOT NULL, rank INT NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, only_auth_users TINYINT(1) NOT NULL, INDEX IDX_4A55B05912469DE2 (category_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;");
$connection->executeQuery("ALTER TABLE faq_question_translation ADD CONSTRAINT FK_C2D1A2C2AC5D3 FOREIGN KEY (translatable_id) REFERENCES faq_question (id) ON DELETE CASCADE;");
$connection->executeQuery("ALTER TABLE faq_category_translation ADD CONSTRAINT FK_5493B0FC2C2AC5D3 FOREIGN KEY (translatable_id) REFERENCES faq_category (id) ON DELETE CASCADE;");
$connection->executeQuery("ALTER TABLE faq_question ADD CONSTRAINT FK_4A55B05912469DE2 FOREIGN KEY (category_id) REFERENCES faq_category (id);");
$connection->executeQuery("CREATE TABLE ext_translations (id INT AUTO_INCREMENT NOT NULL, locale VARCHAR(8) NOT NULL, object_class VARCHAR(255) NOT NULL, field VARCHAR(32) NOT NULL, foreign_key VARCHAR(64) NOT NULL, content LONGTEXT DEFAULT NULL, INDEX translations_lookup_idx (locale, object_class, foreign_key), UNIQUE INDEX lookup_unique_idx (locale, object_class, field, foreign_key), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;");
$connection->executeQuery("CREATE TABLE ext_log_entries (id INT AUTO_INCREMENT NOT NULL, action VARCHAR(8) NOT NULL, logged_at DATETIME NOT NULL, object_id VARCHAR(64) DEFAULT NULL, object_class VARCHAR(255) NOT NULL, version INT NOT NULL, data LONGTEXT DEFAULT NULL COMMENT '(DC2Type:array)', username VARCHAR(255) DEFAULT NULL, INDEX log_class_lookup_idx (object_class), INDEX log_date_lookup_idx (logged_at), INDEX log_user_lookup_idx (username), INDEX log_version_lookup_idx (object_id, object_class, version), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;");
$connection->executeQuery("CREATE TABLE contact_category_translation (id INT AUTO_INCREMENT NOT NULL, translatable_id INT DEFAULT NULL, name VARCHAR(255) NOT NULL, locale VARCHAR(255) NOT NULL, INDEX IDX_3E770F302C2AC5D3 (translatable_id), UNIQUE INDEX contact_category_translation_unique_translation (translatable_id, locale), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;");
$connection->executeQuery("CREATE TABLE contact_category (id INT AUTO_INCREMENT NOT NULL, email VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;");
$connection->executeQuery("CREATE TABLE notification__message (id INT AUTO_INCREMENT NOT NULL, type VARCHAR(255) NOT NULL, body LONGTEXT NOT NULL COMMENT '(DC2Type:json)', state INT NOT NULL, restart_count INT DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME DEFAULT NULL, started_at DATETIME DEFAULT NULL, completed_at DATETIME DEFAULT NULL, INDEX notification_message_state_idx (state), INDEX notification_message_created_at_idx (created_at), INDEX idx_state (state), INDEX idx_created_at (created_at), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;");
//CREATE TABLE sylius_settings (id INT AUTO_INCREMENT NOT NULL, schema_alias VARCHAR(255) NOT NULL, namespace VARCHAR(255) DEFAULT NULL, parameters LONGTEXT NOT NULL COMMENT '(DC2Type:json_array)', UNIQUE INDEX UNIQ_1AFEFB2A894A31AD33E16B56 (schema_alias, namespace), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;
$connection->executeQuery("ALTER TABLE contact_category_translation ADD CONSTRAINT FK_3E770F302C2AC5D3 FOREIGN KEY (translatable_id) REFERENCES contact_category (id) ON DELETE CASCADE;");
$connection->executeQuery("ALTER TABLE fos_group CHANGE name name VARCHAR(180) NOT NULL;");
$connection->executeQuery("CREATE UNIQUE INDEX UNIQ_4B019DDB5E237E06 ON fos_group (name);");
$connection->executeQuery("DROP INDEX UNIQ_8D93D649F85E0677 ON user;");
$connection->executeQuery("UPDATE user set created_at = NOW() where created_at is null");
$connection->executeQuery("UPDATE user set updated_at = NOW() where updated_at is null");
$connection->executeQuery("ALTER TABLE user ADD date_of_birth DATETIME DEFAULT NULL, ADD website VARCHAR(64) DEFAULT NULL, ADD biography VARCHAR(1000) DEFAULT NULL, ADD gender VARCHAR(1) DEFAULT NULL, ADD locale VARCHAR(8) DEFAULT NULL, ADD timezone VARCHAR(64) DEFAULT NULL, ADD facebook_uid VARCHAR(255) DEFAULT NULL, ADD facebook_name VARCHAR(255) DEFAULT NULL, ADD facebook_data LONGTEXT DEFAULT NULL COMMENT '(DC2Type:json)', ADD twitter_uid VARCHAR(255) DEFAULT NULL, ADD twitter_name VARCHAR(255) DEFAULT NULL, ADD twitter_data LONGTEXT DEFAULT NULL COMMENT '(DC2Type:json)', ADD gplus_uid VARCHAR(255) DEFAULT NULL, ADD gplus_name VARCHAR(255) DEFAULT NULL, ADD gplus_data LONGTEXT DEFAULT NULL COMMENT '(DC2Type:json)', ADD token VARCHAR(255) DEFAULT NULL, ADD two_step_code VARCHAR(255) DEFAULT NULL, CHANGE username_canonical username_canonical VARCHAR(180) NOT NULL, CHANGE lastname lastname VARCHAR(64) DEFAULT NULL, CHANGE firstname firstname VARCHAR(64) DEFAULT NULL, CHANGE phone phone VARCHAR(64) DEFAULT NULL, CHANGE salt salt VARCHAR(255) DEFAULT NULL, CHANGE created_at created_at DATETIME NOT NULL, CHANGE updated_at updated_at DATETIME NOT NULL, CHANGE confirmation_token confirmation_token VARCHAR(180) DEFAULT NULL;");
$connection->executeQuery("CREATE UNIQUE INDEX UNIQ_8D93D64992FC23A8 ON user (username_canonical);");
$connection->executeQuery("CREATE UNIQUE INDEX UNIQ_8D93D649C05FB297 ON user (confirmation_token);");
$connection->executeQuery("ALTER TABLE page__site CHANGE locale locale VARCHAR(7) DEFAULT NULL;");
$connection->executeQuery("ALTER TABLE media__gallery_media ADD CONSTRAINT FK_80D4C5414E7AF8F FOREIGN KEY (gallery_id) REFERENCES media__gallery (id) ON DELETE CASCADE;");
$connection->executeQuery("ALTER TABLE media__gallery_media ADD CONSTRAINT FK_80D4C541EA9FDD75 FOREIGN KEY (media_id) REFERENCES media__media (id) ON DELETE CASCADE;");
$sysPath = api_get_path(SYS_PATH);
finishInstallation(
$manager,
$sysPath,
$encryptPassForm,
$passForm,
$adminLastName,
$adminFirstName,
$loginForm,
$emailForm,
$adminPhoneForm,
$languageForm,
$institutionForm,
$institutionUrlForm,
$campusForm,
$allowSelfReg,
$allowSelfRegProf,
$installationProfile
);
include 'install_files.inc.php';
$envFile = api_get_path(SYS_PATH).'.env';
$contents = file_get_contents($envFile);
$params = [
'{{DATABASE_HOST}}' => $dbHostForm,
'{{DATABASE_PORT}}' => $dbPortForm,
'{{DATABASE_NAME}}' => $dbNameForm,
'{{DATABASE_USER}}' => $dbUsernameForm,
'{{DATABASE_PASSWORD}}' => $dbPassForm,
'{{APP_INSTALLED}}' => 1,
'{{APP_ENCRYPT_METHOD}}' => $encryptPassForm
];
$contents = str_replace(array_keys($params), array_values($params), $contents);
file_put_contents($envFile, $contents);
(new Dotenv())->load(api_get_path(SYS_PATH).'.env');
$kernel = new Kernel('dev', true);
$application = new Application($kernel);
$input = new \Symfony\Component\Console\Input\ArrayInput([]);
$command = $application->find('doctrine:schema:create');
$result = $command->run($input, new ConsoleOutput());
// No errors
if ($result == 0) {
$kernel->boot();
$doctrine = $kernel->getContainer()->get('doctrine');
$manager = $doctrine->getManager();
$sysPath = api_get_path(SYS_PATH);
finishInstallation(
$manager,
$sysPath,
$encryptPassForm,
$passForm,
$adminLastName,
$adminFirstName,
$loginForm,
$emailForm,
$adminPhoneForm,
$languageForm,
$institutionForm,
$institutionUrlForm,
$campusForm,
$allowSelfReg,
$allowSelfRegProf,
$installationProfile
);
include 'install_files.inc.php';
}
}
display_after_install_message($installType);

@ -553,7 +553,7 @@ function get_config_param_from_db($param = '')
* @param string $dbNameForm DB name
* @param int $dbPortForm DB port
*
* @return EntityManager
* @return Database
*/
function connectToDatabase(
$dbHostForm,
@ -574,7 +574,7 @@ function connectToDatabase(
$database = new \Database();
$database->connect($dbParams);
return $database->getManager();
return $database;
}
/* DISPLAY FUNCTIONS */
@ -2763,8 +2763,11 @@ function finishInstallation(
$installationProfile = ''
) {
$sysPath = !empty($sysPath) ? $sysPath : api_get_path(SYS_PATH);
$connection = $manager->getConnection();
Database::setConnection($connection);
Database::setManager($manager);
$sql = getVersionTable();
// Add version table
$connection->executeQuery($sql);

@ -12,7 +12,7 @@ use Chamilo\CoreBundle\Entity\Skill;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Event\LifecycleEventArgs;
use Doctrine\ORM\Mapping as ORM;
use Sonata\UserBundle\Entity\BaseUser as BaseUser;
use Sonata\UserBundle\Entity\BaseUser;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\HttpFoundation\File\File;
//use Symfony\Component\Security\Core\User\UserInterface;
@ -28,7 +28,6 @@ use Chamilo\ThemeBundle\Model\UserInterface as ThemeUser;
//use Vich\UploaderBundle\Mapping\Annotation as Vich;
//use Application\Sonata\MediaBundle\Entity\Media;
//use Chamilo\UserBundle\Model\UserInterface as UserInterfaceModel;
//use Sylius\Component\Attribute\Model\AttributeValueInterface as BaseAttributeValueInterface;
//use Sylius\Component\Variation\Model\OptionInterface as BaseOptionInterface;
//use Sylius\Component\Variation\Model\VariantInterface as BaseVariantInterface;
@ -59,7 +58,7 @@ use Chamilo\ThemeBundle\Model\UserInterface as ThemeUser;
* column=@ORM\Column(
* name="email",
* type="string",
* length=255,
* length=100,
* unique=false
* )
* ),
@ -67,7 +66,7 @@ use Chamilo\ThemeBundle\Model\UserInterface as ThemeUser;
* column=@ORM\Column(
* name="email_canonical",
* type="string",
* length=255,
* length=100,
* unique=false
* )
* )
@ -2228,20 +2227,6 @@ class User extends BaseUser implements ThemeUser //implements ParticipantInterfa
return $this;
}
public function setUsername($username)
{
$this->username = $username;
return $this;
}
public function setUsernameCanonical($usernameCanonical)
{
$this->usernameCanonical = $usernameCanonical;
return $this;
}
/**
* @param boolean $boolean
*
@ -2254,13 +2239,6 @@ class User extends BaseUser implements ThemeUser //implements ParticipantInterfa
return $this;
}
public function setEmailCanonical($emailCanonical)
{
$this->emailCanonical = $emailCanonical;
return $this;
}
public function setEnabled($boolean)
{
$this->enabled = (Boolean) $boolean;

Loading…
Cancel
Save