|
|
|
@ -45,7 +45,6 @@ $configurationYMLFile = $includePath.'/../../config/configuration.yml'; |
|
|
|
|
$configurationFileAppPath = $includePath.'/../../config/configuration.php'; |
|
|
|
|
|
|
|
|
|
$alreadyInstalled = false; |
|
|
|
|
|
|
|
|
|
$_configuration = array(); |
|
|
|
|
|
|
|
|
|
if (file_exists($configurationFilePath) || file_exists($configurationYMLFile) || file_exists($configurationFileAppPath)) { |
|
|
|
@ -135,7 +134,6 @@ if (isset($urlInfo['path'])) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$libPath = $includePath.'/lib/'; |
|
|
|
|
$langPath = api_get_path(SYS_LANG_PATH); |
|
|
|
|
|
|
|
|
|
// Database constants |
|
|
|
|
require_once $libPath.'database.constants.inc.php'; |
|
|
|
@ -144,10 +142,10 @@ require_once $libPath.'database.constants.inc.php'; |
|
|
|
|
require_once $libPath.'events.lib.inc.php'; |
|
|
|
|
|
|
|
|
|
// Load allowed tag definitions for kses and/or HTMLPurifier. |
|
|
|
|
require_once $libPath.'formvalidator/Rule/allowed_tags.inc.php'; |
|
|
|
|
//require_once $libPath.'formvalidator/Rule/allowed_tags.inc.php'; |
|
|
|
|
|
|
|
|
|
// Add the path to the pear packages to the include path |
|
|
|
|
ini_set('include_path', api_create_include_path_setting()); |
|
|
|
|
ini_set('include_path', api_create_include_path_setting($includePath)); |
|
|
|
|
|
|
|
|
|
$app['configuration_file'] = $configurationFilePath; |
|
|
|
|
$app['configuration_yml_file'] = $configurationYMLFile; |
|
|
|
@ -212,25 +210,6 @@ if ($alreadyInstalled) { |
|
|
|
|
|
|
|
|
|
/** Including service providers */ |
|
|
|
|
require_once 'services.php'; |
|
|
|
|
|
|
|
|
|
// Setting the static database class |
|
|
|
|
$database = isset($app['database']) ? $app['database'] : null; |
|
|
|
|
|
|
|
|
|
// Retrieving all the chamilo config settings for multiple URLs feature |
|
|
|
|
$_configuration['access_url'] = 1; |
|
|
|
|
|
|
|
|
|
if (api_get_multiple_access_url()) { |
|
|
|
|
$access_urls = api_get_access_urls(); |
|
|
|
|
$protocol = ((!empty($_SERVER['HTTPS']) && strtoupper($_SERVER['HTTPS']) != 'OFF') ? 'https' : 'http').'://'; |
|
|
|
|
$request_url1 = $protocol.$_SERVER['SERVER_NAME'].'/'; |
|
|
|
|
$request_url2 = $protocol.$_SERVER['HTTP_HOST'].'/'; |
|
|
|
|
|
|
|
|
|
foreach ($access_urls as & $details) { |
|
|
|
|
if ($request_url1 == $details['url'] or $request_url2 == $details['url']) { |
|
|
|
|
$_configuration['access_url'] = $details['id']; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$charset = 'UTF-8'; |
|
|
|
@ -257,6 +236,9 @@ $app->error( |
|
|
|
|
} else { |
|
|
|
|
$code = null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Session::setSession($app['session']); |
|
|
|
|
|
|
|
|
|
//$code = ($e instanceof HttpException) ? $e->getStatusCode() : 500; |
|
|
|
|
// It seems that error() is executed first than the before() middleware |
|
|
|
|
// @ŧodo check this one |
|
|
|
@ -267,13 +249,15 @@ $app->error( |
|
|
|
|
if (!is_dir($app['sys_root'].'main/template/'.$templateStyle)) { |
|
|
|
|
$templateStyle = 'default'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$app['template_style'] = $templateStyle; |
|
|
|
|
|
|
|
|
|
// Default layout. |
|
|
|
|
$app['default_layout'] = $app['template_style'].'/layout/layout_1_col.tpl'; |
|
|
|
|
$app['template']->assign('error', array('code' => $code, 'message' => $message)); |
|
|
|
|
$response = $app['template']->render_layout('error.tpl'); |
|
|
|
|
|
|
|
|
|
/** @var Template $template */ |
|
|
|
|
$template = $app['template']; |
|
|
|
|
$template->assign('error', array('code' => $code, 'message' => $message)); |
|
|
|
|
$response = $template->render_layout('error.tpl'); |
|
|
|
|
return new Response($response); |
|
|
|
|
} |
|
|
|
|
); |
|
|
|
@ -512,7 +496,6 @@ $app->before( |
|
|
|
|
$request->getSession()->start(); |
|
|
|
|
|
|
|
|
|
// Setting session obj |
|
|
|
|
|
|
|
|
|
Session::setSession($app['session']); |
|
|
|
|
UserManager::setEntityManager($app['orm.em']); |
|
|
|
|
|
|
|
|
@ -529,14 +512,27 @@ $app->before( |
|
|
|
|
$filesystem->copyFolders($app['temp.paths']->copyFolders); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Check and modify the date of user in the track.e.online table |
|
|
|
|
Online::loginCheck(api_get_user_id()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Setting access_url id (multiple url feature) |
|
|
|
|
|
|
|
|
|
if (api_get_multiple_access_url()) { |
|
|
|
|
//for some reason $app['configuration'] doesn't work. Use $_config |
|
|
|
|
global $_configuration; |
|
|
|
|
$_configuration = $app['configuration']; |
|
|
|
|
$_configuration['access_url'] = 1; |
|
|
|
|
|
|
|
|
|
$access_urls = api_get_access_urls(); |
|
|
|
|
$protocol = ((!empty($_SERVER['HTTPS']) && strtoupper($_SERVER['HTTPS']) != 'OFF') ? 'https' : 'http').'://'; |
|
|
|
|
$request_url1 = $protocol.$_SERVER['SERVER_NAME'].'/'; |
|
|
|
|
$request_url2 = $protocol.$_SERVER['HTTP_HOST'].'/'; |
|
|
|
|
|
|
|
|
|
foreach ($access_urls as & $details) { |
|
|
|
|
if ($request_url1 == $details['url'] or $request_url2 == $details['url']) { |
|
|
|
|
$_configuration['access_url'] = $details['id']; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
Session::write('url_id', $_configuration['access_url']); |
|
|
|
|
Session::write('url_info', api_get_current_access_url_info($_configuration['access_url'])); |
|
|
|
|
} else { |
|
|
|
@ -602,10 +598,12 @@ $app->before( |
|
|
|
|
$user = null; |
|
|
|
|
|
|
|
|
|
/** Security component. */ |
|
|
|
|
if ($app['security']->isGranted('IS_AUTHENTICATED_FULLY')) { |
|
|
|
|
/** @var Symfony\Component\Security\Core\SecurityContext $security */ |
|
|
|
|
$security = $app['security']; |
|
|
|
|
if ($security->isGranted('IS_AUTHENTICATED_FULLY')) { |
|
|
|
|
|
|
|
|
|
// Checking token in order to get the current user. |
|
|
|
|
$token = $app['security']->getToken(); |
|
|
|
|
$token = $security->getToken(); |
|
|
|
|
if (null !== $token) { |
|
|
|
|
/** @var Entity\User $user */ |
|
|
|
|
$user = $token->getUser(); |
|
|
|
@ -619,12 +617,12 @@ $app->before( |
|
|
|
|
$app['current_user'] = $userInfo; |
|
|
|
|
|
|
|
|
|
// Setting admin permissions. |
|
|
|
|
if ($app['security']->isGranted('ROLE_ADMIN')) { |
|
|
|
|
if ($security->isGranted('ROLE_ADMIN')) { |
|
|
|
|
Session::write('is_platformAdmin', true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Setting teachers permissions. |
|
|
|
|
if ($app['security']->isGranted('ROLE_TEACHER')) { |
|
|
|
|
if ($security->isGranted('ROLE_TEACHER')) { |
|
|
|
|
Session::write('is_allowedCreateCourse', true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -639,14 +637,17 @@ $app->before( |
|
|
|
|
|
|
|
|
|
$language = api_get_setting('platformLanguage'); |
|
|
|
|
$iso = api_get_language_isocode($language); |
|
|
|
|
$app['translator']->setLocale($iso); |
|
|
|
|
|
|
|
|
|
/** @var Symfony\Component\Translation\Translator $translator */ |
|
|
|
|
$translator = $app['translator']; |
|
|
|
|
$translator->setLocale($iso); |
|
|
|
|
|
|
|
|
|
// From the login page |
|
|
|
|
$language = $request->get('language'); |
|
|
|
|
|
|
|
|
|
if (!empty($language)) { |
|
|
|
|
$iso = api_get_language_isocode($language); |
|
|
|
|
$app['translator']->setLocale($iso); |
|
|
|
|
$translator->setLocale($iso); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// From the user |
|
|
|
@ -655,14 +656,14 @@ $app->before( |
|
|
|
|
//$language = $user->getLanguage(); |
|
|
|
|
$language = $userInfo['language']; |
|
|
|
|
$iso = api_get_language_isocode($language); |
|
|
|
|
$app['translator']->setLocale($iso); |
|
|
|
|
$translator->setLocale($iso); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// From the course |
|
|
|
|
$courseInfo = api_get_course_info(); |
|
|
|
|
if ($courseInfo && !empty($courseInfo)) { |
|
|
|
|
$iso = api_get_language_isocode($courseInfo['language']); |
|
|
|
|
$app['translator']->setLocale($iso); |
|
|
|
|
$translator->setLocale($iso); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$file = $request->get('file'); |
|
|
|
@ -734,6 +735,7 @@ $app->before( |
|
|
|
|
|
|
|
|
|
$app['template']->assign('course_session', $session); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|