|
|
|
|
@ -115,10 +115,7 @@ class Virtual |
|
|
|
|
} else { |
|
|
|
|
exit("This portal is disabled. Please contact your administrator"); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
// Platform was not configured yet |
|
|
|
|
//die("VChamilo : Could not fetch virtual chamilo configuration"); |
|
|
|
|
} |
|
|
|
|
} // otherwise it means the plugin was not configured yet |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -361,7 +358,7 @@ class Virtual |
|
|
|
|
$databaseName = $params->main_database; |
|
|
|
|
unset($params->main_database); |
|
|
|
|
|
|
|
|
|
$connection = Virtual::getConnectionFromInstance($params); |
|
|
|
|
$connection = self::getConnectionFromInstance($params); |
|
|
|
|
if ($connection) { |
|
|
|
|
$databaseList = $connection->getSchemaManager()->listDatabases(); |
|
|
|
|
|
|
|
|
|
@ -403,7 +400,7 @@ class Virtual |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Retrieves the host configuration (more secure). |
|
|
|
|
$vchamilodata = empty($vchamilodata) ? Virtual::makeThis() : $vchamilodata; |
|
|
|
|
$vchamilodata = empty($vchamilodata) ? self::makeThis() : $vchamilodata; |
|
|
|
|
if (strstr($vchamilodata->db_host, ':') !== false) { |
|
|
|
|
list($vchamilodata->db_host, $vchamilodata->db_port) = explode( |
|
|
|
|
':', |
|
|
|
|
@ -439,7 +436,7 @@ class Virtual |
|
|
|
|
$templatefoldername = 'plugin'.$separator.'vchamilo'.$separator.'templates'; |
|
|
|
|
$absolute_datadir = $_configuration['root_sys'].$templatefoldername.$separator.$template.$separator.'dump.sql'; |
|
|
|
|
|
|
|
|
|
if (!$sqlcmd = Virtual::getDatabaseDumpCmd($vchamilo)) { |
|
|
|
|
if (!$sqlcmd = self::getDatabaseDumpCmd($vchamilo)) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -495,14 +492,14 @@ class Virtual |
|
|
|
|
|
|
|
|
|
// Making the commands for each database. |
|
|
|
|
$cmds = array(); |
|
|
|
|
// Windows environments are not supported for this plugin at this time |
|
|
|
|
//if ($CFG->ostype == 'WINDOWS') { |
|
|
|
|
if (false) { |
|
|
|
|
$cmd_main = "-h{$host} -P{$port} -u{$vchamilo->db_user} {$pass} {$vchamilo->main_database}"; |
|
|
|
|
$cmds[] = $cmd_main . ' > ' . $outputfilerad; |
|
|
|
|
} else { |
|
|
|
|
$cmd_main = "-h{$host} -P{$port} -u{$vchamilo->db_user} {$pass} {$vchamilo->main_database}"; |
|
|
|
|
$cmds[] = $cmd_main . ' > ' . escapeshellarg($outputfilerad); |
|
|
|
|
} |
|
|
|
|
// $cmd_main = "-h{$host} -P{$port} -u{$vchamilo->db_user} {$pass} {$vchamilo->main_database}"; |
|
|
|
|
// $cmds[] = $cmd_main . ' > ' . $outputfilerad; |
|
|
|
|
//} else { |
|
|
|
|
$cmd_main = "-h{$host} -P{$port} -u{$vchamilo->db_user} {$pass} {$vchamilo->main_database}"; |
|
|
|
|
$cmds[] = $cmd_main . ' > ' . escapeshellarg($outputfilerad); |
|
|
|
|
//} |
|
|
|
|
|
|
|
|
|
$mysqldumpcmd = self::getConfig('vchamilo', 'cmd_mysqldump', true); |
|
|
|
|
|
|
|
|
|
@ -955,7 +952,7 @@ class Virtual |
|
|
|
|
|
|
|
|
|
$databaseName = $data->main_database; |
|
|
|
|
$data->main_database = ''; |
|
|
|
|
$connection = Virtual::getConnectionFromInstance($data); |
|
|
|
|
$connection = self::getConnectionFromInstance($data); |
|
|
|
|
$data->main_database = $databaseName; |
|
|
|
|
if (!$connection) { |
|
|
|
|
Display::addFlash( |
|
|
|
|
@ -989,7 +986,7 @@ class Virtual |
|
|
|
|
$virtualInfo = Database::fetch_array($result); |
|
|
|
|
$slug = $virtualInfo['slug']; |
|
|
|
|
} else { |
|
|
|
|
$slug = $data->slug = Virtual::getSlugFromUrl($data->root_web); |
|
|
|
|
$slug = $data->slug = self::getSlugFromUrl($data->root_web); |
|
|
|
|
if (empty($slug)) { |
|
|
|
|
Display::addFlash( |
|
|
|
|
Display::return_message('Cannot create slug from url: '.$data->root_web, 'error') |
|
|
|
|
@ -1002,7 +999,7 @@ class Virtual |
|
|
|
|
if ($registeronly) { |
|
|
|
|
// Stop it now. |
|
|
|
|
self::ctrace('Registering only. out.'); |
|
|
|
|
Virtual::redirect(api_get_path(WEB_PLUGIN_PATH).'vchamilo/views/manage.php'); |
|
|
|
|
self::redirect(api_get_path(WEB_PLUGIN_PATH).'vchamilo/views/manage.php'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// or we continue with physical creation |
|
|
|
|
@ -1011,15 +1008,15 @@ class Virtual |
|
|
|
|
if (!$template) { |
|
|
|
|
// Create empty database for install |
|
|
|
|
self::ctrace("Creating database"); |
|
|
|
|
Virtual::createDatabase($data); |
|
|
|
|
self::createDatabase($data); |
|
|
|
|
} else { |
|
|
|
|
// Deploy template database |
|
|
|
|
self::ctrace("Creating databases from template '$template'"); |
|
|
|
|
Virtual::createDatabase($data); |
|
|
|
|
self::createDatabase($data); |
|
|
|
|
self::ctrace("Loading data template '$template'"); |
|
|
|
|
Virtual::loadDbTemplate($data, $template); |
|
|
|
|
self::loadDbTemplate($data, $template); |
|
|
|
|
self::ctrace("Coying files from template '$template'"); |
|
|
|
|
Virtual::loadFilesFromTemplate($data, $template); |
|
|
|
|
self::loadFilesFromTemplate($data, $template); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// pluging in site name institution |
|
|
|
|
@ -1121,7 +1118,7 @@ class Virtual |
|
|
|
|
return false; |
|
|
|
|
} else { |
|
|
|
|
/** @var EntityManager $em */ |
|
|
|
|
$em = Virtual::getConnectionFromInstance($data, true); |
|
|
|
|
$em = self::getConnectionFromInstance($data, true); |
|
|
|
|
if ($em) { |
|
|
|
|
$connection = $em->getConnection(); |
|
|
|
|
$statement = $connection->query('SELECT * FROM settings_current'); |
|
|
|
|
@ -1135,12 +1132,13 @@ class Virtual |
|
|
|
|
$siteName = $settings['siteName']; |
|
|
|
|
$newDatabase->sitename = $siteName; |
|
|
|
|
$newDatabase->institution = $institution; |
|
|
|
|
$slug = $newDatabase->slug = $data->slug = Virtual::getSlugFromUrl($data->root_web); |
|
|
|
|
$slug = $newDatabase->slug = $data->slug = self::getSlugFromUrl($data->root_web); |
|
|
|
|
$id = Database::insert($table, (array)$newDatabase); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!$id) { |
|
|
|
|
// Show data detail to help debug |
|
|
|
|
var_dump($data); |
|
|
|
|
throw new Exception('Was not registered'); |
|
|
|
|
} |
|
|
|
|
@ -1150,7 +1148,7 @@ class Virtual |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
self::createDirsFromSlug($slug); |
|
|
|
|
$databaseCreated = Virtual::createDatabase($newDatabase); |
|
|
|
|
$databaseCreated = self::createDatabase($newDatabase); |
|
|
|
|
if (!$databaseCreated) { |
|
|
|
|
Display::addFlash( |
|
|
|
|
Display::return_message('Error while creating a DB', 'error') |
|
|
|
|
@ -1164,9 +1162,9 @@ class Virtual |
|
|
|
|
|
|
|
|
|
$dumpFile = api_get_path(SYS_ARCHIVE_PATH).uniqid($data->main_database.'_dump_', true).'.sql'; |
|
|
|
|
self::ctrace('Create backup from "'.$data->main_database.'" here: '.$dumpFile.' '); |
|
|
|
|
Virtual::backupDatabase($data, $dumpFile); |
|
|
|
|
self::backupDatabase($data, $dumpFile); |
|
|
|
|
|
|
|
|
|
$sqlcmd = Virtual::getDatabaseDumpCmd($newDatabase); |
|
|
|
|
$sqlcmd = self::getDatabaseDumpCmd($newDatabase); |
|
|
|
|
$sqlcmd = str_replace('%DATABASE%', $newDatabase->main_database, $sqlcmd); |
|
|
|
|
$import = $sqlcmd.$dumpFile; |
|
|
|
|
|
|
|
|
|
@ -1257,7 +1255,7 @@ class Virtual |
|
|
|
|
|
|
|
|
|
// Create course directory for operations. |
|
|
|
|
// this is very important here (DO NOT USE api_get_path() !!) because storage may be remotely located |
|
|
|
|
$absAlternateCourse = Virtual::getConfig('vchamilo', 'course_real_root'); |
|
|
|
|
$absAlternateCourse = self::getConfig('vchamilo', 'course_real_root'); |
|
|
|
|
$courseDir = $absAlternateCourse.'/'.$slug; |
|
|
|
|
|
|
|
|
|
if (!is_dir($courseDir)) { |
|
|
|
|
@ -1275,9 +1273,9 @@ class Virtual |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$absAlternateHome = Virtual::getConfig('vchamilo', 'home_real_root'); |
|
|
|
|
$absAlternateArchive = Virtual::getConfig('vchamilo', 'archive_real_root'); |
|
|
|
|
$absAlternateUpload = Virtual::getConfig('vchamilo', 'upload_real_root'); |
|
|
|
|
$absAlternateHome = self::getConfig('vchamilo', 'home_real_root'); |
|
|
|
|
$absAlternateArchive = self::getConfig('vchamilo', 'archive_real_root'); |
|
|
|
|
$absAlternateUpload = self::getConfig('vchamilo', 'upload_real_root'); |
|
|
|
|
|
|
|
|
|
// absalternatehome is a vchamilo config setting that tells where the |
|
|
|
|
// real physical storage for home pages are. |
|
|
|
|
@ -1326,7 +1324,7 @@ class Virtual |
|
|
|
|
*/ |
|
|
|
|
public static function canBeUpgraded($instance) |
|
|
|
|
{ |
|
|
|
|
$connection = Virtual::getConnectionFromInstance($instance); |
|
|
|
|
$connection = self::getConnectionFromInstance($instance); |
|
|
|
|
if ($connection) { |
|
|
|
|
$sql = 'SELECT * FROM settings_current WHERE variable = "chamilo_database_version"'; |
|
|
|
|
$statement = $connection->query($sql); |
|
|
|
|
|