I'm new here and this is my first question. First of all I apologize for my poor English. I would like to create an application using userfrosting 0.3.0 where:
I thank you very much for your time.
UserFrosting, as of version 0.3.1, does not have built-in support for group hierarchies. However, it should be pretty easy to implement. Here is how I would do it:
company
and company_user
. The company
table will store information about the companies, with a primary key id
. The company_user
table will associate companies with users, and have four columns:
id
(int)company_id
(int)user_id
(int)flag_admin
(bool)Change the register()
method in AccountController.php
so that when someone registers, it creates a new company and then associates them with this company, marking them as the Administrator of this company by setting flag_admin
to '1'.
Any members that get added to a specific company should also be added to this table, but with flag_admin
set to '0'.
Create a new AccessCondition
called manages(user_id_1, user_id_2)
which returns true
if user_id_1
and user_id_2
belong to the same company and user_id_1
has flag_admin
set to '1', false
otherwise.
Grant appropriate permissions to users in group "Administrators" so that they can create/update/delete/view users, but only users in group "Members" and only if the Administrator manage
s them (so if "Members" has a group_id of "4", condition=in_group(user.id,4)&&manages(self.id,user.id)
.
That should get you started, let me know if you need further clarification.