Repository navigation
Internals Admin Admin
Framework Internals · Subsystem overview · Developer guide
Source: awt_src/classes/admin/Admin.php · Snapshot 8411f4287706.
Admin models and authentication manage the framework administrator record and PHP session. Permission levels are compared numerically with lower values granting broader access. Passwords currently use SHA-512.
use /**
* Class AdminModel
*
* This class represents the model for handling administrative operations
* within the application. It includes methods for managing data interactions
* related to administration and provides functionalities to interact with
* the database, retrieve and modify data specific to administrative needs.
*
* Responsibility:
* - Contains logic for handling administrative data.
* - Interacts with the database for creating, reading, updating, or deleting
* administrative records or entities.
* - Acts as a bridge between the database layer and the controller layer
* specific to administrative modules.
*/
admin\model\AdminModel;class Admin extends AdminModelSource description (behavioral corrections are recorded in Known discrepancies):
Class Admin.
Handles administrative-level functionalities including authentication, permission checks, and session management.
No own constants, enum cases, traits or property declarations. Inherited members are documented on the parent reference page.
| Method | Signature |
|---|---|
| __construct | public function __construct() |
| checkPermission | public function checkPermission(int $level): bool |
| checkAuthentication | public function checkAuthentication(): bool |
| logout | public function logout(): void |
public function __construct()Constructor method for Admin.
Calls the parent constructor from AdminModel to initialize the admin model.
Computes or delegates the operation shown below; no explicit receiver property assignment or throw occurs in this method.
Implementation, validation guards and interaction order
/**
* Constructor method for Admin.
*
* Calls the parent constructor from AdminModel to initialize
* the admin model.
*/
public function __construct() {
parent::__construct();
}public function checkPermission(int $level): bool| Parameter | Type, modifiers and default | Purpose |
|---|---|---|
$level |
int $level |
The permission level to check against. |
Checks if the administrator has permission at a specified level.
Compares the current administrator's permission level with the provided level and returns true if the current level is less than or equal to the specified level.
@param int $level The permission level to check against. @return bool Returns true if the administrator has the required permission level, false otherwise.
Return expressions (including local callbacks): true; false.
Implementation, validation guards and interaction order
/**
* Checks if the administrator has permission at a specified level.
*
* Compares the current administrator's permission level with the
* provided level and returns true if the current level is less than
* or equal to the specified level.
*
* @param int $level The permission level to check against.
* @return bool Returns true if the administrator has the required
* permission level, false otherwise.
*/
public function checkPermission(int $level): bool
{
if($this->getParam("permission_level") <= $level) {
return true;
}
return false;
}public function checkAuthentication(): boolChecks if the administrator is authenticated based on the session token.
This method ensures that a session is started and verifies that the stored token matches the token in the session. Returns true if authenticated, false otherwise.
@return bool Returns true if the administrator is authenticated, false otherwise.
Return expressions (including local callbacks): false; true.
External effects include session_start.
Implementation, validation guards and interaction order
/**
* Checks if the administrator is authenticated based on the session token.
*
* This method ensures that a session is started and verifies that
* the stored token matches the token in the session. Returns true
* if authenticated, false otherwise.
*
* @return bool Returns true if the administrator is authenticated,
* false otherwise.
*/
public function checkAuthentication(): bool
{
if(!isset($_SESSION)) {
session_start();
}
if($this->token === null) {
return false;
}
if($this->token !== $_SESSION['admin']['token']) {
return false;
}
return true;
}public function logout(): voidLogs out the administrator by clearing the session.
This method unsets the admin session to effectively log the administrator out.
@return void
Computes or delegates the operation shown below; no explicit receiver property assignment or throw occurs in this method.
Implementation, validation guards and interaction order
/**
* Logs out the administrator by clearing the session.
*
* This method unsets the admin session to effectively log the
* administrator out.
*
* @return void
*/
public function logout(): void
{
unset($_SESSION['admin']);
}AWT Framework Wiki · Home · Installation Guide · Developer Guide · Framework Internals
Philosophy · Architecture · Known discrepancies · Verification
Installation Guide
Developer Guide
- Learning sequence
- First package
- Package structure
- Lifecycle
- Runtimes
- Events and objects
- Routing and controllers
- Views and resources
- Database and models
- Storage and caching
- Configuration and CLI
- Responses and errors
- Extension points
Framework Internals
- Architecture
- Bootstrap
- Packages
- Runtime
- Events and context
- Objects
- HTTP routing and controllers
- Rendering
- Blade integration
- Database
- Models
- Storage and caching
- Settings
- CLI
- Identity and sessions
- Responses
- Errors
- Complete source inventory
Documentation notes