2

I just installed Tank_Auth in Codeigniter and would like to develop a CMS and to know what is the best approach to create an admin account and client account. Do I have to separate one CI directory and controller for a public website and another CI directory controller for the Admin and Client auth?

Ex: My client has a website so everyone (public) can see the contents. It works fine. I want the admin, client and some of their associated to access Create, Update, Delete contents. How would I do that?

qpixo
  • 39
  • 8

2 Answers2

2

Hi using Tank Auth Groups you can achieve this (I've updated the README with install instructions). This blog post outlines how this code was created and how to create an admin base controller.

JohnWright
  • 248
  • 1
  • 7
1

I followed the link you send and made a change but after the change, it loads into a blank page instead of the default 'tank auth' user login form.

How do I make a link to make it works?

Noticed this line

$this->load->library('tank_auth_groups', '', 'tank_auth');
qpixo
  • 39
  • 8
  • Hi qpixo, I'm the author of the post linked to above ([tank auth groups](http://johnwright.me/blog/tank-auth-groups-roles-admin/)) . Yes you'll need to do steps 1 and 4 to get the zip file download working. Step 4 is the line you mentioned. Let me know if you have any questions. – JohnWright Feb 06 '12 at 22:35
  • Hi JohnWright, for some reason, I can't make that work in my CI. I can't load that tank_auth_groups library. It can't call the defined function if!($this->tank_auth_groups->is_admin()) {...} – qpixo Feb 06 '12 at 22:53
  • Oh I see. The problem is this... the code should be `if(!$this->tank_auth->is_admin()) { ... }` ... the line above `$this->load->library('tank_auth_groups', '', 'tank_auth');` loads the library as '$this->tank_auth' . Since the class 'Tank_auth_groups' extends the class 'Tank_auth', this works fine. – JohnWright Feb 07 '12 at 01:46
  • also, make sure that this line `$this->load->library('tank_auth_groups', '', 'tank_auth');` replaces this line `$this->load->library('tank_auth');` everywhere in your code. – JohnWright Feb 07 '12 at 01:48
  • I just created an answer of my own on this thread and added the install instructions on github. – JohnWright Feb 07 '12 at 02:14
  • That's really weird. I did include $this->load->library('tank_auth_groups', '', 'tank_auth'); in my constructor then in function index() { if(!$this->tank_auth_groups->is_admin()) {...} It doesn't go in this condition. Then I was wondering in CI blocks any outside files of MVC directories. In this case, you must use $CI =& get_instance() instead of $this. I make this change still not working... – qpixo Feb 07 '12 at 16:36
  • You are right, `$this->tank_auth_groups->is_admin()` won't work. You must change it to `$this->tank_auth->is_admin()` . This is your only problem. – JohnWright Feb 07 '12 at 23:22
  • I made a chance like you said, still not working. It doesn't go through the load library line. $this->load->library('tank_auth_groups', '', 'tank_auth'); – qpixo Feb 14 '12 at 20:04
  • I see. Hmmm, are you using CI 2.1.0 and Tank Auth 1.0.9 ? That is what I built the extension with. – JohnWright Feb 14 '12 at 22:58
  • I'm using CI 2.0.3 and the lastest Tank Auth version – qpixo Feb 15 '12 at 18:52
  • I believe my CI version was the main issue :) – qpixo Feb 15 '12 at 21:36
  • it could be... but actually I discovered a small bug in my code... it is fixed on github, but you can also open 'Tank_auth_groups.php' and change this line `require APPPATH . 'libraries/tank_auth.php';` to `require APPPATH . 'libraries/Tank_auth.php';` .. Notice, it's just a capital "T". The case sensitivity could cause issues on some environments. Are you on Linux? – JohnWright Feb 15 '12 at 23:34
  • Just upgraded to CI 2.1, I'll let you know if working or not. Thanks for your help! – qpixo Feb 16 '12 at 16:42
  • Now it's working great! :) Btw, I noticed in your blog you should update your question 4 and in Additional Resources; first letter to capital 'T': $this->load->library('Tank_auth_groups', '', 'Tank_auth'); – qpixo Feb 17 '12 at 23:09