Using $app obj to handle installation process

skala
Julio Montoya 12 years ago
parent fdaf5ad73f
commit 22190bc46a
  1. 40
      composer.lock
  2. 74
      main/inc/global.inc.php
  3. 59
      main/inc/lib/chamilo_session.class.php
  4. 819
      main/inc/lib/database.lib.php
  5. 3
      main/install/index.php
  6. 14
      main/install/install.lib.php
  7. 4
      resources/config/prod.php

40
composer.lock generated

@ -261,12 +261,12 @@
"source": {
"type": "git",
"url": "https://github.com/doctrine/common",
"reference": "f44d98d5fdd102959e2bf71b36392dbacf0e568d"
"reference": "db84fc111652774f22b72a916aef40ce3f584e45"
},
"dist": {
"type": "zip",
"url": "https://github.com/doctrine/common/archive/f44d98d5fdd102959e2bf71b36392dbacf0e568d.zip",
"reference": "f44d98d5fdd102959e2bf71b36392dbacf0e568d",
"url": "https://github.com/doctrine/common/archive/db84fc111652774f22b72a916aef40ce3f584e45.zip",
"reference": "db84fc111652774f22b72a916aef40ce3f584e45",
"shasum": ""
},
"require": {
@ -277,7 +277,7 @@
"doctrine/lexer": "1.*",
"doctrine/annotations": "1.*"
},
"time": "2013-01-20 19:00:57",
"time": "2013-01-25 05:59:24",
"type": "library",
"extra": {
"branch-alias": {
@ -335,12 +335,12 @@
"source": {
"type": "git",
"url": "https://github.com/doctrine/dbal",
"reference": "f444b115d162e50aeeabaaef1edd0b65b61a7438"
"reference": "19269218ee387bd96b4fc8f31b1f492f298c5917"
},
"dist": {
"type": "zip",
"url": "https://github.com/doctrine/dbal/archive/f444b115d162e50aeeabaaef1edd0b65b61a7438.zip",
"reference": "f444b115d162e50aeeabaaef1edd0b65b61a7438",
"url": "https://github.com/doctrine/dbal/archive/19269218ee387bd96b4fc8f31b1f492f298c5917.zip",
"reference": "19269218ee387bd96b4fc8f31b1f492f298c5917",
"shasum": ""
},
"require": {
@ -353,7 +353,7 @@
"suggest": {
"symfony/console": "For helpful console commands such as SQL execution and import of files."
},
"time": "2013-01-23 23:16:30",
"time": "2013-01-25 06:00:32",
"type": "library",
"extra": {
"branch-alias": {
@ -643,12 +643,12 @@
"source": {
"type": "git",
"url": "git://github.com/l3pp4rd/DoctrineExtensions.git",
"reference": "baa42fda5607978d70040b9f38b6b3a13823c903"
"reference": "93349ad3ab200c7aa69237355c4ee811d359d160"
},
"dist": {
"type": "zip",
"url": "https://github.com/l3pp4rd/DoctrineExtensions/archive/baa42fda5607978d70040b9f38b6b3a13823c903.zip",
"reference": "baa42fda5607978d70040b9f38b6b3a13823c903",
"url": "https://github.com/l3pp4rd/DoctrineExtensions/archive/93349ad3ab200c7aa69237355c4ee811d359d160.zip",
"reference": "93349ad3ab200c7aa69237355c4ee811d359d160",
"shasum": ""
},
"require": {
@ -668,7 +668,7 @@
"doctrine/mongodb": ">=1.0.0",
"doctrine/mongodb-odm": ">=1.0.0-BETA7"
},
"time": "2013-01-18 18:21:44",
"time": "2013-01-24 18:57:40",
"type": "library",
"extra": {
"branch-alias": {
@ -968,12 +968,12 @@
"source": {
"type": "git",
"url": "git://github.com/fabpot/Silex.git",
"reference": "f7a8956f96e991f86a5fc4811876bef76e3a4e25"
"reference": "a23c221e609a17dfc2923066e1680149b7678cf9"
},
"dist": {
"type": "zip",
"url": "https://github.com/fabpot/Silex/archive/f7a8956f96e991f86a5fc4811876bef76e3a4e25.zip",
"reference": "f7a8956f96e991f86a5fc4811876bef76e3a4e25",
"url": "https://github.com/fabpot/Silex/archive/a23c221e609a17dfc2923066e1680149b7678cf9.zip",
"reference": "a23c221e609a17dfc2923066e1680149b7678cf9",
"shasum": ""
},
"require": {
@ -1009,7 +1009,7 @@
"symfony/css-selector": ">=2.1,<2.3-dev",
"symfony/dom-crawler": ">=2.1,<2.3-dev"
},
"time": "2013-01-24 12:18:41",
"time": "2013-01-25 06:59:19",
"type": "library",
"extra": {
"branch-alias": {
@ -1145,18 +1145,18 @@
"source": {
"type": "git",
"url": "https://github.com/symfony/Console",
"reference": "v2.2.0-BETA2"
"reference": "fdb2d9320106926266a0f7a5a97aab7213e11ad6"
},
"dist": {
"type": "zip",
"url": "https://github.com/symfony/Console/archive/v2.2.0-BETA2.zip",
"reference": "v2.2.0-BETA2",
"url": "https://github.com/symfony/Console/archive/fdb2d9320106926266a0f7a5a97aab7213e11ad6.zip",
"reference": "fdb2d9320106926266a0f7a5a97aab7213e11ad6",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"time": "2013-01-18 08:14:58",
"time": "2013-01-24 15:55:08",
"type": "library",
"extra": {
"branch-alias": {

@ -147,13 +147,15 @@ $app->register(
$app->register(new Silex\Provider\FormServiceProvider());
//Monolog
$app->register(
new Silex\Provider\MonologServiceProvider(),
array(
'monolog.logfile' => api_get_path(SYS_ARCHIVE_PATH).'chamilo_development.log',
'monolog.name' => 'chamilo',
)
);
if (is_writable(api_get_path(SYS_ARCHIVE_PATH))) {
$app->register(
new Silex\Provider\MonologServiceProvider(),
array(
'monolog.logfile' => api_get_path(SYS_ARCHIVE_PATH).'chamilo_development.log',
'monolog.name' => 'chamilo',
)
);
}
/*
//Monolog examples
@ -239,7 +241,6 @@ if (isset($_configuration['main_database'])) {
)
);
//Setting Doctrine2 extensions
$timestampableListener = new \Gedmo\Timestampable\TimestampableListener();
@ -317,20 +318,24 @@ $app->error(
/*
use Symfony\Component\HttpKernel\Debug\ErrorHandler;
ErrorHandler::register();
*/
*/
use Symfony\Component\HttpFoundation\RedirectResponse;
//Filters
$app->before(
function () use ($app) {
//Check the PHP version
if (api_check_php_version() == false) {
$app->abort(500, "Incorrect PHP version"); //error 1
}
if (!file_exists($app['configuration_file'])) {
return new RedirectResponse(api_get_path(WEB_CODE_PATH).'install');
}
//Check the PHP version
if (api_check_php_version() == false) {
$app->abort(500, "Incorrect PHP version");
}
if (!is_writable(api_get_path(SYS_ARCHIVE_PATH))) {
$app->abort(500, "archive folder must be writeable");
}
//$app['request']->getSession()->start();
}
);
@ -345,14 +350,14 @@ $app->finish(
//@todo will be removed before a stable release
$mtime = microtime();
$mtime = explode(" ", $mtime);
$mtime = $mtime[1] + $mtime[0];
$mtime = $mtime[1] + $mtime[0]; /*
$message = "Page loaded in:".($mtime - START);
$app['monolog']->addInfo($message);
$message = "memory_get_usage: ".format_file_size(memory_get_usage(true));
$app['monolog']->addInfo($message);
$message = "memory_get_peak_usage: ".format_file_size(memory_get_peak_usage(true));
$app['monolog']->addInfo($message);
$app['monolog']->addInfo($message);*/
}
);
@ -392,9 +397,10 @@ if (!($conn_return = @Database::connect(
//$app->abort(500, "Database is unavailable"); //error 3
}
/*
if (!$_configuration['db_host']) {
//$app->abort(500, "Database is unavailable"); //error 3
}
}*/
/* RETRIEVING ALL THE CHAMILO CONFIG SETTINGS FOR MULTIPLE URLs FEATURE*/
@ -418,7 +424,11 @@ if (!empty($_configuration['multiple_access_urls'])) {
// The system has not been designed to use special SQL modes that were introduced since MySQL 5.
Database::query("set session sql_mode='';");
if (!Database::select_db($_configuration['main_database'], $database_connection)) {
if (isset($_configuration['main_database']) && !Database::select_db(
$_configuration['main_database'],
$database_connection
)
) {
//$app->abort(500, "Database is unavailable"); //error 3
}
@ -459,19 +469,21 @@ Database::query("SET NAMES 'utf8';");
//@todo user silex session provider instead of a custom class
Chamilo::session()->start($already_installed);
$settings_refresh_info = api_get_settings_params_simple(array('variable = ?' => 'settings_latest_update'));
$settings_latest_update = $settings_refresh_info ? $settings_refresh_info['selected_value'] : null;
if ($already_installed) {
$settings_refresh_info = api_get_settings_params_simple(array('variable = ?' => 'settings_latest_update'));
$settings_latest_update = $settings_refresh_info ? $settings_refresh_info['selected_value'] : null;
$_setting = isset($_SESSION['_setting']) ? $_SESSION['_setting'] : null;
$_plugins = isset($_SESSION['_plugins']) ? $_SESSION['_plugins'] : null;
$_setting = isset($_SESSION['_setting']) ? $_SESSION['_setting'] : null;
$_plugins = isset($_SESSION['_plugins']) ? $_SESSION['_plugins'] : null;
if (!isset($_setting)) {
api_set_settings_and_plugins();
} else {
if (isset($_setting['settings_latest_update']) && $_setting['settings_latest_update'] != $settings_latest_update) {
if (!isset($_setting)) {
api_set_settings_and_plugins();
$_setting = isset($_SESSION['_setting']) ? $_SESSION['_setting'] : null;
$_plugins = isset($_SESSION['_plugins']) ? $_SESSION['_plugins'] : null;
} else {
if (isset($_setting['settings_latest_update']) && $_setting['settings_latest_update'] != $settings_latest_update) {
api_set_settings_and_plugins();
$_setting = isset($_SESSION['_setting']) ? $_SESSION['_setting'] : null;
$_plugins = isset($_SESSION['_plugins']) ? $_SESSION['_plugins'] : null;
}
}
}
@ -505,10 +517,10 @@ $app->register(
new Silex\Provider\SwiftmailerServiceProvider(),
array(
'swiftmailer.options' => array(
'host' => $platform_email['SMTP_HOST'],
'port' => $platform_email['SMTP_PORT'],
'username' => $platform_email['SMTP_USER'],
'password' => $platform_email['SMTP_PASS'],
'host' => isset($platform_email['SMTP_HOST']) ? $platform_email['SMTP_HOST'] : null,
'port' => isset($platform_email['SMTP_PORT']) ? $platform_email['SMTP_PORT'] : null,
'username' => isset($platform_email['SMTP_USER']) ? $platform_email['SMTP_USER'] : null,
'password' => isset($platform_email['SMTP_PASS']) ? $platform_email['SMTP_PASS'] : null,
'encryption' => null,
'auth_mode' => null
)

@ -2,16 +2,16 @@
/**
* Chamilo session.
*
*
* Usage:
*
*
*
*
* use ChamiloSession as Session;
*
*
* Session::read('name');
*
*
* Or
*
*
* Chamilo::session()->...
* session()->...
*
@ -25,7 +25,7 @@ class ChamiloSession extends System\Session
/**
*
* @return ChamiloSession
* @return ChamiloSession
*/
static function instance()
{
@ -33,13 +33,15 @@ class ChamiloSession extends System\Session
if (empty($result)) {
$result = new ChamiloSession();
}
return $result;
}
static function session_lifetime()
{
global $_configuration;
return $_configuration['session_lifetime'];
return isset($_configuration['session_lifetime']) ? $_configuration['session_lifetime'] : 3600;
}
static function session_stored_in_db()
@ -74,11 +76,18 @@ class ChamiloSession extends System\Session
if (self::session_stored_in_db() && function_exists('session_set_save_handler')) {
$handler = new SessionHandler();
@session_set_save_handler(array(& $handler, 'open'), array(& $handler, 'close'), array(& $handler, 'read'), array(& $handler, 'write'), array(& $handler, 'destroy'), array(& $handler, 'garbage'));
@session_set_save_handler(
array(& $handler, 'open'),
array(& $handler, 'close'),
array(& $handler, 'read'),
array(& $handler, 'write'),
array(& $handler, 'destroy'),
array(& $handler, 'garbage')
);
}
/*
* Prevent Session fixation bug fixes
* Prevent Session fixation bug fixes
* See http://support.chamilo.org/issues/3600
* http://php.net/manual/en/session.configuration.php
* @todo use session_set_cookie_params with some custom admin parameters
@ -88,12 +97,12 @@ class ChamiloSession extends System\Session
//the session ID is only accepted from a cookie
ini_set('session.use_only_cookies', 1);
//HTTPS only if possible
//HTTPS only if possible
//ini_set('session.cookie_secure', 1);
//session ID in the cookie is only readable by the server
//session ID in the cookie is only readable by the server
ini_set('session.cookie_httponly', 1);
//Use entropy file
//Use entropy file
//session.entropy_file
//ini_set('session.entropy_length', 128);
//Do not include the identifier in the URL, and not to read the URL for identifiers.
@ -107,8 +116,10 @@ class ChamiloSession extends System\Session
if ($already_installed) {
if (!isset($session['checkChamiloURL'])) {
$session['checkChamiloURL'] = api_get_path(WEB_PATH);
} else if ($session['checkChamiloURL'] != api_get_path(WEB_PATH)) {
self::clear();
} else {
if ($session['checkChamiloURL'] != api_get_path(WEB_PATH)) {
self::clear();
}
}
}
@ -119,7 +130,7 @@ class ChamiloSession extends System\Session
/**
* Session start time: that is the last time the user accesseed the application.
*
*
* @return int timestamp
*/
function start_time()
@ -129,20 +140,21 @@ class ChamiloSession extends System\Session
/**
* Session end time: when the session expires.
*
*
* @return int timestamp
*/
function end_time()
{
$start_time = $this->start_time();
$lifetime = self::session_lifetime();
return $start_time + $lifetime;
}
/**
* Returns true if the session is stalled. I.e. if session end time is
* greater than now. Returns false otherwise.
*
*
* @return bool
*/
function is_stalled()
@ -161,7 +173,7 @@ class ChamiloSession extends System\Session
/**
* The current (logged in) user.
*
*
* @return CurrentUser
*/
public function user()
@ -170,9 +182,10 @@ class ChamiloSession extends System\Session
if (empty($result)) {
$result = CurrentUser::instance();
}
return $result;
}
/**
*
* @return CurrentCourse
@ -183,14 +196,14 @@ class ChamiloSession extends System\Session
if (empty($result)) {
$result = CurrentCourse::instance();
}
return $result;
}
/**
* The current group for the current (logged in) user.
*
*
* @return int
*/
public function group_id()

File diff suppressed because it is too large Load Diff

@ -27,6 +27,8 @@ define('MAX_FORM_FIELD_LENGTH', 80);
require_once '../inc/global.inc.php';
require_once __DIR__.'../../../vendor/autoload.php';
require_once 'install.lib.php';
require_once 'i_database.class.php';
@ -130,7 +132,6 @@ if (!empty($_POST['old_version'])) {
require_once __DIR__.'/version.php';
// A protection measure for already installed systems.
if (is_already_installed_system()) {

@ -981,7 +981,8 @@ function get_sql_file_contents($file, $section, $print_errors = true)
* @param string $title
* @return id if inserted document
*/
function FileManager::add_document_180($_course, $path, $filetype, $filesize, $title, $comment = null){
function add_document_180($_course, $path, $filetype, $filesize, $title, $comment = null)
{
$table_document = Database::get_course_table(TABLE_DOCUMENT, $_course['dbName']);
$sql = "INSERT INTO $table_document
(`path`,`filetype`,`size`,`title`, `comment`)
@ -1029,17 +1030,6 @@ function display_language_selection_box($name = 'language_list', $default_langua
// Reading language list.
$language_list = get_language_folder_list();
/*
// Reduction of the number of languages shown. Enable this fragment of code for customization purposes.
// Modify the language list according to your preference. Don't exclude the 'english' item.
$language_to_display = array('asturian', 'bulgarian', 'english', 'italian', 'french', 'slovenian', 'slovenian_unicode', 'spanish');
foreach ($language_list as $key => & $value) {
if (!in_array($key, $language_to_display)) {
unset($language_list[$key]);
}
}
*/
// Sanity checks due to the possibility for customizations.
if (!is_array($language_list) || empty($language_list)) {
$language_list = array('english' => 'English');

@ -70,9 +70,9 @@ if (!is_dir($app['assetic.path_to_web'].'/js')) {
*
*/
if (!is_dir($app['db.orm.proxies_dir'])) {
mkdir($app['db.orm.proxies_dir'], api_get_permissions_for_new_directories());
@mkdir($app['db.orm.proxies_dir'], api_get_permissions_for_new_directories());
}
if (!is_dir($app['cache.path'].'twig')) {
mkdir($app['cache.path'].'twig', api_get_permissions_for_new_directories());
@mkdir($app['cache.path'].'twig', api_get_permissions_for_new_directories());
}
Loading…
Cancel
Save