Joomla modules to only displayed to specific usersgroup - joomla

I need to able to restrict menu modules to their user group. I have two user group called "contractor and supplier" I have separate menu module for each and only be seen if they are they user group.
But when I login for either I can see the other user menu, visit http://new.oljanafm.com.au And login as a supplier on both login forms:
username: telstra
pw: 1234
How do I make it so each menu can only be seen when they login.
Thanks,
Nep

Menu's are displayed by modules, simply set the menu to the group you want.
In the module that displays the menu set the Access menu to the "Contractor" or "Supplier" group as required.
e.g. in the Joomla 3 Manager you can see the Modules button on the right end of each Menu row.
If you click on the Modules button you will be shown a summary of where it's displayed (template position) and the viewing access group that can see it, as shown below:
If you click on the module entry you can edit the module directly and set the access, like this:

Try this,
In your module , you can create User Groups as a Module Params.
So using this option once the module is installed for one menu item choose required user groups. Then for the second menu item create New module from Module manager ->Tool bar menu.
choose the other user groups from module param.
Assign each module correctly with menu's. Simply Done!
You can create usergroups in module param using the following code in your module XML
<field name="guest_usergroup" type="usergroup"
label="COM_USERS_CONFIG_FIELD_GUEST_USER_GROUP_LABEL"
description="COM_USERS_CONFIG_FIELD_GUEST_USER_GROUP_DESC"
multiple="true" />
For more about usergroups, and more about module params.
Hope it make sense..

I'd suggest you to use a 3rd party solution called Metamodpro
Once you install that, here are some recipes that you could use:
if (MM_USER_REGISTERED ) return 46; //a plain registered user, no additional privileges
if ( MM_USER_AUTHOR ) return 47; //show a notice for "Author" users
if ( MM_USER_EDITOR ) return 48; //show a notice for "Editor" users
if ( MM_LOGGED_IN && MM_NOT_USER_AUTHOR ) return 53; //show a notice to anyone logged in who is not in the "Author" group
if ( $user->usertype == "My Special Group Name" ) return 54; //if you are using any Joomla extensions that allow you to create your own user groups

Related

Output a resource table inside of a custom Laravel Nova Tool

What I'm trying to build:
A custom tool, where, I can have 4 buttons at the top of the page. Then, when a user clicks a button, it will load an index type table, similar to a Nova resource table.
For example: A user could click on the "Widgets" button and it would load a "Widgets" resource table below. Next, the user could click on the "Doodah" button and it would then, instead, load the "Doodah" table below. ... My main question is if there's a way to just harness what's already written in Nova and import it into my custom tool.
The simplest solution is to add a router-link with the resource details inside the navigation.blade.php like this
:to="{
name: 'index',
params: {
resourceName: 'your resource urlKey',
},
}"

How to hide some sub Categories on top menu if user not login

How to hide some sub Categories on top menu if user not logged in.
I try to use
if($session->isLoggedIn()) {
// $CategoryIdtoHide->setIncludeInMenu(0);
}
But is error (I try to write code in header.phtml for test but did not work)
edit or i can do anything with this code (i use this code in else if login )
'$this->drawCustomMenuItem($_category)'
You need to add conditions in app\code\core\Mage\Page\Block\Html\Topmenu.php.
Add your custom condition in it before rendering the child category.

Assign a non-registered user to a user group (under a generic user) with a button click

I have three buttons: Member (of the organisation, not site), Former Member and Companies.
I would like to change the group of the non-registered guest on the site to the group which they click on. In other words, with one button click log the guest into (a random/pre-made account in) a certain group. I do not want to make them have to log in manually in order to assign them to a certain group.
However, I am unsure how to approach this problem. Could anyone give me some pointers?
I dont think you should mix joomla user groups into this mix, it does not really make sense as long as you do not actually intend to log in your users with user and password. If your question is how to present different content to users based on which button they click, here is how I would approach the problem:
In your template, in the index.php - file, check to get the type of user:
<?php
$app=JFactory::getApplication();
$membertype=$app->getUserStateFromRequest('com_content.membertype',
'membertype','member');
?>
Make your three buttons links like this: index.php?membertype=member , index.php?membertype=former , index.php?membertype=companies
( You can have the links point directly to the start menu item for the different member types, just remember to add the membertype= - for the different types. )
Now, also in the template index.php, load menu modules depending on the member type:
<?php
switch($membertype){
case 'member':
case 'former':
case 'companies':
?>
<jdoc:include type="modules" name="membermenu_<?php echo $membertype; ?>"
style="xhtml" />
<?php
break;
}
?>
You can load other modules this way, depending on how much of your content should differ depending on the member type.
In templatedetails.xml, you can add the new module-positions membermenu_member, membermenu_former, membermenu_companies in the positions-section. This will allow you to select the dynamic module positions from the module administration area.
Finally make different menus for the different menu types, and display the menus in different menu modules and module-positions as described above.
regards Jonas

