dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #19340
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8392: Properly hiding the top menu when there are no accessible maintenance/service modules
------------------------------------------------------------
revno: 8392
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2012-10-05 13:57:54 +0200
message:
Properly hiding the top menu when there are no accessible maintenance/service modules
modified:
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/main.vm
dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/webportal/interceptor/XWorkPortalModuleInterceptor.java
dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/webportal/module/DefaultModuleManager.java
dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/webportal/module/ModuleManager.java
dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/main.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/main.vm 2012-10-03 10:52:54 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/main.vm 2012-10-05 11:57:54 +0000
@@ -61,40 +61,46 @@
<img id="headerBanner" src="../dhis-web-commons/css/${stylesheetDirectory}/logo_banner.png"
onclick="window.location.href='../dhis-web-commons-about/modules.action'" style="cursor:pointer" title="$i18n.getString( 'go_to_system_overview' )">
+ #if( $maintenanceModules.size() > 0 )
<img id="menuSeparator1" src="../dhis-web-commons/css/${stylesheetDirectory}/logo_separator.png">
+ #end
<img id="menuSeparator2" src="../dhis-web-commons/css/${stylesheetDirectory}/logo_separator.png">
<img id="menuSeparator3" src="../dhis-web-commons/css/${stylesheetDirectory}/logo_separator.png">
<img id="menuSeparator4" src="../dhis-web-commons/css/${stylesheetDirectory}/logo_separator.png">
<img id="menuSeparator5" src="../dhis-web-commons/css/${stylesheetDirectory}/logo_separator.png">
+ #if( $maintenanceModules.size() > 0 )
<div id="menuLink1" class="menuLink">$i18n.getString( "maintenance" )</div>
+ #end
+ #if( $serviceModules.size() > 0 )
<div id="menuLink2" class="menuLink">$i18n.getString( "services" )</div>
+ #end
<div id="menuLink3" class="menuLink">$i18n.getString( "help" )</div>
<div id="menuLink4" class="menuLink">$i18n.getString( "log_out" )</div>
+ #if( $maintenanceModules.size() > 0 )
<div id="menuDropDown1" class="menuDropDownArea" >
<ul class="menuDropDownBox">
#foreach( $module in $maintenanceModules )
- #if( $auth.hasAccess( $module.name, "index" ) )
<li>
<a href="${module.defaultAction}">$i18n.getString( $module.name ) </a>
</li>
#end
- #end
</ul>
</div>
+ #end
+ #if( $serviceModules.size() > 0 )
<div id="menuDropDown2" class="menuDropDownArea">
<ul class="menuDropDownBox">
#foreach( $module in $serviceModules )
- #if( $auth.hasAccess( $module.name, "index" ) )
<li>
<a href="${module.defaultAction}">$i18n.getString( $module.name ) </a>
</li>
#end
- #end
</ul>
</div>
+ #end
<div id="menuDropDown3" class="menuDropDownArea">
<ul class="menuDropDownBox">
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/webportal/interceptor/XWorkPortalModuleInterceptor.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/webportal/interceptor/XWorkPortalModuleInterceptor.java 2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/webportal/interceptor/XWorkPortalModuleInterceptor.java 2012-10-05 11:57:54 +0000
@@ -82,8 +82,8 @@
{
Map<String, Object> handle = new HashMap<String, Object>( 2 );
- handle.put( KEY_MAINTENANCE_MODULES, moduleManager.getMaintenanceMenuModules() );
- handle.put( KEY_SERVICE_MODULES, moduleManager.getServiceMenuModules() );
+ handle.put( KEY_MAINTENANCE_MODULES, moduleManager.getAccessibleMaintenanceModules() );
+ handle.put( KEY_SERVICE_MODULES, moduleManager.getAccessibleServiceModules() );
actionInvocation.getStack().push( handle );
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/webportal/module/DefaultModuleManager.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/webportal/module/DefaultModuleManager.java 2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/webportal/module/DefaultModuleManager.java 2012-10-05 11:57:54 +0000
@@ -38,6 +38,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts2.dispatcher.Dispatcher;
+import org.hisp.dhis.security.ActionAccessResolver;
import com.opensymphony.xwork2.config.Configuration;
import com.opensymphony.xwork2.config.entities.PackageConfig;
@@ -69,6 +70,13 @@
// Dependencies
// -------------------------------------------------------------------------
+ private ActionAccessResolver actionAccessResolver;
+
+ public void setActionAccessResolver( ActionAccessResolver actionAccessResolver )
+ {
+ this.actionAccessResolver = actionAccessResolver;
+ }
+
private Comparator<Module> moduleComparator;
public void setModuleComparator( Comparator<Module> moduleComparator )
@@ -127,6 +135,13 @@
return maintenanceMenuModules;
}
+ public List<Module> getAccessibleMaintenanceModules()
+ {
+ detectModules();
+
+ return getAccessibleModules( maintenanceMenuModules );
+ }
+
public List<Module> getServiceMenuModules()
{
detectModules();
@@ -134,6 +149,13 @@
return serviceMenuModules;
}
+ public List<Module> getAccessibleServiceModules()
+ {
+ detectModules();
+
+ return getAccessibleModules( serviceMenuModules );
+ }
+
public Collection<Module> getAllModules()
{
detectModules();
@@ -224,6 +246,10 @@
modulesDetected = true;
}
+ // -------------------------------------------------------------------------
+ // Supportive methods
+ // -------------------------------------------------------------------------
+
private Collection<PackageConfig> getPackageConfigs()
{
Configuration configuration = Dispatcher.getInstance().getConfigurationManager().getConfiguration();
@@ -232,4 +258,19 @@
return packageConfigs.values();
}
+
+ private List<Module> getAccessibleModules( List<Module> modules )
+ {
+ List<Module> list = new ArrayList<Module>();
+
+ for ( Module module : modules )
+ {
+ if ( module != null && actionAccessResolver.hasAccess( module.getName(), defaultActionName ) )
+ {
+ list.add( module );
+ }
+ }
+
+ return list;
+ }
}
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/webportal/module/ModuleManager.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/webportal/module/ModuleManager.java 2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/webportal/module/ModuleManager.java 2012-10-05 11:57:54 +0000
@@ -46,8 +46,12 @@
List<Module> getMaintenanceMenuModules();
+ List<Module> getAccessibleMaintenanceModules();
+
List<Module> getServiceMenuModules();
+ List<Module> getAccessibleServiceModules();
+
Collection<Module> getAllModules();
Module getCurrentModule();
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml 2012-09-19 11:41:19 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml 2012-10-05 11:57:54 +0000
@@ -8,15 +8,10 @@
<!-- Web Portal -->
<bean id="org.hisp.dhis.webportal.module.ModuleManager" class="org.hisp.dhis.webportal.module.DefaultModuleManager">
- <property name="moduleComparator">
- <ref local="org.hisp.dhis.webportal.module.ConfigurableModuleComparator" />
- </property>
- <property name="defaultActionName">
- <value>index</value>
- </property>
- <property name="maintenanceModuleIdentifier">
- <value>maintenance</value>
- </property>
+ <property name="actionAccessResolver" ref="org.hisp.dhis.security.ActionAccessResolver" />
+ <property name="moduleComparator" ref="org.hisp.dhis.webportal.module.ConfigurableModuleComparator" />
+ <property name="defaultActionName" value="index" />
+ <property name="maintenanceModuleIdentifier" value="maintenance" />
</bean>
<bean id="org.hisp.dhis.webportal.module.ConfigurableModuleComparator" class="org.hisp.dhis.webportal.module.ConfigurableModuleComparator">