473,385 Members | 1,676 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

What is wise priviledge system in CMS?

Content management system I'm working consists pages, categories, users (and
images). It is in the first place dircted to companies where 1-10 persons
are taking care of site content. I am thinking how should I set my
privilegde system:

1) use priviledge levels in a simple way: each normal admin is either
allowed just to make drafts for superadmins to accept or not. superadmins
can do anything.
* dbtable solution:
field like priv enum('superadmin', 'admin') in admins table

2) connect piviledge levels to categories also: certain adminLEVEL can write
only to those categories that superadmin allows him/her to (while he/she may
still make drafts to every category?)
* dbtable solution:
connector table levels_categories

3) connect every admin personally to certain categories
* dbtable solution: connector table admins_categories
Jul 17 '05 #1
8 1720
Perttu Pulkkinen wrote:
Content management system I'm working consists pages, categories, users (and
images). It is in the first place dircted to companies where 1-10 persons
are taking care of site content. I am thinking how should I set my
privilegde system:

1) use priviledge levels in a simple way: each normal admin is either
allowed just to make drafts for superadmins to accept or not. superadmins
can do anything.
* dbtable solution:
field like priv enum('superadmin', 'admin') in admins table

2) connect piviledge levels to categories also: certain adminLEVEL can write
only to those categories that superadmin allows him/her to (while he/she may
still make drafts to every category?)
* dbtable solution:
connector table levels_categories

3) connect every admin personally to certain categories
* dbtable solution: connector table admins_categories


I would say Use bit fields.

example.

define("SUPERADMIN", 1);
define("ADMIN", 2);

if ($userpermission & SUPERADMIN) {
//the user is a super user
}

etc...

Each user need a permission field too, with their right bit value stored
in it. That means each user can have many roles as well, because you can
just add all the bit values together and you have one permission int. In
the categories table you can add the bit field required for accessing
the category.

if ($categorypermission & $userpermission) {
//the user have access
}
Do you follow the idea ?

--
Henrik Hansen
Jul 17 '05 #2
If you want a really flexible privilege system then go for a database table
solution. I have outlined my ideas on this in a document at
http://www.tonymarston.co.uk/php-mys...s-control.html which
is based on my experiences of such systems over the past 20 years.

HTH.

--
Tony Marston

http://www.tonymarston.net

"Perttu Pulkkinen" <pe**************@co.jyu.fi> wrote in message
news:98************@read3.inet.fi...
Content management system I'm working consists pages, categories, users (and images). It is in the first place dircted to companies where 1-10 persons
are taking care of site content. I am thinking how should I set my
privilegde system:

1) use priviledge levels in a simple way: each normal admin is either
allowed just to make drafts for superadmins to accept or not. superadmins
can do anything.
* dbtable solution:
field like priv enum('superadmin', 'admin') in admins table

2) connect piviledge levels to categories also: certain adminLEVEL can write only to those categories that superadmin allows him/her to (while he/she may still make drafts to every category?)
* dbtable solution:
connector table levels_categories

3) connect every admin personally to certain categories
* dbtable solution: connector table admins_categories

Jul 17 '05 #3
"Henrik Hansen" <hh****@fsck.dk> kirjoitti viestissä news:apMKc.26086
I would say Use bit fields.
example.
define("SUPERADMIN", 1);
define("ADMIN", 2);
if ($userpermission & SUPERADMIN) {
//the user is a super user
}
etc...
Each user need a permission field too, with their right bit value stored
in it. That means each user can have many roles as well, because you can
just add all the bit values together and you have one permission int. In
the categories table you can add the bit field required for accessing
the category.
if ($categorypermission & $userpermission) {
//the user have access
}
Do you follow the idea ?
Henrik Hansen


I don't have much experience with binary thing other than simple boolean
values. Do you mean that in binary system somepriv = 1, otherpriv= 10 and
someotherpriv = 100 and then all possibilities for user's priv_field are 000
,001, 010, 011, 100, 110 and 111? Can you give more examples?

Jul 17 '05 #4
On Mon, 19 Jul 2004 10:06:02 GMT
"Perttu Pulkkinen" <pe**************@co.jyu.fi> wrote:
"Henrik Hansen" <hh****@fsck.dk> kirjoitti viestissä news:apMKc.26086
I would say Use bit fields.
example.
define("SUPERADMIN", 1);
define("ADMIN", 2);
if ($userpermission & SUPERADMIN) {
//the user is a super user
}
etc...
Each user need a permission field too, with their right bit value
stored in it. That means each user can have many roles as well,
because you can just add all the bit values together and you have
one permission int. In the categories table you can add the bit
field required for accessing the category.
if ($categorypermission & $userpermission) {
//the user have access
}
Do you follow the idea ?
Henrik Hansen


I don't have much experience with binary thing other than simple
boolean values. Do you mean that in binary system somepriv = 1,
otherpriv= 10 and someotherpriv = 100 and then all possibilities for
user's priv_field are 000,001, 010, 011, 100, 110 and 111? Can you
give more examples?


No, a bitwise priv system works this way.
Ex.:

// Map privileges
define("UBERADMIN", 1);
define("NEWS", 2);
define("ARTICLES" 4);
define("FORUM_MOD" 8);
/**
* The sums of these are always unique to the combination.
* Two different combinations of the above privileges
* cannot have the same value.
*/
// Let's pretend that $user has the $priv = 10.
// That is NEWS + FORUM_MOD (2 + 8).

// Then if you want to check if this user has the correct privs
// for an UBERADMIN action you simply do:
if ($priv & UBERADMIN) {
echo "$user has UBERADMIN privilege.";
} else {
echo "$user haven't got UBERADMIN privilege.";
}

You can then easily add more, just remember that numbers are counted as
^2, i.e. 1, 2, 4, 8, 16, 32, 64, 128 etc...
That way no two different combinations can ever be the same.
if ($priv & UBERADMIN)
then checks to see if the UBERADMIN bit is set in $priv.

(This bitwise deal, is actually quite simple, but complicated to
explain.)

Another quick example:
<?php
$privs = array("a" => 1, "b" => 2, "c" => 4, "d" => 8, "e" => 16);
$priv = 27;
foreach ($privs as $key => $val) {
if ($priv & $val) {
$user_priv[] = $key;
}
}

echo "Privileges: " . join(", ", $user_priv);
// Will output: Privileges: a, b, d, e
?>

Does it make more sense now?

Madsen

--
Anders K. Madsen --- http://lillesvin.linux.dk

"There are 10 types of people in the world.
Those who understand binary - and those who don't."

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFA+7mNlNHJe/JASHcRAkMrAJ9/wAGC/N8BxsehQcxsNlrmLbs3tACfe0ww
CAvlWuabuNBCQeCqR2Pgn9g=
=q/YI
-----END PGP SIGNATURE-----

Jul 17 '05 #5
Perttu Pulkkinen wrote:
"Henrik Hansen" <hh****@fsck.dk> kirjoitti viestissä news:apMKc.26086
I would say Use bit fields.
example.
define("SUPERADMIN", 1);
define("ADMIN", 2);
if ($userpermission & SUPERADMIN) {
//the user is a super user
}
etc...
Each user need a permission field too, with their right bit value stored
in it. That means each user can have many roles as well, because you can
just add all the bit values together and you have one permission int. In
the categories table you can add the bit field required for accessing
the category.
if ($categorypermission & $userpermission) {
//the user have access
}
Do you follow the idea ?
Henrik Hansen

I don't have much experience with binary thing other than simple boolean
values. Do you mean that in binary system somepriv = 1, otherpriv= 10 and
someotherpriv = 100 and then all possibilities for user's priv_field are 000
,001, 010, 011, 100, 110 and 111? Can you give more examples?

You need to know how to use bitwise operations
(http://www.php.net/manual/en/languag...rs.bitwise.php) when you
got to know them you see some good potentional in them.

& check if the bit is in both int's example:

$userpermission is 4 which means it contanins the bits 1 2 and 4 which
means if we do:

if (SUPERADMIN & $userpermission) {

}

it will go into the if because we defined SUPERADMIN to 1 in the other
reply. But lets say $userpermission was 0 meaning for example a normal
user, the above if block would fail because the bit 1 is not in 0.

I am not very good at explaining, but hope it helps.
more info:

http://www.web-max.ca/PHP/misc_5.php

Just ask away, I will try to answer the best I can :)

--
Henrik Hansen
Jul 17 '05 #6

"Perttu Pulkkinen" <pe**************@co.jyu.fi> wrote in message
news:e2**************@read3.inet.fi...
"Henrik Hansen" <hh****@fsck.dk> kirjoitti viestissä news:apMKc.26086
I would say Use bit fields.
example.
define("SUPERADMIN", 1);
define("ADMIN", 2);
if ($userpermission & SUPERADMIN) {
//the user is a super user
}
etc...
Each user need a permission field too, with their right bit value stored
in it. That means each user can have many roles as well, because you can
just add all the bit values together and you have one permission int. In
the categories table you can add the bit field required for accessing
the category.
if ($categorypermission & $userpermission) {
//the user have access
}
Do you follow the idea ?
Henrik Hansen
I don't have much experience with binary thing other than simple boolean
values. Do you mean that in binary system somepriv = 1, otherpriv= 10 and
someotherpriv = 100 and then all possibilities for user's priv_field are

000 ,001, 010, 011, 100, 110 and 111? Can you give more examples?

To answer your question, you do have the right idea!
The statement:
if($userpermissions & PERMISSION)
simply tests to see if the bits in PERMISSION are set (=binary 1) in
$userpermission.
To set the bits you can simply use decimal though, eg to set 011 you would
make it equal to 3.
Jul 17 '05 #7
Thanks for these advices! I also ask kindly to check the reply and new
questions I gave to Tony Marston to keep this thread compact.
Jul 17 '05 #8
Thanks for these advices! I also ask kindly to check the reply and new
questions I gave to Tony Marston in order to keep this thread compact.
Jul 17 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Helmut Jarausch | last post by:
Hi, to use a port below 1000 on a Unix system one needs root priviledges. But it's dangerous to execute all of a script under those priviledges. Therefore I'd like to drop the root priviledges...
0
by: Eelko Heuvelmans | last post by:
Hello all, First of all, i'm quite new to programming with XML. So it's quite a long way with lots of discoveries i had lately :-) But now, i need to read this xml file into my application so i...
58
by: Larry David | last post by:
Ok, first of all, let's get the obvious stuff out of the way. I'm an idiot. So please indulge me for a moment. Consider it an act of "community service".... What does "64bit" mean to your friendly...
6
by: mswlogo | last post by:
There are many threads on the lack of a true unmanaged C++ const like behavior in C# (.Net) and that's not what this topic is about. The topic is, what is the best practical way to live with it. ...
16
by: brooks | last post by:
It seems that the Access 97 ADT and 2000 ODE installers can seriously mess up a customer's computer. Sagekey sells a script to prevent this (~$500) which runs on Wise/Installshield (~$500) for a...
39
by: windandwaves | last post by:
Hi Folk I have to store up to eight boolean bits of information about an item in my database. e.g. with restaurant drive-through facility yellow windows
5
by: Enrique Cruiz | last post by:
Hello all, I am currently implementing a fairly simple algorithm. It scans a grayscale image, and computes a pixel's new value as a function of its original value. Two passes are made, first...
5
by: =?Utf-8?B?QWxleCBNYWdoZW4=?= | last post by:
Been a long time since I dealt with some Bit-Wise operations - and never did so in C#. Can someone help me with the following, simple example and how to work with each of my situations (listed...
0
by: ARC | last post by:
Hello all, I currently have an old version of Wise Install Builder version 7, and in getting ready to go with Access 2007 installs with the Sagekey runtime script, I really don't want to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.