Format code, remove unused code.

1.10.x
Julio Montoya 11 years ago
parent 798fae72ee
commit 82a63e9dac
  1. 42
      main/install/update-configuration.inc.php
  2. 19
      main/install/version.php
  3. 44
      tests/main/install/install_upgrade.lib.test.php

@ -1,11 +1,11 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
/** /**
* *
* Chamilo LMS * Chamilo LMS
* *
* Only updates the main/inc/conf/configuration.php file with the new version use only from 1.8.8.1 to 1.8.8.2 (with no DB changes) * Only updates the main/inc/conf/configuration.php
* @package chamilo.install * @package chamilo.install
*/ */
if (defined('SYSTEM_INSTALLATION')) { if (defined('SYSTEM_INSTALLATION')) {
@ -15,28 +15,20 @@ if (defined('SYSTEM_INSTALLATION')) {
// Edit the configuration file // Edit the configuration file
$file = file(api_get_path(CONFIGURATION_PATH) . 'configuration.php'); $file = file(api_get_path(CONFIGURATION_PATH) . 'configuration.php');
$fh = fopen(api_get_path(CONFIGURATION_PATH) . 'configuration.php', 'w'); $fh = fopen(api_get_path(CONFIGURATION_PATH) . 'configuration.php', 'w');
$found_version_old = false; $found_version_old = false;
$found_stable_old = false; $found_stable_old = false;
$found_version = false; $found_version = false;
$found_stable = false; $found_stable = false;
$found_software_name = false; $found_software_name = false;
$found_software_url = false; $found_software_url = false;
foreach ($file as $line) { foreach ($file as $line) {
$ignore = false; $ignore = false;
if (stripos($line, '$_configuration[\'dokeos_version\']') !== false) { if (stripos($line, '$_configuration[\'system_version\']') !== false) {
$found_version_old = true;
$line = '$_configuration[\'dokeos_version\'] = \'' . $new_version . '\';' . "\r\n";
$ignore = true;
} elseif (stripos($line, '$_configuration[\'system_version\']') !== false) {
$found_version = true; $found_version = true;
$line = '$_configuration[\'system_version\'] = \'' . $new_version . '\';' . "\r\n"; $line = '$_configuration[\'system_version\'] = \'' . $new_version . '\';' . "\r\n";
} elseif (stripos($line, '$_configuration[\'dokeos_stable\']') !== false) { } elseif (stripos($line, '$_configuration[\'system_stable\']') !== false) {
$found_stable_old = true;
$line = '$_configuration[\'dokeos_stable\'] = ' . ($new_version_stable ? 'true' : 'false') . ';' . "\r\n";
$ignore = true;
} elseif (stripos($line, '$_configuration[\'system_stable\']') !== false) {
$found_stable = true; $found_stable = true;
$line = '$_configuration[\'system_stable\'] = ' . ($new_version_stable ? 'true' : 'false') . ';' . "\r\n"; $line = '$_configuration[\'system_stable\'] = ' . ($new_version_stable ? 'true' : 'false') . ';' . "\r\n";
} elseif (stripos($line, '$_configuration[\'software_name\']') !== false) { } elseif (stripos($line, '$_configuration[\'software_name\']') !== false) {
@ -47,7 +39,7 @@ if (defined('SYSTEM_INSTALLATION')) {
$line = '$_configuration[\'software_url\'] = \'' . $software_url . '\';' . "\r\n"; $line = '$_configuration[\'software_url\'] = \'' . $software_url . '\';' . "\r\n";
} elseif (stripos($line, '$userPasswordCrypted') !== false) { } elseif (stripos($line, '$userPasswordCrypted') !== false) {
//$line = '$userPasswordCrypted = \'' . ($userPasswordCrypted) . '\';' . "\r\n"; //$line = '$userPasswordCrypted = \'' . ($userPasswordCrypted) . '\';' . "\r\n";
$line = '$_configuration[\'password_encryption\'] = \'' .$userPasswordCrypted.'\';' . "\r\n"; $line = '$_configuration[\'password_encryption\'] = \'' .$userPasswordCrypted.'\';' . "\r\n";
} elseif (stripos($line, '?>') !== false) { } elseif (stripos($line, '?>') !== false) {
$ignore = true; $ignore = true;
} }
@ -55,7 +47,7 @@ if (defined('SYSTEM_INSTALLATION')) {
fwrite($fh, $line); fwrite($fh, $line);
} }
} }
if (!$found_version) { if (!$found_version) {
fwrite($fh, '$_configuration[\'system_version\'] = \'' . $new_version . '\';' . "\r\n"); fwrite($fh, '$_configuration[\'system_version\'] = \'' . $new_version . '\';' . "\r\n");
} }
@ -67,9 +59,9 @@ if (defined('SYSTEM_INSTALLATION')) {
} }
if (!$found_software_url) { if (!$found_software_url) {
fwrite($fh, '$_configuration[\'software_url\'] = \'' . $software_url . '\';' . "\r\n"); fwrite($fh, '$_configuration[\'software_url\'] = \'' . $software_url . '\';' . "\r\n");
} }
fwrite($fh, '?>'); fwrite($fh, '?>');
fclose($fh); fclose($fh);
} else { } else {
echo 'You are not allowed here !'. __FILE__; echo 'You are not allowed here !'. __FILE__;
} }

