In the site header (/login/misc/pagehead.php
), two objects are spawned:
- An authentication object named
$auth
that 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
true
orfalse
value.
- Returns boolean
- Method called like:
$auth->hasRole('Moderator')
- Roles and user/role bindings can be handled in the
/admin/roles.php
page by aSuperadmin
or 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
true
orfalse
value.
- Returns boolean
- Method called like:
$auth->hasPermission('Edit Posts')
- Permissions and role/permission bindings can be handled in the
/admin/permissions.php
page by aSuperadmin
or 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
Admin
role assigned to them.- Returns boolean
true
orfalse
value.
- 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
Superadmin
role assigned to them.- Returns boolean
true
orfalse
value.
- Returns boolean
- Method called like:
$auth->isSuperAdmin
;
- Simple helper function to check if current user has the
-
checkSessionKey($key)
- Checks
$_SESSION
superglobal object for a specified key.- Returns session value of given key if found, or
false
if not
- Returns session value of given key if found, or
- Method called like
$auth->checkSessionKey
- Checks
- A configuration object named
$conf
that can be used to access configuration variables fromapp_config
database 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