Announcement

  •  » Engine
  •  » Automatically add granted permission groups

#1 2014-12-21 01:51:22

Kenpari
Guest

Automatically add granted permission groups

Hi there,

I've been experimenting with the Piwigo system recently, and there's something I would like to do that I can't seem to figure out. Right now I have this in config.inc.php

$conf['newcat_default_status'] = 'private';

This makes a newly created category private by default. However, I want to be able to do a little more than that. Say I have a group "testGroup" and I want testGroup to be automatically added the "Permission granted for groups" list underneath the private options for an album.

The way this currently works is that when I create a new album, it automatically marks it as private with no groups having permission to view it. I want the system to be able to automatically add specific groups to that list when a new album is created so I don't have to add them manually.

Furthermore, as a little bonus, I want it to only do this when a specific group, let's call it "Trusted" creates an album.

In other words, I want to know if I can do this:

1. Automatically add a group to the "Permission granted for groups" list in private options for a new album
2. Check the group of an uploader

In the end I want to have something like this:

If User A is in group "Trusted" and he creates an album, the album is created, set to private, and "testGroup" is automatically added to the groups that can view the private album (but no other groups).

If User B is in the group "testGroup" and he creates an album, the album is set to private and no groups are added to the permission list.

I figured it would work like this:  an if statement is wrapped around a statement that first makes the new album private, then adds "testGroup" to the private permissions list. The if statement checks the groups of the uploader, and if they're in the "Trusted" group then this function carries out. However, if they are not in that group, then an else statement directs the album to be made private, and that's it.

Sorry if this is the incorrect section.

 

#2 2015-02-01 18:02:27

mchack
Guest

Re: Automatically add granted permission groups

+1 I want this, too. Please help.

Although for me a "newcat_default_group" localconf option would suffice.

I have a private site with only pre-registered users and only one group. all can upload files (community plugin) and make new albums and are in the same group so that everyone can see everything but guests see nothing. But when a user creates a new parent album only he can see it and I as the only administrator have to manually change the group of that album. Quite frustrating for the users and me.

 

#3 2015-02-10 07:28:21

bfeiten
Member
2015-02-09
4

Re: Automatically add granted permission groups

Hi,

that's what I need as well.

1. When 'Piwigo automatically creates an album for the user, on first connection',
     - the groups of the user shall be configured for the album
     - a permission is automatically added that allows the user to upload photos to his directory with the option checked that he may create subalbums.

2. When a user creates subalbums the permissions of the album above are copied. 

Does anybody has some hints on the structure of the code ?
Where to look to make the changes and additions accordinlgy?

Offline

 

#4 2015-02-11 06:20:36

bfeiten
Member
2015-02-09
4

Re: Automatically add granted permission groups

Number 2 "Inheritance of permissions" was already introduced in version 2.6.

http://piwigo.org/releases/2.6.0#permission_inheritance

"With $conf['inheritance_by_default'] = true; in your local configuration (false by default), a sub-album will automatically inherit permissions of its parent album."

I configured this. But Upload does not work anymore.

There is a bug report from plg:
http://piwigo.org/forum/viewtopic.php?id=24924

But the bug was obviously not resolved.

Offline

 

#5 2015-02-12 07:27:45

bfeiten
Member
2015-02-09
4

Re: Automatically add granted permission groups

Sorry.
I had another problem. The flash upload didn't work anymore.
After newly installing Flash, also the upload work again.
And the group permission is copied to the subalbum :)

Number 1 I still require :
1. When 'Piwigo automatically creates an album for the user, on first connection',
     - the groups of the user shall be configured for the album
     - a permission is automatically added that allows the user to upload photos to his directory with the option checked that he may create subalbums.

Can this be solved by only modifying the code of the community plug-in?

Offline

 

#6 2015-02-16 07:34:07

bfeiten
Member
2015-02-09
4

Re: Automatically add granted permission groups

Ok.

- "With $conf['inheritance_by_default'] = true; in your local configuration (false by default), a sub-album will automatically inherit permissions of its parent album."

- When 'Piwigo automatically creates an album for the user, on first connection',  the group can be controlled when the user albums are created in an album that has the appropriate group (as the group is inherited because the cong above.  (I wanted the user ablbums on the upper level, but in a sub album it works)

- For the community permissions the general rule that a registered user may upload in his his album
It is a pity that sub albums are not possible for this rule. And it seemed not easy to me to exend the code, to support sub albums.
Hence I added to
     community/include/functions_community.inc.php
some code that  automatically adds a permission that allows the user to upload photos to his directory with the option checked that he may create subalbums.

This hack works for me now, but I think one should add the functionality in a proper and maintainable way.
May be I can do it when i understand the code better.
---
     community/include/functions_community.inc.php
---
    $user_album_category_id = $category_info['id'];

    // here the rule for creation of subdirs is created.
    $insert = array(
            'type' => 'user',
            'group_id' => null,
            'user_id' => $user_id,
            'category_id' => $user_album_category_id,
            'user_album' => 'false',
            'recursive' => 'true',
            'create_subcategories' => 'true',
            'moderated' => 'false',
            'nb_photos' => 5000,
            'storage' => 5000,
            );

    mass_inserts(
              COMMUNITY_PERMISSIONS_TABLE,
              array_keys($insert),
              array($insert)
              );


    // in functions_html::get_cat_display_name_cache we use a cache and this
    // cache must be reset so that new album is included inside it.

Offline

 
  •  » Engine
  •  » Automatically add granted permission groups

Board footer

Powered by FluxBB

github twitter newsletter Donate Piwigo.org © 2002-2024 · Contact