How to have only one tab open in wxribbon bar in wxpython?

I am building a GUI and I am using wxribbon for wxpython. I want to have only one tab(ribbon page) in when user starts my app, from where user can dynamically add more pages or can add panels and buttons to a page. I am able to achieve all the dynamic parts of ribbon. The only problem I have is that I am unable to start with only one ribbon page. When I define only one page, I don't see the ribbon bar(tab bar), what I see is only the page. Now, when I define two page in the beginning, then I see the bar. Can someone tell me what I code have to change in wxribbon so that I am able to have a tab bar visible with only one page in it. Any help would be great. Thanks!. The sample code I am using to add a page is as follows :
import wxRibbon as RB
self._ribbon = RB.RibbonBar(self, id = wx.ID_ANY)
page_1 = RB.RibbonPage(self._ribbon, WORKPIECE, "Workpiece", Bitmap("eye.xpm"))
page_2 = RB.RibbonPage(self._ribbon, wx.ID_ANY, "New Tab", Bitmap("empty.xpm"))
You need the flag RIBBON_BAR_ALWAYS_SHOW_TABS
try this:
self._ribbon = RB.RibbonBar(self, wx.ID_ANY, agwStyle = RB.RIBBON_BAR_DEFAULT_STYLE | RB.RIBBON_BAR_ALWAYS_SHOW_TABS)

Joomla 2.5 - Visible Menu Item - but need login to access

I followed this tutorial about ACL - http://community.joomla.org/blogs/community/1252-16-acl.html
To make everything clear: this is what I need:
having a menu item that is linking to an article
a user enters (not logged yet) the web site (it does not matter if the user is already registered or not)
this user should see the menu item
the user clicks on the menu item
if the user is NOT logged in - the user is asked to enter the username/pass
if the user is logged in -> goto 6
after login is ok, the user can see the content of the article where the menu item was linked.
My aim is to have a menu item that would be visible for all users: logged in and not logged in. But when clicked - only logged in users can view the content where the menu item is pointing. In case the user is not logged in -> log in form should be displayed.
After following the above tutorial I got a menu item that is completely invisible for users that are NOT logged in.
How can I make the menu item to be visible for all, but need login to see content?
Thank you.
EDIT 1:
I just found this solution http://docs.joomla.org/Auto_redirect_guests_to_login
Is it the only solution? I have a huge tree menu structure. That means I need to have a clone of my huge menu... And everytime I change a menu item name - I should do it twice (in visible menu and in invisible menu).
Are there any other solutions without having 2 menus?
EDIT 2:
Found another solution (hacking core files).
This is when menu item is set to "public" but the article ACL is set to "registered"
components/com_content/views/article/view.html.php
from
// Check the view access to the article (the model has already computed the values).
if ($item->params->get('access-view') != true && (($item->params->get('show_noauth') != true && $user->get('guest') ))) {
JError::raiseWarning(403, JText::_('JERROR_ALERTNOAUTHOR'));
return;
}
to
// Check the view access to the article (the model has already computed the values).
if ($item->params->get('access-view') != true && (($item->params->get('show_noauth') != true && $user->get('guest') ))) {
// Redirect to login
$uri = JFactory::getURI();
$app->redirect('index.php?option=com_users&view=login&return=' . base64_encode($uri), JText::_('Members please login to view this page. If you are not a member please <a href="/component/users/?view=registration">register here<a>'));
return;
}
How can I override that code and avoid hacking core files?
Or maybe there is a more elegant solution?
Thanks.
What you can do is a template override and add the login form to the page that provides the message. A template override will allow you to add extras to pages without hacking the core files, therefore when updating Joomla, it will still be there.
For more information on how to override, please see the link below:
http://docs.joomla.org/How_to_override_the_output_from_the_Joomla!_core
Hope this helps.

Resources