@ -2,20 +2,21 @@
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
/** /**
* This script lists the necessary variables that allow the installation * 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 * script should be overwritten with each upgrade of Chamilo. It is not
* required from any other process of Chamilo than the installation or upgrade. * required from any other process of Chamilo than the installation or upgrade.
* It also helps for automatic packaging of unstable versions. * It also helps for automatic packaging of unstable versions.
* *
* @package chamilo.install * @package chamilo.install
*/ */
/** /**
* Variables used from the main/install/index.php * Variables used from the main/install/index.php
*/ */
$new_version = '1.10.0'; $new_version = '1.10.0';
$new_version_status = 'alpha'; $new_version_status = 'alpha';
$new_version_last_id = 0; $new_version_last_id = 0;
$new_version_stable = false; $new_version_stable = false;
$new_version_major = true; $new_version_major = true;
$software_name = 'Chamilo'; $software_name = 'Chamilo';
$software_url = 'http://www.chamilo.org/'; $software_url = 'http://www.chamilo.org/';

@ -15,13 +15,6 @@ class TestInstallUpgrade extends UnitTestCase{
//var_dump($res); //var_dump($res);
} }
public function testFillTrackCountriesTable() {
$track_countries_table='';
$res = fill_track_countries_table($track_countries_table);
$this->assertEqual(null,$res);
//var_dump($res);
}
public function testWriteCoursesHtaccessFile() { public function testWriteCoursesHtaccessFile() {
$chamilo_path_folder = api_get_path(SYS_PATH); $chamilo_path_folder = api_get_path(SYS_PATH);
$url_append=$chamilo_path_folder.'main/install/'; $url_append=$chamilo_path_folder.'main/install/';
@ -33,30 +26,6 @@ class TestInstallUpgrade extends UnitTestCase{
$this->assertEqual($chamilo_path_folder.'main/install/',$res); $this->assertEqual($chamilo_path_folder.'main/install/',$res);
//var_dump($res); //var_dump($res);
} }
//This function is ok but the problem is than create course with other code
/*
public function testLoadMainDatabase() {
$chamilo_path_folder= api_get_path(SYS_CODE_PATH);
$installation_settings['{ORGANISATIONNAME}'] = 'My Organisation';
$installation_settings['{ORGANISATIONURL}'] = 'http://www.chamilo.org';
$installation_settings['{CAMPUSNAME}'] = 'My campus';
$installation_settings['{PLATFORMLANGUAGE}'] = 'spanish';
$installation_settings['{ALLOWSELFREGISTRATION}'] = 1;
$installation_settings['{ALLOWTEACHERSELFREGISTRATION}'] = 1;
$installation_settings['{ADMINLASTNAME}'] = 'Doe';
$installation_settings['{ADMINFIRSTNAME}'] = 'John';
$installation_settings['{ADMINLOGIN}'] = 'admin';
$installation_settings['{ADMINPASSWORD}'] = md5('admin');
$installation_settings['{ADMINEMAIL}'] = '.localdomain';
$installation_settings['{ADMINPHONE}'] = '(000) 001 02 03';
$installation_settings['{PLATFORM_AUTH_SOURCE}'] = PLATFORM_AUTH_SOURCE;
$installation_settings['{ADMINLANGUAGE}'] = 'spanish';
$installation_settings['{HASHFUNCTIONMODE}'] = 'md5';
$db_script = $chamilo_path_folder.'install/db_main.sql';
$res = load_main_database($installation_settings,$db_script);
$this->assertFalse($res);
}
*/
public function testSplitSqlFile() { public function testSplitSqlFile() {
$ret=''; $ret='';
@ -67,19 +36,6 @@ class TestInstallUpgrade extends UnitTestCase{
$this->assertTrue($res===true); $this->assertTrue($res===true);
} }
public function testGetSqlFileContents() {
ob_start();
$file='txt';
$section='course';
$print_errors=true;
$res = get_sql_file_contents($file,$section,$print_errors);
ob_end_clean();
if(is_bool($res));
$this->assertTrue(is_bool($res));
$this->assertTrue($res===true || $res === false);
//var_dump($res);
}
public function testMyDirectoryToArray() { public function testMyDirectoryToArray() {
$chamilo_path_folder= api_get_path(SYS_PATH); $chamilo_path_folder= api_get_path(SYS_PATH);
$directory= $chamilo_path_folder.'home'; $directory= $chamilo_path_folder.'home';

Loading…
Cancel
Save