WIP fix vchamilo plugin fix SYS_ARCHIVE_PATH, SYS_HOME_PATH and SYS_COURSE_PATH using another DB.

ofaj
jmontoyaa 10 years ago
parent 356522a410
commit d8161fa528
  1. 21
      main/inc/lib/api.lib.php
  2. 44
      plugin/vchamilo/lib.php
  3. 26
      plugin/vchamilo/readme.txt
  4. 9
      plugin/vchamilo/views/syncparams.controller.php

@ -739,12 +739,6 @@ function api_get_path($path = '', $configuration = [])
$paths[$root_web][REL_COURSE_PATH] = $root_rel.$course_folder;
$paths[$root_web][REL_DEFAULT_COURSE_DOCUMENT_PATH] = $paths[$root_web][REL_PATH].'main/default_course_document/';
// PATCH : Take VChamilo into account
/*global $VCHAMILO;
if (!empty($VCHAMILO) || !empty($configuration['virtual'])){
$paths[$root_web][SYS_ARCHIVE_PATH] .= $web_host.'/';
$paths[$root_web][SYS_HOME_PATH] .= $web_host.'/';
}*/
$paths[$root_web][WEB_PATH] = $slashed_root_web;
$paths[$root_web][WEB_CODE_PATH] = $slashed_root_web.$code_folder;
$paths[$root_web][WEB_COURSE_PATH] = $slashed_root_web.$course_folder;
@ -752,6 +746,7 @@ function api_get_path($path = '', $configuration = [])
$paths[$root_web][WEB_APP_PATH] = $paths[$root_web][WEB_PATH].$paths[$root_web][WEB_APP_PATH];
$paths[$root_web][WEB_PLUGIN_PATH] = $paths[$root_web][WEB_PATH].$paths[$root_web][WEB_PLUGIN_PATH];
$paths[$root_web][WEB_ARCHIVE_PATH] = $paths[$root_web][WEB_PATH].$paths[$root_web][WEB_ARCHIVE_PATH];
$paths[$root_web][WEB_CSS_PATH] = $paths[$root_web][WEB_PATH].$paths[$root_web][WEB_CSS_PATH];
$paths[$root_web][WEB_IMG_PATH] = $paths[$root_web][WEB_CODE_PATH].$paths[$root_web][WEB_IMG_PATH];
$paths[$root_web][WEB_LIBRARY_PATH] = $paths[$root_web][WEB_CODE_PATH].$paths[$root_web][WEB_LIBRARY_PATH];
@ -779,16 +774,16 @@ function api_get_path($path = '', $configuration = [])
$paths[$root_web][SYS_PLUGIN_PATH] = $paths[$root_web][SYS_PATH].$paths[$root_web][SYS_PLUGIN_PATH];
$paths[$root_web][SYS_INC_PATH] = $paths[$root_web][SYS_CODE_PATH].$paths[$root_web][SYS_INC_PATH];
/*// ADD : Take VChamilo into account
global $VCHAMILO;
if (!empty($VCHAMILO) || !empty($configuration['virtual'])) {
$paths[$root_web][WEB_ARCHIVE_PATH] .= $web_host.'/';
$paths[$root_web][WEB_HOME_PATH] .= $web_host.'/';
}*/
$paths[$root_web][LIBRARY_PATH] = $paths[$root_web][SYS_CODE_PATH].$paths[$root_web][LIBRARY_PATH];
$paths[$root_web][CONFIGURATION_PATH] = $paths[$root_web][SYS_PATH].$paths[$root_web][CONFIGURATION_PATH];
global $VCHAMILO;
if (!empty($VCHAMILO)) {
$paths[$root_web][SYS_ARCHIVE_PATH] = $VCHAMILO[SYS_ARCHIVE_PATH];
$paths[$root_web][SYS_HOME_PATH] = $VCHAMILO[SYS_HOME_PATH];
$paths[$root_web][SYS_COURSE_PATH] = $VCHAMILO[SYS_COURSE_PATH];
}
$isInitialized[$root_web] = true;
}

