parent
d17a0c3aca
commit
b3ba063058
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,39 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
/** |
||||
* Description of VChamilo |
||||
* |
||||
* @copyright (c) 2014 VF Consulting |
||||
* @license GNU General Public License - http://www.gnu.org/copyleft/gpl.html |
||||
* @author Valery Fremaux <valery.fremaux@gmail.com> |
||||
* @author Julio Montoya |
||||
*/ |
||||
class VChamiloPlugin extends Plugin |
||||
{ |
||||
/** |
||||
* VChamiloPlugin constructor. |
||||
*/ |
||||
public function __construct() |
||||
{ |
||||
parent::__construct('1.2', 'Valery Fremaux, Julio Montoya'); |
||||
} |
||||
|
||||
/** |
||||
* |
||||
* @return VChamiloPlugin |
||||
*/ |
||||
public static function create() |
||||
{ |
||||
static $result = null; |
||||
return $result ? $result : $result = new self(); |
||||
} |
||||
|
||||
/** |
||||
* @return string |
||||
*/ |
||||
public function get_name() |
||||
{ |
||||
return 'vchamilo'; |
||||
} |
||||
} |
||||
File diff suppressed because it is too large
Load Diff
@ -1,60 +0,0 @@ |
||||
<?php |
||||
|
||||
/** |
||||
* Description of VChamilo |
||||
* |
||||
* @copyright (c) 2014 VF Consulting |
||||
* @license GNU General Public License - http://www.gnu.org/copyleft/gpl.html |
||||
* @author Valery Fremaux <valery.fremaux@gmail.com> |
||||
* @author Julio Montoya |
||||
*/ |
||||
class VChamiloPlugin extends Plugin |
||||
{ |
||||
/** |
||||
* VChamiloPlugin constructor. |
||||
*/ |
||||
public function __construct() |
||||
{ |
||||
parent::__construct('1.2', 'Valery Fremaux, Julio Montoya'); |
||||
} |
||||
|
||||
/** |
||||
* |
||||
* @return VChamiloPlugin |
||||
*/ |
||||
public static function create() |
||||
{ |
||||
static $result = null; |
||||
return $result ? $result : $result = new self(); |
||||
} |
||||
|
||||
/** |
||||
* @return string |
||||
*/ |
||||
public function get_name() |
||||
{ |
||||
return 'vchamilo'; |
||||
} |
||||
|
||||
/** |
||||
* @param $pixname |
||||
* @param int $size |
||||
* @return string |
||||
*/ |
||||
public function pix_url($pixname, $size = 16) |
||||
{ |
||||
global $_configuration; |
||||
|
||||
if (file_exists($_configuration['root_sys'].'/plugin/vchamilo/pix/'.$pixname.'.png')){ |
||||
return $_configuration['root_web'].'/plugin/vchamilo/pix/'.$pixname.'.png'; |
||||
} |
||||
if (file_exists($_configuration['root_sys'].'/plugin/vchamilo/pix/'.$pixname.'.jpg')){ |
||||
return $_configuration['root_web'].'/plugin/vchamilo/pix/'.$pixname.'.jpg'; |
||||
} |
||||
if (file_exists($_configuration['root_sys'].'/plugin/vchamilo/pix/'.$pixname.'.gif')){ |
||||
return $_configuration['root_web'].'/plugin/vchamilo/pix/'.$pixname.'.gif'; |
||||
} |
||||
|
||||
return $_configuration['root_web'].'/main/img/icons/'.$size.'/'.$pixname.'.png'; |
||||
} |
||||
} |
||||
|
Before Width: | Height: | Size: 315 B |
|
Before Width: | Height: | Size: 212 B |
|
Before Width: | Height: | Size: 213 B |
|
Before Width: | Height: | Size: 223 B |
@ -1,189 +0,0 @@ |
||||
<?php |
||||
|
||||
require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php'; |
||||
|
||||
api_protect_admin_script(); |
||||
|
||||
if (!defined('CHAMILO_INTERNAL')) die('You cannot use this script this way'); |
||||
|
||||
if ($data->what == 'addinstance' || $data->what == 'registerinstance') { |
||||
|
||||
unset($data->what); |
||||
unset($data->submitbutton); |
||||
unset($data->id); |
||||
unset($data->vid); |
||||
unset($data->testconnection); |
||||
unset($data->testdatapath); |
||||
|
||||
$registeronly = $data->registeronly; |
||||
unset($data->registeronly); |
||||
$data->lastcron = 0; |
||||
$data->lastcrongap = 0; |
||||
$data->croncount = 0; |
||||
|
||||
if (!empty($data->template)) { |
||||
$template = $data->template; |
||||
} else { |
||||
$template = ''; |
||||
} |
||||
|
||||
$mainDatabase = api_get_configuration_value('main_database'); |
||||
|
||||
if ($mainDatabase == $data->main_database) { |
||||
Display::addFlash( |
||||
Display::return_message('You cannot use the same database as the chamilo master', 'error') |
||||
); |
||||
return ; |
||||
} |
||||
|
||||
ctrace("Registering: ".$data->root_web); |
||||
$tablename = Database::get_main_table('vchamilo'); |
||||
$sql = "SELECT * FROM $tablename |
||||
WHERE root_web = '".Database::escape_string($data->root_web)."'"; |
||||
$result = Database::query($sql); |
||||
|
||||
if (Database::num_rows($result)) { |
||||
$sql = "SELECT * FROM $tablename |
||||
WHERE root_web = '".Database::escape_string($data->root_web)."'"; |
||||
Database::update($tablename, $data, ['root_web = ?' => $data->root_web]); |
||||
$virtualInfo = Database::fetch_array($result); |
||||
$slug = $virtualInfo['slug']; |
||||
} else { |
||||
$slug = $data->slug = vchamilo_get_slug_from_url($data->root_web); |
||||
Database::insert($tablename, (array) $data); |
||||
} |
||||
|
||||
if ($registeronly) { |
||||
// Stop it now. |
||||
ctrace("Registering only. out."); |
||||
vchamilo_redirect(api_get_path(WEB_PLUGIN_PATH).'vchamilo/views/manage.php'); |
||||
} |
||||
|
||||
// or we continue with physical creation |
||||
|
||||
// Create course directory for operations. |
||||
// this is very important here (DO NOT USE api_get_path() !!) because storage may be remotely located |
||||
$absalternatecourse = vchamilo_get_config('vchamilo', 'course_real_root'); |
||||
$coursedir = $absalternatecourse.'/'.$slug; |
||||
|
||||
if (!is_dir($coursedir)) { |
||||
ctrace("Creating physical course dir in $coursedir"); |
||||
mkdir($coursedir, 0777, true); |
||||
// initiate default index |
||||
$indexFile = $coursedir.'/index.html'; |
||||
if ($indexFile) { |
||||
file_put_contents($indexFile, vchamilo_get_default_course_index_fragment()); |
||||
} |
||||
|
||||
$htaccessFile = $coursedir.'/.htaccess'; |
||||
if ($htaccessFile) { |
||||
file_put_contents($htaccessFile, vchamilo_get_htaccess_fragment($slug)); |
||||
} |
||||
} |
||||
|
||||
$absalternatehome = vchamilo_get_config('vchamilo', 'home_real_root'); |
||||
// absalternatehome is a vchamilo config setting that tells where the |
||||
// real physical storage for home pages are. |
||||
$homedir = $absalternatehome.'/'.$slug; |
||||
|
||||
ctrace("Making home dir as $homedir"); |
||||
|
||||
if (!is_dir($homedir)) { |
||||
if (!mkdir($homedir, 0777, true)) { |
||||
ctrace("Error creating home dir $homedir \n"); |
||||
} |
||||
} |
||||
|
||||
// if real homedir IS NOT under chamilo install, link to it |
||||
// Seems not be necessary as we can globally link the whole Home container |
||||
/* |
||||
$standardlocation = $_configuration['root_sys'].'home/'.$home_folder; // where it should be |
||||
if ($homedir != $standardlocation){ |
||||
ctrace("Linking virtual home dir "); |
||||
if (!symlink($homedir, $standardlocation)){ |
||||
ctrace("could not link $standardlocation => $homedir "); |
||||
} |
||||
} |
||||
*/ |
||||
|
||||
// create archive |
||||
$absalternatearchive = vchamilo_get_config('vchamilo', 'archive_real_root'); |
||||
$archivedir = $absalternatearchive.'/'.$slug; |
||||
|
||||
ctrace("Making archive dir as $archivedir "); |
||||
|
||||
if (!is_dir($archivedir)) { |
||||
if (!mkdir($archivedir, 0777, true)) { |
||||
ctrace("Error creating archive dir $archivedir\n"); |
||||
} |
||||
} |
||||
|
||||
// if real archivedir IS NOT under chamilo install, link to it |
||||
// Seems not be necessary as we can globally link the whole Home container |
||||
/* |
||||
$standardlocation = $_configuration['root_sys'].'archive/'.$archive_folder; // where it should be |
||||
if ($archivedir != $standardlocation){ |
||||
ctrace("Linking virtual archive dir "); |
||||
if (!symlink($archivedir, $standardlocation)){ |
||||
ctrace("could not link $standardlocation => $archivedir "); |
||||
} |
||||
} |
||||
*/ |
||||
|
||||
if (!$template) { |
||||
// Create empty database for install |
||||
ctrace("Creating database"); |
||||
vchamilo_create_databases($data); |
||||
} else { |
||||
// Deploy template database |
||||
ctrace("Creating databases from template '$template'"); |
||||
vchamilo_create_databases($data); |
||||
ctrace("Loading data template '$template'"); |
||||
vchamilo_load_db_template($data, $template); |
||||
ctrace("Coying files from template '$template'"); |
||||
vchamilo_load_files_from_template($data, $template); |
||||
} |
||||
|
||||
// pluging in site name institution |
||||
$settingstable = $data->main_database.'.settings_current'; |
||||
$accessurltable = $data->main_database.'.access_url'; |
||||
|
||||
$sitename = Database::escape_string($data->sitename); |
||||
$institution = Database::escape_string($data->institution); |
||||
$sqls[] = "UPDATE {$settingstable} SET selected_value = '{$sitename}' |
||||
WHERE variable = 'siteName' AND category = 'Platform' "; |
||||
$sqls[] = "UPDATE {$settingstable} SET selected_value = '{$institution}' |
||||
WHERE variable = 'institution' AND category = 'Platform' "; |
||||
|
||||
$sqls[] = "UPDATE {$accessurltable} SET url = '{$data->root_web}' WHERE id = '1' "; |
||||
|
||||
foreach ($sqls as $sql) { |
||||
Database::query($sql); |
||||
} |
||||
|
||||
ctrace("Finished"); |
||||
|
||||
echo '<a class="btn btn-primary" href="'.api_get_path(WEB_PLUGIN_PATH).'vchamilo/views/manage.php'.'">Continue</a>'; |
||||
// vchamilo_redirect(api_get_path(WEB_PLUGIN_PATH).'vchamilo/views/manage.php'); |
||||
die; |
||||
} |
||||
|
||||
if ($data->what == 'updateinstance') { |
||||
|
||||
unset($data->what); |
||||
unset($data->submitbutton); |
||||
unset($data->registeronly); |
||||
unset($data->template); |
||||
$data->lastcron = 0; |
||||
$data->lastcrongap = 0; |
||||
$data->croncount = 0; |
||||
$id = $data->vid; |
||||
unset($data->vid); |
||||
unset($data->testconnection); |
||||
unset($data->testdatapath); |
||||
unset($data->vid); |
||||
|
||||
Database::update('vchamilo', (array) $data, array('id = ?' => $id), true); |
||||
Display::addFlash(Display::return_message(get_lang('Updated'))); |
||||
vchamilo_redirect(api_get_path(WEB_PLUGIN_PATH).'vchamilo/views/manage.php'); |
||||
} |
||||
@ -0,0 +1,97 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
$cidReset = true; |
||||
require_once '../../../main/inc/global.inc.php'; |
||||
|
||||
// Security |
||||
api_protect_admin_script(); |
||||
Virtual::checkSettings(); |
||||
|
||||
$plugin = VChamiloPlugin::create(); |
||||
$form = new FormValidator('import', 'post', api_get_self()); |
||||
|
||||
// Database host. |
||||
$form->addText('db_host', $plugin->get_lang('dbhost'), array('id' => 'id_vdbhost')); |
||||
$form->applyFilter('db_host', 'trim'); |
||||
|
||||
// Database login. |
||||
$form->addText('db_user', $plugin->get_lang('dbuser'), array('id' => 'id_vdbuser')); |
||||
$form->applyFilter('db_user', 'trim'); |
||||
|
||||
// Database password. |
||||
$form->addElement( |
||||
'password', |
||||
'db_password', |
||||
$plugin->get_lang('dbpassword'), |
||||
array('id' => 'id_vdbpassword') |
||||
); |
||||
|
||||
// Database name. |
||||
$form->addText('main_database', [$plugin->get_lang('maindatabase'), $plugin->get_lang('DatabaseDescription')]); |
||||
|
||||
$form->addText( |
||||
'path', |
||||
[ |
||||
$plugin->get_lang('ConfigurationPath'), |
||||
get_lang('Example').': /var/www/site/app/config/configuration.php' |
||||
], |
||||
true, |
||||
array('id' => 'id_vdbhost') |
||||
); |
||||
|
||||
$form->addButtonSave($plugin->get_lang('savechanges'), 'submitbutton'); |
||||
$content = $form->returnForm(); |
||||
|
||||
if ($form->validate()) { |
||||
$values = $form->getSubmitValues(); |
||||
$file = $values['path']; |
||||
|
||||
if (file_exists($file)) { |
||||
// @todo |
||||
$data = file_get_contents($file).' return $_configuration;'; |
||||
$data = str_replace('$_configuration', '$configurationFile', $data); |
||||
$temp = api_get_path(SYS_ARCHIVE_PATH).''.uniqid('file_').'.php'; |
||||
file_put_contents($temp, $data); |
||||
if (file_exists($temp)) { |
||||
|
||||
$currentHost = api_get_configuration_value('db_host'); |
||||
$currentDatabase = api_get_configuration_value('main_database'); |
||||
$currentUser = api_get_configuration_value('db_user'); |
||||
$currentPassword = api_get_configuration_value('db_password'); |
||||
|
||||
if ($values['main_database'] !== $currentDatabase && |
||||
$values['db_user'] !== $currentUser && |
||||
$values['db_password'] !== $currentPassword |
||||
) { |
||||
|
||||
} else { |
||||
Display::addFlash( |
||||
Display::return_message( |
||||
$plugin->get_lang('DatabaseAccessShouldBeDifferentThanMasterChamilo') |
||||
) |
||||
); |
||||
} |
||||
|
||||
$configuration = include $temp; |
||||
|
||||
$vchamilo = new stdClass(); |
||||
$vchamilo->main_database = $configuration['main_database']; |
||||
$vchamilo->db_user = $configuration['db_user']; |
||||
$vchamilo->db_password = $configuration['db_password']; |
||||
$vchamilo->db_host = $configuration['db_host']; |
||||
|
||||
$vchamilo->import_to_main_database = $values['main_database']; |
||||
$vchamilo->import_to_db_user = $values['db_user']; |
||||
$vchamilo->import_to_db_password = $values['db_password']; |
||||
$vchamilo->import_to_db_host = $values['db_host']; |
||||
$vchamilo->import = true; |
||||
|
||||
$plugin->addInstance($vchamilo); |
||||
} |
||||
} |
||||
} |
||||
|
||||
$tpl = new Template(get_lang('VChamilo'), true, true, false, true, false); |
||||
$tpl->assign('content', $content); |
||||
$tpl->display_one_col_template(); |
||||
Loading…
Reference in new issue