• [MOD] Email image validation results to the user v2 5 0 5 1
Currently:  

Author Topic: [MOD] Email image validation results to the user v2  (Read 56585 times)

0 Members and 1 Guest are viewing this topic.

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
[MOD] Email image validation results to the user v2
« on: June 07, 2005, 04:47:18 AM »
This is complete rewrite of SLL's "[MOD] Email image validation results to the user v1". Since SLL is no longer very active on this forum :( I decided create my own mod using his idea, with many new features and most significan change from v1 is that every member will receive only one email with list of accepted/declined images instead of separate email for each image.


------------ [ Features ] -------------
  • members receive only one email with list of added/deleted images
  • admin can send an individual message (comment) for each added/deleted file
  • admin can chose not send any notification emails (per file setting)
  • quick select all files to add or delete
  • after validation return to validation page (by default it only show result of the validation on a blank page)
  • double click on a radio button will remove any sellection (usefull if quick selected all images but then u've changed your mind and decided not add or delete one or more images)
  • displays a link to image details page if an image added

The validation page:


And the email member received after validation the three images above:


------------- [ Installation ] --------------

If u've installed "[MOD] Email image validation results to the user v1" by SLL, you'll need to uninstall it before installing this mod...

Step 1
Open admin/validateimages.php
Find:
Code: [Select]
  $image_list = (isset($HTTP_POST_VARS['image_list'])) ? $HTTP_POST_VARS['image_list'] : "";Insert below:
Code: [Select]
/*
  MOD VALIDATION RESULT V2
  START INSERT
*/
  $msg_list = (isset($HTTP_POST_VARS['msg_list'])) ? $HTTP_POST_VARS['msg_list'] : "";
  $email_cache = array();
  $action = "validateimages";
/*
  MOD VALIDATION RESULT V2
  END INSERT
*/


Step 1.1
Find:
Code: [Select]
            echo $lang['image_add_success'].": <b>".stripslashes($image_name)."</b> (".$image_media_file.")<br />";Replace it with:
Code: [Select]
/*
  MOD VALIDATION RESULT V2
  START ORIGINAL CODE

            echo $lang['image_add_success'].": <b>".stripslashes($image_name)."</b> (".$image_media_file.")<br />";

  MOD VALIDATION RESULT V2
  END ORIGINAL CODE
*/
/*
  MOD VALIDATION RESULT V2
  START REPLACE
*/
            echo $lang['image_add_success'].": <b><a href=\"".$site_sess->url(ROOT_PATH."details.php?image_id=".$image_id)."\" target=\"_blank\">".stripslashes($image_name)."</a></b> (".$image_media_file.")<br />";
            $email_cache[$user_id][] = array(
              "status" => 1,
              "send" => (isset($HTTP_POST_VARS['send'][$key]) && $HTTP_POST_VARS['send'][$key] == 2) ? 1 : 0,
              "image_id" => $image_id,
              "date" => $image_date,
              "image_media_file" => $image_media_file,
              "msg" => $msg_list[$key]
            );
/*
  MOD VALIDATION RESULT V2
  END REPLACE
*/


Step 1.2
Find:
Code: [Select]
        echo $lang['image_delete_success'].": <b>".stripslashes($image_name)."</b> (".$image_media_file.")<br />";Insert below:
Code: [Select]
/*
  MOD VALIDATION RESULT V2
  START INSERT
*/
        $email_cache[$user_id][] = array(
          "status" => 0,
          "send" => (isset($HTTP_POST_VARS['send'][$key]) && $HTTP_POST_VARS['send'][$key] == 2) ? 1 : 0,
          "image_id" => 0,
          "date" => $image_date,
          "image_media_file" => $image_media_file,
          "msg" => $msg_list[$key]
        );
/*
  MOD VALIDATION RESULT V2
  END INSERT
*/


Step 1.3
Find:
Code: [Select]
}
  else {
    echo "<b>Just relaxing because you give me nothing to do!</b>";
Insert above (make sure insert it above the closing bracket "}" above the else !!!!:
Code: [Select]
/*
  MOD VALIDATION RESULT V2
  START INSERT
*/
    if (!empty($email_cache))
    {
      if (!class_exists('Email')) include(ROOT_PATH.'includes/email.php');
      $user_ids = implode(",", array_keys($email_cache));
      $sql = "SELECT ".get_user_table_field("", "user_id").get_user_table_field(", ", "user_name").get_user_table_field(", ", "user_email").get_user_table_field(", ", "user_allowemails")."
              FROM ".USERS_TABLE."
              WHERE ".get_user_table_field("", "user_id")." IN (".$user_ids.") AND ".get_user_table_field("", "user_level")." > ".GUEST;
      $result = $site_db->query($sql);
      $email_template = new Template(ROOT_PATH."lang/".$config['language_dir']."/email");
      while($row = $site_db->fetch_array($result))
      {
        if (!$row['user_allowemails']) continue; //comment this line out to disregard member's setting not to receive emails from administrators
        $list = "";
        $file_list = array();
        $site_url = $script_url;
        $site_url = preg_replace("#/?admin#", "", $site_url);
//        $site_url = "http://yoursite.com/4images"; // uncomment this line and update to the correct domain if your have problem with url in the email message
        $email_template->register_vars(array(
          "lang_upload_date" => $lang['validate_date'],
          "lang_file" => $lang['validate_file'],
          "lang_msg" => $lang['validate_msg'],
          "lang_status" => $lang['validate_status'],
        ));
        foreach ($email_cache[$row['user_id']] as $info)
        {
          if (!$info['send']) continue;
          $file_list[] = $info['image_media_file'];
//          $image_url = ($info['image_id']) ? "( ".$site_sess->url($site_url."/details.php?".URL_IMAGE_ID."=".$info['image_id'], "&")." )" : "";
          $image_url = ($info['image_id']) ? "( ".$site_url."/details.php?".URL_IMAGE_ID."=".$info['image_id']." )" : "";
          $email_template->register_vars(array(
            "status" => ($info['status']) ? $lang['validate_yes'] : $lang['validate_no'],
            "image_url" => $image_url,
            "image_id" => $info['image_id'],
            "date" => format_date($config['date_format']." ".$config['time_format'], $info['date']),
            "file" => $info['image_media_file'],
            "msg" => stripslashes($info['msg'])
          ));
          $list .= $email_template->parse_template("validation_email_bit");
        }
        if (empty($list)) continue;
        $site_email = new Email();
        $site_email->set_to($row['user_email']);
//        $site_email->set_from($config['site_email'], $config['site_name']);
        $site_email->set_subject($lang['valdiate_title']);
        $site_email->register_vars(array(
          "recipient_name" => $row['user_name'],
          "list" => $site_email->prepare_text($list),
          "file_list" => implode(", ", $file_list),
          "site_url" => $site_sess->url($site_url, "&"),
          "date" => format_date($config['date_format']." ".$config['time_format'], time()),
          "site_name" => $config['site_name']
        ));
        $site_email->set_body("validation_email", $config['language_dir']);
        $site_email->send_email();
      }
    }
    echo "<br />";
/*
  MOD VALIDATION RESULT V2
  END INSERT
*/
(make sure that between this block of code and the code u've inserted in previous step are only two (2) closing brackets ( } )!


Step 1.4
Find:
Code: [Select]
    echo "<td class=\"tableseparator\">".$lang['validate']."</td>\n<td class=\"tableseparator\">".$lang['delete']."</td>\n<td class=\"tableseparator\"> </td>\n<td class=\"tableseparator\">".$lang['field_image_name']."</td>\n<td class=\"tableseparator\">".$lang['field_category']."</td>\n<td class=\"tableseparator\">".$lang['field_username']."</td>\n<td class=\"tableseparator\">".$lang['field_date']."</td>\n<td class=\"tableseparator\">".$lang['options']."</td>\n</tr>\n";Replace it with:
Code: [Select]
/*
  MOD VALIDATION RESULT V2
  START ORIGINAL CODE

    echo "<td class=\"tableseparator\">".$lang['validate']."</td>\n<td class=\"tableseparator\">".$lang['delete']."</td>\n<td class=\"tableseparator\"> </td>\n<td class=\"tableseparator\">".$lang['field_image_name']."</td>\n<td class=\"tableseparator\">".$lang['field_category']."</td>\n<td class=\"tableseparator\">".$lang['field_username']."</td>\n<td class=\"tableseparator\">".$lang['field_date']."</td>\n<td class=\"tableseparator\">".$lang['options']."</td>\n</tr>\n";

  MOD VALIDATION RESULT V2
  END ORIGINAL CODE
*/

/*
  MOD VALIDATION RESULT V2
  START REPLACE
*/
    show_hidden_input("cat_id", $cat_id);
    show_hidden_input("limitnumber", $limitnumber);
    echo "<script>
    var yes = false;
    var no = false;
    var send = true;
    var rc = new Array();
    function CheckAllradio(num, checked) {
      for (var i=0;i<document.form.elements.length;i++) {
        var e = document.form.elements[i];
        if (e.type=='radio' && e.value == num) {
          e.checked = checked;
        }
      }
    }
    </script>";
    echo "<td class=\"tableseparator\">".$lang['validate_msg']."</td>\n<td class=\"tableseparator\" onClick=\"if(send){send=false;CheckAllradio(2, false);CheckAllradio(3, true);}else{send=true;CheckAllradio(2, true); CheckAllradio(3, false);}\">Send</td>\n<td class=\"tableseparator\" onClick=\"if(yes){yes=false;no=false}else{yes=true;no=false;}CheckAllradio(1, yes)\">".$lang['validate']."</td>\n<td class=\"tableseparator\" onClick=\"if(no){no=false;yes=false}else{no=true;yes=false;}CheckAllradio(0, no)\">".$lang['delete']."</td>\n<td class=\"tableseparator\"> </td>\n<td class=\"tableseparator\">".$lang['field_image_name']."</td>\n<td class=\"tableseparator\">".$lang['field_category']."</td>\n<td class=\"tableseparator\">".$lang['field_username']."</td>\n<td class=\"tableseparator\">".$lang['field_date']."</td>\n<td class=\"tableseparator\">".$lang['options']."</td>\n</tr>\n";
/*
  MOD VALIDATION RESULT V2
  END REPLACE
*/


Step 1.5
Find:
Code: [Select]
      echo "<td><input type=\"radio\" name=\"image_list[".$image_row['image_id']."]\" value=\"1\"></td>";
      echo "<td><input type=\"radio\" name=\"image_list[".$image_row['image_id']."]\" value=\"0\"></td>";
Replace it with:
Code: [Select]
/*
  MOD VALIDATION RESULT V2
  START ORIGINAL CODE

      echo "<td><input type=\"radio\" name=\"image_list[".$image_row['image_id']."]\" value=\"1\"></td>";
      echo "<td><input type=\"radio\" name=\"image_list[".$image_row['image_id']."]\" value=\"0\"></td>";

  MOD VALIDATION RESULT V2
  END ORIGINAL CODE
*/
/*
  MOD VALIDATION RESULT V2
  START REPLACE
*/
      echo "<td>".(($image_row['user_id'] != GUEST) ? "<textarea name=\"msg_list[".$image_row['image_id']."]\" rows=\"3\" cols=\"40\">".((isset($HTTP_POST_VARS['msg_list'][$image_row['image_id']])) ? stripslashes($HTTP_POST_VARS['msg_list'][$image_row['image_id']]) : "")."</textarea>" : "")."</td>";
      echo "<td>".(($image_row['user_id'] != GUEST) ? "<input type=\"radio\" name=\"send[".$image_row['image_id']."]\" value=\"2\"".(((isset($HTTP_POST_VARS['send'][$image_row['image_id']]) && $HTTP_POST_VARS['send'][$image_row['image_id']] == 2) || !isset($HTTP_POST_VARS['send'][$image_row['image_id']])) ? " checked" : "").">yes&nbsp;<input type=\"radio\" name=\"send[".$image_row['image_id']."]\" value=\"3\"".(((isset($HTTP_POST_VARS['send'][$image_row['image_id']]) && $HTTP_POST_VARS['send'][$image_row['image_id']] == 3)) ? " checked" : "").">no" : "&nbsp;")."</td>";
      echo "<td><input type=\"radio\" name=\"image_list[".$image_row['image_id']."]\" value=\"1\" onDblclick=\"this.checked=false;\"></td>";
      echo "<td><input type=\"radio\" name=\"image_list[".$image_row['image_id']."]\" value=\"0\" onDblclick=\"this.checked=false;\"></td>";
/*
  MOD VALIDATION RESULT V2
  END REPLACE
*/


Step 2
Open lang/<your language>/admin.php
At the end, just above closing ?> insert this:
Code: [Select]
/*
  MOD VALIDATION RESULT V2
  START INSERT
*/
$lang['valdiate_title'] = "Image Validation Results";
$lang['validate_yes'] = "added";
$lang['validate_no'] = "deleted";
$lang['validate_msg'] = "Message";
$lang['validate_file'] = "File";
$lang['validate_date'] = "Uploaded";
$lang['validate_status'] = "Status";
/*
  MOD VALIDATION RESULT V2
  END INSERT
*/


Step 3
Create a new template: lang/<your language>/email/validation_email.html
with the following code inside:
Code: [Select]
Dear {recipient_name},

You've uploaded to the "{site_name}" the following file(s):
{file_list}

The validation result is the following:
___________________________________________________
{list}--
Best regards, {site_name}
{site_url}


Step 4
Create a new template: lang/<your language>/email/validation_email_bit.html
with the following code inside:
Code: [Select]

{lang_file}: {file}
{lang_upload_date}: {date}
{lang_status}: {status} {image_url}
{lang_msg}: {msg}
___________________________________________________





------------- [ Appendix ] ----------------

The following tags are allowed to be used in validation_email.html template (Step 3):
{recipient_name} - will show name of the member to whom the email will be sent
{list} - a list of all validated files (parsed validation_email_bit.html template)
{file_list} - a comma separated list of validated files
{site_name} - site name from the settings
{site_url} - url to your site
{date} - date of validation

The following tags are allowed to be used in validation_email_bit.html template (Step 4):
{lang_upload_date} - text "Uploaded"
{lang_file} - text "File"
{lang_msg} - text "Message"
{lang_status} - text "Status"
{status} - "added" or "deleted"
{image_url} - a url to the image details (empty if image deleted)
{image_id} - image id
{date} - the date when file was uploaded
{file} - filename of the uploaded file
{msg} - a custom message from admin


--------------- [ FAQ ] ----------------

Q: When someone receive an email the url to the site is broken. Why?
A: This might happend on some sertain systems, to fix that, try uncomment this line in admin/validateimages.php
//        $site_url = "http://yoursite.com/4images"; // uncomment this line and update to the correct domain if your have problem with url in the email message
and change yoursite.com/4images to the correct path to your gallery

Q: Why some members dont receive any emails even though I selected "send" during validation?
A: If a member set in their profile "Do not receive emails from administrators" they will not receive validation results either.
But you can force email to be sent by commenting out this line:
        if (!$row['user_allowemails']) continue; //comment this line out to disregard member's setting not to receive emails from administrators

Q: When members receive email, the validation results list is showed in one line, without line breaks. Why?
A: When I was writing this mod I've experienced it myself, it turned out that 4images template engine (atleast in v1.7.1) removes line breaks if a template tag placed at the end of line.
To fix that, simply add one space after each last template tag on each line

Q: What exactly "Send" column does?
A: In some cases (dont ask me what) you might not want the member know if a sertain image was added or deleted, so, by selecting "no" in the "Send" column the file will not be added in the list in the email (if only one file validated and "Send" selected to "no", then no email will be sent at all to that member)

Q: What can I do if I selected a file to be added or deleted and then changed my mind and dont want do any actions to that sertain file? Is page refresh the only way?
A: Page refresh is one way, but not the only way. By double click on the "Add" or "Delete" radio button on the specific image it should "unselect" it.
Another way is click on the column name on top ("Validate" or "Delete"), ones it selected all files, click that column name again, it will unselect everything.
« Last Edit: January 09, 2008, 11:07:23 AM by kai »
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline JensF

  • Addicted member
  • ******
  • Posts: 1.028
    • View Profile
    • http://www.terraristik-galerie.de
Re: [MOD] Email image validation results to the user v2
« Reply #1 on: June 09, 2005, 12:10:12 AM »
Hi,

great Mod. Works fine!!!!
Mit freundlichem Gruß
Jens Funk



-> Sorry for my bad English <-

Offline ascanio

  • Hero Member
  • *****
  • Posts: 569
    • View Profile
    • http://www.surfourspace.net
Re: [MOD] Email image validation results to the user v2
« Reply #2 on: June 09, 2005, 12:48:09 AM »
Niiiiiiiiiiice :) I was waiting for this MOD when I saw it on your Gallery :)
would I get any conflict if i install this mod because I have install the mod that send a email when the images are validated??

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [MOD] Email image validation results to the user v2
« Reply #3 on: June 09, 2005, 01:07:15 AM »
would I get any conflict if i install this mod because I have install the mod that send a email when the images are validated??
no if u uninstall it first (as it mentioned at the beginning of the installation guide)
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline tansamalaja

  • Full Member
  • ***
  • Posts: 185
    • View Profile
Re: [MOD] Email image validation results to the user v2
« Reply #4 on: July 31, 2006, 11:39:59 AM »
Very nice, very helpful - a dream come true... :D

Thank you very much!

Offline tansamalaja

  • Full Member
  • ***
  • Posts: 185
    • View Profile
Re: [MOD] Email image validation results to the user v2
« Reply #5 on: August 01, 2006, 03:50:03 PM »
Is it possible to send automatically the name of the admin who judged the pics?
And I'd like to have the function that an additional mail is send to the webmaster/further email recipient.

Who can help?

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [MOD] Email image validation results to the user v2
« Reply #6 on: August 01, 2006, 04:21:29 PM »
well, I guess, you can try find in the code from step 1.3:
Code: [Select]
          "recipient_name" => $row['user_name'],
Insert below:
Code: [Select]
          "admin_name" => $user_info['user_name'],
          "admin_email" => $user_info['user_email'],

Then in the email template you can use {admin_name} and {admin_email} tags.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline tansamalaja

  • Full Member
  • ***
  • Posts: 185
    • View Profile
Re: [MOD] Email image validation results to the user v2
« Reply #7 on: August 01, 2006, 04:56:47 PM »
Very good!

But I also need a function that sends automatically not only the user this mail but also the webmaster
of the page. So he is informed about what is deleted and why - quality management... 8)

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [MOD] Email image validation results to the user v2
« Reply #8 on: August 01, 2006, 09:07:51 PM »
alright, then try insert below
Code: [Select]
        $site_email->set_to($row['user_email']);
