Aureole Posted November 19, 2007 Share Posted November 19, 2007 I'm trying to build some kind of permissions into the forum I'm attempting to make. Right now I have access levels, 1 = root, 2 = administrator, 3 = super-moderator etc. then each forum has an access level. Every member is in a "member group" and each group has an access level, I just check that against the forum's access level and there you have it. What I'd like to do is for each group have separate permissions for each forum... if anyone is familiar with Invision Power Board then you'll know what I mean. So say if I have two member groups when I go to make my forum in the ACP I'll have it like Forum Permissions Group Show Forum Read Topics Reply to Topics Create Topics Then for each group I will have checkboxes... Now I'm not asking anyone to do this for me, I'm just asking for advise on how to go about coding something like this. I'm assuming I will need to use arrays in some way or another and arrays are one thing I'm not great with.. Thanks a lot. Quote Link to comment Share on other sites More sharing options...
teng84 Posted November 19, 2007 Share Posted November 19, 2007 i guess that is more of database normalization all you have to have is a relation ships of each tables Quote Link to comment Share on other sites More sharing options...
Aureole Posted November 19, 2007 Author Share Posted November 19, 2007 Well maybe but I'm just not sure how to go about it, could you explain that a little better? Anyway I'm currently playing with some ideas I had trying to get this working on a basic level... I'll let you know if I make any progress. Quote Link to comment Share on other sites More sharing options...
teng84 Posted November 19, 2007 Share Posted November 19, 2007 sorry dont wanna elaborate it very long , my english is bad any ways... sample.. when you start a new topic.. it will relate to your identity so the tbl structure would look like id -------+ topicID name |----< topicstarterID sex title etc.. read topic member member_topic thread id -------+ topicID-----------< topicid name |----<topicsread content sex title etc.. edited... hope that make sense Quote Link to comment Share on other sites More sharing options...
phpSensei Posted November 19, 2007 Share Posted November 19, 2007 sorry dont wanna elaborate it very long , my english is bad any ways... sample.. when you start a new topic.. it will relate to your identity so the tbl structure would look like id -------+ topicID name |----< topicstarterID sex title etc.. read topic member member_topic thread id -------+ topicID-----------< topicid name |----<topicsread content sex title etc.. edited... hope that make sense Good job, i think it made alot of sense. Explain the arrows though... Quote Link to comment Share on other sites More sharing options...
Aureole Posted November 19, 2007 Author Share Posted November 19, 2007 I didn't really understand it but I really appreciate you trying to help... Anyhow I've made a little thing where if a category is shown or not depends on whether your group has the permission, It adds another query on top but it works... <?php if($_GET['category'] && is_numeric($_GET['category'])) { if($member->is_logged_in()) { $queryA = "SELECT `show_cat` FROM `cat_perms` WHERE `cat_id` = '{$_GET['category']}' AND `group_id` = '{$_SESSION['mem_group']}'"; $resultA = mysql_query($queryA); $assocA = mysql_fetch_assoc($resultA); $showCat = $assocA['show_cat']; } if($showCat == 1) { echo('You are viewing Cat No. '.$_GET['category']); } else { echo('You ain\'t allowed to view this Cat.'); } } ?> Very basic but it works, now to see if I can do the same kind of thing with the Forums. There's probably a better way to do this (hence why I posted this topic) but hey... Quote Link to comment Share on other sites More sharing options...
teng84 Posted November 19, 2007 Share Posted November 19, 2007 @Aureole.... you cant go down directly just what you want if you will build that forum of yours from scratch look if you dont make a good normalization you will end up doing a nothing but a mess the code you have right there is just a .001 percent of what your really trying to obtain when you have a forum like this you will have to deal with tons of JOINS(combining tables" normalization") Quote Link to comment Share on other sites More sharing options...
Aureole Posted November 19, 2007 Author Share Posted November 19, 2007 Well the part that says... if($showCat == 1) { echo('You are viewing Cat No. '.$_GET['category']); } Instead of the echo there is actually a crap load of code, to show the category and it's forums and I do use joins as often as possible... I just don't get the whole normalization thing... I don't really see how I can achieve what I did above without having a table for it. Again, hence why I asked here. Quote Link to comment Share on other sites More sharing options...
Aureole Posted November 19, 2007 Author Share Posted November 19, 2007 Is this any better... it hasn't really changed much but I figured it'd be easier to do it this way when it comes to updating the database. Basically if a group can view the category then it's group id would be in the array. <?php if($_GET['category'] && is_numeric($_GET['category'])) { if($member->is_logged_in()) { $queryA = "SELECT `show_cat` FROM `categories` WHERE `cat_id` = '{$_GET['category']}'"; $resultA = mysql_query($queryA); $assocA = mysql_fetch_assoc($resultA); $showCatArray = explode(',', $assocA['show_cat']); $showCat = (in_array($_SESSION['mem_group'], $showCatArray)) ? 1 : 0; } else { $queryA = "SELECT `show_cat_g` FROM `categories` WHERE `cat_id` = '{$_GET['category']}'"; $resultA = mysql_query($queryA); $assocA = mysql_fetch_assoc($resultA); $showCat = $assoc['show_cat_g']; } if($showCat == 1) { // Show the Category } } ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.