WIP: vchamilo fixes see BT#11051

remotes/angel/1.11.x
jmontoyaa 9 years ago
parent dfa2039616
commit 8f9f57abb5
  1. 24
      plugin/vchamilo/README.md
  2. 19
      plugin/vchamilo/lang/english.php
  3. 19
      plugin/vchamilo/lang/french.php
  4. 2
      plugin/vchamilo/lang/spanish.php
  5. 96
      plugin/vchamilo/lib.php
  6. 16
      plugin/vchamilo/views/editinstance.controller.php
  7. 1
      plugin/vchamilo/views/editinstance.php
  8. 77
      plugin/vchamilo/views/editinstance_form.php
  9. 22
      plugin/vchamilo/views/manage.controller.php
  10. 20
      plugin/vchamilo/views/manage.php
  11. 48
      plugin/vchamilo/views/manage.testcnx.php

@ -13,7 +13,7 @@ At the moment, the setup of virtual clones still is a technical operation and ha
middle-office GUI. Development is in progress to offer a sufficient medium-level
administrability of the process.
How to setup :
How to setup
===================
You need :
@ -22,26 +22,19 @@ You need :
2. Install the plugin in chamilo administration
3. Insert the virtualisation hook into the chamilo master configuration :
```
file : <chamiloroot>/app/config/configuration.php
```
Insert the hook:
```
include_once $_configuration['root_sys'].'plugin/vchamilo/lib.php';
vchamilo_hook_configuration($_configuration);
```
This should be inserted just after the definition of db_admin_path and
just before the login module section :
<here>
/**
*
* Login modules settings
*/
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
@ -55,7 +48,8 @@ the effective "configuration.php" information.
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;

@ -23,10 +23,10 @@ $strings['datapathavailable'] = 'Data path is available and ready to be used as
$strings['datapathnotavailable'] = 'Data path exists but has already files in it at <br/>';
$strings['datapathcreated'] = 'Data path has been created as :<br/>';
$strings['dbgroup'] = 'Database Settings';
$strings['dbhost'] = 'DB Host';
$strings['dbpassword'] = 'DB Password';
$strings['dbhost'] = 'Host';
$strings['dbpassword'] = 'Password';
$strings['dbprefix'] = 'Database prefix';
$strings['dbuser'] = 'DB Username';
$strings['dbuser'] = 'Username';
$strings['deleteifempty'] = 'Delete if empty';
$strings['deleteinstances'] = 'Remove instance';
$strings['destroyinstances'] = 'Full delete instance';
@ -43,7 +43,7 @@ $strings['hostdefinition'] = 'Host definition';
$strings['hostlist'] = 'Other hosts';
$strings['institution'] = 'Institution';
$strings['lastcron'] = 'Last cron';
$strings['maindatabase'] = 'Main database';
$strings['maindatabase'] = 'Database name';
$strings['manage_instances'] = 'Go to instance manager';
$strings['newinstance'] = 'Add new instance';
$strings['no'] = 'No';
@ -67,9 +67,8 @@ $strings['sync_settings'] = 'Synchronize settings';
$strings['tableprefix'] = 'Table prefix';
$strings['template'] = 'Template';
$strings['templating'] = 'Templating';
$strings['testconnection'] = 'Test DB connexion';
$strings['testconnection'] = 'Test database connexion';
$strings['testdatapath'] = 'Test data location';
$strings['trackingenabled'] = 'Tracking enabled';
$strings['userpersonaldatabase'] = 'User personal database';
$strings['vchamilo'] = 'Virtual Chamilo';
$strings['vchamilosnapshot1'] = 'STEP 1 OF 3 : Directories for snapshot have been created. Continue with database backup ...';
@ -101,3 +100,11 @@ $strings['accessurl'] = 'Access URL';
$strings['value'] = 'Value';
$strings['syncall'] = 'Sync all the selection';
$strings['syncthis'] = 'Sync this setting';
$strings['SiteNameExample'] = 'Example: Chamilo';
$strings['InstitutionExample'] = 'Example: Chamilo Association';
$strings['RootWebExample'] = 'Example: http://www.chamilo.org/';
$strings['DatabaseDescription'] = 'A new database will be created with that name.';
$strings['RootWebExists'] = 'An instance with the same root web exists.';

