In the site header (/login/misc/pagehead.php), two objects are spawned:
- An authentication object named
$auththat can be used as an accessor to various utility methods dealing with user authentication:$auth = new PHPLogin\AuthorizationHandler;
These utility methods are:
-
hasRole($roleName)- Allows checking a role against the current logged-in user.
- Returns boolean
trueorfalsevalue.
- Returns boolean
- Method called like:
$auth->hasRole('Moderator') - Roles and user/role bindings can be handled in the
/admin/roles.phppage by aSuperadminor by another role with the relevant permissions
- Allows checking a role against the current logged-in user.
-
hasPermission($permissionName)- Allows checking a permission against the current logged-in user.
- Returns boolean
trueorfalsevalue.
- Returns boolean
- Method called like:
$auth->hasPermission('Edit Posts') - Permissions and role/permission bindings can be handled in the
/admin/permissions.phppage by aSuperadminor by another role with the relevant permissions
- Allows checking a permission against the current logged-in user.
-
isAdmin()- Simple helper function to check if current user has the
Adminrole assigned to them.- Returns boolean
trueorfalsevalue.
- Returns boolean
- Method called like:
$auth->isAdmin;
- Simple helper function to check if current user has the
-
isSuperAdmin()- Simple helper function to check if current user has the
Superadminrole assigned to them.- Returns boolean
trueorfalsevalue.
- Returns boolean
- Method called like:
$auth->isSuperAdmin;
- Simple helper function to check if current user has the
-
checkSessionKey($key)- Checks
$_SESSIONsuperglobal object for a specified key.- Returns session value of given key if found, or
falseif not
- Returns session value of given key if found, or
- Method called like
$auth->checkSessionKey
- Checks
- A configuration object named
$confthat can be used to access configuration variables fromapp_configdatabase table:$conf = new PHPLogin\PageConstructor($auth); (This extends the AppConfig class)
This object automatically pulls all values from app_config database table as object properties that can be accessed like $conf->property_name
Two useful (static) methods are available in the AppConfig class
pullSetting($setting)- Returns value from given
$setting - Calls can be made like:
$setting = PHPLogin\AppConfig::pullSetting("settingName1")
- Returns value from given
pullMultiSettings($settingArray)- Returns array of values from given
$settingArray - Calls can be made like:
$settings = PHPLogin\AppConfig::pullMultiSettings(array("settingName1", "settingName2", "etc"))
- Returns array of values from given
* Full API documentation can be found by nagivating to: {yoursite.com}/docs/api/index.html