|
|
|
@ -35,6 +35,31 @@ if ($debug) { |
|
|
|
|
Debug::enable(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$isCli = php_sapi_name() === 'cli'; |
|
|
|
|
if ($isCli) { |
|
|
|
|
|
|
|
|
|
$kernel = new Chamilo\Kernel($env, $debug); |
|
|
|
|
$kernel->boot(); |
|
|
|
|
|
|
|
|
|
if (!$kernel->isInstalled()) { |
|
|
|
|
throw new Exception('Chamilo is not installed'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$container = $kernel->getContainer(); |
|
|
|
|
$router = $container->get('router'); |
|
|
|
|
$context = $router->getContext(); |
|
|
|
|
$router->setContext($context); |
|
|
|
|
Database::setManager($container->get('doctrine.orm.entity_manager')); |
|
|
|
|
|
|
|
|
|
$cliOptions = getopt('', ['url:']); |
|
|
|
|
if (!empty($cliOptions['url'])) { |
|
|
|
|
$baseUrl = $cliOptions['url']; |
|
|
|
|
$context->setBaseUrl($baseUrl); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
echo "CLI mode: EntityManager initialized.\n"; |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
$kernel = new Chamilo\Kernel($env, $debug); |
|
|
|
|
// Loading Request from Sonata. In order to use Sonata Pages Bundle. |
|
|
|
|
$request = Request::createFromGlobals(); |
|
|
|
@ -56,18 +81,6 @@ $router->setContext($context); |
|
|
|
|
|
|
|
|
|
$context = Container::getRouter()->getContext(); |
|
|
|
|
|
|
|
|
|
$isCli = 'cli' === php_sapi_name(); |
|
|
|
|
$baseUrl = null; |
|
|
|
|
if ($isCli) { |
|
|
|
|
$cliOptions = getopt('', ['url:']); |
|
|
|
|
if (!empty($cliOptions['url'])) { |
|
|
|
|
$baseUrl = $cliOptions['url']; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($isCli && $baseUrl) { |
|
|
|
|
$context->setBaseUrl($baseUrl); |
|
|
|
|
} else { |
|
|
|
|
$currentUri = $request->getRequestUri(); |
|
|
|
|
|
|
|
|
|
$fullUrl = $currentBaseUrl . $currentUri; |
|
|
|
@ -92,14 +105,8 @@ if ($isCli && $baseUrl) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$context->setBaseUrl($newBaseUrl); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
|
|
if (!$kernel->isInstalled()) { |
|
|
|
|
throw new Exception('Chamilo is not installed'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Do not over-use this variable. It is only for this script's local use. |
|
|
|
|
$libraryPath = __DIR__.'/lib/'; |
|
|
|
|
$container = $kernel->getContainer(); |
|
|
|
@ -120,25 +127,12 @@ try { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Connect Chamilo with the Symfony container |
|
|
|
|
// Container::setContainer($container); |
|
|
|
|
// Container::setLegacyServices($container); |
|
|
|
|
|
|
|
|
|
// The code below is not needed. The connections is now made in the file: |
|
|
|
|
// src/CoreBundle/EventListener/LegacyListener.php |
|
|
|
|
// This is called when when doing the $kernel->handle |
|
|
|
|
$charset = 'UTF-8'; |
|
|
|
|
ini_set('log_errors', '1'); |
|
|
|
|
$this_section = SECTION_GLOBAL; |
|
|
|
|
//Default quota for the course documents folder |
|
|
|
|
/*$default_quota = api_get_setting('default_document_quotum'); |
|
|
|
|
//Just in case the setting is not correctly set |
|
|
|
|
if (empty($default_quota)) { |
|
|
|
|
$default_quota = 100000000; |
|
|
|
|
} |
|
|
|
|
define('DEFAULT_DOCUMENT_QUOTA', $default_quota);*/ |
|
|
|
|
define('DEFAULT_DOCUMENT_QUOTA', 100000000); |
|
|
|
|
} catch (Exception $e) { |
|
|
|
|
$controller = new ExceptionController(); |
|
|
|
|
$controller->show($e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|