Jump to content

Hazy Logic


rofl90

Recommended Posts

I'm building user types eg admin, news editor, page editors etc heres my current logic:

 

in the users tbl we have columns with the names of each administrators page, in each page 1 is able to look at it, 0 being not able then we have something in the config file saying

 

<?php

 

// queries etc

if($row['someAdminPage'] == '1') {

$someAdminPage = "1";

} else {

$someAdminPage = "0";

}

// repeat for all pages

?>

 

I get the feeling this is not efficient..

 

My other question is about decided, I was thinkign select's would be easier on me, but thats lazy! And checkboxes are easier on the user, so do i use checkbox's just like text's to validate them with

 

$someCheckBox = $_POST['someCheckBox'];

 

or do i need to do a switch or whatever.

 

 

Thanks for taking the time to read all this.

 

- Happy Easter -

Link to comment
https://forums.phpfreaks.com/topic/97732-hazy-logic/
Share on other sites

Continually bumping yourself will not get you an answer. Your method is fine, assuming you don't have many admin pages.

 

With a lot of pages, I'd suggest an advanced grouping method, using user groups, and page groups.. or for pure page-by-page customizability, storing per-page access levels in an array and serializing it, or creating a custom serialize-like function.

Link to comment
https://forums.phpfreaks.com/topic/97732-hazy-logic/#findComment-500742
Share on other sites

Most systems use number based values for user levels

 

User = 1

Moderator =5

Editor = 10

Admin = 20

 

than doing comparison checks for the user level is pretty basic comparison.

 

but if ya want lots more flexibility.

u will want to look into bit flags for different activities (Note values are power of 2)

 

Read = 1

Post = 2

Delete = 4

Hide = 8

Edit = 16

 

and using bit testing to see if a user can preform that action or not, a lot more complex, offers more flexibility.

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/97732-hazy-logic/#findComment-500751
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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