Forum .LRN Q&A: Figuring out the community_id for a folder in file-storage

I need to go through all of the Public File folders in a dotLRN installation and change their permissions.  In order to do this I need to get a list of the admin user_ids, which means I need to know my community_id.

I know the data is out there, but this is not a "usual" query and I'm having a hard time figuring out which tables to join.  Before I do the hard work of tracing it down, does anyone happen to know?

TIA!

Hi,

i dont know why you need the admin user_ids but you should get the list of public folders with this query:

select
  cri.item_id,
  cri.name
from
  cr_items cri, fs_root_folders frf, site_nodes s2,
  site_nodes s1, dotlrn_communities_core dcc
where
  cri.parent_id = frf.folder_id
  and frf.package_id = s2.object_id
  and dcc.package_id = s1.object_id
  and s1.node_id = s2.parent_id
  and s2.name = 'file-storage'
  and cri.name = 'public';

you could use a pgsql to go thru all of the folder and change permissions.

Sorry, in your installation it will probably be "dotlrn_communities_all" instead of "dotlrn_communities_core".
Thanks, I guess I wasn't very clear.  Here's a better description of the problem:

Sloan modified the code in dotlrn-fs, add_applet_to_community(), to modify the permissions of the community's Public Files folder so that not even admins could delete or rename it.  This is not just any public folder; it's a specific one named <community>'s Public Files.

The same code change needed to be made to the clone() proc as well, which I just did.  Now I need to modify permissions for all the Public Files folders in all the classes that have been created recently by cloning.

It's easy to get a list of all the folder_ids from cr_folders;  anything with a label like '%Public Files' will do.  But the code I need to execute looks like this:

        permission::set_not_inherit -object_id $public_folder_id
        permission::grant -party_id $admins -object_id $public_folder_id -privilege write

        set dotlrn_public [dotlrn::get_users_rel_segment_id]
        permission::grant -party_id $dotlrn_public -object_id $public_folder_id -privilege read

And for this I have to be able to figure out a list of the user_ids of the admins for each community, so I set things up properly.  And that means I need to figure out the community_id for each folder.

I will study your query - it looks like it might do what I need, even though I didn't explain it very well.  Thanks!

Janine

It may be possible to use a list of the relational segments that are community admins, rather than a list of the users who are admins of the community:

select segment_id
from  rel_segments
where  segment_name like 'Admins of %'
and    rel_type = 'dotlrn_admin_rel'

Unless I'm very much mistaken, that way you ensure any new admins automatically inherit the applied permissions.

One other thought I had was: what happens if you add another community?
The public folder will have default permissions, which you will have to change; unless you change the community creation...

Don't know if that helps, but thought I'd throw it in anyway :)

<Raad>

Thanks, Raad!

I'll go over your suggestion in more detail later today but I wanted to answer your question - the code for creating new communities has already been modified.  The problem was that the code for cloning communities was initially overlooked, so some communities have now been created that don't have the permissions set correctly.  My goal here is to fix those, and then all will be happy. :)