New Picture Notification

i4get75
i4get75's picture

Joined: 2002-10-24
Posts: 5
Posted: Sat, 2002-11-30 06:08

I finally got a notification setup for comments but am looking for something to email me that a new picture is posted. It doesn't have to be complicated but I would like to have notification of which gallery it was posted to.

Also, I'm looking to take the photo count on the main gallery page and move from http://www.hotneons.com/gallery/ to http://www.hotneons.com/index.php so that I can place a number of pictures on the index page of my site. Since it's not in the same directory I run into a problem. Any ideas?

Thanks,
Greg

 
Kommercial
Kommercial's picture

Joined: 2002-08-19
Posts: 38
Posted: Tue, 2002-12-03 07:44

Email notification is covered in the User guide under customizing/scripts.

 
macsamurai

Joined: 2002-12-01
Posts: 16
Posted: Sun, 2002-12-08 18:43
Quote:
Email notification is covered in the User guide under customizing/scripts.

That script is for new comments notification. How does one adapt it to notify when new PHOTOS or nested albums are uploaded?

 
i4get75
i4get75's picture

Joined: 2002-10-24
Posts: 5
Posted: Mon, 2002-12-09 03:33
Quote:
>>Email notification is covered in the User guide under customizing/scripts.

<<

That script is for new comments notification. How does one adapt it to notify when new PHOTOS or nested albums are uploaded?

That's what I'm looking for. Any ideas anyone???

 
ajs279

Joined: 2002-09-01
Posts: 23
Posted: Mon, 2002-12-09 06:21

Just thinking here....
Look at the code for email notification when comments are added. The email goes out when the comments are written to the server. A similiar situation would be to send out the email when the albums.php (main parent album file) file is changed, ie a new album is uploaded.

As for new pictures uploaded to already created albums, I think that a list of pictures is kept in the .dat files in each album. You could set a cron job to scan each of those and grab the latest date if within 3 days or whatever.

 
i4get75
i4get75's picture

Joined: 2002-10-24
Posts: 5
Posted: Tue, 2002-12-10 01:10

Great thinking! Now if you can show a php newbie how to do that I would be most greatfull. My website is growing faster than it ever has before thanks to the ease of the gallery. I did 230 pictures in one year and in the last two months I've added 300+ pictures to the site. I never knew there were that many Neons out there.

Thanks,
Greg

 
shhansen73

Joined: 2002-12-11
Posts: 12
Posted: Sat, 2002-12-28 08:11

Agreed!

I would love this functionality, but cron isn't something I'm familiar with. Could someone suggest what to insert to do so?

--Shawn

 
joan
joan's picture

Joined: 2002-10-21
Posts: 3473
Posted: Sat, 2002-12-28 13:32

This seems a remarkably complicated way of doing something that should be simple. Why don't you just edit save_photos.php. Find this bit:

<?php
if (!$msgcount) {
print "No images uploaded!";
}
?>
<center>

and modify it

<?php
if (!$msgcount) {
print "No images uploaded!";
}
else {
//put email code here.
}
?>
<center>

Much simpler than doing the crontab thing, and you get notification immediately.

 
joan
joan's picture

Joined: 2002-10-21
Posts: 3473
Posted: Sun, 2002-12-29 09:44

I've implemented this. My version sends email to the album owner saying "<username> has added <x> new pictures to gallery <y>" when new items are added, and can be turned on/off on an album by album basis from the properties.

If any one wants to see the changes, let me know. It's in three files, with about 30 new lines altogether.

 
joan
joan's picture

Joined: 2002-10-21
Posts: 3473
Posted: Tue, 2002-12-31 09:20

There have been 3 requests, so here it is.

My gallery is started as 1.3.1, but quite a few changes have been made.
So this is instructions on how to make the changes to send email. Let
me know if it's not clear.

For each section, open the file, find the line shown, then make the changes
described.

Note: this sends email to the album owner. It's an album property
whether or not email is sent for that album. For a typical gallery, you
probably just need email sent to a single administrator, not an album owner,
and you won't want to turn it off. If that is the case, don't bother with this,
just add a very simple email command to save_photos.php as described above.

1) in edit_appearance.php
Find this line
<!-- BBCode Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font class="pn-sub">Code:</font><HR></TD></TR><TR><TD><FONT class="pn-sub"><PRE> $gallery->album->fields["display_clicks"] = $display_clicks; </TD></TR></TABLE><!-- BBCode End -->
and add underneath:
<!-- BBCode Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font class="pn-sub">Code:</font><HR></TD></TR><TR><TD><FONT class="pn-sub"><PRE> $gallery->album->fields["email_update"] = $email_update; </TD></TR></TABLE><!-- BBCode End -->

then find

<!-- BBCode Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font class="pn-sub">Code:</font><HR></TD></TR><TR><TD><FONT class="pn-sub"><PRE> <tr>
<td>Allow public commenting for photos in this album?</td> </TD></TR></TABLE><!-- BBCode End -->
and above it, add
<!-- BBCode Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font class="pn-sub">Code:</font><HR></TD></TR><TR><TD><FONT class="pn-sub"><PRE> <tr>
<td>Email album owner when photo is added?</td>
<td><select name="email_update"><?=selectOptions($gallery->album, "email_update", array("yes", "no")) ?></select></td>
</tr> </TD></TR></TABLE><!-- BBCode End -->

