Comment unused code, set "app" as writable and remove internal dirs.

Rename function from testDbConnect to connectToDatabase
1.10.x
Julio Montoya 10 years ago
parent 6b606da5c7
commit c60f690d70
  1. 8
      main/install/index.php
  2. 100
      main/install/install.lib.php

@ -448,7 +448,7 @@ if (@$_POST['step2']) {
if ($installType == 'update') {
$db_name = $dbNameForm;
$manager = testDbConnect(
$manager = connectToDatabase(
$dbHostForm,
$dbUsernameForm,
$dbPassForm,
@ -624,7 +624,7 @@ if (@$_POST['step2']) {
if ($installType == 'update') {
remove_memory_and_time_limits();
$manager = testDbConnect(
$manager = connectToDatabase(
$dbHostForm,
$dbUsernameForm,
$dbPassForm,
@ -680,7 +680,7 @@ if (@$_POST['step2']) {
} else {
set_file_folder_permissions();
$manager = testDbConnect(
$manager = connectToDatabase(
$dbHostForm,
$dbUsernameForm,
$dbPassForm,
@ -692,7 +692,7 @@ if (@$_POST['step2']) {
// Drop and create the database anyways
$manager->getConnection()->getSchemaManager()->dropAndCreateDatabase($dbNameForm);
$manager = testDbConnect(
$manager = connectToDatabase(
$dbHostForm,
$dbUsernameForm,
$dbPassForm,

@ -13,11 +13,9 @@
use Doctrine\ORM\EntityManager;
/* CONSTANTS */
define('COURSES_HTACCESS_FILENAME', 'htaccess.dist');
//define('COURSES_HTACCESS_FILENAME', 'htaccess.dist');
define('SYSTEM_CONFIG_FILENAME', 'configuration.dist.php');
/* COMMON PURPOSE FUNCTIONS */
/**
* This function detects whether the system has been already installed.
* It should be used for prevention from second running the installation
@ -257,11 +255,12 @@ function check_writable($folder, $suggestion = false)
* This function checks if the given folder is readable
* @param string $folder Full path to a folder
* @param bool $suggestion Whether to show a suggestion or not
*
* @return string
*/
function checkReadable($folder, $suggestion = false)
{
if (is_writable($folder)) {
if (is_readable($folder)) {
return Display::label(get_lang('Readable'), 'success');
} else {
if ($suggestion) {
@ -275,7 +274,8 @@ function checkReadable($folder, $suggestion = false)
/**
* This function is similar to the core file() function, except that it
* works with line endings in Windows (which is not the case of file())
* @param string File path
* @param string $filename
*
* @return array The lines of the file returned as an array
*/
function file_to_array($filename)
@ -286,6 +286,7 @@ function file_to_array($filename)
$fp = fopen($filename, 'rb');
$buffer = fread($fp, filesize($filename));
fclose($fp);
return explode('<br />', nl2br($buffer));
}
@ -303,7 +304,7 @@ function set_file_folder_permissions()
* @param string $url_append The path from your webroot to your chamilo root
* @return bool Result of writing the file
*/
function write_courses_htaccess_file($url_append)
/*function write_courses_htaccess_file($url_append)
{
$content = file_get_contents(dirname(__FILE__).'/'.COURSES_HTACCESS_FILENAME);
$content = str_replace('{CHAMILO_URL_APPEND_PATH}', $url_append, $content);
@ -313,7 +314,7 @@ function write_courses_htaccess_file($url_append)
return fclose($fp);
}
return false;
}
}*/
/**
* Write the main system config file
@ -330,8 +331,6 @@ function write_system_config_file($path)
global $urlAppendPath;
global $languageForm;
global $encryptPassForm;
global $installType;
global $updatePath;
global $session_lifetime;
global $new_version;
global $new_version_stable;
@ -521,15 +520,15 @@ function get_config_param_from_db($param = '')
}
/**
* In step 3. Tests establishing connection to the database server.
* If it's a single database environment the function checks if the database exist.
* If the database does not exist we check the creation permissions.
* @param string $dbHostForm DB host
* @param string $dbUsernameForm DB username
* @param string $dbPassForm DB password
* Connect to the database and returns the entity manager
* @param string $dbHostForm DB host
* @param string $dbUsernameForm DB username
* @param string $dbPassForm DB password
* @param string $dbNameForm DB name
*
* @return EntityManager
*/
function testDbConnect($dbHostForm, $dbUsernameForm, $dbPassForm, $dbNameForm)
function connectToDatabase($dbHostForm, $dbUsernameForm, $dbPassForm, $dbNameForm)
{
$dbParams = array(
'driver' => 'pdo_mysql',
@ -920,38 +919,10 @@ function display_requirements(
}
echo '<table class="table">
<tr>
<td class="requirements-item">'.api_get_path(CONFIGURATION_PATH).'</td>
<td class="requirements-value">'.check_writable(api_get_path(CONFIGURATION_PATH)).'</td>
</tr>
'.$oldConf.'
<tr>
<td class="requirements-item">'.api_get_path(SYS_UPLOAD_PATH).'users/</td>
<td class="requirements-value">'.check_writable(api_get_path(SYS_UPLOAD_PATH).'users/').'</td>
</tr>
<tr>
<td class="requirements-item">'.api_get_path(SYS_UPLOAD_PATH).'sessions/</td>
<td class="requirements-value">'.check_writable(api_get_path(SYS_UPLOAD_PATH).'sessions/').'</td>
</tr>
<tr>
<td class="requirements-item">'.api_get_path(SYS_UPLOAD_PATH).'courses/</td>
<td class="requirements-value">'.check_writable(api_get_path(SYS_UPLOAD_PATH).'courses/').'</td>
</tr>
<tr>
<td class="requirements-item">'.api_get_path(SYS_ARCHIVE_PATH).'</td>
<td class="requirements-value">'.check_writable(api_get_path(SYS_ARCHIVE_PATH)).'</td>
</tr>
<tr>
<td class="requirements-item">'.api_get_path(SYS_COURSE_PATH).'</td>
<td class="requirements-value">'.check_writable(api_get_path(SYS_COURSE_PATH)).' </td>
</tr>
<tr>
<td class="requirements-item">'.api_get_path(SYS_APP_PATH).'home/</td>
<td class="requirements-value">'.check_writable(api_get_path(SYS_APP_PATH).'home/').'</td>
</tr>
<tr>
<td class="requirements-item">'.api_get_path(SYS_CSS_PATH).'</td>
<td class="requirements-value">'.check_writable(api_get_path(SYS_CSS_PATH), true).'</td>
<td class="requirements-item">'.api_get_path(SYS_UPLOAD_PATH).'</td>
<td class="requirements-value">'.check_writable(api_get_path(SYS_UPLOAD_PATH)).'</td>
</tr>
<tr>
<td class="requirements-item">'.api_get_path(SYS_PUBLIC_PATH).'</td>
@ -981,18 +952,7 @@ function display_requirements(
<td class="requirements-item">'.get_lang('PermissionsForNewFiles').'</td>
<td class="requirements-value">'.$file_perm.' </td>
</tr>
'.
//'<tr>
// <td class="requirements-item">chamilo/searchdb/</td>
// <td class="requirements-value">'.check_writable('../searchdb/').'</td>
//</tr>'.
//'<tr>
// <td class="requirements-item">'.session_save_path().'</td>
// <td class="requirements-value">'.(is_writable(session_save_path())
// ? '<strong><font color="green">'.get_lang('Writable').'</font></strong>'
// : '<strong><font color="red">'.get_lang('NotWritable').'</font></strong>').'</td>
//</tr>'.
'';
';
echo ' </table>';
echo ' </div>';
echo '</div>';
@ -1456,7 +1416,7 @@ function display_database_settings_form(
$database_exists_text = '';
$manager = null;
try {
$manager = testDbConnect(
$manager = connectToDatabase(
$dbHostForm,
$dbUsernameForm,
$dbPassForm,
@ -1898,6 +1858,8 @@ function check_course_script_interpretation($course_dir, $course_attempt_name, $
}
/**
* Save settings values
*
* @param string $organizationName
* @param string $organizationUrl
* @param string $siteName
@ -1943,6 +1905,9 @@ function installSettings(
}
/**
* Executes DB changes based in the classes defined in
* src/Chamilo/CoreBundle/Migrations/Schema/*
*
* @param string $chamiloVersion
* @param string $dbNameForm
* @param string $dbUsernameForm
@ -1954,8 +1919,8 @@ function installSettings(
function migrate($chamiloVersion, $dbNameForm, $dbUsernameForm, $dbPassForm, $dbHostForm, $manager)
{
$debug = true;
// Config doctrine migrations
// Config doctrine migrations
$db = \Doctrine\DBAL\DriverManager::getConnection(array(
'dbname' => $dbNameForm,
'user' => $dbUsernameForm,
@ -1970,7 +1935,8 @@ function migrate($chamiloVersion, $dbNameForm, $dbUsernameForm, $dbPassForm, $db
$config = new \Doctrine\DBAL\Migrations\Configuration\Configuration($db);
// Table name that will store migrations log (will be created automatically, default name is: doctrine_migration_versions)
// Table name that will store migrations log (will be created automatically,
// default name is: doctrine_migration_versions)
$config->setMigrationsTableName('version');
// Namespace of your migration classes, do not forget escape slashes, do not add last slash
$config->setMigrationsNamespace('Chamilo\CoreBundle\Migrations\Schema\V'.$chamiloVersion);
@ -1991,6 +1957,7 @@ function migrate($chamiloVersion, $dbNameForm, $dbUsernameForm, $dbPassForm, $db
// Retrieve SQL queries that should be run to migrate you schema to $to version,
// if $to == null - schema will be migrated to latest version
$versions = $migration->getSql($to);
if ($debug) {
$nl = '<br>';
foreach ($versions as $version => $queries) {
@ -2004,7 +1971,8 @@ function migrate($chamiloVersion, $dbNameForm, $dbUsernameForm, $dbPassForm, $db
}
try {
$migration->migrate($to); // Execute migration!
// Execute migration!
$migration->migrate($to);
if ($debug) {
echo 'DONE'.$nl;
}
@ -2016,6 +1984,10 @@ function migrate($chamiloVersion, $dbNameForm, $dbUsernameForm, $dbPassForm, $db
}
/**
*
* After the schema was created (table creation), the function adds
* admin/platform information.
*
* @param EntityManager $manager
* @param string $sysPath
* @param string $encryptPassForm
@ -2071,7 +2043,7 @@ function finishInstallation(
break;
}
// Insert users
// Insert admin and Anonymous users.
$sql = "INSERT INTO user (user_id, lastname, firstname, username, password, auth_source, email, status, official_code, phone, creator_id, registration_date, expiration_date,active,openid,language) VALUES
(1, '$adminLastName','$adminFirstName','$loginForm','$passToStore','".PLATFORM_AUTH_SOURCE."','$emailForm',1,'ADMIN','$adminPhoneForm',1,NOW(),NULL,'1',NULL,'$languageForm'),
@ -2082,7 +2054,7 @@ function finishInstallation(
$sql = "INSERT INTO admin VALUES(1, 1)";
Database::query($sql);
// The chosen during the installation platform language should be enabled.
// Set default language
$sql = "UPDATE language SET available=1 WHERE dokeos_folder = '$languageForm'";
Database::query($sql);

Loading…
Cancel
Save