forum.coppermine-gallery.net

Support => cpg1.3.x Support => Older/other versions => cpg1.3 Permissions & Access Rights => Topic started by: lawless314 on February 22, 2005, 11:53:17 pm

Title: Allowing users to edit their uploaded files...
Post by: lawless314 on February 22, 2005, 11:53:17 pm
As it stands, registered users can upload to any public albulm, but once they have uploaded the file, they cannot edit the file information, such as title, description, keywords, etc.

I can't find any actual permissions setting for this - there's either upload approval or admin access, but not upload+edit personal files.  Is there a database flag for it that I could set manually, or is it just admin only?

Thanks,
--Lindsay
Title: Re: Allowing users to edit their uploaded files...
Post by: Joachim Müller on February 23, 2005, 07:42:45 am
currently (with cpg1.3.x) it's admin only, there's no way to allow users to edit their files once they uploaded it to a public gallery. However, the feature you're looking for will be in cpg1.4.x (which just went into feature freeze status, so you can expect a release soon).

Joachim
Title: Re: Allowing users to edit their uploaded files...
Post by: rusk on March 07, 2005, 01:25:05 am
Add line

Code: [Select]
    $picture_menu = (USER_ID == $CURRENT_PIC_DATA['owner_id']) ? html_picture_menu($pid) : '';
in displayimage.php file after line 153 that allows to edit/delete image only for admins.
Title: Re: Allowing users to edit their uploaded files...
Post by: rusk on March 07, 2005, 01:33:31 am
Sorry, this code wil worc correct:

Code: [Select]
    if (USER_ID == $CURRENT_PIC_DATA['owner_id']) {
        $picture_menu = html_picture_menu($pid);
    }

this lines must be AFTER line

Code: [Select]
    $picture_menu = ((USER_ADMIN_MODE && $CURRENT_ALBUM_DATA['category'] == FIRST_USER_CAT + USER_ID) || GALLERY_ADMIN_MODE) ? html_picture_menu($pid) : '';
Title: Re: Allowing users to edit their uploaded files...
Post by: dbasulto on October 21, 2005, 09:25:59 pm
so this code will enable users to edit their own submitted files?
or just an edit link in case you are admin?
Title: Re: Allowing users to edit their uploaded files...
Post by: Joachim Müller on October 22, 2005, 12:49:12 am
why don't you try and find it out and then let us know?
Title: Re: Allowing users to edit their uploaded files...
Post by: agridoc on October 25, 2005, 10:46:06 pm
The script works OK for editing (Crop and Rotate - Edit description). The  DELETE THIS FILE command gives the error message "You don't have permission to perform this operation."

I was very happy at first but ... (see next message)

Title: Re: Allowing users to edit their uploaded files...
Post by: agridoc on October 26, 2005, 12:56:22 am
The script opens editing (Crop and Rotate - Edit description). The  DELETE THIS FILE command gives the error message "You don't have permission to perform this operation."

The problem is that when you open editing only the personal album is available, so if you save it, it will be moved to a personal album and it can' t be moved back to a public one (version 1.33).
Title: Re: Allowing users to edit their uploaded files...
Post by: Stramm on October 27, 2005, 12:32:00 pm
that code from rusk is just to add a lil bit functionality. To let users have full control over their images outside their own user album would mean editing far more code.
Title: Re: Allowing users to edit their uploaded files...
Post by: Abbas Ali on October 27, 2005, 01:46:23 pm
The problem is that when you open editing only the personal album is available, so if you save it, it will be moved to a personal album and it can' t be moved back to a public one (version 1.33).

To solve this problem edit editOnePic.php (function get_user_albums)

Replace

Code: [Select]
        global $CONFIG, $USER_ALBUMS_ARRAY, $user_albums_list;

        if (!isset($USER_ALBUMS_ARRAY[$user_id])) {
                $user_albums = db_query("SELECT aid, title FROM {$CONFIG['TABLE_ALBUMS']} WHERE category='".(FIRST_USER_CAT + $user_id)."' ORDER BY title");

with

Code: [Select]
        global $CONFIG, $USER_ALBUMS_ARRAY, $user_albums_list, $CURRENT_PIC;

        if (!isset($USER_ALBUMS_ARRAY[$user_id])) {
                if (!GALLERY_ADMIN_MODE) {
                  $user_albums = db_query("SELECT aid, title FROM {$CONFIG['TABLE_ALBUMS']} WHERE category='".(FIRST_USER_CAT + $user_id)."'OR aid = '".$CURRENT_PIC['aid']."'  ORDER BY title");               
                } else {
                  $user_albums = db_query("SELECT aid, title FROM {$CONFIG['TABLE_ALBUMS']} WHERE category='".(FIRST_USER_CAT + $user_id)."' ORDER BY title");
                }

This should solve the problem.
Title: Re: Allowing users to edit their uploaded files...
Post by: Abbas Ali on October 27, 2005, 01:57:49 pm
The script opens editing (Crop and Rotate - Edit description). The DELETE THIS FILE command gives the error message "You don't have permission to perform this operation."

And to solve this edit delete.php (function delete_picture)

Replace

Code: [Select]
        $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__);

with

Code: [Select]
        $query = "SELECT {$CONFIG['TABLE_PICTURES']}.aid as aid, category, filepath, filename, owner_id 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 && $pic['owner_id'] != USER_ID) cpg_die(ERROR, $lang_errors['perm_denied'], __FILE__, __LINE__);
Title: Re: Allowing users to edit their uploaded files...
Post by: agridoc on October 28, 2005, 01:34:28 pm
OK it works know. Thank you very much Abbas Ali and Rusk for the first script. All three modifications are needed.

I have tested it and I will announce it in my forum for further testing.

This modification is quite useful as many times members uploaded photos without descriptions in a public album for an event. I think one more modification is needed but this is another topic so I posted it in Allowing users to move files from own to public album (http://forum.coppermine-gallery.net/index.php?topic=23144.0).