diff --git a/main/inc/lib/api.lib.php b/main/inc/lib/api.lib.php index 299970dac9..5a971f27e1 100644 --- a/main/inc/lib/api.lib.php +++ b/main/inc/lib/api.lib.php @@ -227,16 +227,6 @@ define('USERNAME_PURIFIER', '/[^0-9A-Za-z_\.]/'); define('USERNAME_PURIFIER_MAIL', '/[^0-9A-Za-z_\.@]/'); define('USERNAME_PURIFIER_SHALLOW', '/\s/'); -// Constants for detection some important PHP5 subversions. -$php_version = (float) PHP_VERSION; - -define('IS_PHP_52', !((float)$php_version < 5.2)); -define('IS_PHP_53', !((float)$php_version < 5.3)); - -define('IS_PHP_SUP_OR_EQ_53', ($php_version >= 5.3)); -define('IS_PHP_SUP_OR_EQ_52', ($php_version >= 5.2 && !IS_PHP_53)); -define('IS_PHP_SUP_OR_EQ_51', ($php_version >= 5.1 && !IS_PHP_52 && !IS_PHP_53)); - // This constant is a result of Windows OS detection, it has a boolean value: // true whether the server runs on Windows OS, false otherwise. define('IS_WINDOWS_OS', api_is_windows_os()); @@ -306,13 +296,6 @@ define('TO_WEB', 'TO_WEB'); define('TO_SYS', 'TO_SYS'); define('TO_REL', 'TO_REL'); -// Paths to regidtered specific resource files (scripts, players, etc.) -define('FLASH_PLAYER_AUDIO', '{FLASH_PLAYER_AUDIO}'); -define('FLASH_PLAYER_VIDEO', '{FLASH_PLAYER_VIDEO}'); -define('SCRIPT_SWFOBJECT', '{SCRIPT_SWFOBJECT}'); -define('SCRIPT_ASCIIMATHML', '{SCRIPT_ASCIIMATHML}'); -define('DRAWING_ASCIISVG', '{DRAWING_ASCIISVG}'); - // Relations type with Human resources manager define('COURSE_RELATION_TYPE_RRHH', 1); define('SESSION_RELATION_TYPE_RRHH', 1); @@ -553,13 +536,6 @@ define('TOOL_ADMIN_VISIBLE', 'tooladminvisible'); * api_get_path(WEB_TEMPLATE_PATH) http://www.mychamilo.org/chamilo/main/template/ * * - * This is how we retrieve paths of "registerd" resource files (scripts, players, etc.): - * api_get_path(TO_WEB, FLASH_PLAYER_AUDIO) http://www.mychamilo.org/chamilo/main/inc/lib/mediaplayer/player.swf - * api_get_path(TO_WEB, FLASH_PLAYER_VIDEO) http://www.mychamilo.org/chamilo/main/inc/lib/mediaplayer/player.swf - * api_get_path(TO_SYS, SCRIPT_SWFOBJECT) /var/www/chamilo/main/inc/lib/swfobject/swfobject.js - * api_get_path(TO_REL, SCRIPT_ASCIIMATHML) /chamilo/main/inc/lib/asciimath/ASCIIMathML.js - * ... - * * We can convert arbitrary paths, that are not registered (no defined constant). * For guaranteed result, these paths should point inside the system Chamilo. * Some random examples: @@ -568,9 +544,9 @@ define('TOOL_ADMIN_VISIBLE', 'tooladminvisible'); * api_get_path(TO_REL, __FILE__) * ... */ -function api_get_path($path_type, $path = null) { - - static $paths = array( +function api_get_path($path_type, $path = null) +{ + $paths = array( SYS_DATA_PATH => 'data/', SYS_WEB_PATH => 'web/', SYS_CONFIG_PATH => 'config/', @@ -588,264 +564,93 @@ function api_get_path($path_type, $path = null) { WEB_ARCHIVE_PATH => 'temp/', INCLUDE_PATH => 'inc/', LIBRARY_PATH => 'inc/lib/', - SYS_LIBRARY_JS_PATH => 'bundles/chamilocore//js/', + SYS_LIBRARY_JS_PATH => 'bundles/chamilocore/js/', CONFIGURATION_PATH => 'inc/conf/', WEB_LIBRARY_PATH => 'inc/lib/', - WEB_LIBRARY_JS_PATH => 'bundles/chamilocore//js/', + WEB_LIBRARY_JS_PATH => 'bundles/chamilocore/js/', WEB_AJAX_PATH => 'inc/ajax/', SYS_TEST_PATH => 'tests/', WEB_TEMPLATE_PATH => 'template/', SYS_TEMPLATE_PATH => 'template/' ); - static $resource_paths = array( - FLASH_PLAYER_AUDIO => 'inc/lib/mediaplayer/player.swf', - FLASH_PLAYER_VIDEO => 'inc/lib/mediaplayer/player.swf', - SCRIPT_SWFOBJECT => 'inc/lib/swfobject/swfobject.js', - SCRIPT_ASCIIMATHML => 'inc/lib/javascript/asciimath/ASCIIMathML.js', - DRAWING_ASCIISVG => 'inc/lib/javascript/asciimath/d.svg' - ); - - static $is_this_function_initialized; - static $server_base_web; // No trailing slash. - static $server_base_sys; // No trailing slash. - static $root_rel; - static $code_folder; - static $course_folder; - - global $_configuration; - // Always load root_web modifications for multiple url features. - - // Default $_configuration['root_web'] configuration - //$root_web = isset($_configuration['root_web']) ? $_configuration['root_web'] : $app['url_generator']; - - $root_web = Container::getUrlGenerator()->generate('home'); //$_configuration['root_web']; + $root_web = Container::getUrlGenerator()->generate('home'); $rootDir = Container::getRootDir(); // Configuration data for already installed system. $root_sys = $rootDir; - $load_new_config = false; - - if ($path_type == WEB_PATH) { - $urlId = api_get_current_access_url_id(); - if (isset($urlId) && $urlId != 1) { - //we look into the DB the function api_get_access_url - $url_info = api_get_current_access_url_info(); - $root_web = $url_info['active'] == 1 ? $url_info['url'] : $_configuration['root_web']; - $load_new_config = true; - } - } - - if (!$is_this_function_initialized) { - //$root_rel = $_configuration['url_append']; - - $code_folder = 'main/'; - //$course_folder = isset($_configuration['course_folder']) ? $_configuration['course_folder'] : null; - $course_folder = "courses/"; - - // Dealing with trailing slashes. - $root_web = api_add_trailing_slash($root_web); - $root_sys = api_add_trailing_slash($root_sys); - //$root_rel = api_add_trailing_slash($root_rel); - $code_folder = api_add_trailing_slash($code_folder); - $course_folder = api_add_trailing_slash($course_folder); - - // Web server base and system server base. - //$server_base_web = preg_replace('@'.$root_rel.'$@', '', $root_web); // No trailing slash. - //$server_base_sys = preg_replace('@'.$root_rel.'$@', '', $root_sys); // No trailing slash. - - // Initialization of a table that contains common-purpose paths. - $paths[WEB_PATH] = $root_web; - $paths[WEB_PUBLIC_PATH] = $root_web; - $paths[SYS_PATH] = $root_sys; - - // Update data path to get it from config file if defined - $paths[SYS_DATA_PATH] = Container::getDataDir(); - $paths[SYS_LOG_PATH] = Container::getLogDir(); - $paths[SYS_CONFIG_PATH] = Container::getConfigDir(); - $paths[SYS_COURSE_PATH] = Container::getCourseDir(); - - $paths[SYS_DEFAULT_COURSE_DOCUMENT_PATH] = $paths[SYS_DATA_PATH].'default_course_document/'; - - $paths[SYS_WEB_PATH] = $root_sys.'web/'; - - $paths[REL_PATH] = $root_rel; - //$paths[WEB_SERVER_ROOT_PATH] = $server_base_web.'/'; - //$paths[SYS_SERVER_ROOT_PATH] = $server_base_sys.'/'; - - $paths[WEB_DATA_PATH] = $paths[WEB_PUBLIC_PATH].'data/'; - $paths[WEB_COURSE_PATH] = $root_web.$course_folder; - $paths[WEB_DATA_COURSE_PATH] = $paths[WEB_DATA_PATH].$course_folder; - - $paths[REL_COURSE_PATH] = $root_rel.$course_folder; - $paths[REL_CODE_PATH] = $root_rel.$code_folder; - $paths[WEB_CODE_PATH] = $root_web.$code_folder; - $paths[REL_DATA_PATH] = $root_rel.'data/'; - - $paths[WEB_DEFAULT_COURSE_DOCUMENT_PATH] = $paths[WEB_DATA_PATH].'default_course_document/'; - $paths[REL_DEFAULT_COURSE_DOCUMENT_PATH] = $paths[REL_DATA_PATH].'default_course_document/'; - - $paths[SYS_CODE_PATH] = $root_sys.$code_folder; - - // Now we can switch into api_get_path() "terminology". - $paths[SYS_LANG_PATH] = $paths[SYS_CODE_PATH].$paths[SYS_LANG_PATH]; - $paths[SYS_PLUGIN_PATH] = $paths[SYS_PATH].$paths[SYS_PLUGIN_PATH]; - $paths[SYS_ARCHIVE_PATH] = Container::getTempDir(); - $paths[SYS_TEST_PATH] = $paths[SYS_PATH].$paths[SYS_TEST_PATH]; - $paths[SYS_TEMPLATE_PATH] = $paths[SYS_CODE_PATH].$paths[SYS_TEMPLATE_PATH]; - $paths[SYS_CSS_PATH] = $paths[SYS_PATH].$paths[SYS_CSS_PATH]; - $paths[WEB_CSS_PATH] = $paths[WEB_PATH].$paths[WEB_CSS_PATH]; - $paths[WEB_IMG_PATH] = $paths[WEB_PATH].$paths[WEB_IMG_PATH]; - $paths[SYS_IMG_PATH] = $paths[SYS_PATH].$paths[SYS_IMG_PATH]; - - $paths[WEB_LIBRARY_PATH] = $paths[WEB_CODE_PATH].$paths[WEB_LIBRARY_PATH]; - $paths[WEB_LIBRARY_JS_PATH] = $paths[WEB_PATH].$paths[WEB_LIBRARY_JS_PATH]; - $paths[WEB_AJAX_PATH] = $paths[WEB_PUBLIC_PATH].'main/'.$paths[WEB_AJAX_PATH]; - $paths[WEB_PLUGIN_PATH] = $paths[WEB_PATH].$paths[WEB_PLUGIN_PATH]; - $paths[WEB_ARCHIVE_PATH] = $paths[WEB_PATH].$paths[WEB_ARCHIVE_PATH]; - $paths[WEB_TEMPLATE_PATH] = $paths[WEB_CODE_PATH].$paths[WEB_TEMPLATE_PATH]; - $paths[INCLUDE_PATH] = $paths[SYS_CODE_PATH].$paths[INCLUDE_PATH]; - $paths[LIBRARY_PATH] = $paths[SYS_CODE_PATH].$paths[LIBRARY_PATH]; - $paths[SYS_LIBRARY_JS_PATH] = $paths[SYS_PATH].$paths[SYS_LIBRARY_JS_PATH]; - $paths[CONFIGURATION_PATH] = $paths[SYS_CODE_PATH].$paths[CONFIGURATION_PATH]; - - $is_this_function_initialized = true; - - } else { - if ($load_new_config) { - // Redefining variables to work well with the "multiple url" feature - - // All web paths need to be here - $web_paths = array( - WEB_PATH => '', - WEB_SERVER_ROOT_PATH => '', - WEB_COURSE_PATH => '', - WEB_CODE_PATH => '', - WEB_IMG_PATH => 'img/', - WEB_CSS_PATH => 'css/', - WEB_PLUGIN_PATH => 'plugin/', - WEB_ARCHIVE_PATH => 'archive/', - WEB_LIBRARY_PATH => 'inc/lib/', - WEB_LIBRARY_JS_PATH => 'inc/lib/javascript/', - WEB_AJAX_PATH => 'inc/ajax/', - WEB_PUBLIC_PATH => 'web/', - ); - - $root_web = api_add_trailing_slash($root_web); - // Web server base and system server base. - $server_base_web = preg_replace('@'.$root_rel.'$@', '', $root_web); // No trailing slash. - - // Redefine root webs - $paths[WEB_PATH] = $root_web; - $paths[WEB_SERVER_ROOT_PATH] = $server_base_web.'/'; - $paths[WEB_COURSE_PATH] = $root_web.$course_folder; - $paths[WEB_CODE_PATH] = $root_web.$code_folder; - $paths[WEB_IMG_PATH] = $paths[WEB_CODE_PATH].$web_paths[WEB_IMG_PATH]; - - $paths[WEB_CSS_PATH] = $paths[WEB_CODE_PATH].$web_paths[WEB_CSS_PATH]; - $paths[WEB_PLUGIN_PATH] = $paths[WEB_PATH].$web_paths[WEB_PLUGIN_PATH]; - $paths[WEB_ARCHIVE_PATH] = $paths[WEB_PATH].$web_paths[WEB_ARCHIVE_PATH]; - $paths[WEB_LIBRARY_PATH] = $paths[WEB_CODE_PATH].$web_paths[WEB_LIBRARY_PATH]; - $paths[WEB_LIBRARY_JS_PATH] = $paths[WEB_CODE_PATH].$web_paths[WEB_LIBRARY_JS_PATH]; - $paths[WEB_AJAX_PATH] = $paths[WEB_CODE_PATH].$web_paths[WEB_AJAX_PATH]; - $paths[WEB_PUBLIC_PATH] = $paths[WEB_PATH].$web_paths[WEB_PUBLIC_PATH]; - } - } - - // Shallow purification and validation of input parameters. - - $path_type = trim($path_type); - $path = trim($path); + $code_folder = 'main/'; + //$course_folder = isset($_configuration['course_folder']) ? $_configuration['course_folder'] : null; + $course_folder = "courses/"; + + // Dealing with trailing slashes. + $root_web = api_add_trailing_slash($root_web); + $root_sys = api_add_trailing_slash($root_sys); + //$root_rel = api_add_trailing_slash($root_rel); + $code_folder = api_add_trailing_slash($code_folder); + $course_folder = api_add_trailing_slash($course_folder); + $root_rel = null; + + // Initialization of a table that contains common-purpose paths. + $paths[WEB_PATH] = $root_web; + $paths[WEB_PUBLIC_PATH] = $root_web; + $paths[SYS_PATH] = $root_sys; + + // Update data path to get it from config file if defined + $paths[SYS_DATA_PATH] = Container::getDataDir(); + $paths[SYS_LOG_PATH] = Container::getLogDir(); + $paths[SYS_CONFIG_PATH] = Container::getConfigDir(); + $paths[SYS_COURSE_PATH] = Container::getCourseDir(); + + $paths[SYS_DEFAULT_COURSE_DOCUMENT_PATH] = $paths[SYS_DATA_PATH].'default_course_document/'; + + $paths[SYS_WEB_PATH] = $root_sys.'web/'; + $paths[REL_PATH] = $root_rel; + $paths[WEB_DATA_PATH] = $paths[WEB_PUBLIC_PATH].'data/'; + $paths[WEB_COURSE_PATH] = $root_web.$course_folder; + $paths[WEB_DATA_COURSE_PATH] = $paths[WEB_DATA_PATH].$course_folder; + + $paths[REL_COURSE_PATH] = $root_rel.$course_folder; + $paths[REL_CODE_PATH] = $root_rel.$code_folder; + $paths[WEB_CODE_PATH] = $root_web.$code_folder; + $paths[REL_DATA_PATH] = $root_rel.'data/'; + + $paths[WEB_DEFAULT_COURSE_DOCUMENT_PATH] = $paths[WEB_DATA_PATH].'default_course_document/'; + $paths[REL_DEFAULT_COURSE_DOCUMENT_PATH] = $paths[REL_DATA_PATH].'default_course_document/'; + + $paths[SYS_CODE_PATH] = $root_sys.$code_folder; + + // Now we can switch into api_get_path() "terminology". + $paths[SYS_LANG_PATH] = $paths[SYS_CODE_PATH].$paths[SYS_LANG_PATH]; + $paths[SYS_PLUGIN_PATH] = $paths[SYS_PATH].$paths[SYS_PLUGIN_PATH]; + $paths[SYS_ARCHIVE_PATH] = Container::getTempDir(); + $paths[SYS_TEST_PATH] = $paths[SYS_PATH].$paths[SYS_TEST_PATH]; + $paths[SYS_TEMPLATE_PATH] = $paths[SYS_CODE_PATH].$paths[SYS_TEMPLATE_PATH]; + $paths[SYS_CSS_PATH] = $paths[SYS_PATH].$paths[SYS_CSS_PATH]; + $paths[WEB_CSS_PATH] = $paths[WEB_PATH].$paths[WEB_CSS_PATH]; + $paths[WEB_IMG_PATH] = $paths[WEB_PATH].$paths[WEB_IMG_PATH]; + $paths[SYS_IMG_PATH] = $paths[SYS_PATH].$paths[SYS_IMG_PATH]; + + $paths[WEB_LIBRARY_PATH] = $paths[WEB_CODE_PATH].$paths[WEB_LIBRARY_PATH]; + $paths[WEB_LIBRARY_JS_PATH] = $paths[WEB_PATH].$paths[WEB_LIBRARY_JS_PATH]; + $paths[WEB_AJAX_PATH] = $paths[WEB_PUBLIC_PATH].'main/'.$paths[WEB_AJAX_PATH]; + $paths[WEB_PLUGIN_PATH] = $paths[WEB_PATH].$paths[WEB_PLUGIN_PATH]; + $paths[WEB_ARCHIVE_PATH] = $paths[WEB_PATH].$paths[WEB_ARCHIVE_PATH]; + $paths[WEB_TEMPLATE_PATH] = $paths[WEB_CODE_PATH].$paths[WEB_TEMPLATE_PATH]; + $paths[INCLUDE_PATH] = $paths[SYS_CODE_PATH].$paths[INCLUDE_PATH]; + $paths[LIBRARY_PATH] = $paths[SYS_CODE_PATH].$paths[LIBRARY_PATH]; + $paths[SYS_LIBRARY_JS_PATH] = $paths[SYS_PATH].$paths[SYS_LIBRARY_JS_PATH]; + $paths[CONFIGURATION_PATH] = $paths[SYS_CODE_PATH].$paths[CONFIGURATION_PATH]; + // Path conversion to the requested type. if (empty($path_type)) { return null; } - // Retrieving a common-purpose path. if (isset($paths[$path_type])) { return $paths[$path_type]; } - - // Retrieving a specific resource path. - - if (isset($resource_paths[$path])) { - switch ($path_type) { - case TO_WEB: - return $paths[WEB_CODE_PATH].$resource_paths[$path]; - case TO_SYS: - return $paths[SYS_CODE_PATH].$resource_paths[$path]; - case TO_REL: - return $paths[REL_CODE_PATH].$resource_paths[$path]; - default: - return null; - } - } - - // Common-purpose paths as a second parameter - recognition. - - if (isset($paths[$path])) { - $path = $paths[$path]; - } - - // Second purification. - - // Replacing Windows back slashes. - $path = str_replace('\\', '/', $path); - // Query strings sometimes mighth wrongly appear in non-URLs. - // Let us check remove them from all types of paths. - if (($pos = strpos($path, '?')) !== false) { - $path = substr($path, 0, $pos); - } - - // Detection of the input path type. Conversion to semi-absolute type ( /chamilo/main/inc/.... ). - - if (preg_match(VALID_WEB_PATH, $path)) { - - // A special case: When a URL points to the document download script directly, without - // mod-rewrite translation, we have to translate it into an "ordinary" web path. - // For example: - // http://localhost/chamilo/main/document/download.php?doc_url=/image.png&cDir=/ - // becomes - // http://localhost/chamilo/courses/TEST/document/image.png - // TEST is a course directory name, so called "system course code". - if (strpos($path, 'download.php') !== false) { // Fast detection first. - $path = urldecode($path); - if (preg_match('/(.*)main\/document\/download.php\?doc_url=\/(.*)&cDir=\/(.*)?/', $path, $matches)) { - $sys_course_code = - isset($_SESSION['_course']['sysCode']) // User is inside a course? - ? $_SESSION['_course']['sysCode'] // Yes, then use course's directory name. - : '{SYS_COURSE_CODE}'; // No, then use a fake code, it may be processed later. - $path = $matches[1].'courses/'.$sys_course_code.'/document/'.str_replace('//', '/', $matches[3].'/'.$matches[2]); - } - } - - // Replacement of the present web server base with a slash '/'. - $path = preg_replace(VALID_WEB_SERVER_BASE, '/', $path); - - } elseif (strpos($path, $server_base_sys) === 0) { - $path = preg_replace('@^'.$server_base_sys.'@', '', $path); - } elseif (strpos($path, '/') === 0) { - // Leading slash - we assume that this path is semi-absolute (REL), - // then path is left without further modifications. - } else { - return null; // Probably implementation of this case won't be needed. - } - - // Path now is semi-absolute. It is convenient at this moment repeated slashes to be removed. - $path = preg_replace(REPEATED_SLASHES_PURIFIER, '/', $path); - - // Path conversion to the requested type. - - switch ($path_type) { - case TO_WEB: - return $server_base_web.$path; - case TO_SYS: - return $server_base_sys.$path; - case TO_REL: - return $path; - } - return null; } @@ -1051,9 +856,6 @@ function api_block_anonymous_users($print_headers = true) return true; } -/* ACCESSOR FUNCTIONS - Don't access kernel variables directly, use these functions instead. */ - /** * @return an array with the navigator name and version */ @@ -5845,6 +5647,7 @@ function api_get_unique_id() { } function api_get_home_path() { + return null; $home = 'home/'; $access_url_id = api_get_current_access_url_id(); if (api_get_multiple_access_url() && $access_url_id != -1) { @@ -6286,7 +6089,7 @@ function api_get_js_simple($file) function api_set_settings_and_plugins() { - global $_configuration; + //global $_configuration; $_setting = array(); $_plugins = array(); @@ -6294,21 +6097,18 @@ function api_set_settings_and_plugins() $settings_by_access_list = array(); $access_url_id = api_get_current_access_url_id(); if ($access_url_id != 1) { - $url_info = api_get_current_access_url_info(); - if ($url_info['active'] == 1) { - $settings_by_access = api_get_settings(null, 'list', $_configuration['access_url'], 1); - foreach ($settings_by_access as $row) { - if (empty($row['variable'])) { - $row['variable'] = 0; - } - if (empty($row['subkey'])) { - $row['subkey'] = 0; - } - if (empty($row['category'])) { - $row['category'] = 0; - } - $settings_by_access_list[$row['variable']][$row['subkey']][$row['category']] = $row; + $settings_by_access = api_get_settings(null, 'list', $access_url_id, 1); + foreach ($settings_by_access as $row) { + if (empty($row['variable'])) { + $row['variable'] = 0; } + if (empty($row['subkey'])) { + $row['subkey'] = 0; + } + if (empty($row['category'])) { + $row['category'] = 0; + } + $settings_by_access_list[$row['variable']][$row['subkey']][$row['category']] = $row; } } @@ -6316,13 +6116,13 @@ function api_set_settings_and_plugins() foreach ($result as & $row) { if ($access_url_id != 1) { - if ($url_info['active'] == 1) { + //if ($url_info['active'] == 1) { $var = empty($row['variable']) ? 0 : $row['variable']; $subkey = empty($row['subkey']) ? 0 : $row['subkey']; $category = empty($row['category']) ? 0 : $row['category']; - } + //} - if ($row['access_url_changeable'] == 1 && $url_info['active'] == 1) { + if ($row['access_url_changeable'] == 1) { if (isset($settings_by_access_list[$var]) && $settings_by_access_list[$var][$subkey][$category]['selected_value'] != '') { if ($row['subkey'] == null) { diff --git a/main/inc/lib/internationalization.lib.php b/main/inc/lib/internationalization.lib.php index ce24d272d0..3797fbb0f5 100644 --- a/main/inc/lib/internationalization.lib.php +++ b/main/inc/lib/internationalization.lib.php @@ -125,33 +125,8 @@ function api_purify_language_id($language) function api_get_language_isocode($language = null, $default_code = 'en') { return Container::getTranslator()->getLocale(); - - static $iso_code = array(); - if (empty($language)) { - $language = api_get_interface_language(false, true); - } - - if (!isset($iso_code[$language])) { - $sql = "SELECT isocode - FROM ".Database::get_main_table(TABLE_MAIN_LANGUAGE)." - WHERE dokeos_folder = '$language'"; - $result = Database::query($sql); - if (Database::num_rows($result)) { - $result = Database::fetch_array($result); - $iso_code[$language] = trim($result['isocode']); - } else { - $language_purified_id = api_purify_language_id($language); - $iso_code[$language] = isset($iso_code[$language_purified_id]) ? $iso_code[$language_purified_id] : null; - } - if (empty($iso_code[$language])) { - $iso_code[$language] = $default_code; - } - } - - return $iso_code[$language]; } - /** * Gets language iso code column from the language table * diff --git a/main/inc/lib/login.lib.php b/main/inc/lib/login.lib.php index 4409bdd9c3..f66dd872a4 100644 --- a/main/inc/lib/login.lib.php +++ b/main/inc/lib/login.lib.php @@ -30,10 +30,10 @@ class Login { $portal_url = api_get_path(WEB_PATH); - if (api_is_multiple_url_enabled()) { + /*if (api_is_multiple_url_enabled()) { $url = api_get_current_access_url_info(); $portal_url = $url['url']; - } + }*/ if ($reset) { if ($by_username) { diff --git a/main/inc/lib/usermanager.lib.php b/main/inc/lib/usermanager.lib.php index e6d2163465..121ecf7714 100644 --- a/main/inc/lib/usermanager.lib.php +++ b/main/inc/lib/usermanager.lib.php @@ -378,13 +378,11 @@ class UserManager PERSON_NAME_EMAIL_ADDRESS ); $email_admin = api_get_setting('platform.administrator_email'); - $url = api_get_current_access_url_info(); $params = array( 'complete_user_name' => api_get_person_name($firstName, $lastName), 'login_name' => $loginName, - 'password' => stripslashes($original_password), - 'url' => $url, + 'password' => stripslashes($original_password) ); $message = \Swift_Message::newInstance() @@ -807,8 +805,6 @@ class UserManager } } - - $em = Database::getManager(); /** @var Chamilo\UserBundle\Entity\User $user */ @@ -863,7 +859,6 @@ class UserManager Container::getUserManager()->updateUser($user, true); if (!empty($email) && $send_email) { - //Container::getMailer()->send() $recipient_name = api_get_person_name($firstname, $lastname, null, PERSON_NAME_EMAIL_ADDRESS); $emailsubject = '['.api_get_setting('platform.site_name').'] '.get_lang('YourReg').' '.api_get_setting('platform.site_name'); $sender_name = api_get_person_name( @@ -873,18 +868,9 @@ class UserManager PERSON_NAME_EMAIL_ADDRESS ); $email_admin = api_get_setting('platform.administrator_email'); - $emailbody = null; - if ($_configuration['multiple_access_urls']) { - $access_url_id = api_get_current_access_url_id(); - if ($access_url_id != -1) { - $url = api_get_current_access_url_info(); - $emailbody = get_lang('Dear')." ".stripslashes(api_get_person_name($firstname, $lastname)).",\n\n".get_lang('YouAreReg')." ". api_get_setting('platform.site_name') ." ".get_lang('WithTheFollowingSettings')."\n\n".get_lang('Username')." : ". $username . (($reset_password > 0) ? "\n". get_lang('Pass')." : ".stripslashes($original_password) : "") . "\n\n" .get_lang('Address') ." ". api_get_setting('platform.site_name') ." ". get_lang('Is') ." : ". $url['url'] ."\n\n". get_lang('Problem'). "\n\n". get_lang('Formula').",\n\n".api_get_person_name(api_get_setting('platform.administrator_name'), api_get_setting('platform.administrator_surname'))."\n". get_lang('Manager'). " ".api_get_setting('platform.site_name')."\nT. ".api_get_setting('administratorTelephone')."\n" .get_lang('Email') ." : ".api_get_setting('platform.administrator_email'); - } - } else { - $emailbody=get_lang('Dear')." ".stripslashes(api_get_person_name($firstname, $lastname)).",\n\n".get_lang('YouAreReg')." ". api_get_setting('platform.site_name') ." ".get_lang('WithTheFollowingSettings')."\n\n".get_lang('Username')." : ". $username . (($reset_password > 0) ? "\n". get_lang('Pass')." : ".stripslashes($original_password) : "") . "\n\n" .get_lang('Address') ." ". api_get_setting('platform.site_name') ." ". get_lang('Is') ." : ". api_get_path(WEB_PUBLIC_PATH) ."\n\n". get_lang('Problem'). "\n\n". get_lang('Formula').",\n\n".api_get_person_name(api_get_setting('platform.administrator_name'), api_get_setting('platform.administrator_surname'))."\n". get_lang('Manager'). " ".api_get_setting('platform.site_name')."\nT. ".api_get_setting('administratorTelephone')."\n" .get_lang('Email') ." : ".api_get_setting('platform.administrator_email'); - } - api_mail_html($recipient_name, $email, $emailsubject, $emailbody, $sender_name, $email_admin); + /*api_mail_html($recipient_name, $email, $emailsubject, + $emailbody, $sender_name, $email_admin);*/ } $user_info = api_get_user_info($user_id); @@ -4140,8 +4126,9 @@ class UserManager if (empty($url1)) { $url = $url2; if (empty($url)) { - $url = api_get_current_access_url_info(); - $url = $url[0]; + $url = api_get_path(WEB_PATH); + //$url = api_get_current_access_url_info(); + //$url = $url[0]; } } if (!empty($url)) { diff --git a/main/wiki/wiki.inc.php b/main/wiki/wiki.inc.php index 02b0a5a078..8d90d874ee 100644 --- a/main/wiki/wiki.inc.php +++ b/main/wiki/wiki.inc.php @@ -1625,7 +1625,7 @@ class Wiki $css = str_replace('../../img/', $root_rel.'main/img/', $css); $asciimathmal_script = (api_contains_asciimathml($wikiContents) || api_contains_asciisvg($wikiContents)) - ? ''."\n" : ''; + ? ''."\n" : ''; $template = str_replace(array('{LANGUAGE}', '{ENCODING}', '{TEXT_DIRECTION}', '{TITLE}', '{CSS}', '{ASCIIMATHML_SCRIPT}'), array(api_get_language_isocode(), api_get_system_encoding(), api_get_text_direction(), $wikiTitle, $css, $asciimathmal_script), diff --git a/src/Chamilo/CoreBundle/Controller/IndexController.php b/src/Chamilo/CoreBundle/Controller/IndexController.php index d7cd52e9d5..dcf51d790e 100644 --- a/src/Chamilo/CoreBundle/Controller/IndexController.php +++ b/src/Chamilo/CoreBundle/Controller/IndexController.php @@ -15,7 +15,7 @@ use Symfony\Component\Finder\Finder; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; -//use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security; +use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security; /** * Class IndexController @@ -72,20 +72,22 @@ class IndexController extends BaseController ); } - - //@Security("has_role('ROLE_USER')") /** * @Route("/userportal", name="userportal") * @Method({"GET"}) - * + * @Security("has_role('ROLE_USER')") * * @param string $type courses|sessions|mycoursecategories * @param string $filter for the userportal courses page. Only works when setting 'history' * @param int $page + * * @return Response */ - public function userPortalAction($type = 'courses', $filter = 'current', $page = 1) - { + public function userPortalAction( + $type = 'courses', + $filter = 'current', + $coursePage = 1 + ) { /** @var \Chamilo\CoreBundle\Entity\CourseManager $courseManager */ $courseManager = $this->get('chamilo_core.manager.course'); @@ -96,6 +98,7 @@ class IndexController extends BaseController $user = $this->getUser(); $pageController = new \Chamilo\CoreBundle\Framework\PageController(); $items = null; + $page = $coursePage; if (!empty($user)) { $userId = $user->getId(); @@ -299,14 +302,11 @@ class IndexController extends BaseController } } - - - //* @Security("has_role('ROLE_TEACHER')") /** * Toggle the student view action * * @Route("/toggle_student_view") - + * @Security("has_role('ROLE_TEACHER')") * @Method({"GET"}) * * @return Response diff --git a/src/Chamilo/CoreBundle/EventListener/LegacyListener.php b/src/Chamilo/CoreBundle/EventListener/LegacyListener.php index e62e58070a..6f7c1925fc 100644 --- a/src/Chamilo/CoreBundle/EventListener/LegacyListener.php +++ b/src/Chamilo/CoreBundle/EventListener/LegacyListener.php @@ -115,6 +115,17 @@ class LegacyListener } } + /** @var \Sonata\PageBundle\Model\SnapshotPageProxy $page */ + $page = $request->get('page'); + if (isset($page)) { + $siteId = $page->getSite()->getId(); + $request->getSession()->set('url_info', $page->getSite()); + } else { + $siteId = 1; + } + + $request->getSession()->set('url_id', $siteId); + // Loading portal settings from DB. $settingsRefreshInfo = $em->getRepository('ChamiloCoreBundle:SettingsCurrent')->findOneByVariable('settings_latest_update'); $settingsLatestUpdate = !empty($settingsRefreshInfo) ? $settingsRefreshInfo->getSelectedValue() : null; diff --git a/src/Chamilo/CoreBundle/Framework/Container.php b/src/Chamilo/CoreBundle/Framework/Container.php index 314d598b70..f0e302e499 100644 --- a/src/Chamilo/CoreBundle/Framework/Container.php +++ b/src/Chamilo/CoreBundle/Framework/Container.php @@ -224,4 +224,12 @@ class Container { return self::$container->get('fos_user.group_manager'); } + + /** + * @return \Symfony\Component\HttpKernel\Debug\TraceableEventDispatcher + */ + public static function getEventDispatcher() + { + return self::$container->get('event_dispatcher'); + } } diff --git a/src/Chamilo/CoreBundle/Framework/Template.php b/src/Chamilo/CoreBundle/Framework/Template.php index 22c71019bd..41feee1185 100644 --- a/src/Chamilo/CoreBundle/Framework/Template.php +++ b/src/Chamilo/CoreBundle/Framework/Template.php @@ -655,7 +655,8 @@ class Template $favico = ''; - if (isset($_configuration['multiple_access_urls']) && $_configuration['multiple_access_urls']) { + /*if (isset($_configuration['multiple_access_urls']) && + $_configuration['multiple_access_urls']) { $access_url_id = api_get_current_access_url_id(); if ($access_url_id != -1) { $url_info = api_get_current_access_url_info(); @@ -671,9 +672,9 @@ class Template $favico = ''; } } - } + }*/ - $this->assign('favico', $favico); + //$this->assign('favico', $favico); $this->setHelp(); @@ -869,6 +870,8 @@ class Template */ public function returnMenu() { + return null; + $navigation = $this->navigation_array; $navigation = $navigation['navigation']; diff --git a/src/Chamilo/CoreBundle/Resources/views/Mailer/User/new_user.text.twig b/src/Chamilo/CoreBundle/Resources/views/Mailer/User/new_user.text.twig index 9fec91b90c..4974486b06 100644 --- a/src/Chamilo/CoreBundle/Resources/views/Mailer/User/new_user.text.twig +++ b/src/Chamilo/CoreBundle/Resources/views/Mailer/User/new_user.text.twig @@ -9,7 +9,7 @@ {{ 'Username' | trans }}: {{ login_name }} {{ 'Password' | trans }}: {{ password }} {{ 'Address' | trans }}: {{ site_name }} -{{ 'Is' | trans }} {{ url.url }} +{{ 'Is' | trans }} {{ url('home') }} {{ 'Problem' | trans }} {{ 'Formula' | trans }},