@ -39,7 +39,7 @@ $strings['hostdefinition'] = 'Définition d\'hôte';
$strings['hostlist'] = 'Les sites du réseau';
$strings['institution'] = 'Institution';
$strings['lastcron'] = 'Dernier cron';
$strings['maindatabase'] = 'Base de données principale';
$strings['maindatabase'] = 'Nom du base de données';
$strings['manage_instances'] = 'Aller au gestionnaire d\'instances';
$strings['sync_settings'] = 'Synchroniser des réglages';
$strings['deleteifempty'] = 'Supprimer la clef si vide';
@ -67,11 +67,10 @@ $strings['template'] = 'Modèle';
$strings['templating'] = 'Templating';
$strings['testconnection'] = "Test de la connexion";
$strings['testdatapath'] = "Test de l'emplacement de données";
$strings['trackingenabled'] = "Tracking activé";
$strings['userpersonaldatabase'] = 'base de données des données personnelles';
$strings['vchamilo'] = 'Chamilo Virtuel';
$strings['vchamilosnapshot1'] = 'ETAPE 1 DE 3 : Les répertoires de snapshot ont été créés. contibuer avec la capture des bases...';
$strings['vchamilosnapshot2'] = 'ETAPE 2 DE 3 : Les bases ont été capturées. continuer avec la récupération des fichiers d\'usage... Attention, cette étape peut être longue si la plate-forme est fortement chargée en documents...';
$strings['vchamilosnapshot1'] = 'ETAPE 1 DE 3 : Les répertoires de snapshot ont été créés. Continuer avec la capture des bases...';
$strings['vchamilosnapshot2'] = 'ETAPE 2 DE 3 : Les bases ont été capturées. Continuer avec la récupération des fichiers d\'usage... Attention, cette étape peut être longue si la plate-forme est fortement chargée en documents...';
$strings['vchamilosnapshot3'] = 'ETAPE 3 DE 3 : Fichiers capturés.';
$strings['withselection'] = "Avec la sélection : ";
$strings['yes'] = 'Oui';
@ -81,10 +80,10 @@ $strings['mysqlcmd'] = 'Chemin vers le client mysql';
$strings['mysqldumpcms'] = 'Chemin vers la commande mysqldump';
$strings['sitenameinputerror'] = "Le nom de site est vide";
$strings['institutioninputerror'] = "L'institutiob est vide ou invalide";
$strings['institutioninputerror'] = "L'institution est vide ou invalide";
$strings['rootwebinputerror'] = "L'URL d'acces est vide ou invalide";
$strings['databaseinputerror'] = "La base de données n'est pas définie";
$strings['coursefolderinputerror'] = "Le réperotire de cours n'est pas défini";
$strings['coursefolderinputerror'] = "Le répertoire du cours n'est pas défini";
$strings['httpproxyhost'] = "Hôte Proxy HTTP";
$strings['httpproxyport'] = "Port Proxy HTTP";
@ -94,8 +93,14 @@ $strings['httpproxypassword'] = "Mot de passe Proxy";
$strings['variable'] = 'Variable';
$strings['subkey'] = 'Clef';
$strings['category'] = 'Categorie';
$strings['category'] = 'Catégorie';
$strings['accessurl'] = 'Sous-site';
$strings['value'] = 'Valeur';
$strings['syncall'] = 'Synchroniser la sélection';
$strings['syncthis'] = 'Synchroniser ce réglage';
$strings['SiteNameExample'] = 'Exemple: Chamilo';
$strings['InstitutionExample'] = 'Exemple: Chamilo Association';
$strings['RootWebExample'] = 'Exemple: http://www.chamilo.org/';
$strings['DatabaseDescription'] = 'Une nouvelle base de données sera créée avec ce nom.';
$strings['RootWebExists'] = 'Une instance avec le même nom existe déjà.';

@ -1,3 +1 @@
<?php
$strings['HelloPlugin'] = "Hola chaval!";

