SitePoint Sponsor

User Tag List

Results 1 to 9 of 9

Thread: A Few Questions

  1. #1
    SitePoint Member
    Join Date
    Mar 2005
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    A Few Questions

    Well I'm going to be making my website soon, but I have a few questions because it is going to be complicated in hopes that I can do minimal editing later on. I might also end up releasing the code I used to make my site so that others can use it, so I want it to also be easy to use and customizable.

    My first question is about users and user groups. I want to have the ability to make infinite user groups, each with unique permissions. I thought it might be a somewhat good idea to set up a string of numbers representing their permissions and use that (as a database table field for every option would be massive). How would you go about doing this?

    My next question is about categories. My website will have articles/tutorials that will go into several different categories. These categories will need to be able to have infinite depth, however I do not want to use the set up that MySQL has said is best (numbering each category and using left and right). I thought that the thing most comparable to these would be directories. I was thinking that perhaps I might be able to create something somewhat like a directory system, though I have absolutely no idea on how they work. What are your opinions on these solutions? What would you recommend?

    Finally I want to have extensions/modules to be able to easily install, preferably from an admin panel (extensions will most likely be made by me or other programmers familiar with the application). The problem comes up that in the code I will need to execute these, and I need to be able know when. It would be best to not have to check each extension for when it needs to be added (which would either mean database searching or code editing), though I might have to. Ideas? Opinions?


    Thanks for the help guys.

  2. #2
    SitePoint Addict
    Join Date
    Dec 2005
    Posts
    262
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    1) I would use a table like:
    Code:
    group name -- Mod --  View --  Admin --  Vote --  Restricted --  
    Admins        --         1      --    1     --           1          --      1   --          1        --
    Regular       --          0     --    1      --          0          --      1   --          1        --
    Guest         --          0     --     1      --          0          --      0   --          0        --
    group a       --          1     --     0      --          1         --       1  --          0        --
    Just use 1's as having permission and 0's as no permission. Of course you could name your fields and expand it to your needs.

    2) I would use a parent category and a main category for each subcategory and then use nested whiles to select the information from the parent categories and their 1st level subcategories. Then when selecting the 1st level sub categories you see the 2nd level subcategories:

    So the main page would look like:
    Main category
    -Sub main category1
    -Sub main category2
    -Sub main category2

    Then clicking on the sub main catagory would look like:
    Main category
    -Sub main category1
    --Sub Sub main category1
    --Sub Sub main category2
    --Sub Sub main category3
    --Sub Sub main category4
    Then clicking on a sub sub would get you:
    Main category
    --Sub Sub main category2
    ---Sub Sub Sub main category1
    ---Sub Sub Sub main category2

    You get the idea.
    3) I would suggest using a phpBB format for modules. Just use seperate files for most of it with selected editing of the main files. Anything else would probubly be a little over your head and lead to hours of fustration.

  3. #3
    SitePoint Member
    Join Date
    Mar 2005
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    1) I would use a table like:
    Code:
    group name -- Mod --  View --  Admin --  Vote --  Restricted --  
    Admins        --         1      --    1     --           1          --      1   --          1        --
    Regular       --          0     --    1      --          0          --      1   --          1        --
    Guest         --          0     --     1      --          0          --      0   --          0        --
    group a       --          1     --     0      --          1         --       1  --          0        --
    Just use 1's as having permission and 0's as no permission. Of course you could name your fields and expand it to your needs.
    I already expressed that there would be a problem with the huge number of fields for the table. The number of permissions I would like to be able to specificy will be of an enormous size.

    2) I would use a parent category and a main category for each subcategory and then use nested whiles to select the information from the parent categories and their 1st level subcategories. Then when selecting the 1st level sub categories you see the 2nd level subcategories:
    The problem is not how to set it up to display, but rather how to store it. Since I want to do infinite depth, I wouldn't really use the normal set up of having an id, a name, and a parent id. That fails to work due to the number of queries that it would take to get the crumb trail to work.

    3) I would suggest using a phpBB format for modules. Just use seperate files for most of it with selected editing of the main files. Anything else would probubly be a little over your head and lead to hours of fustration.
    I had already planned on using separate files, my idea was to set up a directory specifically for extensions, and then have a main class for each extension. The main reason that I am using the word extension, is that it is an add-on, and not really a mod (which would require the editing of an existing file).

    I would also like to note that I am willing to spend a lot of time learning what is necessary to set this up properly, so while I might not understand something completely now, it doesn't mean that I am unwilling to learn it and will only use my current knowledge. So if you have a more complicated idea for extensions, I might be open to it.

  4. #4
    SitePoint Addict
    Join Date
    Dec 2005
    Posts
    262
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Forte925
    I already expressed that there would be a problem with the huge number of fields for the table. The number of permissions I would like to be able to specificy will be of an enormous size.
    Well your only other option wold be a three field approach:
    group -- permission -- value

    If the row exists then the group has permission or visa-versa depending on what is more common.

    Quote Originally Posted by Forte925
    The problem is not how to set it up to display, but rather how to store it. Since I want to do infinite depth, I wouldn't really use the normal set up of having an id, a name, and a parent id. That fails to work due to the number of queries that it would take to get the crumb trail to work.
    Thats why you limit yourself to the 3 levels displayed.
    For example if you have the following vertical structure: animals, dogs, small dogs, poodles, toy poodles, training, barking, shock collers, inhumane

    The most you would show is three vertical sections: the main category (animals), the closest parent (training) and then the current (barking) and other categories horizontal to barking.
    Quote Originally Posted by Forte925
    I had already planned on using separate files, my idea was to set up a directory specifically for extensions, and then have a main class for each extension. The main reason that I am using the word extension, is that it is an add-on, and not really a mod (which would require the editing of an existing file).
    You will need to have a database checking or code editing there is really no easy way around it. The only other thing I can think of is you program certain check points into the code and then use xml files or something similar to direct the php to run certain codes in certain places. You could use a master xml file that will list the conditions under which you need to run the code and then have a php file parse the xml and find out which statements are true and then follow the instructions.
    eg:
    Code:
     >FILE: index.php
      >>STATUS: logged out
      >>> IMPORT: MODULE: registration - ZONE: 1
      >>STATS: logged in 
      >>> IMPORT: MODULE: arcade - ZONE: 2
      >>> IMPORT: MODULE: recent - ZONE: 1
    Of course this is 100% conceptual.

    Quote Originally Posted by Forte925
    I would also like to note that I am willing to spend a lot of time learning what is necessary to set this up properly, so while I might not understand something completely now, it doesn't mean that I am unwilling to learn it and will only use my current knowledge. So if you have a more complicated idea for extensions, I might be open to it.
    Right but the problem is if you plan too big you will get burned out halfway throgh and never be able to finish.

  5. #5
    SitePoint Member
    Join Date
    Mar 2005
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well your only other option wold be a three field approach:
    group -- permission -- value

    If the row exists then the group has permission or visa-versa depending on what is more common.
    Or you could do something like what I said in my first post and do a string of numbers, which means far less fields.
    Like: 1100101001110



    Thats why you limit yourself to the 3 levels displayed.
    For example if you have the following vertical structure: animals, dogs, small dogs, poodles, toy poodles, training, barking, shock collers, inhumane

    The most you would show is three vertical sections: the main category (animals), the closest parent (training) and then the current (barking) and other categories horizontal to barking.
    Though that may work, that really isn't how I plan on displaying it. ALl I want is a simple cookie crumb trail that goes back to the beginning. Even if only 3 queries, it could still be done in one, either by the method that MySQL has given as best, or by possibly even using a path type of system, where each category would have a path. Though I am looking for some creative solutions to this, as opposed to the default one of using a parent id.

    You will need to have a database checking or code editing there is really no easy way around it. The only other thing I can think of is you program certain check points into the code and then use xml files or something similar to direct the php to run certain codes in certain places. You could use a master xml file that will list the conditions under which you need to run the code and then have a php file parse the xml and find out which statements are true and then follow the instructions.
    I suppose that I will have to do some more research into this field.

  6. #6
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello,

    Thats why you limit yourself to the 3 levels displayed.
    Are you looking to build your breadcrumb trails via a single database query? I have done this before easily and efficiently with the Adjacency List approach if your interested?

    You can find more information about this from this thread,

    http://www.sitepoint.com/forums/showthread.php?t=296176

    In that case, you are not limited to a number of levels either; Composing the structure to do so, in a manner that also addresses performance issues that'd you would have with other algorithmic methods

  7. #7
    SitePoint Member
    Join Date
    Mar 2005
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Dr Livingston
    Hello,



    Are you looking to build your breadcrumb trails via a single database query? I have done this before easily and efficiently with the Adjacency List approach if your interested?

    You can find more information about this from this thread,

    http://www.sitepoint.com/forums/showthread.php?t=296176

    In that case, you are not limited to a number of levels either; Composing the structure to do so, in a manner that also addresses performance issues that'd you would have with other algorithmic methods
    Yes, but should I have a large list of categories, then that would become illogical to select all of those? The way I usually work is to keep the most weeding out that I can on the SQL end.

    What would you guys think about using something equivalent to the nested set? Or perhaps storing the whole path to a category like in a file system, ie: /main/tutorials/programming/php/?

  8. #8
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, but should I have a large list of categories, then that would become illogical to select all of those?
    How large a list of categories are you talking about though? In my thoughts, you can pretty much get away with using the approach I describe with confidence upto about 600 rows, with reasonable flexibility.

    But anything more than the typical 600 rows, you would be better off using something like MPTT for example?

    EDIT:

    I'm proberly talking down the approach I use as the 600 rows is the limit I've tested with, on shared hosting and there was minimal performance loss compared to a lesser algorithm I found, but as I said, 600 ~ 750 is proberly the cut off point, for me anyways

  9. #9
    SitePoint Member
    Join Date
    Mar 2005
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Dr Livingston
    How large a list of categories are you talking about though? In my thoughts, you can pretty much get away with using the approach I describe with confidence upto about 600 rows, with reasonable flexibility.

    But anything more than the typical 600 rows, you would be better off using something like MPTT for example?

    EDIT:

    I'm proberly talking down the approach I use as the 600 rows is the limit I've tested with, on shared hosting and there was minimal performance loss compared to a lesser algorithm I found, but as I said, 600 ~ 750 is proberly the cut off point, for me anyways
    It probably won't get that big. However, before I resolve to use a certain method I like to get a general opinion about the others. What would you say about the other possibilities that I mentioned, and perhaps some advice on the other questions.

    Thanks for helping out.


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
  •