The company has branches in various provinces, so employees in Wuhan can only see information in Wuhan, but all information in senior BOSS can be viewed across regions. Can I do this only through database fields, are there any other ideas? Thank you. How can a set of pages be viewed by people with different identities. The company has branches in various provinces, so employees in Wuhan can only see information in Wuhan, but all information in senior BOSS can be viewed across regions. Can I do this only through database fields, are there any other ideas? Thank you.
How can a set of pages be viewed by people with different identities.
Reply content:
The company has branches in various provinces, so employees in Wuhan can only see information in Wuhan, but all information in senior BOSS can be viewed across regions. Can I do this only through database fields, are there any other ideas? Thank you.
How can a set of pages be viewed by people with different identities.
First of all, I assume that you need to log on to the system to differentiate your permissions. I usually solve this problem using database fields. If you do not want, you can setsession
For example$_SESSION['privilege']
According to thissession
Value to determine what to display in a region, for example:
This is what the User sees.
This is what the Boss sees.
This is what big BOSS sees.
It seems that the code has to be thrown out again ......
It can only be done through fields. Otherwise, how do you know the permissions of the login user?
There is a simple way to view how a set of pages can adapt to different identities, that is, grading permissions. Employees are 1, BOSS is 2, and Big BOSS is 3. set the webpage permission to 2, so that the page can only be viewed by the BOSS.
Design a class for permissions and send it as an object to the front-end.
$access->can('action')
In this case, permission rules and actions are judged and implemented in the permission class.
See Auth and Rbac.
I have done a similar design before, but it is not very mature. You can refer to it.
resource + section + action = permission
For example
Item + item list in Wuhan Region = item list in Wuhan Region
Thenpermission
Assignedrole
, Assign employeesrole
Write a class when determining the permission$checker->has_permission(resource , section , action)
;
If the framework is used, it should containRBAC
Let's take a look at the framework.RBAC
How to use it.
If the framework is not used, you can also find a framework to check the framework'sRBAC
, And then strip it out!
You can refer to this article I wrote: http://codeigniter.org.cn/forums/forum.php? Mod = viewthread & tid = 5792.