@ -19,8 +19,9 @@ function vchamilo_hook_configuration(&$_configuration)
// We are on physical chamilo. Let original config play
$virtualChamiloWebRoot = $_configuration['vchamilo_web_root'].'/';
$virtualChamilo = [];
if ($_configuration['root_web'] == $virtualChamiloWebRoot) {
$virtualChamilo = [];
return;
}
@ -81,7 +82,8 @@ function vchamilo_hook_configuration(&$_configuration)
$virtualChamilo = $data;
}
} else {
die("VChamilo : Could not fetch virtual chamilo configuration");
// Platform was not configured yet
//die("VChamilo : Could not fetch virtual chamilo configuration");
}
}
@ -143,6 +145,7 @@ function vchamilo_boot_connection(&$_configuration)
// Only relevant for pdo_mysql, pdo_pgsql, and pdo_oci/oci8,
'port' => isset($_configuration['db_port']) ? $_configuration['db_port'] : '',
);
try {
$database = new \Database();
$connection = $database->connect(
@ -235,29 +238,21 @@ function vchamilo_template_exists($template)
*/
function vchamilo_drop_databases(&$vchamilo)
{
global $plugininstance;
if (is_array($vchamilo)) {
$vchamilo = (object)$vchamilo;
}
if (empty($vchamilo->main_database)) {
Display::addFlash(Display::return_message('No database found'));
return;
}
// Drop databases you need to drop
$sqls = array(" DROP DATABASE `{$vchamilo->main_database}` ");
$connection = vchamilo_get_connection_from_instance($vchamilo);
$connection->getSchemaManager()->dropDatabase($vchamilo->main_database);
Display::addFlash(Display::return_message("Dropping database: ".$vchamilo->main_database));
foreach ($sqls as $sql){
$res = Database::query($sql);
if (!$res) {
Display::addFlash(Display::return_message($plugininstance->get_lang('couldnotdropdb')));
}
}
return false;
}
@ -295,7 +290,6 @@ function vchamilo_get_database_dump_cmd($vchamilodata)
if (!$pgm) {
$pgm = '/usr/bin/mysql';
Display::addFlash(Display::return_message("Using default database command $pgm "));
}
$phppgm = str_replace("\\", '/', $pgm);
@ -345,7 +339,7 @@ function vchamilo_load_db_template($vchamilo, $template)
$import = $sqlcmd.$absolute_datadir;
// Execute the command.
Display::addFlash(Display::return_message("load_database_from_dump : executing feeding sql as \n $import "));
Display::addFlash(Display::return_message("Load database from template dump: \n $import "));
if (!defined('CLI_SCRIPT')) {
putenv('LANG=en_US.utf-8');
@ -557,7 +551,7 @@ function vchamilo_get_config($module, $key, $isplugin = true)
}
/**
* @param $vchamilo
* @param array $vchamilo
* @param string $template
*/
function vchamilo_load_files_from_template($vchamilo, $template)
@ -570,10 +564,9 @@ function vchamilo_load_files_from_template($vchamilo, $template)
$vchamilo->virtual = true;
// Get Vchamilo known record.
$vcoursepath = api_get_path(SYS_COURSE_PATH, (array)$vchamilo);
$vhomepath = api_get_path(SYS_HOME_PATH, (array)$vchamilo);
$varchivepath = api_get_path(SYS_ARCHIVE_PATH, (array)$vchamilo);
$coursePath = vchamilo_get_config('vchamilo', 'course_real_root').$separator.$vchamilo->slug;
$homePath = vchamilo_get_config('vchamilo', 'home_real_root').$separator.$vchamilo->slug;
$archivePath = vchamilo_get_config('vchamilo', 'archive_real_root').$separator.$vchamilo->slug;
// Rename some dirs top match instance requirements
$manifest = vchamilo_get_vmanifest($template);
@ -581,28 +574,31 @@ function vchamilo_load_files_from_template($vchamilo, $template)
// get the protocol free hostname
Display::addFlash(
Display::return_message("Copying {$absolute_template_datadir}/data/courses => $vcoursepath")
);
Display::addFlash(
Display::return_message("Copying {$absolute_template_datadir}/data/archive => $varchivepath")
);
Display::addFlash(
Display::return_message("Copying {$absolute_template_datadir}/data/home => $vhomepath")
Display::return_message("Copying {$absolute_template_datadir}/data/courses => $coursePath")
);
copyDirTo(
chop_last_slash($absolute_template_datadir.'/data/courses'),
chop_last_slash($vcoursepath),
chop_last_slash($coursePath),
false
);
Display::addFlash(
Display::return_message("Copying {$absolute_template_datadir}/data/archive => $archivePath")
);
copyDirTo(
chop_last_slash($absolute_template_datadir.'/data/archive'),
chop_last_slash($varchivepath),
chop_last_slash($archivePath),
false
);
Display::addFlash(
Display::return_message("Copying {$absolute_template_datadir}/data/home => $homePath")
);
copyDirTo(
chop_last_slash($absolute_template_datadir.'/data/home'),
chop_last_slash($vhomepath),
chop_last_slash($homePath),
false
);
}
@ -1123,6 +1119,11 @@ function vchamilo_check_settings()
api_not_allowed(true, 'Plugin is not enabled');
}
global $virtualChamilo;
if (!isset($virtualChamilo)) {
api_not_allowed(true, 'You have to edit the configuration.php. Please check the readme file.');
}
$coursePath = vchamilo_get_config('vchamilo', 'course_real_root');
$homePath = vchamilo_get_config('vchamilo', 'home_real_root');
$archivePath = vchamilo_get_config('vchamilo', 'archive_real_root');
@ -1132,5 +1133,38 @@ function vchamilo_check_settings()
if (empty($coursePath) || empty($homePath) || empty($archivePath) || empty($cmdSql)|| empty($cmdMySql)) {
api_not_allowed(true, 'You have to complete all plugin settings.');
}
}
/**
* @param object $instance
* @return \Doctrine\DBAL\Connection
*/
function vchamilo_get_connection_from_instance($instance)
{
$dbParams = array(
'driver' => 'pdo_mysql',
'host' => $instance->db_host,
'user' => $instance->db_user,
'password' => $instance->db_password,
'dbname' => $instance->main_database,
// Only relevant for pdo_sqlite, specifies the path to the SQLite database.
//'path' => isset($_configuration['db_path']) ? $_configuration['db_path'] : '',
// Only relevant for pdo_mysql, pdo_pgsql, and pdo_oci/oci8,
//'port' => isset($_configuration['db_port']) ? $_configuration['db_port'] : '',
);
try {
$database = new \Database();
$connection = $database->connect(
$dbParams,
api_get_configuration_value('root_sys'),
api_get_configuration_value('root_sys'),
true
);
return $connection;
} catch (Exception $e) {
echo $e->getMessage();
exit;
}
}

