Services Protection System
The concept is really simple, at login process, you assign a level number to someone, or you let Sphex do the job for you by giving to the SPHEX_LEVEL_KEY config value the exact name of the field that contains the level value in your users table.
If you use the SPHEX_LEVEL_KEY config:
SphexAuth::authenticate($user);
By example, the $user var contains "$user['level'] = 500" and the "SPHEX_LEVEL_KEY = 'level'" so Sphex will assign 500 to the session of this dude
If you want to do it manually:
SphexAuth::setLevel(500);
Then, you just need to set a level number to all your classes, to some specific ones or to specific functions, this is how to do it:
public static $sphexProtection = array(
'*' => 1, // by default set everything to 1
'login*' => 0, // to be able to login we need to set all the login functions to 0
'*admin' => 500 // functions ending by admin need 500 level privileges
);
You only have to set a $sphexProtection public variable in your service classes, or/and in the SphexBaseService class that contains the name of your functions and the levels of the protection you need.
You may use wildcards (star) and put as many levels as you want that will be treated in natural array order. First rule that fit, first rule Sphex use !