2) in save_photos.php
find
<!-- BBCode Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font class="pn-sub">Code:</font><HR></TD></TR><TR><TD><FONT class="pn-sub"><PRE> while (sizeof($userfile)) { </TD></TR></TABLE><!-- BBCode End -->

and above it, add
<!-- BBCode Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font class="pn-sub">Code:</font><HR></TD></TR><TR><TD><FONT class="pn-sub"><PRE> $imagecount=0; </TD></TR></TABLE><!-- BBCode End -->

find
<!-- BBCode Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font class="pn-sub">Code:</font><HR></TD></TR><TR><TD><FONT class="pn-sub"><PRE>global $gallery; </TD></TR></TABLE><!-- BBCode End -->
and change it to
<!-- BBCode Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font class="pn-sub">Code:</font><HR></TD></TR><TR><TD><FONT class="pn-sub"><PRE>global $gallery, $imagecount; </TD></TR></TABLE><!-- BBCode End -->

Find
<!-- BBCode Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font class="pn-sub">Code:</font><HR></TD></TR><TR><TD><FONT class="pn-sub"><PRE> msg("- Adding $name"); </TD></TR></TABLE><!-- BBCode End -->
and under it, add
<!-- BBCode Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font class="pn-sub">Code:</font><HR></TD></TR><TR><TD><FONT class="pn-sub"><PRE> $imagecount++; </TD></TR></TABLE><!-- BBCode End -->

Find
<!-- BBCode Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font class="pn-sub">Code:</font><HR></TD></TR><TR><TD><FONT class="pn-sub"><PRE>if (!$msgcount) {
print "No images uploaded!";
} </TD></TR></TABLE><!-- BBCode End -->
and under it, add:
<!-- BBCode Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font class="pn-sub">Code:</font><HR></TD></TR><TR><TD><FONT class="pn-sub"><PRE>else if ($gallery->album->getEmailUpdate()) {
$owner=$gallery->album->getOwner();
$to='"'.$owner->fullname.'" <'.$owner->email.'>';
$from=$to;
$text="[Note: This is an automatically generated email. If you no longer want to receive these emails, follow the link below, and turn the email option off in "properties"]rnrn".
$gallery->user->fullname." (".$gallery->user->username.") ".
"has added ".pluralize($imagecount, "image")." to your album ".
makeAlbumUrl($gallery->session->albumName).".";
$subject="[".$gallery->app->galleryTitle."] New images in ".$gallery->session->albumName;
mail($to, $subject, $text, "From: ".$from."rn");
} </TD></TR></TABLE><!-- BBCode End -->

3) in classes/Album.php

find
<!-- BBCode Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font class="pn-sub">Code:</font><HR></TD></TR><TR><TD><FONT class="pn-sub"><PRE> $this->fields["public_comments"] = $gallery->app->default["public_comments"]; </TD></TR></TABLE><!-- BBCode End -->

and under it, add
<!-- BBCode Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font class="pn-sub">Code:</font><HR></TD></TR><TR><TD><FONT class="pn-sub"><PRE> $this->fields["email_update"]="yes"; </TD></TR></TABLE><!-- BBCode End -->

find
<!-- BBCode Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font class="pn-sub">Code:</font><HR></TD></TR><TR><TD><FONT class="pn-sub"><PRE> $nestedAlbum->fields["public_comments"] = $this->fields["public_comments"]; </TD></TR></TABLE><!-- BBCode End -->
and under it, add
<!-- BBCode Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font class="pn-sub">Code:</font><HR></TD></TR><TR><TD><FONT class="pn-sub"><PRE> $nestedAlbum->fields["email_update"] = $this->fields["email_update"]; </TD></TR></TABLE><!-- BBCode End -->

find

<!-- BBCode Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font class="pn-sub">Code:</font><HR></TD></TR><TR><TD><FONT class="pn-sub"><PRE> function getOwner() {
global $gallery;
return $gallery->userDB->getUserByUid($this->fields["owner"]); } </TD></TR></TABLE><!-- BBCode End -->

and under it, add

<!-- BBCode Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font class="pn-sub">Code:</font><HR></TD></TR><TR><TD><FONT class="pn-sub"><PRE> function getEmailUpdate() {
if (isset($this->fields["email_update"])) {
if (strcmp($this->fields["email_update"], "yes"))
{
return false;
}
}
return true;
} </TD></TR></TABLE><!-- BBCode End -->

 
shhansen73

Joined: 2002-12-11
Posts: 12
Posted: Sat, 2003-01-04 07:02

Perfect!

Thank you--I'll try it immediately.

The next big thing I'd like to accomplish is a block that shows on the main page what last ten photos have been posted. I wonder if we could use this code to populate a file that only contained ten entries, and then create a block based on that. It's unfortunate I don't know php well enough to write that..

Any takers?

 
i4get75
i4get75's picture

Joined: 2002-10-24
Posts: 5
Posted: Sun, 2003-01-05 00:35

It works!!!!! THANK YOU VERY MUCH!!!! You did great and I'm loving getting notices when new pictures are added. The notices even show me which album they're added to which is an added bonus that no other mod I've seen has done.

You did great and thank you very much for that.

Greg
:smile: :wink:

 
darnellsmith

Joined: 2009-11-08
Posts: 2
Posted: Sun, 2009-11-08 17:51

I can not find save_photos.php to save my life. Can anyone point me to the right path for this file so i can edit it?

 
darnellsmith

Joined: 2009-11-08
Posts: 2
Posted: Sun, 2009-11-08 17:52

Could you tell me where i can find this file so i can edit it? I have searched for save_photos.php and nothing comes up.

Thanks