Due to health issues support is very limited

file How to prevent modules being assigned to menus users don't have access to?

More
8 years 1 month ago #8121 by alexblock
We've discovered a small issue that we're not sure how to address.

We've created several user groups, each having access to their own set of menus.

We also created a set of modules for each user group. These modules are assigned to only their menus.

But now we see that each user group can assign modules to all menus -- they aren't restricted to assigning modules to only the menus they have access to.

This means that our user groups (let's say marketing and finance) can create modules and assign them to each other's menus -- not the result we are after.

It would be nice if finance was restricted to only assigning modules to their menu items, and the same for marketing.

Any ideas how this can be done?

Please Log in or Create an account to join the conversation.

More
8 years 1 month ago #8122 by carsten888
I see your point. However, unfortunately Admin-User-Access can not override Joomla on that menu-item selector. Sorry.

Please Log in or Create an account to join the conversation.

More
8 years 1 month ago #8124 by alexblock
What about a hack into Joomla's core code to hide menus that the user doesn't have access to (as defined in Admin-User-Access?

My client might be willing to pay to have you provide a solution, even if it does affect Joomla core (we're working with Joomla 1.5.26).

Please Log in or Create an account to join the conversation.

More
8 years 1 month ago - 8 years 1 month ago #8130 by carsten888
here is the hack. B)

file:
administrator/components/com_modules/admin.modules.html.php
line: 433
<?php echo $lists['selections'];?>
replace with
<?php 
//echo $lists['selections'];							


$database = JFactory::getDBO();

$user =& JFactory::getUser();
$user_id = $user->get('id');
$user_type = $user->get('usertype');	

$module_id = JRequest::getVar('id', 0)	;					
							
//get usergroup					
$database->setQuery("SELECT group_id FROM #__pi_aua_userindex WHERE user_id='$user_id' LIMIT 1 ");		
$groups = $database->loadObjectList();
$group_id = 0;	
foreach($groups as $group){
	$group_id = $group->group_id;				
}	

//get menu access data							
$database->setQuery("SELECT menu_groupid FROM #__pi_aua_menus ");
$menutype_access_rights = $database->loadResultArray();	

//get menuitems
$database->setQuery("SELECT id, menutype, name, parent, ordering FROM #__menu WHERE (published='0' OR published='1') ORDER BY ordering ASC");
$aua_menu_items = $database->loadObjectList();	

//get module-menu assignment
$database->setQuery("SELECT * FROM #__modules_menu ");
$moduleassignments_obj = $database->loadObjectList();
$moduleassignments_array = array();											
foreach($moduleassignments_obj as $moduleassignment){
	$moduleassignments_array[] = $moduleassignment->moduleid.'__'.$moduleassignment->menuid;
}

//get menus
//$menus_with_access = array();
$database->setQuery("SELECT id, menutype, title "
." FROM #__menu_types "
);
$menutypes = $database->loadObjectList();
echo '<select name="selections[]" id="selections" class="inputbox" size="15" multiple="multiple">';
foreach($menutypes as $menutype){
	$menutype_right = $menutype->id.'__'.$group_id;										
	if(in_array($menutype_right, $menutype_access_rights) || $user_type=='Super Administrator'){	
		//$menus_with_access[] = $menutype->id;
		echo '<optgroup label="'.$menutype->menutype.'">';
		foreach($aua_menu_items as $menuitem){
			if($menuitem->menutype==$menutype->menutype){
				
				echo '<option value="'.$menuitem->id.'"';											
				if($row->pages=='all'){
					echo ' selected="selected"';
				}elseif($row->pages=='none'){
					//nothing
				}else{
					//per menuitem
					$temp = $module_id.'__'.$menuitem->id;
					if(in_array($temp, $moduleassignments_array)){
						echo ' selected="selected"';
					}
				}
				echo '>'.$menuitem->name.'</option>';
			}
		}
		echo '</optgroup>';
	}
}
echo '</select>';
//print_r($menus_with_access);	

	


?>
Last edit: 8 years 1 month ago by carsten888.

Please Log in or Create an account to join the conversation.

More
8 years 1 month ago #8131 by alexblock
Wow! Thank you, we'll give it a go!

Please Log in or Create an account to join the conversation.

More
8 years 1 month ago #8135 by alexblock
Tried out the code. Very close to what we need... Only thing we notice is that the indentation on the menu structure is missing. See this screen movie:

screencast.com/t/dDrvUdZh

The first 5 seconds is after implementing the hack, and the last bit is with the hack removed... Notice how the parent-child, spacing/hyphen bits get lost when the hack is implemented?

Is there an easy way to address this in your code? Again we're willing to pay for your time on this (although I'm sure the hack would also be useful to others).

Please Log in or Create an account to join the conversation.

Time to create page: 0.172 seconds
Powered by Kunena Forum
 
spicy-sacerdotal