4images Forum & Community

4images Modifications / Modifikationen => Mods & Plugins (Releases & Support) => Topic started by: SLL on January 16, 2003, 11:46:00 PM

Title: [Mod] Email image validation results to the user
Post by: SLL on January 16, 2003, 11:46:00 PM
I've made this small MOD on my users request. They were waiting for their photo validation, without knowing if it was declined. The idea and some code are from Vraxor (mail on comments MOD).
Code: [Select]
#############################################################################################
## Title: Email image validation results to the user
##        for 4images - Image Gallery Management System.
##
## Version: 1.0
## Author: Silly Little Lamer <sll@dalnet.ru>
## Description: This Mod sends the email to the users, informing them if uploaded
## image(s) were validated or declined by the Administrator of the Gallery.
##        Email being sent only to the users, which have "Receive emails from
## administrators" set "on"
##
## Installation Level: Easy
## Installation Time: 5 Minutes
##
## Files To Edit: 1
## /4images/admin/validateimages.php
##
#############################################################################################
download: http://faces.dalnet.ru/files.php?id=7&l=english
Title: :-) Thanx for the MOD
Post by: heiko on January 17, 2003, 02:42:07 AM
Cooles und nützliches MOD für 4images.  :lol:

Allerdings mußte ich folgende Modifikation vornehmen, da ansonsten
der Link zum Bild  in der Bestätigungsmail (bei erfolgreicher Freigabe) nicht korrekt wiedergegeben wird.

$image_url = $cut_url."details.php?".URL_IMAGE_ID."=".$image_id."";

ändern zu:

$image_url = $cut_url."/details.php?".URL_IMAGE_ID."=".$image_id."";

                               ^^^^^



und nochmals Danke


Gruss Heiko
Title: Re: :-) Thanx for the MOD
Post by: SLL on January 17, 2003, 09:39:29 AM
Quote from: heiko
Allerdings mußte ich folgende Modifikation vornehmen, da ansonsten der Link zum Bild  in der Bestätigungsmail (bei erfolgreicher Freigabe) nicht korrekt wiedergegeben wird.


Well... I'm a bit confused myself  :roll:

Theoretically you're right, but if I do it this way, I've got double slash in this link... I've checked it on my local test gallery (OMHIhttpd with WinPHP), and then on my running gallery (Apache, Linux) - in both cases my first code works fine.

So, I believe, this is up to this MOD users to experiment, which of the varians of this line will works for them.

BTW, could you please email me the German text for these templates? I'll include it in the code. Also, if somebody could correct my silly English up there in the templates, that would be also good  :)
Title: help!
Post by: Jasondavis on February 02, 2003, 01:57:47 AM
Image deleted: 43ef (HQ0.JPG)

Email Error: Couldn't open Template ./../lang/english/email/declined_email.html


I get this error any ideas?
Title: fixed
Post by: Jasondavis on February 02, 2003, 02:41:41 AM
Hi, it was an error on my part....the email files were named .htm instead of .html
Title: [Mod] Email image validation results to the user
Post by: ai-gu on April 16, 2003, 02:52:27 PM
Hi all,
My 4images was integrated with phpBB, and I tried to install this MOD, after I did all as instructed in here, I got this error:

Quote
Image added: test (cbnu.JPG)

DB Error: Bad SQL Query: SELECT user_email, user_name, user_allowemails FROM phpbb202_users WHERE user_id = 4
Unknown column 'user_name' in 'field list'


I would appreciate if any one could help me out this problem.
Thanks in advance.
Title: [Mod] Email image validation results to the user
Post by: SLL on April 16, 2003, 03:29:44 PM
just check phpbb field names and change this query accordingly
Title: [Mod] Email image validation results to the user
Post by: ai-gu on April 16, 2003, 04:50:50 PM
Hi all,

