Customising interface based on user's role

JIRA Documentation

Index

Sometimes it is useful to remove certain elements from JIRA's user interface if the user does not belong to a certain group. Most of the time this can be achieved by editing certain JSP / Velocity files. The JSP files are easy to edit as they are text files, and one does not need access to JIRA's source code.

For JIRA 3.5+

In velocity, you can hide certain elements from the UI by surrounding the relevant code with:

#if ($authcontext.user.inGroup('jira-administrators'))
...
#end

So to hide the security level you need to edit the file WEB-INF\classes\templates\jira\issue\field\comment-edit.vm and end up with something like this.

#if ($authcontext.user.inGroup('jira-administrators'))
    #if ($commentLevels && !$commentLevels.isEmpty())
        #controlHeader ($action 'commentLevel' $i18n.getText('comment.viewable') false $displayParameters.get('noHeader'))
        ...
        #controlFooter ($action '' $displayParameters.get('noHeader'))
    #end
#end

You need to update both places in the file and then restart JIRA.

For versions prior to 3.5

To hide certain elements from the UI one has to surround the relevant code with:

<webwork:if test="/remoteUser/inGroup('jira-administrators') == true">
...
</webwork:if>

If you would like to allow only members of the jira-administrators group to be able to set a level for a comment (restrict comment's visibility), just surround the code that creates the ' Viewable By:' drop down box.

So that the code looks something like:

<webwork:if test="/remoteUser/inGroup('jira-administrators') == true">
    <webwork:if test="commentLevels/size > 0">
        <ui:select label="text('comment.add.viewableby.label')" name="'commentLevel'" list="commentLevels"
               listKey="'.'" listValue="'.'">
            <ui:param name="'headerrow'" value="text('comment.constants.allusers')" />
            <ui:param name="'headervalue'" value="''" />
        </ui:select>
    </webwork:if>
</webwork:if>

You will need to do this in the following files that are located under the JIRA web application:

  • secure/views/issue/addcomment.jsp
  • includes/panels/updateissue_comment.jsp
  • secure/views/issue/viewissue.jsp

If you make changes such as this, you will need to remember to port them to a new version of JIRA when you upgrade

Labels

 
(None)
  1. Feb 03, 2006

    Sven Breidenstein says:

    Hi there, I think this needs to be updated for Jira 3.5, the jsp mentioned here ...

    Hi there,
    I think this needs to be updated for Jira 3.5, the jsp mentioned here have changed.
    Any help is welcome ...

    Regards
    Sven 

  2. Oct 28, 2006

    Neal Applebaum says:

    For anyone attempting this... remember that if the user is also getting notifica...

    For anyone attempting this... remember that if the user is also getting notifications, you would have to modify the email template(s) to hide the fields as well. Not sure if it can be done based on group as is the .jsp, or if it would have to be done per project or globally.