Welcome Guest, Not a member yet? Register   Sign In
how to show parts of my view, if user does have access?
#1

[eluser]K.OS[/eluser]
Hi,

quick question, how would you approach this problem:

I have one view, lets say a view called 'nav'. This view contains the complete menu structure for my site. I have some Users with different roles and not all of them are allowed to access all function through the menu.

i blocked access for some controller functions with this function:
Code:
function requireUserRole($role = 3)
    {
      if ($role >= $this->session->userdata['role']) {
     return true;
      }else{
      return false;
      }

    }

only if this function call is true, certain other function will be executed… this works well to block access to functions in my controller.

But because of the MVC structure i want to avoid calling this functions in my controller as well. How would you filter your view to show just some entries?

Code:
<ul>
  &lt;!-- this should be available to every user --&gt;
  <li>
      <a href="&lt;?= site_url('presentation/add') ?&gt;">neue Präsentation</a>
  </li>
  &lt;!-- this item should just be available to certain users with certain roles --&gt;
  <li>
      <a href="&lt;?= site_url('presentation/list_all') ?&gt;">alle Präsentationen</a>
      <a href="&lt;?= site_url('presentation/list_all/xml') ?&gt;">xml</a>
  </li>
</ul>


Messages In This Thread
how to show parts of my view, if user does have access? - by El Forum - 08-16-2010, 04:49 AM
how to show parts of my view, if user does have access? - by El Forum - 08-16-2010, 05:54 AM
how to show parts of my view, if user does have access? - by El Forum - 08-16-2010, 05:58 AM
how to show parts of my view, if user does have access? - by El Forum - 08-16-2010, 06:07 AM



Theme © iAndrew 2016 - Forum software by © MyBB