Jump to content

[SOLVED] permissions


Ninjakreborn

Recommended Posts

I have created a system (replication of old project), that I am using as the base of something that needs to be done for a client.  There are projects, and there are clients.  Some clients have permissions to whatever projects they have permissions to, and can't use the one's they don't have permission to.  I created a table for permissions, which takes the project id and name, the clients id and name.  It inserts them into a "permissions table".  I had an idea, and when I sought to implement it, it did not work.  I have 2 areas to change permissions.

 

If you are a client, you have an area called project permissions.  The idea is to pull the name's, of ALL the projects, and show there names on the screen with check boxes beside them.  If they are allowed to use that project, it's checked, if not it's unchecked.  They can alter the check boxes as needed, then they submit, and it does all the necessary "alterations" to the permissions table.

 

If you are in the project view, you have an area called "Client Permissions".  The idea is the pull the name's, of ALL the clients, and show there names on the screen with check boxes beside them.  If they are allowed to view that project they are checked, if not they are unchecked.  They can alter the check boxes as needed, then they submit and it does all the necessary "alterations" to the permissions table.

 

When I first created the idea behind the check boxes, I thought about it and presented the idea, and rough sketches to the client.  He was happy about the idea, and wanted me to implement it.  I went ahead and sat down to do it, and my mind when blank, I really have no idea "how" to implement the idea.  I went ahead and started with the projects.  I have a link that says "Client Permissions".  They click on that and are taken to clientpermissions.php which is the page that holds the script for showing the check box list of names of clients.  However, I ran into a problem.  If I go ahead and pull all the data from the "clients" table, and show there names on the screen, each one with a check box beside it, that check box name will be the id number of the client to be able to identify which client it is.  Then the value is either allowed or disallowed.  The problem now comes that I can't figure out how to check the permissions table with EACH client name, to see if they have a permission record for that project.  I will run into the same problem when I try to update all of the client lists.  I could look through it, the one's that are enabled automatically get a database record for permissions, with the information.  However the issue is when the system get's the results.  I have a list of those who they want enabled, and the one's they want disabled.  I have to somehow figure out how to set it up. I am thinking for that I could delete all project permissions related to that one project, then just re-enter the ones that are enabled, ignoring the ones that are disabled.  That will give the permissions for that project reset each time. That part I can come to a solution for.

 

In the end I have a current problem.  As I mentioned above, I can get the names of the clients out on the screen with check boxes.  I can also make the name the id number, and the value either allowed, or disallowed.  That is fine, and I can definitely work that out.  What can I do to check the client to see if they are enabled or disabled.  I am afraid of resources for one reason.

 

For instance.  I could have

 

1. hit the clients table and get all the data

2. Display all there names with check boxes.

3. For each check box hit the permissions table to see if there is a record, if there is mark the x, if there isn't don't. 

 

Sounds pretty simple to me, but then I am worried about it making that many database calls.  If there are (for example), 50 clients.  When they load that page it's going to make a total of 51 calls on that one page (1 call to the clients table, 50 calls to the permissions table).

This same issue is going to be encountered when I begin to deal with the clients, and try to allow them project permissions from that console.  I will be able to solve that problem however I solve this one, but I need some advice on solving this one.  Any advice is greatly appreciated?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.