@ -16,13 +16,12 @@ function vchamilo_hook_configuration(&$_configuration)
// provides an effective value for the virtual root_web based on domain analysis
vchamilo_get_hostname($_configuration);
//$plugin = VChamiloPlugin::create();
// We are on physical chamilo. Let original config play
$virtualChamiloWebRoot = $_configuration['vchamilo_web_root'].'/';
if ($_configuration['root_web'] == $virtualChamiloWebRoot){
$VCHAMILO = 'main';
if ($_configuration['root_web'] == $virtualChamiloWebRoot) {
$VCHAMILO = [];
return;
}
@ -37,16 +36,47 @@ function vchamilo_hook_configuration(&$_configuration)
$excludes = array('id', 'name');
$query = "SELECT * FROM settings_current WHERE subkey = 'vchamilo'";
$virtualSettings = $connection->executeQuery($query);
$virtualSettings = $virtualSettings->fetchAll();
$homePath = '';
$coursePath = '';
$archivePath = '';
foreach ($virtualSettings as $setting) {
switch ($setting['variable']) {
case 'vchamilo_home_real_root':
$homePath = $setting['selected_value'];
break;
case 'vchamilo_course_real_root':
$coursePath = $setting['selected_value'];
break;
case 'vchamilo_archive_real_root':
$archivePath = $setting['selected_value'];
break;
}
}
if (empty($homePath) || empty($coursePath) || empty($archivePath)) {
echo 'Configure correctly the vchamilo plugin';
exit;
}
if ($result->rowCount()) {
$data = $result->fetch();
foreach ($data as $key => $value){
if (!in_array($key, $excludes)){
if (!in_array($key, $excludes)) {
$_configuration[$key] = $value;
}
$_configuration['virtual'] = $data['root_web'].'/';
$VCHAMILO = $data['root_web'];
}
$data['SYS_ARCHIVE_PATH'] = $homePath.'/'.$data['slug'];
$data['SYS_HOME_PATH'] = $coursePath.'/'.$data['slug'];
$data['SYS_COURSE_PATH'] = $archivePath.'/'.$data['slug'];
$VCHAMILO = $data;
} else {
//die ("VChamilo : No configuration for this host. May be faked.");
die ("VChamilo : Could not fetch virtual chamilo configuration");

@ -9,22 +9,22 @@ code base.
Version features
##############################
This is a yet prototypal version that is not full featured in back-office tools.
At the moment, the setup of virtual clones still is a technical operation and has no
At the moment, the setup of virtual clones still is a technical operation and has no
middle-office GUI. Developement is in progress to offer a sufficiant medium-level
administrability of the process.
How to setup :
How to setup :
##############################
You need :
You need :
1/ Install the vchamilo package into the <chamiloroot>/plugin directory
2/ Install the plugin in chamilo administration
3/ Insert the virtualisation hook into the chamilo master configuration :
3/ Insert the virtualisation hook into the chamilo master configuration :
file : <chamiloroot>/main/inc/config/configure.php
file : <chamiloroot>/app/config/configuration.php
insert the hook:
insert the hook:
include_once $_configuration['root_sys'].'plugin/vchamilo/lib.php';
vchamilo_hook_configuration($_configuration);
@ -35,13 +35,13 @@ just before the login module section :
<here>
/**
*
*
* Login modules settings
*/
Setup of virtual nodes :
Setup of virtual nodes :
what you need for a virtual node is :
what you need for a virtual node is :
- a blank database copy of chamilo
- a dedicated course directory, that needs being accessible from chamilo installation root (directly, or using symlinks). the name
@ -49,24 +49,24 @@ of this directory is free, as it will be mapped into the vchamilo record.
- a dedicated home page directory, that is located into <chamiloroot>/home directory and is named
as the chamilo instance domain name.
- a vchamilo record into the vchamilo table of the master installation. (the master installation is the install that refers to
the effective "configuration.php" information.
the effective "configuration.php" information.
- an appropriate multiroot home root setup in the local chamilo instance
# Prerequisites for VCHamilo working nice
Multiple URL access must be enabled :
Multiple URL access must be enabled :
# in <chamiloroot>/main/inc/config/configuration.php
$_configuration['multiple_access_urls'] = true;
In the administration, you will need configure an adequate home root definition for the instance finding
the dedicated home directory. You just need editing the http://localhost default host, and give the real domain
name you are using.
name you are using.
Check you have the <chamilo>/home/<instancedomain> clone of the standard home directory.
# Important note about file system permissions
Vchamilos will use several side-directories apart from the standard installation (dedicated courses,
Vchamilos will use several side-directories apart from the standard installation (dedicated courses,
dedicated home page). Check you set the adequate filesystem permissions (usually let the server write
in there) for them.

@ -72,10 +72,11 @@ if ($action == 'syncthis') {
foreach ($vchamilos as $vcid => $chm) {
$table = $chm['main_database'].".settings_current";
if ($delifempty && empty($value)) {
$sql = "DELETE FROM $table WHERE
selected_value = '$value' AND
variable = '{{$setting['variable']}}' AND
access_url = '{$setting['access_url']}'
$sql = "DELETE FROM $table
WHERE
selected_value = '$value' AND
variable = '{{$setting['variable']}}' AND
access_url = '{$setting['access_url']}'
";
Database::query($sql);

Loading…
Cancel
Save