Thanks SLL I changed the field names and there was no Error. But it seems that no mail was sent. The problem may be at the red colored text. (most of the e-mail addresses at the phpBB forum are not viewable by users (user_viewemail).

Can you guide me to change the code so that whoever post an image will receive the mail upon validation or decline??


Quote
$current_time = time();
   $row = array();
   $sql = "SELECT user_email, username, user_viewemail FROM ".USERS_TABLE." WHERE user_id = $user_id";
   $result = $site_db->query($sql);
   $row = $site_db->fetch_array($result);
   $user_allowemails = ($row['user_viewemail']);   $recipient_email = ($row['user_email']);
   $recipient_name = ($row['username']);
   $cut_url = str_replace("admin", "", $script_url);
   $image_url = $cut_url."details.php?".URL_IMAGE_ID."=".$image_id."";

   if ($user_allowemails == 1) {
   $site_email = new Email();
   $site_email->set_to($recipient_email);
   $site_email->set_from($config['site_email'], $config['site_name']);
   $site_email->set_subject("Image Validation Results");
   $site_email->register_vars(array(
   "recipient_name" => $recipient_name,
   "lang_image_add_success" => $lang['image_add_success'],
   "validation_date" => format_date($config['date_format']." ".$config['time_format'], $current_time),
   "site_name" => $config['site_name'],
   "yr_image_name" => strtoupper($image_media_file),
   "image_url" => $image_url,
   ));
   $site_email->set_body("validation_email", $config['language_dir']);
   $site_email->send_email();
   }
//-------------------------------------------------------
Title: [Mod] Email image validation results to the user
Post by: SLL on April 16, 2003, 09:27:20 PM
just remove these two lines and } bracket at the very end.
Title: [Mod] Email image validation results to the user
Post by: eXup on June 16, 2003, 09:43:01 AM
Hi all,

der Mod ist wirklich sehr nützlich.

Könnte man ihn so umbauen, dass der Uploader beim Upload definieren kann ob er die
"Validation-E-Mail" erhalten will oder nicht? Meine Gedanken dazu: Man müsste ein Auswahlfeld
in die Uploadmaske einfügen und beim Validieren fallabhängig die E-Mail schicken.

Leider geht das aber eindeutig über meinen Horizont. Wäre nett, wenn es jemandem gelingen würde
diese Modifikation einzubauen.
Title: [Mod] Email image validation results to the user
Post by: SLL on June 16, 2003, 10:18:02 AM
there's no need to change anything. as you can see, the line if ($user_allowemails == 1) checks, if user set "allow emails from admin" in his profile. this setting is effective for all emails, including those sent by this mod too.
Title: [Mod] Email image validation results to the user
Post by: CrEaTi0n on June 18, 2003, 12:59:57 PM
Hi,

I have integrated 4Images with Invision Board. It works well. I have just added this mod. Now, i cant figure out what it wrong with it.

The code as it stands:
Quote

// Validated picture message --------------------------
//-----------------------------------------------------

        $current_time = time();
        $row = array();
        $sql = "SELECT user_email, user_name, user_allowemails FROM ".USERS_TABLE." WHERE user_id = $user_id";
        $result = $site_db->query($sql);
        $row = $site_db->fetch_array($result);
        $user_allowemails = ($row['user_allowemails']);
        $recipient_email = ($row['user_email']);
        $recipient_name = ($row['user_name']);
        $cut_url = str_replace("admin", "", $script_url);
        $image_url = $cut_url."details.php?".URL_IMAGE_ID."=".$image_id."";

        if ($user_allowemails == 1) {
        $site_email = new Email();
        $site_email->set_to($recipient_email);
        $site_email->set_from($config['site_email'], $config['site_name']);
        $site_email->set_subject("Image Validation Results");
        $site_email->register_vars(array(
        "recipient_name" => $recipient_name,
        "lang_image_add_success" => $lang['image_add_success'],
        "validation_date" => format_date($config['date_format']." ".$config['time_format'], $current_time),
        "site_name" => $config['site_name'],
        "yr_image_name" => strtoupper($image_media_file),
        "image_url" => $image_url,
        ));
        $site_email->set_body("validation_email", $config['language_dir']);
        $site_email->send_email();
        }
//-------------------------------------------------------


Now, in Invision Board, we have a few different fields, namely.

