In my custom component, I'd like to be able to restrict specific views to only certain usergroups. If I create a menu item for one of my views, that's pretty easy to do: I just select the access level for that menu item and I'm done.
Now, the problem comes if someone tries to access directly an URL with option=com_mycomponent, or any of the internal redirections of my component goes to a page with no assigned Itemid... in that case, it's the component itself the one that needs to check the user group and determine if it's able to view that page... how can I restrict that in my code? Just a simple hardcoded check for user's usergroup? Or there's a "standard" way for doing it?
I've been checking documentation, and have found this:
http://docs.joomla.org/J2.5:How_to_implement_actions_in_your_code
but that's for what user can do, not for what user can see. I've also found this forum thread:
http://forum.joomla.org/viewtopic.php?t=530721
the code at the beginning is quite old, but at the end it's recommended to use this:
http://api.joomla.org/cms-3/classes/JUser.html#method_authorise
How should I proceed for that? Should I define assets for main object generated by my view so I can test access for it with JUser?
Thanks in advance.