Scarab commit: svn commit: r10669 - trunk/src: java/org/tigris/scarab/om webapp/WEB-INF/templates/navigations

Hussayn Dabbous <[email protected]>
Newsgroups gmane.comp.java.scarab.cvs
Message-ID <[email protected]>
Author: dabbous
Date: 2009-01-07 17:24:02-0800
New Revision: 10669

Modified:
   trunk/src/java/org/tigris/scarab/om/IssueType.java
   trunk/src/webapp/WEB-INF/templates/navigations/CommonLinks.vm

Log:
If a user has no permission to create issues, no issue type should be listed in the left navigation bar. The implemented permission check was incomplete. 
I also added an additional check in the CommonLinks.vm to avoid the display
of an empty issue-type list.

this commit fixes http://www.solitone.org/scarab/issues/id/SCB2753

Modified: trunk/src/java/org/tigris/scarab/om/IssueType.java
Url: http://scarab.tigris.org/source/browse/scarab/trunk/src/java/org/tigris/scarab/om/IssueType.java?view=diff&pathrev=10669&r1=10668&r2=10669
==============================================================================
--- trunk/src/java/org/tigris/scarab/om/IssueType.java	(original)
+++ trunk/src/java/org/tigris/scarab/om/IssueType.java	2009-01-07 17:24:02-0800
@@ -61,6 +61,7 @@
 import org.apache.fulcrum.localization.Localization;
 
 import org.tigris.scarab.services.cache.ScarabCache;
+import org.tigris.scarab.services.security.ScarabSecurity;
 import org.tigris.scarab.tools.localization.L10NKeySet;
 import org.tigris.scarab.om.Module;
 import org.tigris.scarab.om.IssuePeer;
@@ -1088,9 +1089,10 @@
     
     /**
      * Checks whether the current user can create issues of this issueType
-     * in the given module. Currently we only check whether the user is
-     * allowed to create all necessary input (i.e. the required attributes).
-     * If at least one attribute can not be set by the user due to transition
+     * in the given module. Currently we only check whether the user has Issue create permission
+     * and whether the user is allowed to create all necessary input (i.e. the required attributes).
+     * If Either the Issue create permission is not granted, or if
+     * at least one attribute can not be set by the user due to transition
      * constraints, this method returns false, otherwise true.
      * @param user
      * @param module
@@ -1100,24 +1102,29 @@
      */
     public boolean canCreateIssueInScope(ScarabUser user, Module module) throws TorqueException, ScarabException
     {
-        boolean result = true;
-        List requiredAttributes = getRequiredAttributes(module);
-        Iterator iter = requiredAttributes.iterator();
-        while(iter.hasNext())
-        {
-            Attribute attribute = (Attribute)iter.next();
-            Workflow workflow = WorkflowFactory.getInstance();
-            if(attribute.isOptionAttribute())
-            {
-                boolean canDoPartial = workflow.canMakeTransitionsFrom(user, this, attribute, null);
-                if(!canDoPartial)
+        //[HD first check, if user has IssueCreate permission in this module
+        boolean isPermissionGranted = user.hasPermission(ScarabSecurity.ISSUE__ENTER, module);
+        
+        if(isPermissionGranted)
+        {
+            List requiredAttributes = getRequiredAttributes(module);
+            Iterator iter = requiredAttributes.iterator();
+            while(iter.hasNext())
+            {
+                Attribute attribute = (Attribute)iter.next();
+                Workflow workflow = WorkflowFactory.getInstance();
+                if(attribute.isOptionAttribute())
                 {
-                    result = false;
-                    break;
+                    boolean canDoPartial = workflow.canMakeTransitionsFrom(user, this, attribute, null);
+                    if(!canDoPartial)
+                    {
+                        isPermissionGranted = false;
+                        break;
+                    }
                 }
             }
         }
-        return result;
+        return isPermissionGranted;
     }
     
     /**

Modified: trunk/src/webapp/WEB-INF/templates/navigations/CommonLinks.vm
Url: http://scarab.tigris.org/source/browse/scarab/trunk/src/webapp/WEB-INF/templates/navigations/CommonLinks.vm?view=diff&pathrev=10669&r1=10668&r2=10669
==============================================================================
--- trunk/src/webapp/WEB-INF/templates/navigations/CommonLinks.vm	(original)
+++ trunk/src/webapp/WEB-INF/templates/navigations/CommonLinks.vm	2009-01-07 17:24:02-0800
@@ -54,7 +54,7 @@
 ## Show shortcuts to all available issue types (if permission granted)
 ## ====================================================================
 
-#if ( $moduleHasIssueTypes && $module.allowsNewIssues() )
+#if (    $moduleHasIssueTypes && $module.allowsNewIssues() && $user.hasPermission($scarabG.Permission.ISSUE__ENTER,$module) )
 
 ##
 ## The toolgroup-title is a link to the issueTypes section

------------------------------------------------------
http://scarab.tigris.org/ds/viewMessage.do?dsForumId=3577&dsMessageId=1010721
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.