Skip to content

Commit

Permalink
Use jobauthorizations if available, otherwise evaluate auth values on…
Browse files Browse the repository at this point in the history
… demand
  • Loading branch information
gschueler committed Nov 19, 2010
1 parent 477ee6a commit 9992ef2
Showing 1 changed file with 26 additions and 16 deletions.
42 changes: 26 additions & 16 deletions rundeckapp/grails-app/views/scheduledExecution/_actionButtons.gsp
Expand Up @@ -16,39 +16,48 @@
--%>
<%--
_actionButtons.gsp
Author: Greg Schueler <a href="mailto:greg@dtosolutions.com">greg@dtosolutions.com</a>
Created: Jun 1, 2010 3:42:29 PM
$Id$
--%>
<g:timerStart key="actionButtonsNew"/>
<g:set var="ukey" value="${g.rkey()}"/>
<g:set var="jobAuthorized" value="${ !authMap || authMap[scheduledExecution.id.toString()] || jobAuthorized}"/>
<g:set var="jobRunAuth" value="${ auth.allowedTest(job:scheduledExecution, action:UserAuth.WF_RUN)}"/>
<g:set var="canRun" value="${ jobRunAuth }"/>
<g:set var="idKey" value="${scheduledExecution.id.toString()}"/>
<g:if test="${!jobauthorizations}">
<%-- evaluate auth for the job on demand --%>
<g:set var="jobauthorizations" value="${[:]}"/>
<%
[UserAuth.WF_DELETE,UserAuth.WF_RUN,UserAuth.WF_CREATE,UserAuth.WF_READ,UserAuth.WF_UPDATE].each{action->
jobauthorizations[action]=auth.allowedTest(job:scheduledExecution,action:action)?[idKey]:[]
}
%>
</g:if>
<g:set var="jobAuths" value="${ jobauthorizations }"/>
<div class="buttons">
<span class="group floatr" id="${ukey}jobDisplayButtons${scheduledExecution.id}">
<g:if test="${!small}">
<g:if test="${!small }">
<g:if test="${!execPage}">
<auth:allowed job="${scheduledExecution}" action="${UserAuth.WF_DELETE}">
<g:if test="${jobAuths[UserAuth.WF_DELETE].contains(idKey) }">
<span class="icon button floatl" title="Delete ${g.message(code:'domain.ScheduledExecution.title')}" onclick="menus.showRelativeTo(this,'${ukey}jobDisplayDeleteConf${scheduledExecution.id}',-2,-2);return false;"><img src="${resource(dir:'images',file:'icon-small-removex.png')}" alt="delete" width="16px" height="16px"/></span>
</auth:allowed>
</g:if>
<auth:allowed job="${scheduledExecution}" action="${UserAuth.WF_CREATE}">
</g:if>
<g:if test="${jobAuths[UserAuth.WF_CREATE].contains(idKey) }">
<g:link controller="scheduledExecution" title="Copy Job" action="copy" id="${scheduledExecution.id}" class="icon button floatl"><img src="${resource(dir:'images',file:'icon-small-copy.png')}" alt="copy" width="16px" height="16px"/></g:link>
</auth:allowed>
</g:if>
<g:if test="${!execPage}">
<auth:allowed job="${scheduledExecution}" name="${UserAuth.WF_UPDATE}">
<g:if test="${jobAuths[UserAuth.WF_UPDATE].contains(idKey) }">
<g:link controller="scheduledExecution" title="Edit Job" action="edit" id="${scheduledExecution.id}" class="icon button floatl"><img src="${resource(dir:'images',file:'icon-small-edit.png')}" alt="edit" width="16px" height="16px"/></g:link>
</auth:allowed>
</g:if>
<auth:allowed job="${scheduledExecution}" name="${UserAuth.WF_READ}">
</g:if>
<g:if test="${jobAuths[UserAuth.WF_READ].contains(idKey) }">
<g:link controller="scheduledExecution" title="Download XML" action="show" id="${scheduledExecution.id}.xml" class="icon button floatl"><img src="${resource(dir:'images',file:'icon-small-file-xml.png')}" alt="Download XML" width="13px" height="16px"/></g:link>
</auth:allowed>
</g:if>
</g:if>
<g:if test="${canRun}">
<g:if test="${jobAuthorized || jobAuths[UserAuth.WF_RUN].contains(idKey) }">
<g:link controller="scheduledExecution" action="execute" id="${scheduledExecution.id}" class="icon button floatl" onclick="loadExec(${scheduledExecution.id});return false;"><img src="${resource(dir:'images',file:'icon-small-run.png')}" title="Run ${g.message(code:'domain.ScheduledExecution.title')}&hellip;" alt="run" width="16px" height="16px"/></g:link>
</g:if>
<g:elseif test="${ !jobAuthorized || !jobRunAuth}">
<g:elseif test="${ !jobAuthorized }">
<span class="info note floatl" style="width:16px;padding: 2px;" title="${message(code:'unauthorized.job.run')}"><img src="${resource(dir:'images',file:'icon-small-warn.png')}" alt="" width="16px" height="16px"/></span>
</g:elseif>
<g:else>
Expand All @@ -63,4 +72,5 @@
</g:form>
</div>
<span class="clear"></span>
</div>
</div>
<g:timerEnd key="actionButtonsNew"/>

0 comments on commit 9992ef2

Please sign in to comment.