I'm having problems with my permissions system. What I'm trying to add is a feature to add a user group.
When adding the group, we have checkboxes with certain fields that come from information that is stored in the $perms array.
First off, I'm trying to make it so when a checkbox is checked by the permission value, it is 1, if its not checked, the value is 0, that is already done.
When I post my form, the error I receive is:
Fatal error: Unsupported operand types in C:\Program Files\xampp\htdocs\lenix\modules\test.php on line 50
I have never even had that error before.
The $perms array looks like this:
PHP Code:
<?php
$perms = array( 'forum' => array(
1 => 'f_view',
2 => 'f_post_topic',
3 => 'f_post_reply',
4 => 'f_attach',
5 => 'f_manage_comment',
6 => 'f_manage_cat',
7 => 'f_moderator',
8 => 'f_bypass_flood',
),
'users' => array(
1 => 'u_view_users',
2 => 'u_view_online',
3 => 'u_view_profile',
4 => 'u_manage_users',
5 => 'u_manage_groups',
),
)
// So how I display these is like this:
foreach($GLOBALS['perms'] as $permgroup => $perms )
{
echo $permgroup.'<br>';
foreach( $perms as $bit => $name )
{
echo '--'.$name.'<br>';
}
}
?>
Notice this isn't the full html, I have certain code for the check boxes, but that's not important right now.
All that displays all fine and everything, the html is perfectly fine, getting the post data shouldn't be a problem.
This is where my code goes wrong:
PHP Code:
<?php
// if any permissions were checked
if( $_POST['perms'] )
{
// for all of the groups that had any checked boxes
foreach($_POST['perms'] as $permgroup => $p)
{
// for each item checked in the bitfield
foreach($p as $bit)
{
// add the bit to the permission group
$perms[$permgroup] += $bit;
}
}
}
// the error is on this line of code:
// add the bit to the permission group
$perms[$permgroup] += $bit;
?>
Does anybody see anything out of the ordinary? I sure don't. This is why I'm asking for help, lol.
If anybody can point me in the right, or a better direction, that would be completely awesome, and I would be very thankful.
Thanks in advance.