Jump to content

Archived

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

abdul_zu

PHP logic required

Recommended Posts

Hi all,

I am looking some idea about to create control panel with privileg. and the DB will be MySQL.

Here is the full stracture which i need.

I will have one Admin account who will have full access of all tools. and he will create one reseller and assign some releated tool privileg so the reseller can access what admin giving him permission.

For the example:

Admin have full tools:
tool1    tool2        tool3
tool4    tool5        tool6

He created one reseller and assign assign only tool3 and tool6 from checkbox while he was creating new reseller.

once reseller will login he will see only:
tool3    tool6


I hope this explaination will be sufficient. So please advice me what should be logic to do these setup in PHP with MySQL.

Regards,

Share this post


Link to post
Share on other sites
You mean kinda like the cPanel WHM permission system work?

Share this post


Link to post
Share on other sites
What is all this about are you trying to add a members system.

for example

a member joins the site the member signs for a high end account related to grade 6
so there fore the member has the number 6 in the member deatals.

you select do a select statement that says where member='6'

and on the members pages only allow access to tools relating to a memeber 6 access

Share this post


Link to post
Share on other sites
Hello,

I am doing CallShop application which is going to have multi employee. and each employee will have different privileg to access his area.

for the example

1- Employee
    * Create Phone Booth
    * Add balance to Booth
    * Rollback etc...
    * Modify calling rate

2- Employee
    * Add balance
    * Rollback
    * View Call Logs

What i was making my logic to create function for each action and store it in one table with Employee ID. so when employee will login in his control panel only those fuction will be called which is assigned by admin.

Or is there any better way?

Abdul

Share this post


Link to post
Share on other sites
Your way with admin controll is the best way in my option.

Might be a lot more work but worth it.

so basickly you add a number field to the users accounts and then that number relate to provilages.

example

1 basic
2 bronz
3 silver
4 gold

So depending on the value of the number will controll the users previlages

Share this post


Link to post
Share on other sites
You can add some binary representation of tools
tool1 - 1
tool2 - 2
tool3 - 4
...
tooln - 2^(n-1)
try[code]<?php
echo "<form  method=\"POST\" action=\"\">";
if ($_POST['submit']) $a=array_sum($_POST['tool']);
for ($i=1;$i<7;$i++) {
$b=pow(2,$i-1);
$c= ($a & $b) ? "checked=\"checked\"" :"";
echo "<input type=\"checkbox\" name=\"tool[]\" value=\"$b\" $c>tool$i</input><br />\n";
}
echo "<input type=\"submit\" name=\"submit\"></form>";

if ($_POST['submit']) {
$a=array_sum($_POST['tool']);
echo "<hr />Put in database number $a.<hr />
When you read this number :<br />";
for ($i=1;$i<7;$i++){
$b= pow(2,$i-1);
$c= ($a & $b) ? true : false;
echo "tool$i - $c <br />\n";
}
}
?>[/code]

Share this post


Link to post
Share on other sites

×

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.