Suggestions please!

Suggestions please!

am 21.11.2005 12:41:58 von jusa_98

--0-1394604818-1132573318=:52191
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit

Hi,

Okay I have a dj site, I have alogin script and cookies to handle the login.

Next I want to add some permissions for each dj account. Maybe 3 to start with, 3 permissions.

A value or y or n will be set in each permission, with n being the default.

Now I need to know how to output the permission out with some add php code.

So let me explain:

Three permissions lets say are perm_1 , perm_2 , and perm_3

If user bob has a y in perm_2 I want to output the perm_2 permission. Which lets say is to delete a dj account. So it needs to output some php code to work with the database. Is IF statements relevent/safe for this or is there a better method?

So each user account on default will need to also check the values of the permission. So I need a code that checks for a y value in each permission. If none is found than nothing is displayed or a message saying you have no special permissions currently. But if one or more are met than those permissions are outputed to the relevant permission code.

If you need any further information please let me know. All help mostly appreciated in advance.

J


---------------------------------
Do you Yahoo!?
The best of Hasselhoff on the web - Hoffice Attachments
--0-1394604818-1132573318=:52191--

Re: Suggestions please!

am 21.11.2005 16:57:11 von Micah Stevens

Sounds like a decision needs to be made. If statements were born for that.




On Monday 21 November 2005 3:41 am, JeRRy wrote:
> Hi,
>
> Okay I have a dj site, I have alogin script and cookies to handle the
> login.
>
> Next I want to add some permissions for each dj account. Maybe 3 to
> start with, 3 permissions.
>
> A value or y or n will be set in each permission, with n being the
> default.
>
> Now I need to know how to output the permission out with some add php
> code.
>
> So let me explain:
>
> Three permissions lets say are perm_1 , perm_2 , and perm_3
>
> If user bob has a y in perm_2 I want to output the perm_2 permission.
> Which lets say is to delete a dj account. So it needs to output some php
> code to work with the database. Is IF statements relevent/safe for this or
> is there a better method?
>
> So each user account on default will need to also check the values of the
> permission. So I need a code that checks for a y value in each permission.
> If none is found than nothing is displayed or a message saying you have no
> special permissions currently. But if one or more are met than those
> permissions are outputed to the relevant permission code.
>
> If you need any further information please let me know. All help mostly
> appreciated in advance.
>
> J
>
>
> ---------------------------------
> Do you Yahoo!?
> The best of Hasselhoff on the web - Hoffice Attachments

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Suggestions please!

am 22.11.2005 15:45:40 von Graham Cossey

On 11/21/05, Micah Stevens wrote:
> Sounds like a decision needs to be made. If statements were born for that=
..
> On Monday 21 November 2005 3:41 am, JeRRy wrote:
> > Hi,
> >
> > Okay I have a dj site, I have alogin script and cookies to handle the
> > login.
> >
> > Next I want to add some permissions for each dj account. Maybe 3 to
> > start with, 3 permissions.
> >
> > A value or y or n will be set in each permission, with n being the
> > default.
> >
> > Now I need to know how to output the permission out with some add php
> > code.
> >
> > So let me explain:
> >
> > Three permissions lets say are perm_1 , perm_2 , and perm_3
> >
> > If user bob has a y in perm_2 I want to output the perm_2 permission.
> > Which lets say is to delete a dj account. So it needs to output some p=
hp
> > code to work with the database. Is IF statements relevent/safe for thi=
s or
> > is there a better method?
> >
> > So each user account on default will need to also check the values of=
the
> > permission. So I need a code that checks for a y value in each permiss=
ion.
> > If none is found than nothing is displayed or a message saying you hav=
e no
> > special permissions currently. But if one or more are met than those
> > permissions are outputed to the relevant permission code.
> >
> > If you need any further information please let me know. All help mos=
tly
> > appreciated in advance.
> >
> > J

You may want to consider values.

perm1 on =3D 1
perm2 on =3D 3
perm3 on =3D 5

therefore:
perm1 + perm2 =3D 4
perm1 + perm3 =3D 6

Might make some of the permission checking simpler?

Just a thought.

--
Graham

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Suggestions please!

am 22.11.2005 16:57:01 von Joseph Crawford

------=_Part_1964_2782610.1132675021134
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

you might want to create a table called perms and have each row contain a
user id and a perm for each

the way i have mine setup is a bit more complex but fully configurable.
Here's how i would set it up

user_permissions
- user_id
- action
- value

user_actions
- id
- title

users
- id
- username
- passwd

then to get the permissions i would use a user object maybe something like
this

class user {
var $_id;
var $_permissions;

function user() {
$this->loadPermissions();
}

function hasPermission($val) {
$perm =3D $this->getPermission($val);
if(isset($perm) && $perm == 1) return true;
else return false
}

function loadPermissions() {
global $db;
$res =3D $db->Query("SELECT user_permissions.value, user_actions.title valu=
e
FROM user_permissions INNER JOIN user_actions ON
user_permissions.action==user_actions.id"
$data =3D $db->fetchAll($res);
return $data
}
}

Understand that this code will not work out of the box and no security
measures were implemented, i did this just to show an example ;)

In my system i have user permissions and group permissions, i load the grou=
p
permissions then override with the user permissions.

--
Joseph Crawford Jr.
Zend Certified Engineer
Codebowl Solutions, Inc.
1-802-671-2021
codebowl@gmail.com

------=_Part_1964_2782610.1132675021134--