Welcome Guest, Not a member yet? Register   Sign In
Roles Navigation and Permissions
#5

[eluser]boltsabre[/eluser]
If statements sound fine to me!

But I'd use int's, not names, so let's say you have a link the level 3 and 4 (editor & admin) can view it'd just be like this:

Code:
<?php if ($user_permission > 2): ?>
<a class="current" href="&lt;?php echo base_url(); ?&gt;dashboard" data-toggle="tooltip" data-placement="right" title="" data-original-title="Dashboard"> <i class="fa fa-home"></i> </a>
&lt;?php endif; ?&gt;

I'd be checking the user login status (and redirecting them if not logged in) and getting the user permission and assigning it to the $data variable in MY_Controller, that way you you're not calling class methods every time you want to check something in a view, you're just doing a greater than comparison. It's a bit quicker, and in my opinion a bit neater to have all this stuff hidden away in MY_Controller.

Another advantage is now in all your controllers you can also easily check the user permission and redirect them (or throw a 404 page) if they try to access a controller that they are not allowed to access.



Messages In This Thread
Roles Navigation and Permissions - by El Forum - 02-20-2014, 09:06 AM
Roles Navigation and Permissions - by El Forum - 02-20-2014, 11:38 AM
Roles Navigation and Permissions - by El Forum - 02-20-2014, 12:19 PM
Roles Navigation and Permissions - by El Forum - 02-20-2014, 12:46 PM
Roles Navigation and Permissions - by El Forum - 02-21-2014, 07:00 AM



Theme © iAndrew 2016 - Forum software by © MyBB