@ -71,10 +71,14 @@ if ($data->what == 'addinstance' || $data->what == 'registerinstance') {
mkdir($coursedir, 0777, true);
// initiate default index
$indexFile = fopen($coursedir.'/index.html', 'w');
file_put_contents($indexFile, vchamilo_get_default_course_index_fragment());
if ($indexFile) {
file_put_contents($indexFile, vchamilo_get_default_course_index_fragment());
}
$htaccessFile = fopen($coursedir.'/.htaccess', 'w');
file_put_contents($htaccessFile, vchamilo_get_htaccess_fragment($slug));
if ($htaccessFile) {
file_put_contents($htaccessFile, vchamilo_get_htaccess_fragment($slug));
}
}
$absalternatehome = vchamilo_get_config('vchamilo', 'home_real_root');
@ -128,15 +132,15 @@ if ($data->what == 'addinstance' || $data->what == 'registerinstance') {
if (!$template) {
// Create empty database for install
ctrace("Creating databases (empty)");
ctrace("Creating database");
vchamilo_create_databases($data);
} else {
// Deploy template database
ctrace("Creating databases from template $template ");
ctrace("Creating databases from template '$template'");
vchamilo_create_databases($data);
ctrace("Loading data template $template ");
ctrace("Loading data template '$template'");
vchamilo_load_db_template($data, $template);
ctrace("Coying files from template $template ");
ctrace("Coying files from template '$template'");
vchamilo_load_files_from_template($data, $template);
}

@ -10,7 +10,6 @@ require_once api_get_path(SYS_PLUGIN_PATH).'vchamilo/lib.php';
require_once api_get_path(SYS_PLUGIN_PATH).'vchamilo/lib/vchamilo_plugin.class.php';
require_once api_get_path(SYS_PLUGIN_PATH).'vchamilo/views/editinstance_form.php';
// security
api_protect_admin_script();
$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_PLUGIN_PATH).'vchamilo/js/host_form.js" type="text/javascript" language="javascript"></script>';

