From 8dd695ebcfd1d60a8e269cec6de4a47c988e0688 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Thu, 25 Sep 2014 09:28:55 +0200 Subject: [PATCH] Fixing old links see BT#8704 --- main/admin/configure_homepage.php | 52 +++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 17 deletions(-) diff --git a/main/admin/configure_homepage.php b/main/admin/configure_homepage.php index dd9d32d9d2..2573cccb71 100755 --- a/main/admin/configure_homepage.php +++ b/main/admin/configure_homepage.php @@ -228,7 +228,7 @@ if (!empty($action)) { $fp = fopen($homep.$topf.'_'.$lang.$ext, 'w'); fputs($fp, $home_top); fclose($fp); - + foreach ($_languages['name'] as $key => $value) { $lang_name = $_languages['folder'][$key]; if (isset($_POST[$lang_name])) { @@ -241,7 +241,7 @@ if (!empty($action)) { } } } - + } else { $errorMsg = get_lang('HomePageFilesNotWritable'); } @@ -250,7 +250,7 @@ if (!empty($action)) { $fp = fopen($homep.$topf.'_'.$lang.$ext, 'w'); fputs($fp, $home_top); fclose($fp); - + foreach ($_languages['name'] as $key => $value) { $lang_name = $_languages['folder'][$key]; if (isset($_POST[$lang_name])) { @@ -258,10 +258,10 @@ if (!empty($action)) { $fp = fopen($homep.$topf.'_'.$lang_name.$ext, 'w'); fputs($fp, $home_top); fclose($fp); - + } } - } + } } if (EventsMail::check_if_using_class('portal_homepage_edited')) { @@ -295,10 +295,10 @@ if (!empty($action)) { } } } - + } else { fputs($fp, ''); - + foreach ($_languages['name'] as $key => $value) { $lang_name = $_languages['folder'][$key]; if (isset($_POST[$lang_name])) { @@ -395,6 +395,7 @@ if (!empty($action)) { $link_url='http://'.$link_url; } $menuf = ($action == 'insert_tabs' || $action == 'edit_tabs')? $mtloggedin : $menuf; + if (!is_writable($homep.$menuf.'_'.$lang.$ext)) { $errorMsg = get_lang('HomePageFilesNotWritable'); } elseif (empty($link_name)) { @@ -404,6 +405,7 @@ if (!empty($action)) { if ($action == 'insert_link' || $action == 'insert_tabs' || empty($filename) || strstr($filename, '/') || !strstr($filename, '.html')) { $filename = replace_dangerous_char($link_name, 'strict').'.html'; } + // "home_" prefix for links are renamed to "user_" prefix (to avoid name clash with existing home page files) if (!empty($filename)) { $filename = str_replace('home_', 'user_', $filename); @@ -492,7 +494,7 @@ if (!empty($action)) { fputs($fp, $home_menu); home_tabs($homep.$menuf.'_'.$lang.$ext); fclose($fp); - + foreach ($_languages['name'] as $key => $value) { $lang_name = $_languages['folder'][$key]; if (isset($_POST[$lang_name])) { @@ -502,7 +504,7 @@ if (!empty($action)) { fclose($fp); } } - + if (file_exists($homep.$menuf.$ext)) { if (is_writable($homep.$menuf.$ext)) { $fpo = fopen($homep.$menuf.$ext, 'w'); @@ -520,7 +522,7 @@ if (!empty($action)) { fputs($fp, $home_menu); home_tabs($homep.$menuf.'_'.$lang.$ext); fclose($fp); - + foreach ($_languages['name'] as $key => $value) { $lang_name = $_languages['folder'][$key]; if (isset($_POST[$lang_name])) { @@ -529,7 +531,7 @@ if (!empty($action)) { home_tabs($homep.$menuf.'_'.$lang_name.$ext); fclose($fp); } - } + } } } event_system(LOG_HOMEPAGE_CHANGED, $action, cut($link_name.':'.$link_url, 254), api_get_utc_datetime(), api_get_user_id()); @@ -679,6 +681,13 @@ if (!empty($action)) { } else { $errorMsg = get_lang('HomePageFilesNotReadable'); } + + if (empty($home_menu)) { + if (file_exists($homep.$menutabs.'_'.$lang.$ext)) { + $home_menu = @file($homep.$menutabs.'_'.$lang.$ext); + } + } + if (empty($home_menu)) { $home_menu = array(); } @@ -880,7 +889,7 @@ switch ($action) { $form->addElement('html',''); $i = 0; foreach ($_languages['name'] as $key => $value) { - $i++; + $i++; $lang_name = $_languages['folder'][$key]; $html_langs = '
'; $html_langs .= '

'); + $form->addElement('html','
'); $form->addElement('style_submit_button', null, get_lang('Save'), 'class="save"'); } @@ -953,7 +962,7 @@ switch ($action) { $form->addElement('html',''); $i = 0; foreach ($_languages['name'] as $key => $value) { - $i++; + $i++; $lang_name = $_languages['folder'][$key]; if (file_exists($homep.$topf.'_'.$lang_name.$ext)) { $html_langs = ''; } $form->addElement('html', $html_langs); - + } } - $form->addElement('html','
'; @@ -963,10 +972,10 @@ switch ($action) { $html_langs .= '

'); + $form->addElement('html','
'); $form->addElement('style_submit_button', null, get_lang('Save'), 'class="save"'); $form->setDefaults($default); $form->display(); @@ -1000,7 +1009,7 @@ switch ($action) {