Author Topic: Send mails with new images  (Read 20977 times)

0 Members and 1 Guest are viewing this topic.

Offline Mr_LovaLove

  • Full Member
  • ***
  • Posts: 233
  • Unkown
    • View Profile
Send mails with new images
« on: August 27, 2007, 01:47:59 PM »

thanks guyz for the all MODs and help you have done to all 4images users around the world

while i was searching in the google !

i found the google group

in fact, this was already done also in yahoo groups !

but what i was thinkin about is


Can we create a MOD to send an email with all the new images that have been uploaded for every week as an example

so the email with have the major information like:

image name  - image link - author

options:

time and day

also its could be better if this option can be controlled by the admin, so he/she can set this option to work or not

this just an idea !

u r welcome to add ur idea also

all are welcome

hope this idea can be done from someone :)
English Please :@

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: Send mails with new images
« Reply #1 on: January 03, 2008, 11:24:45 PM »
Ok, I like. ;)

[BETA - v0.2]

Note: If install BETA version of before, restore backup index.php file. No upgrade for this.

[log] - 06/01/2008 - v0.2 -

- Fix: cutoff value no match correct with mday.
- Fix: All new images (match with cutoff value and mday + image_date with cutoff range) is now send one email for all.
- Fix: Each email send to user and admin to server. Now send one email for each user and admin (email template check with user level check).
- Add: Cutoff boolean is check for user and admin level only - no guest.
- Add: Additional user fields in email with HTML tags.
- Affect change: index.php, lang/your_lang/main.php, lang/your_lang/email (two email template).

- [end log]

// Step 1

In index.php file,

in block:

Code: [Select]
//-----------------------------------------------------
//--- Show New Images ---------------------------------
//-----------------------------------------------------

find:

