coppermine-gallery.com/forum

Support => Older/other versions => cpg1.2 Standalone Support => Topic started by: XBleed on May 19, 2004, 05:42:07 PM

Title: I searched everywhere for this..
Post by: XBleed on May 19, 2004, 05:42:07 PM
I launched my site for beta testing yesterday and I'm already getting people saying, "How do I edit the images?" ha

The way I have it set up is just showing the newest added images on the main page.  I have 30 albums in one category that would need to be displayed on the same page so I did it differently than how Coppermine originally lists them.

I guess my question is, Is there anyway for me to add "Edit this image |  Delete this image"  to the Intermediate photo display if the user is the one who added the image?

I appologize if this is already a mod, I searched for it.
Thanks
Title: Re: I searched everywhere for this..
Post by: Carrie on May 20, 2004, 04:16:54 AM
Yeah that would be a great mod to have *nods* Someone??
Title: Re: I searched everywhere for this..
Post by: XBleed on May 20, 2004, 04:38:54 AM
Although I've been working with it all day and made LITTLE progress... I still can't figure it out. :(
Title: Re: I searched everywhere for this..
Post by: hyperion on May 20, 2004, 04:52:49 AM
Have your read this?

http://forum.coppermine-gallery.net/index.php?topic=2057.0
Title: Re: I searched everywhere for this..
Post by: XBleed on May 20, 2004, 05:11:22 AM
Yes I did see that, but (correct me if I'm wrong) isn't that just to DELETE the photo, and not Edit it?

I would need to be able to add a "Edit this image" link there as well.
Title: Re: I searched everywhere for this..
Post by: hyperion on May 20, 2004, 05:40:07 AM
Yes, but I linked as a reference for you -- not a step by step guide.  ;)  

As you see, the menu code is generated after two comparisons are made.  First, CPG checks to see if this is the user's private album.  Then it checks to see if the gallery is in admin mode. If one of these conditions is true, it creates the delete buttons (and the edit and crop/rotate buttons in 1.3) for the page.  The user can then click on these links.  Now each of the associated scripts for will check to see if the person calling them has authorization to perform the requested action.  

In displayimage.php:


   $picture_menu = ((USER_ADMIN_MODE && $CURRENT_ALBUM_DATA['category'] == FIRST_USER_CAT + USER_ID) || GALLERY_ADMIN_MODE) ? html_picture_menu($pid) : '';


You would need to add an additional comparison here to see if the pic owner is the same as the current user.

In delete.php:


   } else {
       $query = "SELECT {$CONFIG['TABLE_PICTURES']}.aid as aid, category, filepath, filename FROM {$CONFIG['TABLE_PICTURES']}, {$CONFIG['TABLE_ALBUMS']} WHERE {$CONFIG['TABLE_PICTURES']}.aid = {$CONFIG['TABLE_ALBUMS']}.aid AND pid='$pid'";
       $result = db_query($query);
       if (!mysql_num_rows($result)) cpg_die(CRITICAL_ERROR, $lang_errors['non_exist_ap'], __FILE__, __LINE__);
       $pic = mysql_fetch_array($result);
       if ($pic['category'] != FIRST_USER_CAT + USER_ID) cpg_die(ERROR, $lang_errors['perm_denied'], __FILE__, __LINE__);
   }


and


   case 'picture':
       if (!(GALLERY_ADMIN_MODE || USER_ADMIN_MODE)) cpg_die(ERROR, $lang_errors['access_denied'], __FILE__, __LINE__);


The ability to edit the description of a single image and crop/rotate that image are available in 1.3.  You will have to do a query for the pic's owner ID in delete.php, editOnePic.php, and picEditor.php, as all initially test for Gallery or user admin modes. You would compare the result to the current user's ID. You would then add an extra testing condition to the guard lines that would grant access based on the outcome of the comparison.  
Title: Re: I searched everywhere for this..
Post by: XBleed on May 20, 2004, 05:49:06 AM
Hmm, I'm sorry but that seldomly makes sense to me.  Not your fault.. PHP is to blame.

BUT.. I can wait for 1.3 to be more stable and upgrade if necesary.. I think?  :-[
Title: Re: I searched everywhere for this..
Post by: hyperion on May 20, 2004, 06:12:54 AM
Yes, just wait until we release the next 1.3 package.

Description editing is available for whole albums in 1.2.1, but this makes the mod far more complex than it needs to be.

I would suggest creating a CPG 1.2.1 installation where you can play with the code to your heart's content while you wait.  When you figure out how to do the queries and code changes for the delete option, you will have learned how to do them for all the options in 1.3.

You did well on the templating, so I'm sure with a little more time you will finish this out, too.  ;D