The Authentication Library Admin Panel
The easiest Authentication Library just got easier to use because now it comes bundled with an administration backend that allows you to add, edit and delete user accounts.
Notice
Because of the new administration panel, The Authentication Library has become an application. As a result of this the number of files used in The Authentication Library has grown. Most of these files are simply views, but there are now two controllers used by The Authentication Library that are required if you wish to use the administration panel. These controllers are located in controllers/admin/
The admin controller
The admin controller - located at controllers/admin/admin.php - is used to show the user their dashboard. At the moment this simply welcomes the user as what would go here is totally application specific. This is required if you wish to use the administration panel dashboard. Feel free to add to this as you see fit for your application.
The users controller
The users controller is used to control the user management part of the admin panel. It enables you to add, edit and delete user accounts. Feel free to add to or edit the controller to suit your needs.
The Layout
The administration layout is very simple and was not made with any other template in mind. Any resemblance is pure coincidence. The CSS for the panel is in the view views/auth/header.php and the template can be changed to suit the needs of you or your client. The panel should be easy to change to fit in with an existing panel.
Adding to the panel
Aside from creating a new controller or adding to an existing one, you'll need to add your views into the views/auth/pages/ folder. You can include the page you need with the panel's headers and footers using the following functions.
$this->auth->view('$name_of_your_file');
Building on top of the Admin Panel
Create a controller
If you want to build on top of the admin panel (and it is highly likely that you will) — you need to do a new things. The first thing you'll need to do is create a new controller for your addition. In this example we'll add a task manager. So you will create a new file in controllers/admin/ called tasks.php. This controller should extend the Application class.
A typical constructor
Your constructor for additional addons to the admin panel should look something like this, you can restrict the addon to either user group and a model is not necessary.
function Tasks()
{
parent::Application();
$this->auth->restrict('admin'); // restrict this controller to admins only
$this->load->model($this->models."taskmodel", 'tasks'); // Load the task model - gets lists of users etc
}
Create a navigation item
The next step is to add a new navigation item. Open up views/auth/nav.php and add a new list item with a link to the correct URI string for your addition, in this example case it will be admin/tasks or even admin/tasks/manage if you have set up a manage function.
Placing and using view files
The view files should be located at views/auth/pages — you should bunch your view files into a folder to keep it easy to navigate and go through at a later stage. You can include your view files by using the function provided, an example is below.
$this->auth->view('tasks/manage');