From the postcard_preview.html template, 4images versions 1.7 and 1.7.1 both tie the {lang_edit_postcard}, "Modify eCard" / "eCard bearbeiten", form button to the browser history back function. This sends the visitor back to the postcard_create.html templated page. But whether the values previously entered into the form fields appear or the form is reset to its defaults depends on the browser being used. Under Internet Explorer 6, the browser doesn't even navigate back!
The code posted here fixes the "Modify eCard" / "eCard bearbeiten" button so that the user is always sent back to the postcard_create.html templated page and the values they entered previously are reused when the page loads.
Open postcards.php
Locate:
$main_template = ($action == "createcard") ? "postcard_create" : (($action == "previewcard") ? "postcard_create" : "postcard_send");
Change to:
$main_template = ($action == "createcard" || $action == "modifycard") ? "postcard_create" : (($action == "previewcard") ? "postcard_create" : "postcard_send");
Locate:
if ($action == "createcard") {
Change to:
if ($action == "createcard" || $action == "modifycard") {
Locate:
if (!$sendprocess) {
$bg_color = "";
$border_color = "";
$font_color = "";
$font_face = "";
$sender_name = ($user_info['user_level'] != GUEST) ? $user_info['user_name'] : "";
$sender_email = ($user_info['user_level'] != GUEST) ? $user_info['user_email'] : "";
$recipient_name = "";
$recipient_email = "";
$headline = "";
$message = "";
}
Add immediately after on a new line:
if ($action == "modifycard") {
$bg_color = un_htmlspecialchars(trim($HTTP_POST_VARS['bg_color']));
$border_color = un_htmlspecialchars(trim($HTTP_POST_VARS['border_color']));
$font_color = un_htmlspecialchars(trim($HTTP_POST_VARS['font_color']));
$font_face = un_htmlspecialchars(trim($HTTP_POST_VARS['font_face']));
$sender_name = un_htmlspecialchars(trim($HTTP_POST_VARS['sender_name']));
$sender_email = un_htmlspecialchars(trim($HTTP_POST_VARS['sender_email']));
$recipient_name = un_htmlspecialchars(trim($HTTP_POST_VARS['recipient_name']));
$recipient_email = un_htmlspecialchars(trim($HTTP_POST_VARS['recipient_email']));
$headline = un_htmlspecialchars(trim($HTTP_POST_VARS['headline']));
$message = un_htmlspecialchars(trim($HTTP_POST_VARS['message']));
}
Three lines down locate:
$site_template->register_vars(array(
"image" => $image,
"thumbnail" => $thumbnail,
"image_name" => $image_row['image_name'],
"lang_bg_color" => $lang['bg_color'],
"lang_border_color" => $lang['border_color'],
"lang_font_color" => $lang['font_color'],
"lang_font_face" => $lang['font_face'],
"lang_sender" => $lang['sender'],
"lang_recipient" => $lang['recipient'],
"lang_email" => $lang['email'],
"lang_name" => $lang['name'],
"lang_headline" => $lang['headline'],
"lang_message" => $lang['message'],
"lang_preview_postcard" => $lang['preview_postcard'],
"url_postcard" => $site_sess->url(ROOT_PATH."postcards.php?".URL_IMAGE_ID."=".$image_id),
"sender_name" => stripslashes($sender_name),
"sender_email" => stripslashes($sender_email),
"recipient_name" => stripslashes($recipient_name),
"recipient_email" => stripslashes($recipient_email),
"headline" => stripslashes($headline),
"message" => stripslashes($message),
"lang_send_postcard" => $lang['send_postcard'],
"back_url" => stripslashes($url)
));
Change to:
$site_template->register_vars(array(
"image" => $image,
"thumbnail" => $thumbnail,
"image_name" => $image_row['image_name'],
"lang_bg_color" => $lang['bg_color'],
"bg_color" => $bg_color,
"lang_border_color" => $lang['border_color'],
"border_color" => $border_color,
"lang_font_color" => $lang['font_color'],
"font_color" => $font_color,
"lang_font_face" => $lang['font_face'],
"font_face" => $font_face,
"lang_sender" => $lang['sender'],
"lang_recipient" => $lang['recipient'],
"lang_email" => $lang['email'],
"lang_name" => $lang['name'],
"lang_headline" => $lang['headline'],
"lang_message" => $lang['message'],
"lang_preview_postcard" => $lang['preview_postcard'],
"url_postcard" => $site_sess->url(ROOT_PATH."postcards.php?".URL_IMAGE_ID."=".$image_id),
"sender_name" => stripslashes($sender_name),
"sender_email" => stripslashes($sender_email),
"recipient_name" => stripslashes($recipient_name),
"recipient_email" => stripslashes($recipient_email),
"headline" => stripslashes($headline),
"message" => stripslashes($message),
"lang_send_postcard" => $lang['send_postcard'],
"back_url" => stripslashes($url)
));
Open postcard_create.html
Locate:
<form method="post" action="{url_postcard}">
Change to:
<form method="post" action="{url_postcard}" name="createCard">
Locate:
</form>
Change to:
</form>
<script language="javascript" type="text/javascript">
var bg_color = "{bg_color}";
var border_color = "{border_color}";
var font_color = "{font_color}";
var font_face = "{font_face}";
function RestoreUserValues()
{
var x = document.forms.createCard;
for (i=0;i<x.bg_color.length;i++) {
if (x.bg_color[i].value == bg_color) {
x.bg_color[i].checked = true;
break;
}
}
for (i=0;i<x.border_color.length;i++) {
if (x.border_color[i].value == border_color) {
x.border_color[i].checked = true;
break;
}
}
for (i=0;i<x.font_color.length;i++) {
if (x.font_color[i].value == font_color) {
x.font_color[i].checked = true;
break;
}
}
for (i=0;i<x.font_face.length;i++) {
if (x.font_face[i].value == font_face) {
x.font_face[i].checked = true;
break;
}
}
}
if( bg_color != "" )
RestoreUserValues();
</script>
Open postcard_preview.html
Locate:
<form action="{url_postcard}" method="post">
Change to:
<form action="{url_postcard}" method="post" name="previewCard">
Locate:
<input type="button" value="{lang_edit_postcard}" onclick="history.go(-1)" class="button" />
Change to:
<input type="button" value="{lang_edit_postcard}" onclick="document.forms.previewCard.elements['action'].value = 'modifycard';document.forms.previewCard.submit();" class="button" />
NOTES:
This FIX is compatible with the [Mod] Keep text formatting of eCard message