Area Division-how does PHP divide role permissions to display content?

Source: Internet
Author: User
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 setsessionFor example$_SESSION['privilege']According to thissessionValue 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

ThenpermissionAssignedrole, Assign employeesrole
Write a class when determining the permission$checker->has_permission(resource , section , action);

If the framework is used, it should containRBACLet's take a look at the framework.RBACHow 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.