diff --git a/main/admin/configure_homepage.php b/main/admin/configure_homepage.php
index bdce0263cb..a63a659fe1 100755
--- a/main/admin/configure_homepage.php
+++ b/main/admin/configure_homepage.php
@@ -143,6 +143,8 @@ if (!empty($_SESSION['user_language_choice'])) {
$lang = api_get_setting('platformLanguage');
}
+$languageGet = isset($_GET['language']) ? Security::remove_XSS($_GET['language']) : $lang;
+
// Ensuring availability of main files in the corresponding language
if (api_is_multiple_url_enabled()) {
@@ -195,6 +197,7 @@ foreach ($homef as $my_file) {
}
}
}
+
if (api_is_multiple_url_enabled()) {
$homep = $homep_new;
}
@@ -233,22 +236,20 @@ if (!empty($action)) {
}
// Write
- if (file_exists($homep.$topf.'_'.$lang.$ext)) {
+ if (is_writable($homep)) {
+ // Default
if (is_writable($homep.$topf.'_'.$lang.$ext)) {
$fp = fopen($homep.$topf.'_'.$lang.$ext, 'w');
fputs($fp, $home_top);
fclose($fp);
-var_dump($_languages['name']);exit;
+
+ // Language
foreach ($_languages['name'] as $key => $value) {
$lang_name = $_languages['folder'][$key];
if (isset($_POST[$lang_name])) {
- if (file_exists($homep.$topf.'_'.$lang_name.$ext)) {
- if (is_writable($homep.$topf.'_'.$lang_name.$ext)) {
- $fp = fopen($homep.$topf.'_'.$lang_name.$ext, 'w');
- fputs($fp, $home_top);
- fclose($fp);
- }
- }
+ $fp = fopen($homep.$topf.'_'.$lang_name.$ext, 'w');
+ fputs($fp, $home_top);
+ fclose($fp);
}
}
} else {
@@ -275,7 +276,13 @@ var_dump($_languages['name']);exit;
if (EventsMail::check_if_using_class('portal_homepage_edited')) {
EventsDispatcher::events('portal_homepage_edited',array('about_user' => api_get_user_id()));
}
- event_system(LOG_HOMEPAGE_CHANGED, 'edit_top', cut(strip_tags($home_top), 254), api_get_utc_datetime(), api_get_user_id());
+ event_system(
+ LOG_HOMEPAGE_CHANGED,
+ 'edit_top',
+ cut(strip_tags($home_top), 254),
+ api_get_utc_datetime(),
+ api_get_user_id()
+ );
break;
case 'edit_notice':
// Filter
@@ -549,7 +556,7 @@ var_dump($_languages['name']);exit;
} //end of switch($action)
if (empty($errorMsg)) {
- header('Location: '.api_get_self());
+ header('Location: '.api_get_self().'?language='.$languageGet);
exit();
}
} else {
@@ -899,14 +906,13 @@ switch ($action) {
$form->addElement('checkbox', 'all_langs', null, get_lang('ApplyAllLanguages'), array('id' => 'all_langs'));
$form->addElement('html','