tonyck — 2013-10-05T14:59:18-04:00 — #1
I have setup a MySQL database with user access levels. I have them display information from the different sections. I would like them to display info pertaining to their particular sections only. If say someone is with section 1 to only see section 1 info and not all sections. How do I achieve this? The access levels are working fine.
spacephoenix — 2013-10-05T21:04:10-04:00 — #2
You could have a table with two fields:
section_id and group_id
Each record would record a section that the group is allowed to view. When a user requests a given page, you first look up which groups that user is a member of, then you look up if that group is allowed to to that section. If they are the section is displayed, if they aren't then they get taken back to what page they were on, an error message is displayed and you might log the fact they tried to access a section they're not allowed to access.
tonyck — 2013-10-06T19:57:46-04:00 — #3
Thanks for your response. I have about 10 Groups number 1 - 10. Then each Group has numbered Sections 1 - 15. Meaning that each Group has say a section 1 ... So, I am wondering how I can set these access to group/sections with your approach.
spacephoenix — 2013-10-06T20:21:27-04:00 — #4
Can someone be a member of more then one group?
Can a group ever be allowed access to more then one section?
tonyck — 2013-10-07T05:51:13-04:00 — #5
No. One can only be a member of one group as the group leader. Under him are sections. He can see only the sections under him. Each section has a section leader who can only see his section.I am using numeric values for both groups and sections. Groups are 1 - 10 and sections are more than 10. This means that each group has a say section 1, 2 ,3 etc.
spacephoenix — 2013-10-07T16:20:02-04:00 — #6
- User: Records details of the users
- UserGroup: Lookup table for recording each group a user is a member of (allows for the future possibility of a user being a member of multiple groups)
- Group: Records details of each group (possibly user ID as a FK from the users table)
- GroupSection: Lookup table as to what sections a group can access (allows for the future possibility of a group being able to access multiple sections)
- Section: Records details of each section
What's the existing table structure (the output of a SHOW CREATE TABLE for each table)?
Could you please post some sample data for each table?
tonyck — 2013-10-12T14:33:36-04:00 — #7
role enum(pastor, rleader, zleader, cleader)
membership_tbl - has so many field but the only common one is mid (member ID)
I have a Registration form where these leaders register. Then as admin I assign the level from the database. I am using this level to assign what they have access to. But my challenge is when it comes to viewing records. It displays records from all regions (zones, sections). But what I want to achieve is that a region, zone, section leader can only see there particular region, zone, section respectively.
tonyck — 2013-10-14T09:31:58-04:00 — #8
Currently I only have 2 tables. The Usertbl this captures user registration for login purposes and I also set there privileges in here. Then the membership tbl is basically used by these users to capture their region, zone, section members. At this point it works fine. There is about 4 levels of access. What I want to achieve is one a member from say central region logins in and goes to this membership table, he should only see members from his region, zone, sec.