How to... transfer shares (not ownership) to other users


I’ve done a script that I want to share also to verify that it’s done properly becase I’m modifying directly the database

We use circles intensively, but we found a “problem” related to shares strategy.

  1. We have a group folder
  2. one of the users of the group (user_A) creates a folder inside (projectX), creates a circle (subcircle_projectX), adds user_B and user_C to that circle and shares the folder projectX with subcircle_projectX.
  3. Everyone is happy and access to the files
  4. User_A changes its role and leaves subcircle_projectX: the share projectX-subcircle_projectX dissapears (because user_A is no longer part of the circle and share belongs to him). Now userB and userC cannot longer access the data. Panic mode on!

Shares can be rebuilt but maybe user_A has created a complex structure with multiples circles, permissions settings… So my solution is, before leaving circle, user_A names a new admin of circle (userB) and transfers shares ownership (directly from the database) to the new admin (I did it by script). Obviously userB has to: be part of the subcircle_projectX and be allowed to share projectX folder (as user of the group folder for example)

The preconditions seem clear but from the DB perspective I want to ensure that is as simple as ONLY modify records of share table changing uid_initiator from the old user uid to the new admin uid.

update_query="UPDATE oc_share s
SET **s.uid_initiator='$uid_new_admin'** 
WHERE **s.uid_initiator='$uid_old_admin'**
AND s.share_with='$selected_circle_id';"

(it has to be refined in order to include only records owned to the group folder, not private resources, but this is the idea)

This is a right approach? Currently I have a functional script that I’m polishing in order to be resilient, but it seems to work fine.



I think, the right approach would be, not to use such shares as group-folders.
Have you seen the app „groupfolders“?
You define folders and permissions as admin. No files are affected, when users leave.

I do not know if there are sideeffects in your database-manipulation

Best regards

1 Like

Thanks @anschuetz. The problem is that group folders were not enough flexible when we tried it to allow user to create “subsubgroups” or multiple levels, relaying on administration to create those new levels.

I will look again into groups folder to find if now they can fit our needs.


Hi @gonzalo.cao
Hmmm. I fear if you need more complex levels of permissions you will see the limits of group folders soon.

My solution is to keep those permissions simple. Might not work for everyone though…

Let us know how you solve it :slight_smile: