SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    Can we go to a 48 hour day?
    Join Date
    May 2002
    Location
    MI
    Posts
    906
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    using listbox to select multiple permissions

    I have an intranet site that houses several applications. The idea is that person may have permissions to one or more apps.

    To authenticate for this I am thinking that what I would like to do is to provide the admin with a listbox populated current projects (entered into a mysql db). The listbox would allow multiple selections.

    The idea (and trouble) is that:
    1. I can't seem to find how a listbox will pass multiple values. I want to get the data into a comma separated list. This would allow me to use explode and implode to work with the value in a single db field to find permissions. The idea would then be using a check on the pages with the in_array function to see if this project is one of the ones this login has permissions to. Then a array of permissions would be all I would need.

    2. On the admin side, how to have the listbox select the permissions someone alreeady has to update with. In other words, check the ones a person already has permission to so I can then add others.

    Any ideas on working with a listbox in this way?
    mitechie.com
    "Techies just think a little differently
    ...at least that is what they keep telling me."

  2. #2
    SitePoint Zealot infoxicated's Avatar
    Join Date
    Jun 2001
    Location
    UK
    Posts
    140
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In your listbox name put name="permissions[]" so that php picks up the variables as an array of the values selected.

    I do think a better way would be check boxes or radio buttons for each app they're allowed to use, though, plus a db field for each app. Comma seperated values are a bit cowboy for this.

    (I know, I done it myself a couple of years back and it led to a lot of grief later on! )

    Radio buttons would allow an admin to glance down the page and see exactly which apps a user has permission for

  3. #3
    Can we go to a 48 hour day?
    Join Date
    May 2002
    Location
    MI
    Posts
    906
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok, using radio buttons the problem I run into is adding an addional t/f field as future apps are added.

    How do you handle the check then on each app. When a user logs in do they have a session variable for each field in the db? Again, when you add a new app does this mess up the login scripts?

    I do admit I can see it as more visually appealing and I worry about someone accidentally clicking a wrong thing in the list and forgetting what was selected.
    mitechie.com
    "Techies just think a little differently
    ...at least that is what they keep telling me."

  4. #4
    SitePoint Zealot infoxicated's Avatar
    Join Date
    Jun 2001
    Location
    UK
    Posts
    140
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If it truly is a dynamic number of apps then maybe you want to list your projects in a database table and then create a lookup table with user_id, project_id, permission.

    That way you can dynamically add projects and nothing needs to change for the user table.

    Or maybe someone else will have a better idea...

  5. #5
    Can we go to a 48 hour day?
    Join Date
    May 2002
    Location
    MI
    Posts
    906
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    maybe you want to list your projects in a database table and then create a lookup table with user_id, project_id, permission.
    That was where I started out at. I was trying to simplify it from there. I only have two apps right now, but within a year think there will be about 4. It is not that dynamic, so adding a couple of fields to the admin page for a user would not kill me.

    Thanks for the idea on the radio buttons. I will think on it some more and see if anyone else has any ideas.
    mitechie.com
    "Techies just think a little differently
    ...at least that is what they keep telling me."


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •