Jump to content


Photo

Modular Systems?


  • Please log in to reply
28 replies to this topic

#21 newb

newb
  • Members
  • PipPipPip
  • Advanced Member
  • 454 posts

Posted 13 September 2006 - 09:21 PM

i said usergroups can be done in sessions not bitwise.

#22 Jenk

Jenk
  • Members
  • PipPipPip
  • Advanced Member
  • 778 posts

Posted 15 September 2006 - 11:17 AM

comparing bitwise and sessions is like comparing brick walls with clouds, they are entriely different paradigms.

#23 roopurt18

roopurt18
  • Staff Alumni
  • Advanced Member
  • 3,749 posts
  • LocationCalifornia, southern

Posted 20 September 2006 - 05:48 AM

I've been thinking about designing a modular site as well and here are my thoughts on permissions.  I've not yet put it into practice and the coding would be tricky, but I think it would offer the most robust solution.

Each module installed on the site should export privileges relating to that module.  For instance, a forums module should provide privileges to edit, moderate, delete, move, etc. posts.  A gallery module should allow for the deletion of images.  Each module would be required to provide a privileges.php with a function export_privileges().

Every account to the site should have a user type associated with it and the user types should not be hard coded (with the possible exception being the administrator)!  They should exist in a table.  The admin should be able to log in and dynamically create new user types.  As each type is created, the site should get a list of the exported privileges from each module and allow the admin to configure those privileges for the new user type.

With this method, when the site is accessing a module for a user, it can pass in the user's privileges for that module and the module can behave accordingly.
PHP Forms : Part I | Part II

JavaScript: Singleton

http://www.rbredlau.com

#24 Nolongerused3921

Nolongerused3921
  • Members
  • PipPipPip
  • Advanced Member
  • 142 posts

Posted 20 September 2006 - 05:53 AM

I was thinking about a much easier, messier but yet just as robust system... Each module is self contained in a single file, in a single class... You include it by defining a complex array filled with various information in a singular file used by the modular system.
One of the array variables would be the name of the permission list, along with a list of possible permissions.

This way, you can store permissions for each module in a single column, in a setup like this:
main:64;gallery:96;etc:112
(Obviously those numbers aren't bitwise)

Its a bit sloppy... But it allows for you to plug and play modules, quickly search for permissions on a module by module basis, etc.

#25 Jenk

Jenk
  • Members
  • PipPipPip
  • Advanced Member
  • 778 posts

Posted 20 September 2006 - 11:45 AM

do not store multiple components of data within the same column, separate them.

If using bitwise, you only need to store one number for all of your permissions.

If you need a name/description of all permissions, create a new table for it.
CREATE TABLE `permissions` {
  `id` INT NOT NULL AUTO_INCREMENT,
  `name` VARCHAR(20) NOT NULL,
  `description` TEXT,
  `level` BIGINT NOT NULL DEFAULT 0
} PRIMARY KEY `id`;



#26 Nolongerused3921

Nolongerused3921
  • Members
  • PipPipPip
  • Advanced Member
  • 142 posts

Posted 20 September 2006 - 06:32 PM

That makes no sense... The entire purpose of my design is to allow plug and play, if you have to create a new column for each module's permission... Well, not only is that NOT plug and play, but you'll end up having possibly hundreds of columns.
The permissions would be split up before being read obviously.

#27 Jenk

Jenk
  • Members
  • PipPipPip
  • Advanced Member
  • 778 posts

Posted 21 September 2006 - 08:05 AM

Read my post again.

When using bitwise, you only need one number for all permissions

#28 Nolongerused3921

Nolongerused3921
  • Members
  • PipPipPip
  • Advanced Member
  • 142 posts

Posted 21 September 2006 - 08:09 AM

Read my post again.

When using bitwise, you only need one number for all permissions


No no I understand that part perfectly, however you can't call it plug and play when the permissions are dependant on other modules. How would you know what bitwise has already been used, and what hasn't been? The results of accidentally using the same number twice for two different modules would... Be potentially horrible, and a possible vulnerability to boot.

#29 Jenk

Jenk
  • Members
  • PipPipPip
  • Advanced Member
  • 778 posts

Posted 21 September 2006 - 08:22 AM

er..
$newpermission = $oldpermissions << 1;





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users