Replacing root_sys with api_get_path(SYS_PATH), setting sys path in global inc instead of api_get_path() changing some other paths due the new "data" folder see #6104

skala
Julio Montoya 13 years ago
parent 4d89dc9d04
commit 4f50329704
  1. 10
      main/inc/global.inc.php
  2. 4
      main/inc/lib/fck_course_document.inc.php
  3. 97
      main/inc/lib/fckeditor/editor/plugins/ImageManager/config.inc.php
  4. 1
      main/inc/lib/fckeditor/editor/plugins/ImageManager/images.php
  5. 6
      main/inc/lib/main_api.lib.php
  6. 90
      main/install/configuration.dist.yml.php
  7. 3
      main/install/install.lib.php
  8. 6
      main/newscorm/learnpath.class.php
  9. 2
      main/newscorm/resourcelinker.php
  10. 2
      main/resourcelinker/resourcelinker.php
  11. 4
      main/work/work.php
  12. 1
      src/ChamiloLMS/Command/Database/InstallCommand.php
  13. 2
      src/ChamiloLMS/Command/Database/StatusCommand.php
  14. 4
      src/ChamiloLMS/Command/Database/UpgradeCommand.php
  15. 10
      src/ChamiloLMS/Resources/config/prod.php

@ -38,6 +38,14 @@ use Symfony\Component\Yaml\Parser;
// Start Silex
$app = new Application();
// Setting paths
$app['root_sys'] = dirname(dirname(__DIR__)).'/';
$app['sys_data_path'] = $app['root_sys'].'data/';
$app['sys_config_path'] = $app['root_sys'].'config/';
$app['sys_temp_path'] = $app['root_sys'].'temp/';
$app['sys_log_path'] = $app['root_sys'].'logs/';
// @todo add a helper to read the configuration file once!
// Reading configuration file from main/inc/conf/configuration.php or app/config/configuration.yml
@ -90,6 +98,8 @@ if (file_exists($configurationYMLFile)) {
// Include the main Chamilo platform library file.
require_once $includePath.'/lib/main_api.lib.php';
// Setting url_append
$_configuration['url_append'] = '/'.basename(str_replace(api_get_path(WEB_SERVER_ROOT_PATH), '', api_get_path(WEB_PATH)));
// Inclusion of internationalization libraries
require_once $includePath.'/lib/internationalization.lib.php';

@ -63,8 +63,8 @@ if (api_is_in_course()) {
} else {
if (api_is_platform_admin() && $_SESSION['this_section'] == 'platform_admin') {
// 3. Platform administration activities.
$base_work_dir = $_configuration['root_sys'].'home/default_platform_document/';
$http_www = $_configuration['root_web'].'home/default_platform_document/';
$base_work_dir = api_get_path(SYS_DATA_PATH).'default_platform_document/';
$http_www = api_get_path(WEB_PUBLIC_PATH).'data/default_platform_document/';
} else {
// 4. The user is outside courses.
$my_path = UserManager::get_user_picture_path_by_id(api_get_user_id(),'system');

@ -33,56 +33,47 @@ include '../../../../../../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'fckeditor/repository.php';
// Choosing the repository to be used.
if (api_is_in_course())
{
if (!api_is_in_group())
{
// 1. We are inside a course and not in a group.
if (api_is_allowed_to_edit())
{
// 1.1. Teacher
$IMConfig['base_dir'] = api_get_path(SYS_COURSE_PATH).api_get_course_path().'/document/';
$IMConfig['base_url'] = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/';
}
else
{
// 1.2. Student
$current_session_id = api_get_session_id();
if($current_session_id==0)
{
$IMConfig['base_dir'] = api_get_path(SYS_COURSE_PATH).api_get_course_path().'/document/shared_folder/sf_user_'.api_get_user_id().'/';
$IMConfig['base_url'] = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/shared_folder/sf_user_'.api_get_user_id().'/';
}
else
{
$IMConfig['base_dir'] = api_get_path(SYS_COURSE_PATH).api_get_course_path().'/document/shared_folder_session_'.$current_session_id.'/sf_user_'.api_get_user_id().'/';
$IMConfig['base_url'] = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/shared_folder_session_'.$current_session_id.'/sf_user_'.api_get_user_id().'/';
}
}
}
else
{
// 2. Inside a course and inside a group.
$IMConfig['base_dir'] = api_get_path(SYS_COURSE_PATH).api_get_course_path().'/document'.$group_properties['directory'].'/';
$IMConfig['base_url'] = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document'.$group_properties['directory'].'/';
}
}
else
{
if (api_is_platform_admin() && $_SESSION['this_section'] == 'platform_admin')
{
// 3. Platform administration activities.
$IMConfig['base_dir'] = $_configuration['root_sys'].'home/default_platform_document/';
$IMConfig['base_url'] = $_configuration['root_web'].'home/default_platform_document/';
}
else
{
// 4. The user is outside courses.
$my_path = UserManager::get_user_picture_path_by_id(api_get_user_id(),'system');
$IMConfig['base_dir'] = $my_path['dir'].'my_files/';
$my_path = UserManager::get_user_picture_path_by_id(api_get_user_id(),'web');
$IMConfig['base_url'] = $my_path['dir'].'my_files/';
}
if (api_is_in_course()) {
if (!api_is_in_group()) {
// 1. We are inside a course and not in a group.
if (api_is_allowed_to_edit()) {
// 1.1. Teacher
$IMConfig['base_dir'] = api_get_path(SYS_COURSE_PATH).api_get_course_path().'/document/';
$IMConfig['base_url'] = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/';
} else {
// 1.2. Student
$current_session_id = api_get_session_id();
if ($current_session_id == 0) {
$IMConfig['base_dir'] = api_get_path(SYS_COURSE_PATH).api_get_course_path(
).'/document/shared_folder/sf_user_'.api_get_user_id().'/';
$IMConfig['base_url'] = api_get_path(WEB_COURSE_PATH).api_get_course_path(
).'/document/shared_folder/sf_user_'.api_get_user_id().'/';
} else {
$IMConfig['base_dir'] = api_get_path(SYS_COURSE_PATH).api_get_course_path(
).'/document/shared_folder_session_'.$current_session_id.'/sf_user_'.api_get_user_id().'/';
$IMConfig['base_url'] = api_get_path(WEB_COURSE_PATH).api_get_course_path(
).'/document/shared_folder_session_'.$current_session_id.'/sf_user_'.api_get_user_id().'/';
}
}
} else {
// 2. Inside a course and inside a group.
$IMConfig['base_dir'] = api_get_path(SYS_COURSE_PATH).api_get_course_path(
).'/document'.$group_properties['directory'].'/';
$IMConfig['base_url'] = api_get_path(WEB_COURSE_PATH).api_get_course_path(
).'/document'.$group_properties['directory'].'/';
}
} else {
if (api_is_platform_admin() && $_SESSION['this_section'] == 'platform_admin') {
// 3. Platform administration activities.
$IMConfig['base_dir'] = api_get_path(SYS_DATA).'default_platform_document/';
$IMConfig['base_url'] = api_get_path(WEB_PUBLIC_PATH).'data/default_platform_document/';
} else {
// 4. The user is outside courses.
$my_path = UserManager::get_user_picture_path_by_id(api_get_user_id(), 'system');
$IMConfig['base_dir'] = $my_path['dir'].'my_files/';
$my_path = UserManager::get_user_picture_path_by_id(api_get_user_id(), 'web');
$IMConfig['base_url'] = $my_path['dir'].'my_files/';
}
}
$IMConfig['server_name'] = $_SERVER['SERVER_NAME'];
@ -236,7 +227,7 @@ $IMConfig['watermarks'] = array();
//$IMConfig['maxHeight'][0] = 333;
//$IMConfig['maxWidth'][1] = 100;
//$IMConfig['maxHeight'][1] = 180;
$IMConfig['maxWidth'][0] = 0;
$IMConfig['maxWidth'][0] = 0;
$IMConfig['maxHeight'][0] = 0;
@ -267,7 +258,7 @@ $IMConfig['default_thumbnail'] = 'img/default.gif';
/*
Thumbnail dimensions.
*/
$IMConfig['thumbnail_width'] = 96;
$IMConfig['thumbnail_width'] = 96;
$IMConfig['thumbnail_height'] = 96;
/*
@ -278,5 +269,5 @@ $IMConfig['tmp_prefix'] = '.editor_';
/*
Language and text direction.
*/
$IMConfig['language'] = api_get_language_isocode();
$IMConfig['language'] = api_get_language_isocode();
$IMConfig['text_direction'] = api_get_text_direction($IMConfig['language']);

@ -57,7 +57,6 @@ function drawFiles($list, &$manager) {
$in_course = $course_id != -1 ? true : false;
foreach ($list as $entry => $file) {
//$chamiloPath = '/'.$_configuration['url_append'].'/courses/'.api_get_course_path().'/document'.$file['relative'];
?>
<td><table width="100" cellpadding="0" cellspacing="0"><tr><td class="block">
<!-- change <?php echo $file['relative'];?> with <?php echo $chamiloPath; ?>

@ -495,6 +495,7 @@ define ('SKILL_TYPE_BOTH', 'both');
* ...
*/
function api_get_path($path_type, $path = null) {
global $app;
static $paths = array(
WEB_PATH => '',
@ -556,7 +557,8 @@ function api_get_path($path_type, $path = null) {
$root_web = isset($_configuration['root_web']) ? $_configuration['root_web'] : null;
// Configuration data for already installed system.
$root_sys = isset($_configuration['root_sys']) ? $_configuration['root_sys'] : realpath(dirname(__FILE__).'/../../../');
$root_sys = isset($_configuration['root_sys']) ? $_configuration['root_sys'] : $app['root_sys'];
$load_new_config = false;
// To avoid that the api_get_access_url() function fails since global.inc.php also calls the main_api.lib.php
@ -570,8 +572,6 @@ function api_get_path($path_type, $path = null) {
}
if (!$is_this_function_initialized) {
//$root_rel = isset($_configuration['url_append']) ? $_configuration['url_append'] : null;
$root_rel = "/".basename($root_sys);
$code_folder = 'main/';

@ -3,7 +3,7 @@
// File generated by /install/index.php script - {DATE_GENERATED}
/* For licensing terms, see /license.txt */
/**
* Virtual campus configuration
* Chamilo configuration
*
* This file contains a list of variables that can be modified by the campus
* site's server administrator. Pay attention when changing these variables,
@ -21,8 +21,6 @@
* contains variables that can be changed and will not break the platform.
* These optional settings are defined in the database, now
* (table settings_current).
* example: $_configuration['tracking_enabled'] (assuming that the install
* script creates the necessary tables anyway).
*/
/**
@ -50,90 +48,11 @@ $_configuration['main_database'] = 'chamilo';
/**
* Directory settings
*/
// Path to the webroot of system, example: /var/www/
$_configuration['root_sys'] = getcwd().'/';
// Path from your WWW-root to the root of your Chamilo installation, example: chamilo (this means chamilo is installed in /var/www/chamilo/
$_configuration['url_append'] = '/'.basename(getcwd());
// URL to the root of your Chamilo installation, e.g.: http://www.mychamilo.com/
$_configuration['root_web'] = 'http://localhost'.$_configuration['url_append'];
// Directory of the Chamilo code. You could change this but it is not advised since this has not been tested yet.
$_configuration['code_append'] = "main/";
// Directory to store all course-related files. You could change this but it is not advised since this has not been tested yet.
$_configuration['course_folder'] = "courses/";
// URL to your phpMyAdmin installation.
// If not empty, a link will be available in the Platform Administration
$_configuration['db_admin_path'] = '';
/**
*
* Login modules settings
*/
// CAS IMPLEMENTATION
// -> Go to your portal Chamilo > Administration > CAS to activate CAS
// You can leave these lines uncommented even if you don't use CAS authentification
$extAuthSource["cas"]["login"] = $_configuration['root_sys'].$_configuration['code_append']."auth/cas/login.php";
$extAuthSource["cas"]["newUser"] = $_configuration['root_sys'].$_configuration['code_append']."auth/cas/newUser.php";
//
// NEW LDAP IMPLEMENTATION BASED ON external_login info
// -> Uncomment the two lines bellow to activate LDAP AND edit main/auth/external_login/ldap.conf.php for configuration
// $extAuthSource["extldap"]["login"] = $_configuration['root_sys'].$_configuration['code_append']."auth/external_login/login.ldap.php";
// $extAuthSource["extldap"]["newUser"] = $_configuration['root_sys'].$_configuration['code_append']."auth/external_login/newUser.ldap.php";
//
// FACEBOOK IMPLEMENTATION BASED ON external_login info
// -> Uncomment the line bellow to activate Facebook Auth AND edit main/auth/external_login/ldap.conf.php for configuration
// $_configuration['facebook_auth'] = 1;
//
// OTHER EXTERNAL LOGIN INFORMATION
// To fetch external login information, uncomment those 2 lines and modify files auth/external_login/newUser.php and auth/external_login/updateUser.php files
// $extAuthSource["external_login"]["newUser"] = $_configuration['root_sys'].$_configuration['code_append']."auth/external_login/newUser.php";
// $extAuthSource["external_login"]["updateUser"] = $_configuration['root_sys'].$_configuration['code_append']."auth/external_login/updateUser.php";
$_configuration['root_web'] = 'http://localhost/chamilo';
/**
*
* Hosting settings - Allows you to set limits to the Chamilo portal when
* hosting it for a third party. These settings can be overwritten by an
* optionally-loaded extension file with only the settings (no comments).
* The settings use an index at the first level to represent the ID of the
* URL in case you use multi-url (otherwise it will always use 1, which is
* the ID of the only URL inside the access_url table).
*/
// Set a maximum number of users. Default (0) = no limit
$_configuration[1]['hosting_limit_users'] = 0;
// Set a maximum number of teachers. Default (0) = no limit
$_configuration[1]['hosting_limit_teachers'] = 0;
// Set a maximum number of courses. Default (0) = no limit
$_configuration[1]['hosting_limit_courses'] = 0;
// Set a maximum number of sessions. Default (0) = no limit
$_configuration[1]['hosting_limit_sessions'] = 0;
// Set a maximum disk space used, in MB (set to 1024 for 1GB, 5120 for 5GB).
// Default (0) = no limit
$_configuration[1]['hosting_limit_disk_space'] = 0;
/**
* Content Delivery Network (CDN) settings. Only use if you need a separate
* server to serve your static data. If you don't know what a CDN is, you
* don't need it. These settings are for simple Origin Pull CDNs and are
* experimental. Enable only if you really know what you're doing.
* This might conflict with multiple-access urls.
*/
// Set the following setting to true to start using the CDN
$_configuration['cdn_enable'] = false;
// The following setting will be ignored if the previous one is set to false
$_configuration['cdn'] = array(
//You can define several CDNs and split them by extensions
//Replace the following by your full CDN URL, which should point to
// your Chamilo's root directory. DO NOT INCLUDE a final slash! (won't work)
'http://cdn.chamilo.org' => array('.css','.js','.jpg','.jpeg','.png','.gif','.avi','.flv'),
// copy the line above and modify following your needs
);
/**
* Misc. settings
*/
@ -147,10 +66,7 @@ $_configuration['session_stored_in_db'] = false;
$_configuration['session_lifetime'] = 3600;
// Activation for multi-url access
//$_configuration['multiple_access_urls'] = true;
$_configuration['software_name'] = 'Chamilo';
$_configuration['software_url'] = 'http://www.chamilo.org/';
//Deny the elimination of users
$_configuration['deny_delete_users'] = false;
// Version settings
$_configuration['system_version'] = '1.10';
$_configuration['system_stable'] = '1.10';
$_configuration['system_version'] = '1.10';

@ -10,7 +10,7 @@
* of older versions before upgrading.
*/
/* CONSTANTS */
/* CONSTANTS */
define('SYSTEM_MAIN_DATABASE_FILE', $new_version.'/db_main.sql');
define('COUNTRY_DATA_FILENAME', 'country_data.csv');
@ -306,7 +306,6 @@ function write_courses_htaccess_file($url_append)
*/
function write_system_config_file($path)
{
global $dbHostForm;
global $dbUsernameForm;
global $dbPassForm;

@ -6414,11 +6414,7 @@ class learnpath
$file = $filepath.$row['path'];
if ($fp = @ fopen($file, 'w')) {
$content = str_replace(
api_get_path(WEB_COURSE_PATH),
$_configuration['url_append'].'/courses/',
$content
);
$content = str_replace(api_get_path(WEB_COURSE_PATH), $_configuration['url_append'].'/courses/',$content);
// Change the path of mp3 to absolute.
// The first regexp deals with ../../../ urls.

@ -775,7 +775,7 @@ if ($content == 'Document' || (empty($content) && (api_is_allowed_to_edit() || i
))) && !$_GET['showresources']
) {
// setting variables for file locations
$baseServDir = $_configuration['root_sys'];
$baseServDir = api_get_path(SYS_PATH);
$courseDir = $_course['path'].'/document';
$baseWorkDir = $baseServDir.$courseDir;
// showing the link to move one folder up (when not in the root folder)

@ -680,7 +680,7 @@ if ($content == "Document" OR (empty($content) AND (api_is_allowed_to_edit() OR
))) AND !$_GET['showresources']
) {
// setting variables for file locations
$baseServDir = $_configuration['root_sys'];
$baseServDir = api_get_path(SYS_PATH);
$courseDir = $_course['path']."/document";
$baseWorkDir = $baseServDir.$courseDir;
// showing the link to move one folder up (when not in the root folder)

@ -440,9 +440,9 @@ switch ($action) {
$show_progress_bar = false;
if ($submitGroupWorkUrl) {
// For user comming from group space to publish his work
// For user coming from group space to publish his work
$realUrl = str_replace(
$_configuration['root_sys'],
api_get_path(SYS_PATH),
api_get_path(WEB_PATH),
str_replace("\\", '/', realpath($submitGroupWorkUrl))
);

@ -193,7 +193,6 @@ class InstallCommand extends CommonCommand
//'main_database', //default is chamilo
'db_glue',
'table_prefix',
'code_append',
'course_folder',
'db_admin_path',
'cdn_enable',

@ -33,7 +33,7 @@ class StatusCommand extends AbstractCommand
{
global $_configuration;
if (!isset($_configuration['root_sys'])) {
if (empty($_configuration)) {
$output->writeln("<comment>Chamilo is not installed here!</comment>");
exit;
}

@ -49,7 +49,7 @@ class UpgradeCommand extends CommonCommand
$_configuration = $this->getHelper('configuration')->getConfiguration();
if (!isset($_configuration['root_sys'])) {
if (empty($_configuration)) {
$output->writeln("<comment>Chamilo is not installed here!</comment>");
exit;
}
@ -85,7 +85,7 @@ class UpgradeCommand extends CommonCommand
$currentVersion = null;
//Checking root_sys and correct Chamilo version to install
if (!isset($_configuration['root_sys'])) {
if (empty($_configuration)) {
$output->writeln("<comment>Can't migrate Chamilo. This is not a Chamilo folder installation.</comment>");
exit;
}

@ -6,14 +6,14 @@ $app['app.title'] = '';
$app['jquery_ui_theme'] = 'smoothness';
// Temp folder
$app['temp.path'] = api_get_path(SYS_ARCHIVE_PATH);
$app['temp.path'] = $app['sys_temp_path'];
$app['temp.paths'] = new stdClass();
$app['temp.paths']->folders[] = $app['data.path'] = api_get_path(SYS_DATA_PATH);
$app['temp.paths']->folders[] = $app['sys_data_path'];
//Monolog
$app['temp.paths']->folders[] = $app['log.path'] = api_get_path(SYS_LOG_PATH);
$app['temp.paths']->folders[] = $app['sys_log_path'];
//Twig cache
$app['temp.paths']->folders[] = $app['twig.cache.path'] = $app['temp.path'].'twig';
@ -111,8 +111,8 @@ foreach ($app['temp.paths']->folders as $folder) {
}
}
//Monolog log file
$app['chamilo.log'] = $app['log.path'].'/chamilo.log';
// Monolog log file
$app['chamilo.log'] = $app['sys_log_path'].'/chamilo.log';
if (is_file($app['chamilo.log']) && !is_writable($app['chamilo.log'])) {
unlink($app['chamilo.log']);

Loading…
Cancel
Save