Jump to content

website settings.. how do I handle them?


TeddyKiller

Recommended Posts

sessions and access level.

$access=$_SESSION['access_level'];
if($acess>=2)
{$page=index.php;
  if($access>=9)$page2=admin.php;
}else
{$page=under_construction.php;}

or something like that depending on how your control is setup.

 

 

HTH

Teamatomic

Link to comment
Share on other sites

sessions and access level.

$access=$_SESSION['access_level'];
if($acess>=2)
{$page=index.php;
  if($access>=9)$page2=admin.php;
}else
{$page=under_construction.php;}

or something like that depending on how your control is setup.

 

 

HTH

Teamatomic

I was thinking along the lines of.. classes?

include("settings.php");

class settings {
       public $status;

       public function sitestatus() {
               if($this->status == '1') {
                       header("location: error.php?csok=24131");
               }
      }
}

$settings = new settings();
$settings->status = $status; //gets this from settings.php
$settings->sitestatus();

Then I thought.. what if I had to extend settings..

I could call private functons within the public function. Though depending on the return of them.. some may return values, some may redirect, some may return nothing. That wont be possible to handle in just a public function?

Link to comment
Share on other sites

Do not use

 

if ($accesLevel === 1)

 

This is annoying as anyone joining your project needs to create a "map" to match numbers to roles/groups instead use

 

if ($accessLevel === GROUP_ADMINISTRATOR)

 

Everyone knows in a blink that the if-body contains code specific for administrators while

 

if ($accessLevel === 5 || $accessLevel === 12)

 

Just keeps you guessing as to whom this applies. Some gave the argument that they were alone on the project and knew what numbers represent which roles. Well, try to go over this code again 6 months after you wrote this. Still remember? Make your maintenance work as easy as possible not harder, you just increase the chances of breaking your code.

 

In OOP terms there are many ways you can go, but your client most presumably wants to be able to add roles leaving you no option of hard-coding them. Zend_Acl gives you some great options in Access-Control.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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