user_email is just email
user_name is just name
user_allowemails could be one of two: allow_admin_emails or email_full (both of wich are toggled with a 1 or a 0)
user_id is just id

Now, i replaced all of those. And i dont get an error message. Just nothing happens. No mail gets send, and the image is added to the gallery.

Any insight would be helpfull.

I havent posted the Declined code, because if this gets sorted, then im sure i can sort that...

Thanks.

Ian
Title: [Mod] Email image validation results to the user
Post by: V@no on June 18, 2003, 02:01:17 PM
u must do steps from integration guide again for this mod.
for example as u said user_id now is id then, look through the mod and replace all u can find with corrected names. (i.e. $row['user_email'] should be $row['email'] )
Title: [Mod] Email image validation results to the user
Post by: CrEaTi0n on June 18, 2003, 04:51:09 PM
Hi,

i did all that. but nothing happends when you do that. When you validate an image, no mail is sent off.


Ian
Title: [Mod] Email image validation results to the user
Post by: SLL on June 18, 2003, 09:47:51 PM
you should post ib adopted (not original) mod code here, maybe we'll see something you've missed
Title: [Mod] Email image validation results to the user
Post by: CrEaTi0n on June 21, 2003, 07:15:10 AM
Hi,

This is my code as it stands at the moment:

Quote

//-----------------------------------------------------
// Validated picture message --------------------------
//-----------------------------------------------------

        $current_time = time();
        $row = array();
        $sql = "SELECT email, name, allow_admin_mails FROM ".USERS_TABLE." WHERE id = $user_id";
        $result = $site_db->query($sql);
        $row = $site_db->fetch_array($result);
        $user_allowemails = ($row['allow_admin_mails']);
        $recipient_email = ($row['email']);
        $recipient_name = ($row['name']);
        $cut_url = str_replace("admin", "", $script_url);
        $image_url = $cut_url."details.php?".URL_IMAGE_ID."=".$image_id."";

        if ($user_allowemails == 1) {
        $site_email = new Email();
        $site_email->set_to($recipient_email);
        $site_email->set_from($config['site_email'], $config['site_name']);
        $site_email->set_subject("Image Validation Results");
        $site_email->register_vars(array(
        "recipient_name" => $recipient_name,
        "lang_image_add_success" => $lang['image_add_success'],
        "validation_date" => format_date($config['date_format']." ".$config['time_format'], $current_time),
        "site_name" => $config['site_name'],
        "yr_image_name" => strtoupper($image_media_file),
        "image_url" => $image_url,
        ));
        $site_email->set_body("validation_email", $config['language_dir']);
        $site_email->send_email();
        }
//-------------------------------------------------------


//-----------------------------------------------------
// Declined picture message ---------------------------
//-----------------------------------------------------

        $row = array();
        $sql = "SELECT email, name, allow_admin_mails FROM ".USERS_TABLE." WHERE id = $user_id";
        $result = $site_db->query($sql);
        $row = $site_db->fetch_array($result);
        $user_allowemails = ($row['allow_admin_mails']);
        $recipient_email = ($row['email']);
        $recipient_name = ($row['name']);

        if ($user_allowemails == 1) {
        $site_email = new Email();
        $site_email->set_to($recipient_email);
        $site_email->set_from($config['site_email'], $config['site_name']);
        $site_email->set_subject("Image Validation Results");
        $site_email->register_vars(array(
        "recipient_name" => $recipient_name,
        "lang_image_delete_success" => $lang['image_delete_success'],
        "site_name" => $config['site_name'],
        "yr_image_name" => strtoupper($image_media_file),
        ));
        $site_email->set_body("declined_email", $config['language_dir']);
        $site_email->send_email();
        }
//-------------------------------------------------------


I hope someone can help!

Thanks alot.

Ian
Title: [Mod] Email image validation results to the user
Post by: SLL on June 21, 2003, 10:32:05 AM
hmm... looks ok  :roll:

i'd suggest you to temporarily put echo commands after each variable  (like echo $recipient_email; ) and debug script this way. then at least you'll see what is taken from db and hopefully find out what's wrong
Title: [Mod] Email image validation results to the user
Post by: CrEaTi0n on June 23, 2003, 03:33:49 PM
Hi,

