CodeIgniter Forums
How to organize code for multiple purposes ? - 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: How to organize code for multiple purposes ? (/showthread.php?tid=13527)



How to organize code for multiple purposes ? - El Forum - 11-25-2008

[eluser]majidmx[/eluser]
Hi All,
In my previous project with CI, I had different types of users [eg. Admin, Manager, User]
Admin manages everyone and Manager manages some users.
So they have interfaces for managing the users, also each user has his own [My Account] section to update his own information.
Also there is a signup page.
What I mean is all these funtionalities are basically the same, which is managing user.
The difference is showing/Hiding some fields and having some restrictions and so on. And sometimes validations are different.

The way I organized these was like this :

Code:
/controller/admin/account.php
/controller/admin/users.php
/controller/managers/account.php
/controller/managers/users.php
/controller/users/account.php
/controller/signup.php

and in each controller, functions for Update/Add/Edit.
But I feel that I'm doing it in the wrong way, because each time I want to ask a simple field to users table, I have to change all these files which is error-prone.

Can you give me your feedback about how can I overcome this in future projects ?
Do you think having a library for managing users will be a better way and just doing some settings in each file ?
Any idea is appreciated.

Thanks,
MajiD


How to organize code for multiple purposes ? - El Forum - 12-02-2008

[eluser]majidmx[/eluser]
Has any body any Idea ?
How do you guys handle the same situation in your projects ?