Allow to install again (just for tests)

Add course_rel_user c_id.
1.10.x
Julio Montoya 10 years ago
parent 28ed19d76b
commit 748cec8feb
  1. 11
      main/install/index.php
  2. 103
      main/install/install.lib.php
  3. 23
      src/Chamilo/CoreBundle/Migrations/Schema/v1/Version110.php

@ -108,6 +108,7 @@ $my_old_version = '';
if (empty($tmp_version)) {
$tmp_version = get_config_param('system_version');
}
if (!empty($_POST['old_version'])) {
$my_old_version = $_POST['old_version'];
} elseif (!empty($tmp_version)) {
@ -121,8 +122,8 @@ require_once __DIR__.'/version.php';
if (isAlreadyInstalledSystem()) {
// The system has already been installed, so block re-installation.
$global_error_code = 6;
require '../inc/global_error_message.inc.php';
die();
/*require '../inc/global_error_message.inc.php';
die();*/
}
/* STEP 1 : INITIALIZES FORM VARIABLES IF IT IS THE FIRST VISIT */
@ -628,7 +629,6 @@ if (@$_POST['step2']) {
Log::notice('Starting migration process from '.$my_old_version.' ('.time().')');
switch ($my_old_version) {
case '1.9.0':
case '1.9.2':
@ -650,10 +650,11 @@ if (@$_POST['step2']) {
Database::query("ALTER TABLE c_blog_rating MODIFY COLUMN rating_type char(40) NOT NULL default 'post'");
Database::query("ALTER TABLE c_survey MODIFY COLUMN anonymous char(10) NOT NULL default '0'");
// Migrate using the file Version110.php
migrate('110', 1, $dbNameForm, $dbUsernameForm, $dbPassForm, $dbHostForm);
include 'update-files-1.9.0-1.10.0.inc.php';
//include 'update-files-1.9.0-1.10.0.inc.php';
// Only updates the configuration.inc.php with the new version
include 'update-configuration.inc.php';
//include 'update-configuration.inc.php';
break;
default:
break;

@ -440,6 +440,7 @@ function get_config_param($param, $updatePath = '')
if (empty($updatePath) && !empty($_POST['updatePath'])) {
$updatePath = $_POST['updatePath'];
}
if (empty($updatePath)) {
$updatePath = api_get_path(SYS_PATH);
}
@ -458,105 +459,23 @@ function get_config_param($param, $updatePath = '')
}
}
if (file_exists($updatePath.$updateFromConfigFile) && !is_dir($updatePath.$updateFromConfigFile)) {
// The parameter was not found among the global variables, so look into the old configuration file.
// Make sure the installedVersion file is read first so it is overwritten
// by the config file if the config file contains the version (from 1.8.4).
$config_data_2 = array();
if (file_exists($updatePath.$updateFromInstalledVersionFile)) {
$config_data_2 = file_to_array($updatePath.$updateFromInstalledVersionFile);
}
$configFile = array();
$config_data = file_to_array($updatePath.$updateFromConfigFile);
$config_data = array_merge($config_data, $config_data_2);
$val = '';
// Parse the configuration file, statement by statement (line by line, actually).
foreach ($config_data as $php_statement) {
if (strpos($php_statement, '=') !== false) {
// Variable assignment statement have been detected (probably).
// It is expected to be as follows:
// $variable = 'some_value'; // A comment that is not mandatory.
// Split the statement into its left and right sides.
$php_statement = explode('=', $php_statement);
$variable = trim($php_statement[0]);
$value = $php_statement[1];
if (substr($variable, 0, 1) == '$') {
// We have for sure a php variable assignment detected.
// On the left side: Retrieve the pure variable's name
$variable = trim(str_replace('$', '', $variable));
// On the right side: Remove the comment, if it exists.
list($value) = explode(' //', $value);
// Remove extra whitespace, if any. Remove the trailing semicolon (;).
$value = substr(trim($value), 0, -1);
// Remove surroundig quotes, restore escaped quotes.
$value = str_replace('\"', '"', preg_replace('/^"|"$/', '', $value));
$value = str_replace('\'', '"', preg_replace('/^\'|\'$/', '', $value));
if (strtolower($value) == 'true') {
// A boolean true value have been recognized.
$value = 1;
} elseif (strtolower($value) == 'false') {
// A boolean false value have been recognized.
$value = 0;
} else {
// Probably we have a string value, but also we have to check
// possible string concatenations that may include string values
// and other configuration variables. I this case we have to
// get the calculated result of the concatenation.
$implode_string = ' ';
if (!strstr($value, '." ".') && strstr($value, '.$')) {
// Yes, there is concatenation, insert a special separator string.
$value = str_replace('.$', '." ".$', $value);
$implode_string = '';
}
// Split the concatenated values, if they are more than one.
$sub_strings = explode('." ".', $value);
// Seek for variables and retrieve their values.
foreach ($sub_strings as $key => & $sub_string) {
if (preg_match('/^\$[a-zA-Z_][a-zA-Z0-9_]*$/', $sub_string)) {
// A variable has been detected, read it by recursive call.
$sub_string = get_config_param(str_replace('$', '', $sub_string));
}
}
// Concatenate everything into the final, the calculated string value.
$value = implode($implode_string, $sub_strings);
if (file_exists($updatePath.$updateFromConfigFile) &&
!is_dir($updatePath.$updateFromConfigFile)
) {
require $updatePath.$updateFromConfigFile;
$config = new Zend\Config\Config($_configuration);
return $config->get($param);
}
// Cache the result value.
$configFile[$variable] = $value;
$a = explode("'", $variable);
$key_tmp = isset($a[1]) ? $a[1] : null;
if ($key_tmp == $param) {
$val = $value;
}
}
}
}
}
error_log('Config array could not be found in get_config_param()', 0);
return null;
if (file_exists($updatePath.$updateFromConfigFile)) {
/*if (file_exists($updatePath.$updateFromConfigFile)) {
return $val;
} else {
error_log('Config array could not be found in get_config_param()', 0);
return null;
}
}*/
}
/* DATABASE RELATED FUNCTIONS */

@ -26,9 +26,9 @@ class Version110 extends AbstractMigration
$this->addSql("CREATE TABLE IF NOT EXISTS c_student_publication_comment (id INT PRIMARY KEY NOT NULL AUTO_INCREMENT, work_id INT NOT NULL, c_id INT NOT NULL, comment text, file VARCHAR(255), user_id int NOT NULL, sent_at datetime NOT NULL)");
$this->addSql("CREATE TABLE IF NOT EXISTS c_attendance_calendar_rel_group (id int NOT NULL auto_increment PRIMARY KEY, c_id INT NOT NULL, group_id INT NOT NULL, calendar_id INT NOT NULL)");
$this->addSql("ALTER TABLE skill_rel_user ADD COLUMN course_id INT NOT NULL DEFAULT 0 AFTER id");
$this->addSql("ALTER TABLE skill_rel_user ADD COLUMN session_id INT NOT NULL DEFAULT 0 AFTER course_id");
$this->addSql("ALTER TABLE skill_rel_user ADD INDEX idx_select_cs (course_id, session_id)");
//$this->addSql("ALTER TABLE skill_rel_user ADD COLUMN course_id INT NOT NULL DEFAULT 0 AFTER id");
//$this->addSql("ALTER TABLE skill_rel_user ADD COLUMN session_id INT NOT NULL DEFAULT 0 AFTER course_id");
//$this->addSql("ALTER TABLE skill_rel_user ADD INDEX idx_select_cs (course_id, session_id)");
$table = $schema->getTable('session');
if (!$table->hasColumn('description')) {
@ -38,8 +38,14 @@ class Version110 extends AbstractMigration
array('default' => 'NULL')
);
}
//$this->addSql("ALTER TABLE session ADD COLUMN description TEXT DEFAULT NULL");
$this->addSql("ALTER TABLE session ADD COLUMN show_description TINYINT UNSIGNED DEFAULT 0 AFTER description");
if (!$table->hasColumn('show_description')) {
$table->addColumn(
'show_description',
'smallint',
array('default' => 0, 'unsigned' => true)
);
}
$this->addSql("ALTER TABLE session_rel_course ADD COLUMN position int NOT NULL default 0");
$this->addSql("ALTER TABLE session_rel_course ADD COLUMN category varchar(255) default ''");
@ -71,12 +77,16 @@ class Version110 extends AbstractMigration
$this->addSql("ALTER TABLE user ADD COLUMN id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT AFTER user_id");
$this->addSql("ALTER TABLE user MODIFY COLUMN chatcall_date datetime default NULL");
$this->addSql("ALTER TABLE user MODIFY COLUMN chatcall_text varchar(50) default NULL");
$this->addSql("ALTER TABLE user MODIFY COLUMN chatcall_user_id int unsigned default '0");
$this->addSql("ALTER TABLE user MODIFY COLUMN chatcall_user_id int unsigned default 0");
$this->addSql("ALTER TABLE user MODIFY COLUMN expiration_date datetime default NULL");
$this->addSql("ALTER TABLE user MODIFY COLUMN registration_date datetime NOT NULL");
$this->addSql("ALTER TABLE course ADD COLUMN add_teachers_to_sessions_courses tinyint NOT NULL default 0");
$this->addSql("ALTER TABLE session MODIFY COLUMN name char(100) NOT NULL DEFAULT ''");
$this->addSql("ALTER TABLE track_e_default MODIFY COLUMN c_id int default NULL");
$this->addSql("ALTER TABLE course_rel_user ADD COLUMN c_id int default NULL");
$this->addSql("UPDATE course_rel_user SET c_id = (SELECT id FROM course WHERE code = course_code)");
// Course
$this->addSql("ALTER TABLE c_survey ADD COLUMN visible_results INT UNSIGNED DEFAULT 0");
$this->addSql("ALTER TABLE c_survey_invitation ADD COLUMN group_id INT NOT NULL");
$this->addSql("ALTER TABLE c_lp_item ADD COLUMN prerequisite_min_score float");
@ -92,6 +102,7 @@ class Version110 extends AbstractMigration
$this->addSql("ALTER TABLE c_blog_rating MODIFY COLUMN rating_type char(40) NOT NULL default 'post' ");
$this->addSql("ALTER TABLE c_survey MODIFY COLUMN anonymous char(10) NOT NULL default '0'");
$this->addSql("ALTER TABLE c_course_setting MODIFY COLUMN value varchar(255) default ''");
$this->addSql("UPDATE user SET id = user_id");
$this->addSql("UPDATE course_field SET field_type = 1 WHERE field_variable = 'special_course'");
$this->addSql("UPDATE user SET registration_date = NULL WHERE registration_date = '0000-00-00 00:00:00'");

Loading…
Cancel
Save