forum.coppermine-gallery.net

Dev Board => cpg1.4 Testing/Bugs => cpg1.4 Testing/Bugs: FIXED/CLOSED => Topic started by: LilAngel on December 10, 2005, 03:58:23 pm

Title: Group permissions don't work
Post by: LilAngel on December 10, 2005, 03:58:23 pm
It seems like the group settings aren't working on my gallery after the upgrade.
I used to have a group "BannedUploading" for users which didn't have upload permission. I noticed members of that group started to upload crap, so I reviewed my settings; everything was ok. I created a test user and assigned it to that group and guess what: I can still upload with that account. It terribly bugs me, cause I'm really annoyed by the files these people upload, I keep having to disapprove them.
I created the BannedUploading group again, but it still doesnt work.

I honestly don't know what's wrong with the settings; is this a common bug?

(https://forum.coppermine-gallery.net/proxy.php?request=http%3A%2F%2Ftinypic.com%2Fief789.jpg&hash=d6f9eb0c61c0e89be5412815ee75ca06aa7aa1f6)
(https://forum.coppermine-gallery.net/proxy.php?request=http%3A%2F%2Ftinypic.com%2Fief7ev.jpg&hash=fb4a3e46af52aae81180b17f9dbb005fae2e6660)

Sorry for the low quality screencaps.
Title: Re: Group permissions don't work
Post by: Nibbler on December 10, 2005, 05:01:25 pm
Looks like a new bug. You need to edit bridge/coppermine.inc.php, find this function

Code: [Select]
        // Get groups of which user is member
        function get_groups( &$user )
        {

                $group_list = in_array($user['group_id'] - 100, $this->admingroups) ? 1 : 2;

                $sql = "SELECT user_group_list FROM {$this->usertable} AS u WHERE {$this->field['user_id']}='{$user['id']}' and user_group_list <> '';";

                $result = cpg_db_query($sql, $this->link_id);

                if ( $row = mysql_fetch_array($result) ) {

                        if ($row['user_group_list']) {
                                $group_list .= ','.$row['user_group_list'];
                        }

                        mysql_free_result($result);
                }

                $all_groups = explode(',',$group_list);

                if ( $admin_groups = array_intersect($this->admingroups, $all_groups) ) {
                        $all_groups[0] = 1;
                }

                if ( !in_array($user['group_id'] - 100, $all_groups) ) {
                        $all_groups[] = intval($user['group_id'] - 100);
                }

                return $all_groups;
        }

And replace it with this new version

Code: [Select]
        // Get groups of which user is member
        function get_groups( &$user )
        {
$groups = array($user['group_id'] - 100);

$sql = "SELECT user_group_list FROM {$this->usertable} AS u WHERE {$this->field['user_id']}='{$user['id']}' and user_group_list <> '';";

$result = cpg_db_query($sql, $this->link_id);

if ($row = mysql_fetch_array($result)){
$groups = array_merge($groups, explode(',', $row['user_group_list']));
}

mysql_free_result($result);

return $groups;
        }

Please report back if this solves the issue for you.

Also report back if it doesn't :)
Title: Re: Group permissions don't work
Post by: LilAngel on December 10, 2005, 09:26:32 pm
Yep, that worked!

Issue is solved!  ;D
Title: Re: Group permissions don't work
Post by: Nibbler on December 10, 2005, 10:11:37 pm
Fix committed to CVS.
Title: Re: Group permissions don't work
Post by: LilAngel on December 15, 2005, 12:16:59 am
I noticed something.

About 2 days ago, someone complained about not being able to log in. Then today there was someone else complaining, and I also noticed people could upload without upload upproval. I checked the group settings, and ALL of the custom groups were gone. Thankfully, we did have a backup. I'm not sure if this is related to this bug and the editing, but it's very odd. Maybe something you need to double check?
Just saying to warn you. :)