Fixing old links see BT#8704

1.9.x
Julio Montoya 11 years ago
parent b61eab0c00
commit 8dd695ebcf
  1. 52
      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','<table id="table_langs" style="margin-left:159px;"><tr>');
$i = 0;
foreach ($_languages['name'] as $key => $value) {
$i++;
$i++;
$lang_name = $_languages['folder'][$key];
$html_langs = '<td width="300">';
$html_langs .= '<label><input type="checkbox" id="lang" name="'.$lang_name.'" />&nbsp;'.$lang_name.'<label/>';
@ -890,7 +899,7 @@ switch ($action) {
}
$form->addElement('html', $html_langs);
}
$form->addElement('html','</tr></table><br/>');
$form->addElement('html','</tr></table><br/>');
$form->addElement('style_submit_button', null, get_lang('Save'), 'class="save"');
}
@ -953,7 +962,7 @@ switch ($action) {
$form->addElement('html','<table id="table_langs" style="margin-left:5px;"><tr>');
$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 = '<td width="300">';
@ -963,10 +972,10 @@ switch ($action) {
$html_langs .= '</tr><tr>';
}
$form->addElement('html', $html_langs);
}
}
$form->addElement('html','</tr></table><br/>');
$form->addElement('html','</tr></table><br/>');
$form->addElement('style_submit_button', null, get_lang('Save'), 'class="save"');
$form->setDefaults($default);
$form->display();
@ -1000,7 +1009,7 @@ switch ($action) {
</tr>
<tr>
<?php
$access_url_id = 1;
// we only show the category options for the main chamilo installation
if (api_is_multiple_url_enabled()) {
@ -1055,14 +1064,23 @@ switch ($action) {
// Add new page
$home_menu = '';
if (file_exists($homep.$mtloggedin.'_'.$lang.$ext)) {
$home_menu = @file($homep.$mtloggedin.'_'.$lang.$ext);
} else {
$home_menu = @file($homep.$mtloggedin.$ext);
}
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();
}
if (!empty($home_menu)) {
$home_menu = implode("\n", $home_menu);
$home_menu = api_to_system_encoding($home_menu, api_detect_encoding(strip_tags($home_menu)));

Loading…
Cancel
Save