Code: [Select]
else  {
  $new_images = "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\">";
  $count = 0;
  $bgcounter = 0;
  while ($image_row = $site_db->fetch_array($result)) {

replace:

Code: [Select]
else  {
  $new_images = "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\">";
  $count = 0;
  $bgcounter = 0;
  $new_images_name = array();
  $new_images_url = array();
  $new_images_author = array();
  $new_images_time = time() - 60 * 60 * 24 * $config['new_cutoff'];
  $new_images_today = getdate();
  $new_images_email_announcement = false;
  while ($image_row = $site_db->fetch_array($result)) {
      if (defined('NEW_IMAGES_EMAIL_ANNOUNCEMENT') && NEW_IMAGES_EMAIL_ANNOUNCEMENT == 1 && $new_images_today['mday'] == $config['new_cutoff'] - 1 && $config['new_cutoff'] > 0 && $config['new_cutoff'] <= 7 && $image_row['image_date'] >= $new_images_time && isset($image_row['new_images_email_announcement']) && $image_row['new_images_email_announcement'] == 1) {
          $new_images_name[] = format_text(trim($image_row['image_name']), 2);
          $new_images_url[] = format_url($script_url . "/details.php?" . URL_IMAGE_ID . "=" . $image_row['image_id']);
          $new_images_author[] = format_text(trim($image_row['user_name']), 2);
          $new_images_email_announcement = true;
      }

// Step 1.1

Same file - find:

Code: [Select]
$new_images .= "</table>\n";

add after:

Code: [Select]
if ($new_images_email_announcement == true && $user_info['user_level'] >= USER) {
      @include_once(ROOT_PATH . "includes/email.php");
      if (isset($site_email) && is_object($site_email) && !empty($site_email)) {
          unset ($site_email);
      }
           
      if (isset($additional_user_fields) && is_array($additional_user_fields) && !empty($additional_user_fields)) {
          $additional_sql = "";
          foreach ($additional_user_fields as $key => $val) {
              $additional_sql .= ", " . $key;
          }
      }
     
      $sql = "
     
      SELECT " . get_user_table_field(", ", "user_name") . get_user_table_field(", ", "user_email") . get_user_table_field(", ", "user_level") . $additional_sql . "
      FROM " . USERS_TABLE . "
      WHERE " . get_user_table_field("", "user_allowemails") . " = 1
     
      ";
     
      $row = $site_db->query_firstrow($sql);
     
      $site_email = new Email();
         
          $site_email->set_to(stripslashes(trim($user_info['user_email'])));
          $site_email->set_from(stripslashes(trim($config['site_email'])));
         
          $site_email->set_subject(preg_replace("/" . $site_template->start . "site_name" . $site_template->end . "/siU", format_text(trim($config['site_name']), 2), $lang['new_images_email_announcement_subject_title']));
          $site_email->register_vars(array(
            "user_name" => (isset($row[$user_table_fields['user_name']]) && $row[$user_table_fields['user_name']] == $user_info['user_name']) ? format_text(trim($user_info['user_name']), 2) : format_text(trim($row[$user_table_fields['user_name']]), 2),
            "gallery_url" => format_url($script_url . "/index.php"),
            "site_name" => (isset($config['site_name'])) ? format_text(trim($config['site_name']), 2) : "",
            "site_email" => (isset($config['site_email'])) ? (stripslashes(trim($config['site_email']))) : ""
          ));         
          if (isset($new_images_name) && is_array($new_images_name) && !empty($new_images_name)) {
              if (isset($new_images_url) && is_array($new_images_url) && !empty($new_images_url)) {
                  if (isset($new_images_author) && is_array($new_images_author) && !empty($new_images_author)) {     
                      $num_name = sizeof($new_images_name);
                      $num_url = sizeof($new_images_url);
                      $num_author = sizeof($new_images_author);
                     
                      $new_images_email_content = "";
                      for ($j = 0; $j < $num_name; $j++) {   
                          for ($k = 0; $k < $num_url; $k++) {
                              for ($l = 0; $l < $num_author; $l++) {
                                  $new_images_email_content .= $lang['new_images_email_content_titles'][0] . $new_images_name[$k] . "<br />" . $lang['new_images_email_content_titles'][1] . $new_images_url[$k] . "<br />" . $lang['new_images_email_content_titles'][2] . $new_images_author[$k] . "<br /><br />";
                                  break;
                              }       
                          }
                          break;
                      }                     
                      if (isset($new_images_email_content) && !empty($new_images_email_content)) {
                          $site_email->register_vars("new_images_email_content", $new_images_email_content);
                          unset ($new_images_email_content);
                      }
                      if (isset($additional_user_fields) && is_array($additional_user_fields) && !empty($additional_user_fields)) {
                         $additional_field_array = array();
                         foreach ($additional_user_fields as $key => $val) {
                            $additional_field_array[$key] = (isset($row[$key]) && !empty($row[$key])) ? format_text($row[$key], 1) : REPLACE_EMPTY;
                            $additional_field_array['lang_'.$key] = $val[0];
                         }
                         if (isset($additional_field_array) && is_array($additional_field_array) && !empty($additional_field_array)) {
                            $site_email->register_vars($additional_field_array);
                         }
                         unset ($additional_field_array);
                      }
                  }
              }
          }
         
          if ($row[$user_table_fields['user_level']] == USER) {
            $site_email->set_body("new_images_email_announcement", $config['language_dir_default']);
          } elseif ($row[$user_table_fields['user_level']] == ADMIN) {
                    $site_email->set_body("admin_new_images_email_announcement", $config['language_dir_default']);            
          }
 
  if ((stripslashes(trim($row[$user_table_fields['user_email']]))) != (stripslashes(trim($user_info['user_email']))) || (stripslashes(trim($row[$user_table_fields['user_email']]))) != (stripslashes(trim($config['site_email'])))) {
              $email_imploded = implode(", ", $row[$user_table_fields['user_email']]);
              $site_email->set_bcc(stripslashes(trim($email_imploded)));
          }
          $site_email->send_email();
         
  unset ($new_images_email_content);
  $site_db->query("UPDATE " . IMAGES_TABLE . " SET new_images_email_announcement = 0 WHERE image_id = " . $image_row['image_id']);
  }

// Step 2

In includes/constants.php file,

add in top ?>:

Code: [Select]
define('NEW_IMAGES_EMAIL_ANNOUNCEMENT', 1); // Set 1 for active or 0 for no active.

// Step 3

In lang/english/main.php file,

add in top ?>:

Code: [Select]
$lang['new_images_email_announcement_subject_title'] = "{site_name} - New images for this week";
$lang['new_images_email_admin_announcement_subject_title'] = "{site_name} - Confirmation of new images for this week";
$lang['new_images_email_content_titles'] = array("Image name: ", "URL: ", "Author: ");

// Step 4

In includes/db_field_definitions.php file,

add in top ?>:

Code: [Select]
$additional_image_fields['new_images_email_announcement'] = array($lang['new_images_email_announcement'], "text", 1); // Set for required field.

// Step 5

In lang/english/email - create new file: new_images_email_announcement.html .

Add (and I ask someone for type text for me - I really bad English):

Code: [Select]
Dear {user_name},

we would like to announce you our new image for this week:

{new_images_email_content}

Thank you.

{site_name}
Gallery URL: {gallery_url}
Email address: {site_email}

Create new file: admin_new_images_email_announcement .

Add:

Code: [Select]
Dear {user_name},

New emails has been sent to users for new images announcement .

New images for this week announce to users are:

{new_images_email_content}

{site_name} .

// Step 6

In ACP - > SQL Patches plugin, use:

Code: [Select]
ALTER TABLE `4images_images` ADD new_images_email_announcement INT(1) NOT NULL DEFAULT '1';

// Is work

Ok so how is work - email is send to user (allow email from admin must) with image cells (ACP - > setting page). If set 5 (default) - is mean all 5 day is send new image and is count day in week for send (so no mass email is do). ;)

Note: Is [BETA] :!:

Finish.
« Last Edit: January 06, 2008, 06:06:26 PM by thunderstrike »
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline † manurom

  • Full Member
  • ***
  • Posts: 227
    • View Profile
    • manurom's 4images templates
Re: Send mails with new images
« Reply #2 on: January 04, 2008, 11:44:26 AM »
Hello;
yatahonga has such newsletter.
Try to go to his site and subscribe to his newsletter.

Maybe he would be able to share it with us.

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: Send mails with new images
« Reply #3 on: January 04, 2008, 01:37:04 PM »
No need for ... go to other site ... I post MOD here ...
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline Mr_LovaLove

  • Full Member
  • ***
  • Posts: 233
  • Unkown
    • View Profile
Re: Send mails with new images
« Reply #4 on: January 05, 2008, 09:55:40 AM »
ThaaaaaaaaaankSs Thunder

:)

i will try it and give u the result

(expect it as BETA :P )

 :wink:

thanks again :)
English Please :@

Offline Mr_LovaLove

  • Full Member
  • ***
  • Posts: 233
  • Unkown
    • View Profile
Re: Send mails with new images
« Reply #5 on: January 05, 2008, 10:05:55 AM »
DB Error: Bad SQL Query: SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits, i.new_images_email_announcement, c.cat_name, u.username FROM (4images_images i, 4images_categories c) LEFT JOIN user u ON (u.userid = i.user_id) WHERE i.image_active = 1 AND c.cat_id = i.cat_id AND i.cat_id NOT IN (0) ORDER BY i.image_date DESC LIMIT 6
Unknown column 'i.new_images_email_announcement' in 'field list'

give me the properties for this filed so i can add it manual to the database

which table ?
int ?
null ?

:)