This line:[qcode]        $site_email->set_bcc("your@email.com");
[/qcode]
« Last Edit: November 16, 2007, 04:16:32 PM by kai »
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline tansamalaja

  • Full Member
  • ***
  • Posts: 185
    • View Profile
Re: [MOD] Email image validation results to the user v2
« Reply #9 on: August 02, 2006, 09:22:57 AM »
Thanx a lot!

Offline tansamalaja

  • Full Member
  • ***
  • Posts: 185
    • View Profile
Re: [MOD] Email image validation results to the user v2
« Reply #10 on: August 02, 2006, 01:58:47 PM »
Warning: Invalid argument supplied for foreach() in /var/www/vhosts/bos-fahrzeuge.info/httpdocs/includes/email.php on line 135

And no email was sent to webmaster, the user get one

And I've changed  "your@mail.com" to my Mailadress

Offline tansamalaja

  • Full Member
  • ***
  • Posts: 185
    • View Profile
Re: [MOD] Email image validation results to the user v2
« Reply #11 on: August 11, 2006, 09:38:38 PM »
Zeile 130-141 der includes/email.php
[qcode]  function set_simple_body($body = "") {
    $this->body = ((!empty($this->body)) ? $this->body : "").$this->prepare_text($body);
  }

  function set_bcc($bcc) {
    foreach ($bcc as $val) {  (135)
      $val = trim($val);
      if (preg_match('/^[-!#$%&\'*+\\.\/0-9=?A-Z^_`{|}~]+@([-0-9A-Z]+\.)+([0-9A-Z]){2,4}$/i', $val)) {
        $this->bcc[] = $val;
      }
    }
  }[/qcode]

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [MOD] Email image validation results to the user v2
« Reply #12 on: August 12, 2006, 09:08:24 AM »
Sorry, my misstake.
It should be:[qcode]        $site_email->set_bcc(array("your@email.com","your2@email2.com"));
[/qcode](you can add as many emails as you wish)
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline tansamalaja

  • Full Member
  • ***
  • Posts: 185
    • View Profile
Re: [MOD] Email image validation results to the user v2
« Reply #13 on: August 12, 2006, 09:18:32 PM »
No Email was sent to the additional Mailaddress, the user got one...

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [MOD] Email image validation results to the user v2
« Reply #14 on: August 12, 2006, 10:45:52 PM »
and if you send emails to members via ACP (email members) do they receive them all?
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)