The Trongate Administrators Module
This module provides functionality for managing administrators of the application. The controller class (Trongate_administrators.php) handles admin login, admin user management, and admin authentication-related tasks.
__construct()
Constructor for the Trongate_administrators module. Calls parent constructor and initializes dashboard home URL and login URL.
create()
Renders a page for the creation or updating of Trongate administrator records.
delete_conf()
Displays a confirmation page before deleting a record. Prevents users from deleting their own account. Requires a valid update ID in URL segment 3.
logout()
Handles user logout by destroying tokens and redirects based on the existence of the secret login segment.
make_sure_allowed()
Ensures the current request is from an authenticated admin user (user level 1). Blocks direct URL access to this method for security.
manage()
Renders a page for the management of records within the 'trongate_administrators' table. Retrieves necessary data such as admin ID, username rows from the model, and loads the management view.
not_found()
Renders a "Record Not Found" page with a descriptive message and a "Go Back" link. Called internally when a requested record doesn't exist or has been deleted.
set_per_page()
Sets the number of records to display per page in the admin management view. Reads the selected index from URL segment 3, validates it against the available options, stores the preference in the session, and redirects to the manage page.
show()
Displays a single record's details. Requires a valid update ID in the URL (segment 3). If the record doesn't exist, renders a "not found" page instead.
submit()
Handles form submission for user data, validates input, updates existing records, or creates new ones accordingly. Redirects to management view or the creation form based on form submission.
submit_delete()
Handles the deletion of a specific user record and related entries based on the given update ID. Performs the deletion of related records from 'trongate_users' and 'trongate_administrators' tables. Redirects to the management page after successful deletion.
submit_update_password()
Handles the password update form submission. Validates that the password meets minimum requirements (8+ characters, matches confirmation), then updates the password in the database.
update_password()
Displays the password update form for a user record. Requires a valid update ID in URL segment 3. The form submits to submit_update_password().
update_your_details()
Redirects the currently logged‑in user to their own profile page for editing. Uses the authentication token to identify the user and redirects to trongate_administrators/show/{user_id}.
username_check()
Checks the availability of a username and validates it against existing usernames in the 'trongate_administrators' table.