How to let users modify/delete ONLY the photos that they hav

Len

Joined: 2003-04-10
Posts: 18
Posted: Thu, 2003-04-10 23:27

Hello - I have recently downloaded and installed vallimar's 'patched' version of Gallery that allows users to self-register. <!-- BBCode Start --><A HREF="http://gallery.menalto.com/modules.php?op=modload&amp;name=phpBB_14&amp;file=index&amp;action=viewtopic&amp;topic=3657&amp;start=15" TARGET="_blank"> discussed here.</A><!-- BBCode End --> <!-- BBCode Start --><A HREF="http://sexorcisto.net/gallery-patch/gallery-selfreg.tar.gz" TARGET="_blank">download here</A><!-- BBCode End -->. It works great. However I have some more general questions:

a) Is there any way to let users modify/delete ONLY the photos that they have uploaded? (whether the users self-registered or not is beside the point). For example, on this BB I can see everyone's post, but I can only edit the things I post.

b) Is there any way to indicate which user posted which photograph? (again, like posts in this, or any BB)

Thanks to the whole Gallery community for an amazing tool - LEN

PS - the answer to this would be really usefull in the currently empty "Users And Permissions" section of the User Guide

 
joan
joan's picture

Joined: 2002-10-21
Posts: 3473
Posted: Fri, 2003-04-11 01:53

My gallery is modified this way. Unfortunately, all together the changes mean it has 6000 lines different from 1.3.3, which makes it quite hard to extract just the changes you want.

Basically it adds a field called "owner" to the AlbumItem class, which is populated with UID.

 
Len

Joined: 2003-04-10
Posts: 18
Posted: Fri, 2003-04-11 16:35

Thanks for responding, but unfortunately I am no closer to a even a conceptual solution (note: although I have been able to 'tweak' some php/css files, unfortunately I do not know how to program php).

It's odd, since Gallery seems to have 99% of the necessary components: registered users (self- or otherwise), permissions (though they seem to be mainly at the whole-album level), some means of tracking posts (comments indicate who posted them - if it can work for comments, then surely for images?), plus a developer community that is obviously aware of the conventions and usefulness of online community tools.

The closest thing I can figure out is to manually configure each user's permission on a per-album basis to allow them to only modify their album (which, in addtion to being a major hassle, defeats the whole point of self-registering). Also, this means users can only contribute to thier album, so albums cannot be organized by common themes.

One possible, imperfect hack, for at least issue (b) would be to add a (mandatory?) name and/or email field to the add photos window (like in the add comments window) and display this info along with the photo's caption in the album. Ideally this would simply use the info the user already entered when they registered, thus saving them tedious retyping, but it would be useful for galleries that allow posting by non-registered users. In sum, posting author info already works for comments, how could I use the same functionality for pictures?

Any ideas? Thanks - LEN

 
joan
joan's picture

Joined: 2002-10-21
Posts: 3473
Posted: Sun, 2003-04-13 00:31

<!-- BBCode Start --><A HREF="http://gallery.menalto.com/modules.php?op=modload&amp;name=phpWiki&amp;file=index&amp;pagename=Owners%20for%20individual%20images" TARGET="_blank">Album Owner Patch</A><!-- BBCode End -->

 
CHEETAH
CHEETAH's picture

Joined: 2003-02-26
Posts: 37
Posted: Sun, 2003-04-13 06:55
Quote:
<!-- BBCode Start --><A HREF="http://gallery.menalto.com/modules.php?op=modload&amp;name=phpWiki&amp;file=index&amp;pagename=Owners%20for%20individual%20images" TARGET="_blank">Album Owner Patch</A><!-- BBCode End -->

Ok it seems like i always get problem when doing the patching. anyway what I got when patching itemowner.patch:

patching file delete_photo.php
patching file edit_caption.php
patching file gallery_remote.php
patching file gallery_remote2.php
patching file init.php
patching file move_photo.php
patching file publish_xp.php
patching file save_photos.php
patching file search.php
patching file slideshow.php
patching file slideshow_I ow.php
patching file util.php
patching file view_album.php
Hunk #1 succeeded at 405 (offset 3 lines).
Hunk #3 succeeded at 469 (offset 5 lines).
patching file view_photo_properties.php
patching file classes/Album.php
Hunk #1 succeeded at 567 (offset 3 lines).
Hunk #3 succeeded at 850 (offset 5 lines).
Hunk #5 succeeded at 1306 with fuzz 2 (offset 36 lines).
patching file classes/albumtem.php
Hunk #1 FAILE at 34.
Hunk #2 succeeded at 176 (offset 1 line).
1 out of 2 hunks FAILED -- saving rejects to file classes/Albumtem.php. rej
patching file classes/User.php