@ -310,6 +310,7 @@ abstract class ChamiloForm
*/
class InstanceForm extends ChamiloForm
{
/** @var Plugin */
public $_plugin;
public $instance;
@ -323,13 +324,13 @@ class InstanceForm extends ChamiloForm
global $_configuration;
$this->_plugin = $plugin;
$returnurl = $_configuration['root_web'].'plugin/vchamilo/views/editinstance.php';
$returnUrl = $_configuration['root_web'].'plugin/vchamilo/views/editinstance.php';
if ($mode == 'update') {
$returnurl = $_configuration['root_web'].'plugin/vchamilo/views/editinstance.php?vid='.intval($_GET['vid']);
$returnUrl = $_configuration['root_web'].'plugin/vchamilo/views/editinstance.php?vid='.intval($_GET['vid']);
}
$cancelurl = $_configuration['root_web'].'plugin/vchamilo/views/manage.php';
parent::__construct($mode, $returnurl, $cancelurl);
parent::__construct($mode, $returnUrl, $cancelurl);
$this->instance = $instance;
$this->definition();
}
@ -341,38 +342,28 @@ class InstanceForm extends ChamiloForm
{
global $_configuration;
$cform = $this->_form;
$form = $this->_form;
$plugin = $this->_plugin;
/*
* Host's id.
*/
$cform->addElement('hidden', 'vid');
$cform->addElement('hidden', 'what', $this->_mode.'instance');
$cform->addElement('hidden', 'registeronly');
$form->addElement('hidden', 'vid');
$form->addElement('hidden', 'what', $this->_mode.'instance');
$form->addElement('hidden', 'registeronly');
/*
* Features fieldset.
*/
$cform->addElement('header', $this->_plugin->get_lang('hostdefinition'));
// Name.
$cform->addElement('text', 'sitename', $this->_plugin->get_lang('sitename'));
$cform->applyFilter('sitename', 'trim');
$form->addHeader($plugin->get_lang('hostdefinition'));
$form->addText('sitename', [$plugin->get_lang('sitename'), $plugin->get_lang('SiteNameExample')]);
$form->applyFilter('sitename', 'trim');
$cform->addElement(
'text',
'institution',
$this->_plugin->get_lang('institution')
);
$form->addText('institution', [$plugin->get_lang('institution'), $plugin->get_lang('InstitutionExample')]);
$cform->applyFilter('institution', 'trim');
$form->applyFilter('institution', 'trim');
// Host's name.
$elementWeb = $cform->addElement(
$elementWeb = $form->addElement(
'text',
'root_web',
$this->_plugin->get_lang('rootweb')
[$this->_plugin->get_lang('rootweb'), $plugin->get_lang('RootWebExample')]
);
$cform->applyFilter('root_web', 'trim');
$form->applyFilter('root_web', 'trim');
if ($this->_mode == 'update') {
$elementWeb->freeze();
@ -381,18 +372,18 @@ class InstanceForm extends ChamiloForm
/*
* Database fieldset.
*/
$cform->addElement('header', $this->_plugin->get_lang('dbgroup'));
$form->addElement('header', $plugin->get_lang('dbgroup'));
// Database host.
$cform->addElement('text', 'db_host', $this->_plugin->get_lang('dbhost'), array('id' => 'id_vdbhost'));
$cform->applyFilter('db_host', 'trim');
$form->addElement('text', 'db_host', $this->_plugin->get_lang('dbhost'), array('id' => 'id_vdbhost'));
$form->applyFilter('db_host', 'trim');
// Database login.
$cform->addElement('text', 'db_user', $this->_plugin->get_lang('dbuser'), array('id' => 'id_vdbuser'));
$cform->applyFilter('db_user', 'trim');
$form->addElement('text', 'db_user', $this->_plugin->get_lang('dbuser'), array('id' => 'id_vdbuser'));
$form->applyFilter('db_user', 'trim');
// Database password.
$cform->addElement(
$form->addElement(
'password',
'db_password',
$this->_plugin->get_lang('dbpassword'),
@ -400,10 +391,10 @@ class InstanceForm extends ChamiloForm
);
// Database name.
$cform->addElement('text', 'main_database', $this->_plugin->get_lang('maindatabase'));
$form->addText('main_database', [$plugin->get_lang('maindatabase'), $plugin->get_lang('DatabaseDescription')]);
// Button for testing database connection.
$cform->addElement(
$form->addElement(
'button',
'testconnection',
$this->_plugin->get_lang('testconnection'),
@ -418,31 +409,31 @@ class InstanceForm extends ChamiloForm
* Template selection.
*/
if ($this->is_in_add_mode()) {
$cform->addElement('header', $this->_plugin->get_lang('templating'));
$form->addElement('header', $this->_plugin->get_lang('templating'));
$templateoptions = vchamilo_get_available_templates();
// Template choice
$cform->addElement('select', 'template', $this->_plugin->get_lang('template'), $templateoptions);
$form->addElement('select', 'template', $this->_plugin->get_lang('template'), $templateoptions);
} else {
if ($this->instance) {
$cform->addLabel($this->_plugin->get_lang('template'), $this->instance->template);
$form->addLabel($this->_plugin->get_lang('template'), $this->instance->template);
}
}
$cform->addButtonSave($this->_plugin->get_lang('savechanges'), 'submitbutton');
$form->addButtonSave($this->_plugin->get_lang('savechanges'), 'submitbutton');
// Rules
$cform->addRule('sitename', $this->_plugin->get_lang('sitenameinputerror'), 'required', null, 'client');
$cform->addRule(
$form->addRule('sitename', $this->_plugin->get_lang('sitenameinputerror'), 'required', null, 'client');
$form->addRule(
'institution',
$this->_plugin->get_lang('institutioninputerror'),
'required',
null,
'client'
);
$cform->addRule('root_web', $this->_plugin->get_lang('rootwebinputerror'), 'required', null, 'client');
$cform->addRule(
$form->addRule('root_web', $this->_plugin->get_lang('rootwebinputerror'), 'required', null, 'client');
$form->addRule(
'main_database',
$this->_plugin->get_lang('databaseinputerror'),
'required',
@ -471,7 +462,7 @@ class InstanceForm extends ChamiloForm
);
if ($vchamilo && isset($data['vid']) && $data['vid'] != $vchamilo['id']) {
$errors['root_web'] = $plugininstance->get_lang('errorrootwebexists');
$errors['root_web'] = $plugininstance->get_lang('RootWebExists');
}
if (!empty($errors)) {

@ -33,7 +33,7 @@ if ($action == 'deleteinstances' || $action == 'disableinstances') {
if ($action == 'enableinstances') {
if (!empty($vidlist)) {
Display::addFlash(Display::return_message("Enabling instance"));
$sql = " UPDATE $table SET visible = 1 WHERE id IN ('$vidlist') ";
$sql = "UPDATE $table SET visible = 1 WHERE id IN ('$vidlist') ";
Database::query($sql);
}
vchamilo_redirect(api_get_path(WEB_PLUGIN_PATH).'vchamilo/views/manage.php');
@ -48,22 +48,24 @@ if ($action == 'fulldeleteinstances') {
$todelete = Database::select('*', 'vchamilo', array('where' => array("id IN ('$vidlist')" => array())));
}
} else {
$todelete = Database::select('*', 'vchamilo', array('where' => array("root_web = '{$n->root_web}' " => array())));
$todelete = Database::select(
'*',
'vchamilo',
array('where' => array("root_web = '{$n->root_web}' " => array()))
);
}
if ($todelete) {
foreach ($todelete as $fooid => $instance) {
$slug = $instance['slug'];
Display::addFlash(Display::return_message("Removing instance: ".$instance['root_web']));
vchamilo_drop_databases($instance);
// Remove all files and eventual symlinks
$absalternatecourse = vchamilo_get_config('vchamilo', 'course_real_root');
$coursedir = $absalternatecourse.$slug;
Display::addFlash(Display::return_message("Deleting $coursedir"));
removeDir($coursedir);
if ($absalternatehome = vchamilo_get_config('vchamilo', 'home_real_root')) {
$homedir = $absalternatehome.'/'.$slug;
@ -78,9 +80,13 @@ if ($action == 'fulldeleteinstances') {
Display::addFlash(Display::return_message("Deleting $archivedir"));
removeDir($archivedir);
}
$sql = "DELETE FROM {$table} WHERE id = {$instance->id}";
$sql = "DELETE FROM {$table} WHERE id = ".$instance['id'];
Database::query($sql);
Display::addFlash(Display::return_message("Removing instance: ".$instance['root_web']));
vchamilo_drop_databases($instance);
}
}
}

@ -5,9 +5,8 @@ require_once '../../../main/inc/global.inc.php';
require_once api_get_path(SYS_PLUGIN_PATH).'vchamilo/lib.php';
require_once api_get_path(SYS_PLUGIN_PATH).'vchamilo/lib/vchamilo_plugin.class.php';
// security
// Security
api_protect_admin_script();
vchamilo_check_settings();
$action = isset($_GET['what']) ? $_GET['what'] : '';
@ -31,6 +30,15 @@ while ($instance = Database::fetch_object($result)) {
$templates = vchamilo_get_available_templates(false);
/*
$sql = "SELECT * FROM vchamilo
WHERE root_web = '".Database::escape_string('http://my.chamilo222.net/')."'";
$result = Database::query($sql);
$result = Database::store_result($result, 'ASSOC');
vchamilo_load_files_from_template((object)$result[0], 'localhost');
exit;*/
if (empty($templates)) {
$url = api_get_path(WEB_PLUGIN_PATH).'vchamilo/views/manage.php?what=snapshotinstance';
$url = Display::url($url, $url);
@ -60,8 +68,6 @@ $table->addRow($headers, $attrs, 'th');
$i = 0;
foreach ($instances as $instance) {
$checkbox = '<input type="checkbox" class="vnodessel" name="vids[]" value="'.$instance->id.'" />';
//$sitelink = '<a href="'.$instance->root_web.'" target="_blank">'.$instance->sitename.'</a>';
$sitelink = $instance->sitename;
if ($instance->visible) {
@ -85,7 +91,7 @@ foreach ($instances as $instance) {
<img src="'.$plugininstance->pix_url('delete').'" /></a>';
}
$crondate = ($instance->lastcron) ? date('r', $instance->lastcron) : '';
$crondate = $instance->lastcron ? date('r', $instance->lastcron) : '';
$data = array(
$checkbox,
$sitelink.' ('.Display::url($instance->root_web, $instance->root_web).')',
@ -106,10 +112,10 @@ $items = [
'url' => $thisurl.'?what=newinstance',
'content' => $plugininstance->get_lang('newinstance')
],
[
/*[
'url' => $thisurl.'?what=instance&registeronly=1',
'content' => $plugininstance->get_lang('registerinstance')
],
],*/
[
'url' => $thisurl.'?what=snapshotinstance&vid=0',
'content' => $plugininstance->get_lang('snapshotmaster')

@ -14,18 +14,42 @@ require_once api_get_path(SYS_PLUGIN_PATH).'vchamilo/lib.php';
api_protect_admin_script();
global $_configuration;
$plugininstance = VChamiloPlugin::create();
// Retrieve parameters for database connection test.
$database = array();
$database['db_host'] = $_REQUEST['vdbhost'];
$database['db_user'] = $_REQUEST['vdblogin'];
$database['db_password'] = $_REQUEST['vdbpass'];
$database['root_sys'] = api_get_path(SYS_PATH);
// Works, but need to improve the style...
if (vchamilo_boot_connection($database, false)) {
echo($plugininstance->get_lang('connectionok'));
} else {
echo($plugininstance->get_lang('badconnection'));
}
$dbParams = array();
$dbParams['db_host'] = $_REQUEST['vdbhost'];
$dbParams['db_user'] = $_REQUEST['vdblogin'];
$dbParams['db_password'] = $_REQUEST['vdbpass'];
$dbParams['root_sys'] = api_get_path(SYS_PATH);
$dbParams = array(
'driver' => 'pdo_mysql',
'host' => $_REQUEST['vdbhost'],
'user' => $_REQUEST['vdblogin'],
'password' => $_REQUEST['vdbpass'],
//'dbname' => isset($_configuration['main_database']) ? $_configuration['main_database'] : '',
// Only relevant for pdo_sqlite, specifies the path to the SQLite database.
//'path' => isset($_configuration['db_path']) ? $_configuration['db_path'] : '',
// Only relevant for pdo_mysql, pdo_pgsql, and pdo_oci/oci8,
//'port' => isset($_configuration['db_port']) ? $_configuration['db_port'] : '',
);
try {
$database = new \Database();
$connection = $database->connect(
$dbParams,
$_configuration['root_sys'],
$_configuration['root_sys'],
true
);
$list = $connection->getSchemaManager()->listDatabases();
echo $plugininstance->get_lang('connectionok');
} catch (Exception $e) {
echo $plugininstance->get_lang('badconnection');
die();
}
Loading…
Cancel
Save