English Please :@

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: Send mails with new images
« Reply #6 on: January 05, 2008, 03:02:11 PM »
Quote
which table ?
int ?
null ?

This is right. I add step 6 in instruction. ;)
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline Mr_LovaLove

  • Full Member
  • ***
  • Posts: 233
  • Unkown
    • View Profile
Re: Send mails with new images
« Reply #7 on: January 05, 2008, 04:14:38 PM »
English Please :@

Offline Mr_LovaLove

  • Full Member
  • ***
  • Posts: 233
  • Unkown
    • View Profile
Re: Send mails with new images
« Reply #8 on: January 05, 2008, 05:03:31 PM »
Quote
Ok so how is work - email is send to user (allow email from admin must) with image cells (ACP - > setting page). If set 5 (default) - is mean all 5 day is send new image and is count day in week for send (so no mass email is do).


1- how can i test the mod
2- setting page ?? do u mean this: Number of "previous" and "next" pages displayed in site navigation


thanks
English Please :@

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: Send mails with new images
« Reply #9 on: January 05, 2008, 05:05:48 PM »
Quote
1- how can i test the mod

Read instruction in 1st post.

Quote
2- setting page ?? do u mean this: Number of "previous" and "next" pages displayed in site navigation

No. Is for new images value. ACP - > setting page. You see text box value for new images. Value you set is same time of delay day for send email for announce new images. ;)
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline Mr_LovaLove

  • Full Member
  • ***
  • Posts: 233
  • Unkown
    • View Profile
Re: Send mails with new images
« Reply #10 on: January 05, 2008, 05:10:14 PM »
Sorry ,,

i didnt get you

can u give me a screenshot of the setting page ( and acp ) if possible

English Please :@

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: Send mails with new images
« Reply #11 on: January 05, 2008, 05:11:45 PM »
ACP - > Setting and search line text: Number of days each image is marked as new .
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline Mr_LovaLove

  • Full Member
  • ***
  • Posts: 233
  • Unkown
    • View Profile
Re: Send mails with new images
« Reply #12 on: January 05, 2008, 05:25:10 PM »
thanks !! :P

done

so its BETA and cannot test the mailing !!

everything seems fine

and waiting to see what will happen after 7 days O_o
English Please :@

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: Send mails with new images
« Reply #13 on: January 05, 2008, 05:27:19 PM »
Quote
and waiting to see what will happen after 7 days O_o

If like, install new gallery and set for 1 day for see result. ;)
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline Mr_LovaLove

  • Full Member
  • ***
  • Posts: 233
  • Unkown
    • View Profile
Re: Send mails with new images
« Reply #14 on: January 05, 2008, 05:34:52 PM »
one question:

Code: [Select]
Dear {user_name},

we would like to announce you our new image for this week:

- Image name: {image_name}
- Image link: {image_link}
- Author name: {author_name}

Thank you.

{site_name}
Gallery URL: {gallery_url}
Email address: {site_email}

this mean if i have 10 new images !

this mod will send 10 emails ?

or all 10 images ( image name + image link + author ) will be includes in one email !
English Please :@