![]() |
Controllers/Views being shared between user types - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Controllers/Views being shared between user types (/showthread.php?tid=4868) |
Controllers/Views being shared between user types - El Forum - 12-20-2007 [eluser]jleequeen[/eluser] I have a question concerning controllers being shared between different types of users. Let me give an example. I have an application where I have two different types of users, an admin, and a registrant. The registrant user type basically logs in and completes an annual registration (of water data). The admin just basically logs in and reviews the registrations that have been submitted and edits them if necessary, but in the end approves them to where they can be displayed online. My main question is...there are a lot of the data entry screens that are shared between the two users, ie. the registrant being able to input/edit his data...and the admin being able to view and edit the same data. I'm wondering for these screens that would be shared among the two user types, if they should be in a single controller that both users have access to, or do I create a separate admin section where the admin would use a different controller, but just share the view file between the two controllers? Before CI, what I did was use the same view/controller (they were the same file, I know spaghetti code!) , I just had a session variable set to let me know which type of user was accessing the view/controller and made appropriate decisions on how to handle the actions based on that. Just wonder what everyone else does in this case. Thanks. Controllers/Views being shared between user types - El Forum - 12-20-2007 [eluser]Negligence[/eluser] You've got the right idea. Use the same controller, the same view, and just use a toggle to determine who has access to what. |