Suppose I am building a web application using Codeigniter. I have two levels of user- 1. Admin
and 2. Manager
. I want my admin to be able to ADD,EDIT, DELETE, so in my view file I have the following:
<a href="somelink">ADD</a>
<a href="somelink">EDIT</a>
<a href="somelink">DELETE</a>
But in some specific pages, I don't want my Manager to be able to delete or edit any record, he will be allowed to add data only . Now my question is since I have multiple types of user and user- privileges do I have to create a new controller and a view file for my manager(and for each other user levels) or there are some better ways to handle this in the same controller and view file that I will be using for the admin ?
At present I am creating separate controller, model and view files for my ADMIN and MANAGER which is very painful. So I thought there got to be a better way to do this.
Would you please give me some of your expert advice on how to handle this?
To figure out what type of user is logged in I am using the following code in my controllers:
parent::__construct();
if ( !($this->session->userdata('user_type')== 'flex_admin'))
{
redirect('login');
}
Thanks in Advance :)