now what shall i do!??? was it something that didn't go well!??

 
fingery
fingery's picture

Joined: 2003-03-15
Posts: 38
Posted: Sun, 2003-04-13 12:26

Great mods as usual Joan... I don't know where you find the time :wink:

There seems to be a slight problem with the album owner mod though.

When i move an image between albums, after moving, the owner details are corrupt. You get the following error in bold displayed where you would expect the owner.

Warning: Illegal offset type in /mygallerypath/UserDB.php on line 107

Warning: Illegal offset type in /mygallerypath/UserDB.php on line 110

Any ideas?

Thanks in advance,

Chris

 
joan
joan's picture

Joined: 2002-10-21
Posts: 3473
Posted: Sun, 2003-04-13 21:46
Quote:
Great mods as usual Joan... I don't know where you find the time :wink:

Well, I wouldn't have time if I did them properly. However, if I quickly build patch files while half asleep, and don't test them, I have plenty of time.
:-0

Quote:
There seems to be a slight problem with the album owner mod though.

When i move an image between albums, after moving, the owner details are corrupt. You get the following error in bold displayed where you would expect the owner.

Warning: Illegal offset type in /mygallerypath/UserDB.php on line 107

Warning: Illegal offset type in /mygallerypath/UserDB.php on line 110

Arrggghhh!! Bug!

open move_photo.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> $err = $postAlbum->addPhoto($myfile, $mytype, $myname, $gallery->album->getCaption($index), $gallery->album->getOwner($index), $pathToThumb);</TD></TR></TABLE><!-- BBCode End -->
and change it to this <!-- 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>
$err = $postAlbum->addPhoto($myfile, $mytype, $myname, $gallery->album->getCaption($index), $gallery->album->getItemOwner($index), $pathToThumb);
</TD></TR></TABLE><!-- BBCode End -->
You can fix the broken images by using "change owner" in the pull down menu.

patch file fixed as well.

 
CHEETAH
CHEETAH's picture

Joined: 2003-02-26
Posts: 37
Posted: Mon, 2003-04-14 05:05

Joan, Joan, Joan, Joaaaane (Dylan-track, right?) - what about my question about my patching???

thx /CHEETAH

 
beckett
beckett's picture

Joined: 2002-08-16
Posts: 3474
Posted: Mon, 2003-04-14 05:23

CHEETAH:

You should apply the patch by hand.
Open up the patch file in a text editor and hand-edit the original files.
Unless your Gallery version matches Joan's exactly, there's a good chance the patchfile won't work.

Obviously, you only need to worry about the files with failed hunks.

-Beckett (

)

 
joan
joan's picture

Joined: 2002-10-21
Posts: 3473
Posted: Mon, 2003-04-14 08:02

Yup. Again, just look in the *.rej files for the bits of the patches that didn't work.

 
fingery
fingery's picture

Joined: 2003-03-15
Posts: 38
Posted: Mon, 2003-04-14 20:33

Great mod Joan.... and after applying your mods by hand i'm beginning to get the hang of things.

Since you corrected the line in move_photo.php it works a treat :grin: . I knew that was where the error was but i couldnt see it for looking. Now you've pointed it out it seems so obvious.

Anyway, one more slight problem. If you're admin, when using the options below an image you've uploaded, you get duplicate choices. ie, change caption etc. twice. Images that others have uploaded have the correct options. I presume this is something to do with detecting that you have admin (so you get the options) but also as you are "isItemOwner".

Any chance you can help me out how to get rid of the duplicates. I think i'm learning now... Basically need to do something along the lines of if you're admin then don't do the following:

if ($gallery->album->isItemOwner($gallery->user, $i) &amp;&amp; !$gallery->album->isAlbumName($i)) {
showChoice("Edit Caption", "edit_caption.php", array("index" => $i));
showChoice("Delete $label", "delete_photo.php", array("id" => $id));

....only problem is i don't know how to do it though :???:

 
joan
joan's picture

Joined: 2002-10-21
Posts: 3473
Posted: Mon, 2003-04-14 22:03

you need to make the if condition something like
<!-- 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 ($gallery->album->isItemOwner($gallery->user, $i)
&amp;&amp; !$gallery->album->isAlbumName($i)
&amp;&amp; !$gallery->user->canChangeTextOfAlbum($gallery->album)
&amp;&amp; $gallery->user->canDeleteFromAlbum($gallery->album)
) {</TD></TR></TABLE><!-- BBCode End -->
me, I'd rather have duplicates :smile:

 
joan
joan's picture

Joined: 2002-10-21
Posts: 3473
Posted: Mon, 2003-04-14 22:06

actually, it's more complicated than this. You only want delete if the user can't delete from album and you only want edit if the user can't otherwise write to album. So you'll need to split it into two if statements.

have fun!

 
fingery
fingery's picture

Joined: 2003-03-15
Posts: 38
Posted: Sun, 2003-04-20 16:50
Quote:
actually, it's more complicated than this. You only want delete if the user can't delete from album and you only want edit if the user can't otherwise write to album. So you'll need to split it into two if statements.

have fun!

....i gave up trying to fix the options. You were right, it was easier to live with :roll:

Another quick question...

In public albums, i am set as owner but logged in users can still upload. I've modded the add_comment.php to mail me when a comment is made.
How can i also mail the item owner?? I've absolutely no idea how to get the itemowner and their email address :sad:

Open to ideas....

Thanks,

Chris

 
joan
joan's picture

Joined: 2002-10-21
Posts: 3473
Posted: Sun, 2003-04-20 18:49

You could go all the way and allow all logged in users to <!-- BBCode Start --><A HREF="http://gallery.menalto.com/modules.php?op=modload&amp;name=phpBB_14&amp;file=index&amp;action=viewtopic&amp;topic=5277&amp;22586" TARGET="_blank">subscribe</A><!-- BBCode End -->
or try something like this
<!-- 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>
$user=$gallery->userDB->getUserByUsername($gallery->album->getItemOwnerById($id));
if ($user)
{

$to=$user->email;
</TD></TR></TABLE><!-- BBCode End -->

 
fingery
fingery's picture

Joined: 2003-03-15
Posts: 38
Posted: Sun, 2003-04-20 19:44

I'm stuck.. :???:

I find this really hard going... The syntax has be be absolutely spot on or it doesnt work. Kind of hard when you don't have a clue.. :eek:

I've tried to amend add_comment.php by adding the following :

$user=$gallery->userDB->getUserByUsername($gallery->album->getItemOwnerById($id));

if ($user) {

$to=$user->email;
mail($to, "Gallery comment in ".$gallery->album->fields["title"]." added by ".$commenter_name,
"Name : ".$commenter_name .
"nnComment: " .$comment_text .
"nPicture no. : " . $index .
"nnView Comments @ ".makeAlbumUrl($gallery->session->albumName),
"From: $commenter_name");

}

..it doesn't work. Anybody spot the deliberate mistakes? (there's probably a few)

Chris

 
joan
joan's picture

Joined: 2002-10-21
Posts: 3473
Posted: Sun, 2003-04-20 21:34

Yeah. It's a mess. Try usng varaibles for the different parameters. Then 1) you can see what you are doing 2) you can print them out.

My code looked someting like this:

<!-- 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 ($user)
{
$to=$user->email;
$from='"'.$gallery->user->fullname.'" <'.$gallery->user->email.'>';
$text="[Note: This is an automatically generated email]nnA comment has been added to your image, ".makeAlbumUrl($gallery->session->albumName, $id)." (You'll need to login first)nnThe latest comment is from ".$commenter_name." and says: ".ereg_replace("r", "n", ereg_replace("rn", "n", $comment_text));
$subject="[MCC Gallery] A comment has just been added to one of your photos";
mail($to, $subject, $text, "From: ".$from."n");
print "to: ".$to. "<br>from: ".$from."<br>subject: ".$subject. "<p>text: ".$text;
}
</TD></TR></TABLE><!-- BBCode End -->

(the ereg stuff is about one of my users mail was was truncated at the first \r)

 
fingery
fingery's picture

Joined: 2003-03-15
Posts: 38
Posted: Mon, 2003-04-21 09:29

Finally managed to get the error...

ERROR: requested index [-1] out of bounds [5]
Fatal error: Call to a member function on a non-object in /fullgalleryurl/classes/Album.php on line 879

The line 879 is in the following function :

function setItemOwner($index, $owner) {
$photo = &amp;$this->getPhoto($index);
$photo->setOwner($owner);
}

I'm guessing (wild stab in the dark) the problem will be in the $user=$gallery->userDB->getUserByUsername($gallery->album->getItemOwnerById($id)); line.???

 
joan
joan's picture

Joined: 2002-10-21
Posts: 3473
Posted: Mon, 2003-04-21 21:30

Chris, you have my email address in your PM. Send me your albums.php and add_comments, and I'll have a look at them.

[the fix is probably change the $id to $index and a couple of related things in the code example I gave]

 
Chrisgoh11

Joined: 2007-09-15
Posts: 10
Posted: Sat, 2007-09-15 06:03

Is there a way to allow users to edit there own posted images?

I could not find the solution in the forum

Thanks
chris