Could you show me what you mean. I cant get it right, everytime i put an echo somewhere i get lots of errors.

Could you maybee just show me in the code that I posted before?

Thanks
Ian
Title: [Mod] Email image validation results to the user
Post by: SLL on June 23, 2003, 04:08:00 PM
something like
Code: [Select]
$recipient_email = ($row['email']);
echo $recipient_email;
$recipient_name = ($row['name']);
echo $recipient_name;

...for all variables. of course you'll see a lot of "garbage", but this way can debug what's going on
Title: [Mod] Email image validation results to the user
Post by: CrEaTi0n on June 23, 2003, 04:39:23 PM
Hi,

I cant seem to see anything wrong.

Here is my config:

Quote

//-----------------------------------------------------
// Validated picture message --------------------------
//-----------------------------------------------------

   $current_time = time();
   echo $current_time;
   $row = array();
   echo $row;
   $sql = "SELECT email, name, allow_admin_mails FROM ".USERS_TABLE." WHERE id = $user_id";
   echo $sql;
   $result = $site_db->query($sql);
   echo $result;
   $row = $site_db->fetch_array($result);
   echo $row;
   $user_allowemails = ($row['allow_admin_mails']);
   echo $user_allowemails;
   $recipient_email = ($row['email']);
      echo $recipient_email;
   $recipient_name = ($row['name']);
   echo $recipient_name;
   $cut_url = str_replace("admin", "", $script_url);
   $image_url = $cut_url."details.php?".URL_IMAGE_ID."=".$image_id."";

   if ($user_allowemails == 1) {
   $site_email = new Email();
   echo $site_email;
   $site_email->set_to($recipient_email);
   echo $site_email;
   $site_email->set_from($config['site_email'], $config['site_name']);
   echo $site_email;
   $site_email->set_subject("Image Validation Results");
   echo $site_email;
   $site_email->register_vars(array(
   "recipient_name" => $recipient_name,
   "lang_image_add_success" => $lang['image_add_success'],
   "validation_date" => format_date($config['date_format']." ".$config['time_format'], $current_time),
   "site_name" => $config['site_name'],
   "yr_image_name" => strtoupper($image_media_file),
   "image_url" => $image_url,
   ));
   $site_email->set_body("validation_email", $config['language_dir']);
   $site_email->send_email();
   }
//-------------------------------------------------------


and here is what i get in my browser:

Quote

Image added: Sinfest - Agent (sf20030526.gif)
1056379035ArraySELECT email, name, allow_admin_mails FROM ibf_members WHERE id = 827Resource id #34Arrayian@cerebellum.za.netCrEaTi0n


Any ideas ?

Ian
Title: [Mod] Email image validation results to the user
Post by: SLL on June 23, 2003, 04:50:41 PM
WHERE id = $user_id";  query seems to be an error.

827Resource id #34 is definatelly wrong user id
Title: [Mod] Email image validation results to the user
Post by: CrEaTi0n on June 23, 2003, 05:29:38 PM
Hi,

okay. I changed user_id to just id to match the db. But this is still the output i get. It seems as though it sees me as a guest, but i am logged in as administrator.

Quote

1056381796ArraySELECT email, name, allow_admin_mails FROM ibf_members WHERE id = 0Resource id #34Arrayguest@ibforums.comGuest


any ideas?

Ian
Title: [Mod] Email image validation results to the user
Post by: SLL on June 23, 2003, 05:39:34 PM
Quote from: CrEaTi0n
any ideas?


nope... i don't use any integration, so the only chance for you is to dig yourself, sorry
Title: Re: [Mod] Email image validation results to the user
Post by: rjp123 on May 25, 2005, 02:03:27 PM
Does this bad guy work with 1.7.1?

Thanks.
Title: Re: [Mod] Email image validation results to the user
Post by: TIMT on May 29, 2005, 03:51:21 PM
Hi

There is no validation e-Mail sent. Why???

May be because in the ACP, user administration, the flag "Receving Mails from the Administrator" ist not "YES"!!   :wink:

Serge