4images Forum & Community

4images Help / Hilfe => Bug Fixes & Patches => Topic started by: Chris on March 16, 2005, 04:17:32 AM

Title: [1.7 / 1.7.1] "Modify eCard" / "eCard bearbeiten" button
Post by: Chris on March 16, 2005, 04:17:32 AM
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:
Code: [Select]
$main_template = ($action == "createcard") ? "postcard_create" : (($action == "previewcard") ? "postcard_create" : "postcard_send");
Change to:
Code: [Select]
$main_template = ($action == "createcard" || $action == "modifycard") ? "postcard_create" : (($action == "previewcard") ? "postcard_create" : "postcard_send");

Locate:
Code: [Select]
if ($action == "createcard") {
Change to:
Code: [Select]
if ($action == "createcard" || $action == "modifycard") {

Locate:
Code: [Select]
  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:
Code: [Select]
  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:
Code: [Select]
  $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:
Code: [Select]
  $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:
Code: [Select]
                  <form method="post" action="{url_postcard}">
Change to:
Code: [Select]
                  <form method="post" action="{url_postcard}" name="createCard">

Locate:
Code: [Select]
                  </form>
Change to:
Code: [Select]
                  </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:
Code: [Select]
<form action="{url_postcard}" method="post">
Change to:
Code: [Select]
<form action="{url_postcard}" method="post" name="previewCard">

Locate:
Code: [Select]
    <input type="button" value="{lang_edit_postcard}" onclick="history.go(-1)" class="button" />
Change to:
Code: [Select]
    <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
Title: Re: 1.7, 1.7.1: "Modify eCard" / "eCard bearbeiten" button
Post by: glitzer on March 19, 2005, 06:51:40 PM
THANX THANX THANX

this was i m searching!!

Thanx a lot! :lol: :lol: :D :D
Title: Re: 1.7, 1.7.1: "Modify eCard" / "eCard bearbeiten" button
Post by: RoadDogg on March 25, 2005, 09:39:49 PM
Sind die fixes in der zum Download angebotenen Version jeweils schon eingearbeitet?

Danke
Title: Re: 1.7, 1.7.1: "Modify eCard" / "eCard bearbeiten" button
Post by: Hernán on June 06, 2005, 12:20:16 AM
Gracias a quien haya puesto a disposición este MOD, me ayudó a resolver este problema :) :D

Gracias por tu ayuda
Saludos de Hernán
Title: Re: 1.7, 1.7.1: "Modify eCard" / "eCard bearbeiten" button
Post by: Chris on June 06, 2005, 02:47:26 PM
Sind die fixes in der zum Download angebotenen Version jeweils schon eingearbeitet?
Nein, und Ich spreche nicht Deutsches
Title: Re: 1.7, 1.7.1: "Modify eCard" / "eCard bearbeiten" button
Post by: Chris on June 06, 2005, 02:47:47 PM
Gracias a quien haya puesto a disposición este MOD, me ayudó a resolver este problema :)
No hablo español
Title: Re: 1.7, 1.7.1: "Modify eCard" / "eCard bearbeiten" button
Post by: V@no on June 06, 2005, 02:51:21 PM
No hablo espaсol
but u just did! :lol: ;)
Title: Re: 1.7, 1.7.1: "Modify eCard" / "eCard bearbeiten" button
Post by: Chris on June 06, 2005, 02:56:02 PM
That's all I remember from 3 years of high school spanish.   :P
Title: Re: 1.7, 1.7.1: "Modify eCard" / "eCard bearbeiten" button
Post by: WhiteRabbit on July 30, 2005, 02:28:11 PM
Gracias a quien haya puesto a disposición este MOD, me ayudó a resolver este problema :) :D

Gracias por tu ayuda
Saludos de Hernán

He did just say:

"Thanks to who has released this mod, It did help me to solve this problem.
thanks for your help.
Greetings from Hernán".

I think that he has a little confusion... it's a bugfix, not a mod...

Quote from: Chris
That's all I remember from 3 years of high school spanish.


hehehe spanish is my first language, and my english is of 5 years of secondary school... :lol:

Best regards.
WR.
Title: Re: [1.7 / 1.7.1] "Modify eCard" / "eCard bearbeiten" button
Post by: renicolay on November 13, 2005, 05:51:02 PM
Hi Chris,
Thanks for the great fix! I've added another choice to the postcard_create.html and it allows the user to choose one of three postcard templates to send.  However that is the only field that is not sticky.  How can I make this field stay when the user clicks modify ecard?

The radio button has three choices and is named "template_card"

Thanks!

Title: Re: [1.7 / 1.7.1] "Modify eCard" / "eCard bearbeiten" button
Post by: Eagle Eye on January 21, 2006, 04:53:00 PM
Hi Chris

Thank you very much for this fix!

Quote
Hi Chris,
Thanks for the great fix! I've added another choice to the postcard_create.html and it allows the user to choose one of three postcard templates to send.  However that is the only field that is not sticky.  How can I make this field stay when the user clicks modify ecard?

The radio button has three choices and is named "template_card"

Thanks!


if you don't mind, can you share this MOD, looks intresting.....
Title: Re: [1.7 / 1.7.1] "Modify eCard" / "eCard bearbeiten" button
Post by: germish on July 13, 2006, 03:32:14 PM
Hi,
I have version 1.72 and the mod is part of it.
Unfortunaley it's not so easy to sort out and get it working because I had to alter 1.72 to get my sound modifation of 1.70 working.
Since the sent card has a button to turn of sond when the receiver gets the card I have various form actions already.
And in my HTML files the form already has a name to make the javascript toggle the sound with the button.
Not sure How to give the same form two different names to also get this datamemorising working.
Title: Re: [1.7 / 1.7.1] "Modify eCard" / "eCard bearbeiten" button
Post by: siavashmusic on July 28, 2006, 08:49:12 PM
Hi
Help me I Want To See Example ..Please
Title: Re: [1.7 / 1.7.1] "Modify eCard" / "eCard bearbeiten" button
Post by: orb4 on September 09, 2007, 10:49:05 PM
Hi,
I got an error message when  I want to access "postcard_preview.php" after filling the e-card:

Fatal error: Call to undefined function: check_email() in /x/x/x/x/x/x/postcards.php on line 199

Here is line 199 to 202:

Code: [Select]
  if (($sender_email != "" && !check_email($sender_email)) || ($recipient_email != "" && !check_email($recipient_email))) {
    $msg .= (($msg != "") ? "<br />" : "").$lang['invalid_email_format'];
    $error = 1;
  }

Anyone has an idea please?  :?
Title: Re: [1.7 / 1.7.1] "Modify eCard" / "eCard bearbeiten" button
Post by: thunderstrike on September 09, 2007, 11:01:01 PM
Your includes/functions.php file is alter or check_email function uncomment. Chek for function in file.
Title: Re: [1.7 / 1.7.1] "Modify eCard" / "eCard bearbeiten" button
Post by: orb4 on September 10, 2007, 04:55:17 PM
ok, solved.
The following code in red was missing in "functions.php".
(To compare 2 files,the original and the modified one, I use WINMERGE software which is very usefull to immediatly see differences).

function check_email($email) {
  return (preg_match('/^[-!#$%&\'*+\\.\/0-9=?A-Z^_`{|}~]+@([-0-9A-Z]+\.)+([0-9A-Z]){2,4}$/i', $email)) ? 1 : 0;
}.

Ouch, now when I click to send the postcard, it tells me to enter the captcha code, okk I 'll try to install this.. (hey this is the neverending story)