Welcome to Dream.In.Code
Become a PHP Expert!

Join 150,003 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,336 people online right now. Registration is fast and FREE... Join Now!




admin compared to regular user permissions

 
Reply to this topicStart new topic

admin compared to regular user permissions

capty99
17 Nov, 2006 - 09:59 AM
Post #1

the real kya
Group Icon

Joined: 26 Apr, 2001
Posts: 9,253



Thanked: 16 times
Dream Kudos: 550
My Contributions
alright,
built myself a site,
pretty much a simple forum
ability for user to post , edit, delete w/e.

right now, if a user wants to delete, or edit a post they have to go to a master list of the things they have submitted.

just having trouble grasping the idea of or implementation of user levels like on this forum where a moderator will see edit/delete buttons on every post, or the user that submitted it will see that also but a normal viewer will not.

any way to clarify me how to implement it? thanks
User is online!Profile CardPM
+Quote Post

skyhawk133
RE: Admin Compared To Regular User Permissions
17 Nov, 2006 - 10:08 AM
Post #2

Head DIC Head
Group Icon

Joined: 17 Mar, 2001
Posts: 15,277



Thanked: 61 times
Dream Kudos: 1650
Expert In: Web Development

My Contributions
Think object oriented.

You a table with permissions, call "Groups", each permission is 1/0. Create an object that pulls all the permissions each user has based on their "Group". Then, create a function that calls the permissions object and returns a true or false for each permission

So you would have an object for "permissions" that has:

edit_own_posts = 1
edit_others_posts = 1
delete_others_posts = 1
etc.

Then you would have a function that you would call:

CanThey('edit_own_posts') and it would return true/false.

You would also override some of your permissions if they are a moderator.
User is online!Profile CardPM
+Quote Post

BetaWar
RE: Admin Compared To Regular User Permissions
17 Nov, 2006 - 05:06 PM
Post #3

#include <soul.h>
Group Icon

Joined: 7 Sep, 2006
Posts: 2,304



Thanked: 101 times
Dream Kudos: 1275
My Contributions
also use an if statement where depending on the permissions it will use a seperate template part.

example:
Mod (edit/delete on all)
if($level>=2){
echo'<a href="?edit">Edit</a> <a href="?delete">Delete</a> <a href="?quote">Quote</a>';
}
else{
echo'<a href="?quote">Quote</a>';
}

or something like that.
User is online!Profile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/8/09 08:34PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month