Jump to content

Permissions


Aureole

Recommended Posts

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.

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

@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")

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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
}
}
?>

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.