Author: tchemit Date: 2012-06-19 14:22:07 +0200 (Tue, 19 Jun 2012) New Revision: 3524 Url: http://chorem.org/repositories/revision/pollen/3524 Log: - fixes #620: On ne peut pas d?\195?\169pouiller un sondage priv?\195?\169 m?\195?\170me quand on en est le cr?\195?\169ateur (remove all security stuff from Result action and jsp...) - remove obsolete resources directory Removed: trunk/pollen-ui-struts2/src/main/resources/org/chorem/pollen/ui/actions/ Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ResultForPoll.java trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/result.jsp Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ResultForPoll.java =================================================================== --- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ResultForPoll.java 2012-06-19 12:10:43 UTC (rev 3523) +++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ResultForPoll.java 2012-06-19 12:22:07 UTC (rev 3524) @@ -30,7 +30,6 @@ import com.google.common.collect.Multimap; import com.opensymphony.xwork2.inject.Inject; import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.struts2.views.util.UrlHelper; @@ -41,7 +40,6 @@ import org.chorem.pollen.common.ChoiceType; import org.chorem.pollen.common.PollType; import org.chorem.pollen.common.VoteCountingType; -import org.chorem.pollen.services.exceptions.PollNotFoundException; import org.chorem.pollen.services.impl.PollResultsService; import org.chorem.pollen.ui.actions.PageSkin; import org.chorem.pollen.ui.converters.DateConverter; @@ -74,15 +72,6 @@ private Boolean byGroup; /** - * Can user be on this page ? - * <p/> - * TODO-tchemit-2012-06-03 Security is managed by shiro, why doing it here again ? - * - * @since 1.3 - */ - private boolean userAllowed; - - /** * Is user is poll's creator ? * * @since 1.4 @@ -150,14 +139,10 @@ return poll; } - public boolean isUserAllowed() { - return userAllowed; + public boolean isCreatorOrAdmin() { + return creatorUser || isUserAdmin(); } - public boolean isCreatorUser() { - return creatorUser; - } - public boolean isFeedFileExisting() { return feedFileExisting; } @@ -165,7 +150,6 @@ public String getSummaryUrl() { PollUrl url = getPollUrlService().getPollSummaryUrl(poll); url.getPollUri().setAccountId(getAccountId()); - getSecurityService().removeAccountIdWhenConnected(url, getPollenUserAccount()); return url.getUrl(); } @@ -245,34 +229,50 @@ byGroup = isGroupPoll(); } - String accountId = getAccountId(); + creatorUser = getSecurityService().isPollCreator( + poll, + getAccountId(), getPollenUserAccount()); - creatorUser = poll.getCreator().getAccountId().equals(accountId); + if (poll.isRunning(serviceContext.getCurrentTime())) { + addFlashWarning(_("pollen.information.pollRunning")); + } - if (poll.isPublicResults()) { - userAllowed = true; - } else if (StringUtils.isNotEmpty(accountId)) { + // load results - // create is allowed to be ther - userAllowed = creatorUser; + PollResultsService service = getPollResultsService(); -// PollAccount creator = poll.getCreator(); -// if (accountId.equals(creator.getAccountId())) { -// userAllowed = true; -// } + PollResultList resultListDTO = service.getResults(poll); + + results = resultListDTO.getPollResults(); + + if (log.isDebugEnabled()) { + for (PollResult res : results) { + log.debug(res + + ", (voteCounting=" + res.getVoteCountingType() + + ", byGroup=" + res.isByGroup() + ")"); + } } - if (!userAllowed) { - addFlashError(_("pollen.error.userNotAllowed")); + if (isNumberVoteCounting()) { - } else if (poll.isRunning(serviceContext.getCurrentTime())) { - addFlashWarning(_("pollen.information.pollRunning")); - loadResults(); + // resultats des choix cachés + choicesResults = LinkedHashMultimap.create(); - } else { - loadResults(); + // sous-titres des vrais choix (les choix pas cachés) + subtitles = ArrayListMultimap.create(); + + results = service.createNumberVoteCountingResult( + resultListDTO, + choicesResults, + subtitles); } + topRanking = service.getTopRanking(results); + + if (log.isDebugEnabled()) { + log.debug("topRanking = " + topRanking); + } + return SUCCESS; } @@ -328,43 +328,6 @@ this.byGroup = byGroup; } - protected void loadResults() throws PollNotFoundException { - - PollResultsService service = getPollResultsService(); - - PollResultList resultListDTO = service.getResults(poll); - - results = resultListDTO.getPollResults(); - - if (log.isDebugEnabled()) { - for (PollResult res : results) { - log.debug(res - + ", (voteCounting=" + res.getVoteCountingType() - + ", byGroup=" + res.isByGroup() + ")"); - } - } - - if (isNumberVoteCounting()) { - - // resultats des choix cachés - choicesResults = LinkedHashMultimap.create(); - - // sous-titres des vrais choix (les choix pas cachés) - subtitles = ArrayListMultimap.create(); - - results = service.createNumberVoteCountingResult( - resultListDTO, - choicesResults, - subtitles); - } - - topRanking = service.getTopRanking(results); - - if (log.isInfoEnabled()) { - log.info("topRanking = " + topRanking); - } - } - /** @return Récupération de la liste des résultats pour le diagramme. */ public List<String> getChoices() { @@ -398,7 +361,6 @@ params.put("title", ""); params.put("values", getChoices()); - urlHelper.buildParametersString(params, url, "&"); String chartUrl = url.toString(); Modified: trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/result.jsp =================================================================== --- trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/result.jsp 2012-06-19 12:10:43 UTC (rev 3523) +++ trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/result.jsp 2012-06-19 12:22:07 UTC (rev 3524) @@ -67,158 +67,155 @@ }); </script> -<s:if test="userAllowed"> +<h1 class="titleVoteCounting"><s:property value="poll.title"/></h1> - <h1 class="titleVoteCounting"><s:property value="poll.title"/></h1> - - <!-- Informations sur le sondage --> - <div id="resultTop"> - <div style="white-space:pre-wrap; text-align: start;"> - <s:property value="poll.description"/> - </div> - <fieldset> - <legend><s:text name="pollen.common.aboutPoll"/></legend> - <div style="float: right"> - <s:if test="creatorUser or userAdmin"> - <s:a href="%{summaryUrl}"> - <img src="<s:url value='/img/editSmall.png'/>" - title="<s:text name='pollen.action.summaryPoll'/>" - alt="<s:text name='pollen.action.summaryPoll'/>"/> - </s:a> - </s:if> - <s:a href='%{voteUrl}'> - <img src="<s:url value='/img/vote.png'/>" - title="<s:text name="pollen.common.vote.return-help"/>" - alt="<s:text name="pollen.common.vote.return"/>"/> - </s:a> - <s:if test="feedFileExisting"> - <s:a namespace="/poll" action="getFeed"> - <s:param name="pollId" value="poll.pollId"/> - <img src="<s:url value='/img/feed.png'/>" title="Atom" alt="Atom"/> - </s:a> - </s:if> - </div> - <s:label value="%{poll.creator.votingId}" - key='pollen.common.pollCreator'/> - <s:label value="%{poll.beginDate}" key='pollen.common.beginDate'/> - <s:label value="%{poll.endDate}" - label='%{getText("pollen.common.endDate")}'/> - <s:label value="%{poll.voteCountingType}" - label='%{getText("pollen.common.voteCountingType")}' - tooltip="%{getVoteCountingTypeHelp(poll.voteCountingType)}" - tooltipIconPath="/img/tooltip.png"/> - </fieldset> +<!-- Informations sur le sondage --> +<div id="resultTop"> + <div style="white-space:pre-wrap; text-align: start;"> + <s:property value="poll.description"/> </div> + <fieldset> + <legend><s:text name="pollen.common.aboutPoll"/></legend> + <div style="float: right"> + <s:if test="creatorOrAdmin"> + <s:a href="%{summaryUrl}"> + <img src="<s:url value='/img/editSmall.png'/>" + title="<s:text name='pollen.action.summaryPoll'/>" + alt="<s:text name='pollen.action.summaryPoll'/>"/> + </s:a> + </s:if> + <s:a href='%{voteUrl}'> + <img src="<s:url value='/img/vote.png'/>" + title="<s:text name="pollen.common.vote.return-help"/>" + alt="<s:text name="pollen.common.vote.return"/>"/> + </s:a> + <s:if test="feedFileExisting"> + <s:a namespace="/poll" action="getFeed"> + <s:param name="pollId" value="poll.pollId"/> + <img src="<s:url value='/img/feed.png'/>" title="Atom" alt="Atom"/> + </s:a> + </s:if> + </div> + <s:label value="%{poll.creator.votingId}" + key='pollen.common.pollCreator'/> + <s:label value="%{poll.beginDate}" key='pollen.common.beginDate'/> + <s:label value="%{poll.endDate}" + label='%{getText("pollen.common.endDate")}'/> + <s:label value="%{poll.voteCountingType}" + label='%{getText("pollen.common.voteCountingType")}' + tooltip="%{getVoteCountingTypeHelp(poll.voteCountingType)}" + tooltipIconPath="/img/tooltip.png"/> + </fieldset> +</div> - <!-- Victoire --> - <s:if test="victoryMessage != ''"> - <h4><s:property value="victoryMessage"/> +<!-- Victoire --> +<s:if test="victoryMessage != ''"> + <h4><s:property value="victoryMessage"/> + <br/> + <s:iterator value="topRanking" var="result"> + <s:if test="textType"> + <s:property value="name"/> + </s:if> + <s:elseif test="dateType"> + <s:property value="%{getResultAsDate(#result)}"/> + </s:elseif> + <s:elseif test="imageType"> + <s:url id="imageUrl" namespace="/io" action="getPollChoiceImage" + escapeAmp="false"> + <s:param name="choiceId" value="name"/> + <s:param name="pollId" value="poll.pollId"/> + <s:param name="thumb" value="false"/> + </s:url> + <s:url id="imageUrlThumb" namespace="/io" action="getPollChoiceImage" + escapeAmp="false"> + <s:param name="choiceId" value="name"/> + <s:param name="pollId" value="poll.pollId"/> + <s:param name="thumb" value="true"/> + </s:url> + <a href="<s:property value='imageUrl'/>" rel="lightbox"> + <img alt="<s:property value='name'/>" + title="<s:property value='name'/>" + src="<s:property value='imageUrlThumb'/>"> + </a> + + </s:elseif> <br/> - <s:iterator value="topRanking" var="result"> - <s:if test="textType"> - <s:property value="name"/> - </s:if> - <s:elseif test="dateType"> - <s:property value="%{getResultAsDate(#result)}"/> - </s:elseif> - <s:elseif test="imageType"> - <s:url id="imageUrl" namespace="/io" action="getPollChoiceImage" - escapeAmp="false"> - <s:param name="choiceId" value="name"/> - <s:param name="pollId" value="poll.pollId"/> - <s:param name="thumb" value="false"/> - </s:url> - <s:url id="imageUrlThumb" namespace="/io" action="getPollChoiceImage" - escapeAmp="false"> - <s:param name="choiceId" value="name"/> - <s:param name="pollId" value="poll.pollId"/> - <s:param name="thumb" value="true"/> - </s:url> - <a href="<s:property value='imageUrl'/>" rel="lightbox"> - <img alt="<s:property value='name'/>" - title="<s:property value='name'/>" - src="<s:property value='imageUrlThumb'/>"> - </a> + </s:iterator> + </h4> +</s:if> - </s:elseif> - <br/> - </s:iterator> - </h4> - </s:if> +<!-- Diagramme --> +<div id="resultChart"> + <div class="chartTypeDiv"> + <sj:a id='displayChart1' href="#" onclick="return displayCharts(1);"> + <img src="<s:url value='/img/rep1.png'/>" + title='<s:text name="pollen.common.chartType-pie"/>' alt="1"/> + </sj:a> + <sj:a id='displayChart2' href="#" onclick="return displayCharts(2);"> + <img src="<s:url value='/img/rep2.png'/>" + title='<s:text name="pollen.common.chartType-pie3d"/>' alt="2"/> + </sj:a> + <sj:a id='displayChart3' href="#" onclick="return displayCharts(3);"> + <img src="<s:url value='/img/rep3.png'/>" + title='<s:text name="pollen.common.chartType-ring"/>' alt="3"/> + </sj:a> + </div> - <!-- Diagramme --> - <div id="resultChart"> - <div class="chartTypeDiv"> - <sj:a id='displayChart1' href="#" onclick="return displayCharts(1);"> - <img src="<s:url value='/img/rep1.png'/>" - title='<s:text name="pollen.common.chartType-pie"/>' alt="1"/> - </sj:a> - <sj:a id='displayChart2' href="#" onclick="return displayCharts(2);"> - <img src="<s:url value='/img/rep2.png'/>" - title='<s:text name="pollen.common.chartType-pie3d"/>' alt="2"/> - </sj:a> - <sj:a id='displayChart3' href="#" onclick="return displayCharts(3);"> - <img src="<s:url value='/img/rep3.png'/>" - title='<s:text name="pollen.common.chartType-ring"/>' alt="3"/> - </sj:a> - </div> - - <div class="displayTypeDiv"> - <s:if test="groupPoll"> - <s:text name="pollen.common.results"/> - <s:if test="byGroup"> - <s:a namespace="/poll" action="results/%{poll.pollId}"> - <s:param name="byGroup" value="false"/> - <s:text name="pollen.common.normal"/> - </s:a> - - <s:text name="pollen.common.group"/> - </s:if> - <s:else> - <s:text name="pollen.common.normal"/> - - <s:a namespace="/poll" action="results/%{poll.pollId}"> - <s:text name="pollen.common.group"/> - </s:a> - </s:else> + <div class="displayTypeDiv"> + <s:if test="groupPoll"> + <s:text name="pollen.common.results"/> + <s:if test="byGroup"> + <s:a namespace="/poll" action="results/%{poll.pollId}"> + <s:param name="byGroup" value="false"/> + <s:text name="pollen.common.normal"/> + </s:a> + - <s:text name="pollen.common.group"/> </s:if> - </div> + <s:else> + <s:text name="pollen.common.normal"/> - + <s:a namespace="/poll" action="results/%{poll.pollId}"> + <s:text name="pollen.common.group"/> + </s:a> + </s:else> + </s:if> + </div> - <sj:div id='chartContainer'> - <img id='chart_normal'/> - </sj:div> + <sj:div id='chartContainer'> + <img id='chart_normal'/> + </sj:div> - <!-- Diagramme par choix --> - <s:if test="choicesResults != null"> - <div id="resultChart"> - <div> - <s:iterator value="choicesResultNames" var="choicesResultName" - status="status"> - <img id='chart_<s:property value="#status.index"/>' - alt="<s:property/>" - title="<s:property/>" - src="<s:property value='%{getChoicesResultCharUrl(400,300, #choicesResultName)}'/>"> - </s:iterator> - </div> + <!-- Diagramme par choix --> + <s:if test="choicesResults != null"> + <div id="resultChart"> + <div> + <s:iterator value="choicesResultNames" var="choicesResultName" + status="status"> + <img id='chart_<s:property value="#status.index"/>' + alt="<s:property/>" + title="<s:property/>" + src="<s:property value='%{getChoicesResultCharUrl(400,300, #choicesResultName)}'/>"> + </s:iterator> </div> - </s:if> - </div> - <!-- Classement --> - <%--<t:remove>--%> - <%--<div id="resultList">--%> - <%--<ol>--%> - <%--<s:iterator value="ranking" var="result">--%> - <%--<li>--%> - <%--<s:if test="dateType">--%> - <%--<s:property value="%{getResultNameAsDate(#result.name)}"/>--%> - <%--<%–<t:output value="resultNameAsDate" format="dateFormat"/>–%>--%> - <%--</s:if>--%> - <%--<s:else>--%> - <%--<s:property value="name"/>--%> - <%--</s:else>--%> - <%--(<s:property value="%{getTrimValue(#result)}"/>)--%> - <%--</li>--%> - <%--</s:iterator>--%> - <%--</ol>--%> - <%--</div>--%> - <%--</t:remove>--%> + </div> + </s:if> +</div> +<!-- Classement --> +<%--<t:remove>--%> +<%--<div id="resultList">--%> +<%--<ol>--%> +<%--<s:iterator value="ranking" var="result">--%> +<%--<li>--%> +<%--<s:if test="dateType">--%> +<%--<s:property value="%{getResultNameAsDate(#result.name)}"/>--%> +<%--<%–<t:output value="resultNameAsDate" format="dateFormat"/>–%>--%> +<%--</s:if>--%> +<%--<s:else>--%> +<%--<s:property value="name"/>--%> +<%--</s:else>--%> +<%--(<s:property value="%{getTrimValue(#result)}"/>)--%> +<%--</li>--%> +<%--</s:iterator>--%> +<%--</ol>--%> +<%--</div>--%> +<%--</t:remove>--%> -</s:if>
participants (1)
-
tchemit@users.chorem.org