Pollen-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
June 2012
- 5 participants
- 163 discussions
r3510 - trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll
by tchemit@users.chorem.org 18 Jun '12
by tchemit@users.chorem.org 18 Jun '12
18 Jun '12
Author: tchemit
Date: 2012-06-18 12:34:48 +0200 (Mon, 18 Jun 2012)
New Revision: 3510
Url: http://chorem.org/repositories/revision/pollen/3510
Log:
remove double test
Modified:
trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp
Modified: trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp
===================================================================
--- trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp 2012-06-18 10:01:58 UTC (rev 3509)
+++ trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp 2012-06-18 10:34:48 UTC (rev 3510)
@@ -335,25 +335,23 @@
?
</s:else>
</s:if>
- <s:if test="!poll.anonymous">
- <s:if test="isModifyVoteAllowed(#vote)">
- <s:a action="editVote" namespace="/poll">
- <s:param name="pollId" value="%{pollId}"/>
- <s:param name="accountId" value="%{#vote.pollAccount.accountId}"/>
- <img src="<s:url value="/img/editSmall.png"/>"
- title="<s:text name="pollen.action.editVote"/>"
- alt="<s:text name="pollen.action.editVote"/>"/>
- </s:a>
- </s:if>
- <s:if test="isDeleteVoteAllowed(#vote)">
- <s:a action="deleteVote" namespace="/poll" href="#"
- onclick="return openDeleteVoteDialog('%{#vote.topiaId}');">
- <img src="<s:url value="/img/delete.png"/>"
- title="<s:text name="pollen.action.deleteVote"/>"
- alt="<s:text name="pollen.action.deleteVote"/>"/>
- </s:a>
- </s:if>
+ <s:if test="isModifyVoteAllowed(#vote)">
+ <s:a action="editVote" namespace="/poll">
+ <s:param name="pollId" value="%{pollId}"/>
+ <s:param name="accountId" value="%{#vote.pollAccount.accountId}"/>
+ <img src="<s:url value="/img/editSmall.png"/>"
+ title="<s:text name="pollen.action.editVote"/>"
+ alt="<s:text name="pollen.action.editVote"/>"/>
+ </s:a>
</s:if>
+ <s:if test="isDeleteVoteAllowed(#vote)">
+ <s:a action="deleteVote" namespace="/poll" href="#"
+ onclick="return openDeleteVoteDialog('%{#vote.topiaId}');">
+ <img src="<s:url value="/img/delete.png"/>"
+ title="<s:text name="pollen.action.deleteVote"/>"
+ alt="<s:text name="pollen.action.deleteVote"/>"/>
+ </s:a>
+ </s:if>
</td>
<s:iterator value="poll.choice" var="choice">
<s:if test="!isChoiceHidden(#choice)">
1
0
r3509 - in trunk: pollen-services/src/main/java/org/chorem/pollen/services/impl pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll
by tchemit@users.chorem.org 18 Jun '12
by tchemit@users.chorem.org 18 Jun '12
18 Jun '12
Author: tchemit
Date: 2012-06-18 12:01:58 +0200 (Mon, 18 Jun 2012)
New Revision: 3509
Url: http://chorem.org/repositories/revision/pollen/3509
Log:
fix security stuffs
Modified:
trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/SecurityService.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteVote.java
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/SecurityService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/SecurityService.java 2012-06-18 09:45:51 UTC (rev 3508)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/SecurityService.java 2012-06-18 10:01:58 UTC (rev 3509)
@@ -24,7 +24,6 @@
import com.google.common.base.Preconditions;
import com.google.common.collect.Sets;
-import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.chorem.pollen.PollenTechnicalException;
import org.chorem.pollen.bean.PollUri;
@@ -59,9 +58,11 @@
boolean result = creator.getAccountId().equals(uriId.getAccountId());
if (!result) {
- // try to match userAccount
- result = ObjectUtils.equals(pollenUserAccount,
- creator.getUserAccount());
+ if (pollenUserAccount != null) {
+
+ // try to match userAccount
+ result = pollenUserAccount.equals(creator.getUserAccount());
+ }
}
return result;
}
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteVote.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteVote.java 2012-06-18 09:45:51 UTC (rev 3508)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/DeleteVote.java 2012-06-18 10:01:58 UTC (rev 3509)
@@ -24,6 +24,7 @@
import com.google.common.base.Preconditions;
import org.chorem.pollen.business.persistence.Poll;
+import org.chorem.pollen.common.PollType;
/**
* To delete a poll vote.
@@ -68,6 +69,14 @@
getVoteService().deleteVote(poll, voteId, reason);
addFlashMessage(_("pollen.information.vote.deleted"));
+
+ if (poll.getPollType() == PollType.FREE &&
+ getUriId().isAccountIdNotBlank() &&
+ !poll.getCreator().getAccountId().equals(getAccountId())) {
+
+ // remove accountId from url, voter does no longer exists.
+ getUriId().setAccountId(null);
+ }
return SUCCESS;
}
}
1
0
r3508 - in trunk/pollen-ui-struts2/src/main/webapp: WEB-INF/jsp/poll css img js
by tchemit@users.chorem.org 18 Jun '12
by tchemit@users.chorem.org 18 Jun '12
18 Jun '12
Author: tchemit
Date: 2012-06-18 11:45:51 +0200 (Mon, 18 Jun 2012)
New Revision: 3508
Url: http://chorem.org/repositories/revision/pollen/3508
Log:
fixes #614: We cannot see images in real size anymore
Added:
trunk/pollen-ui-struts2/src/main/webapp/css/jquery.lightbox-0.5.css
trunk/pollen-ui-struts2/src/main/webapp/img/lightbox-blank.gif
trunk/pollen-ui-struts2/src/main/webapp/img/lightbox-btn-close.gif
trunk/pollen-ui-struts2/src/main/webapp/img/lightbox-btn-next.gif
trunk/pollen-ui-struts2/src/main/webapp/img/lightbox-btn-prev.gif
trunk/pollen-ui-struts2/src/main/webapp/img/lightbox-ico-loading.gif
trunk/pollen-ui-struts2/src/main/webapp/js/jquery.lightbox-0.5.js
trunk/pollen-ui-struts2/src/main/webapp/js/jquery.lightbox-0.5.min.js
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/vote.jsp
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-18 09:45:47 UTC (rev 3507)
+++ trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/result.jsp 2012-06-18 09:45:51 UTC (rev 3508)
@@ -25,7 +25,13 @@
<%@ taglib prefix="sj" uri="/struts-jquery-tags" %>
<link rel="stylesheet" type="text/css"
href="<s:url value='/css/results.css'/>"/>
+<link rel="stylesheet" type="text/css"
+ href="<s:url value='/css/jquery.lightbox-0.5.css'/>"/>
+
+<script type="text/javascript"
+ src="<s:url value='/js/jquery.lightbox-0.5.js' />"></script>
+
<script type="text/javascript">
function displayCharts(type) {
@@ -49,10 +55,18 @@
// register all chart url (without the type in it)
displayCharts(1);
- });
+ $('a[rel*="lightbox"]').lightBox(
+ {
+ imageLoading:'<s:url value="/img/lightbox-ico-loading.gif"/>',
+ imageBtnClose:'<s:url value="/img/lightbox-btn-close.gif"/>',
+ imageBtnPrev:'<s:url value="/img/lightbox-btn-prev.gif"/>',
+ imageBtnNext:'<s:url value="/img/lightbox-btn-next.gif"/>'
+ });
+ });
</script>
+
<s:if test="userAllowed">
<h1 class="titleVoteCounting"><s:property value="poll.title"/></h1>
@@ -106,11 +120,19 @@
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>
- <img alt="<s:property value='name'/>"
- title="<s:property value='name'/>"
- src="<s:property value='imageUrl'/>">
+ <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/>
@@ -162,8 +184,10 @@
<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/>"
+ <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>
Modified: trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp
===================================================================
--- trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp 2012-06-18 09:45:47 UTC (rev 3507)
+++ trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp 2012-06-18 09:45:51 UTC (rev 3508)
@@ -28,9 +28,13 @@
<link rel="stylesheet" type="text/css"
href="<s:url value='/css/vote.css'/>"/>
+<link rel="stylesheet" type="text/css"
+ href="<s:url value='/css/jquery.lightbox-0.5.css'/>"/>
<script type="text/javascript"
src="<s:url value='/js/gridHelper.js' />"></script>
+<script type="text/javascript"
+ src="<s:url value='/js/jquery.lightbox-0.5.js' />"></script>
<s:set id='deleteCommentTitle'>
<s:text name="pollen.title.delete.pollComment"/>
@@ -97,6 +101,13 @@
$votingIdField.attr('disabled', $(this).prop('checked'));
});
+ $('a[rel*="lightbox"]').lightBox(
+ {
+ imageLoading:'<s:url value="/img/lightbox-ico-loading.gif"/>',
+ imageBtnClose:'<s:url value="/img/lightbox-btn-close.gif"/>',
+ imageBtnPrev:'<s:url value="/img/lightbox-btn-prev.gif"/>',
+ imageBtnNext:'<s:url value="/img/lightbox-btn-next.gif"/>'
+ });
});
</script>
@@ -232,26 +243,36 @@
<s:if test="imageType">
<s:iterator value="poll.choice" var="choice">
<s:if test="!isChoiceHidden(#choice)">
+
<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>
<s:if test="!isDescNull(#choice)">
<th class="desc">
-
- <img alt="<s:property value='name'/>"
- title='<s:property value="escapeLineBreak(#choice.description)"/>'
- src="<s:property value='imageUrl'/>">
+ <a href="<s:property value='imageUrl'/>" rel="lightbox">
+ <img alt="<s:property value='name'/>"
+ title='<s:property value="escapeLineBreak(#choice.description)"/>'
+ src="<s:property value='imageUrlThumb'/>">
+ </a>
</th>
</s:if>
<s:else>
<th>
- <img alt="<s:property value='name'/>"
- title='<s:property value="escapeLineBreak(#choice.description)"/>'
- src="<s:property value='imageUrl'/>">
+ <a href="<s:property value='imageUrl'/>" rel="lightbox">
+ <img alt="<s:property value='name'/>"
+ title='<s:property value="escapeLineBreak(#choice.description)"/>'
+ src="<s:property value='imageUrlThumb'/>">
+ </a>
</th>
</s:else>
</s:if>
Added: trunk/pollen-ui-struts2/src/main/webapp/css/jquery.lightbox-0.5.css
===================================================================
--- trunk/pollen-ui-struts2/src/main/webapp/css/jquery.lightbox-0.5.css (rev 0)
+++ trunk/pollen-ui-struts2/src/main/webapp/css/jquery.lightbox-0.5.css 2012-06-18 09:45:51 UTC (rev 3508)
@@ -0,0 +1,102 @@
+/**
+ * %%Ignore-License
+ * jQuery lightBox plugin
+ * This jQuery plugin was inspired and based on Lightbox 2 by Lokesh Dhakar (http://www.huddletogether.com/projects/lightbox2/)
+ * and adapted to me for use like a plugin from jQuery.
+ * @name jquery-lightbox-0.5.css
+ * @author Leandro Vieira Pinho - http://leandrovieira.com
+ * @version 0.5
+ * @date April 11, 2008
+ * @category jQuery plugin
+ * @copyright (c) 2008 Leandro Vieira Pinho (leandrovieira.com)
+ * @license CCAttribution-ShareAlike 2.5 Brazil - http://creativecommons.org/licenses/by-sa/2.5/br/deed.en_US
+ * @example Visit http://leandrovieira.com/projects/jquery/lightbox/ for more informations about this jQuery plugin
+ */
+#jquery-overlay {
+ position: absolute;
+ top: 0;
+ left: 0;
+ z-index: 90;
+ width: 100%;
+ height: 500px;
+}
+#jquery-lightbox {
+ position: absolute;
+ top: 0;
+ left: 0;
+ width: 100%;
+ z-index: 100;
+ text-align: center;
+ line-height: 0;
+}
+#jquery-lightbox a img { border: none; }
+#lightbox-container-image-box {
+ position: relative;
+ background-color: #fff;
+ width: 250px;
+ height: 250px;
+ margin: 0 auto;
+}
+#lightbox-container-image { padding: 10px; }
+#lightbox-loading {
+ position: absolute;
+ top: 40%;
+ left: 0%;
+ height: 25%;
+ width: 100%;
+ text-align: center;
+ line-height: 0;
+}
+#lightbox-nav {
+ position: absolute;
+ top: 0;
+ left: 0;
+ height: 100%;
+ width: 100%;
+ z-index: 10;
+}
+#lightbox-container-image-box > #lightbox-nav { left: 0; }
+#lightbox-nav a { outline: none;}
+#lightbox-nav-btnPrev, #lightbox-nav-btnNext {
+ width: 49%;
+ height: 100%;
+ zoom: 1;
+ display: block;
+}
+#lightbox-nav-btnPrev {
+ left: 0;
+ float: left;
+}
+#lightbox-nav-btnNext {
+ right: 0;
+ float: right;
+}
+#lightbox-container-image-data-box {
+ font: 10px Verdana, Helvetica, sans-serif;
+ background-color: #fff;
+ margin: 0 auto;
+ line-height: 1.4em;
+ overflow: auto;
+ width: 100%;
+ padding: 0 10px 0;
+}
+#lightbox-container-image-data {
+ padding: 0 10px;
+ color: #666;
+}
+#lightbox-container-image-data #lightbox-image-details {
+ width: 70%;
+ float: left;
+ text-align: left;
+}
+#lightbox-image-details-caption { font-weight: bold; }
+#lightbox-image-details-currentNumber {
+ display: block;
+ clear: left;
+ padding-bottom: 1.0em;
+}
+#lightbox-secNav-btnClose {
+ width: 66px;
+ float: right;
+ padding-bottom: 0.7em;
+}
\ No newline at end of file
Property changes on: trunk/pollen-ui-struts2/src/main/webapp/css/jquery.lightbox-0.5.css
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/pollen-ui-struts2/src/main/webapp/img/lightbox-blank.gif
===================================================================
(Binary files differ)
Property changes on: trunk/pollen-ui-struts2/src/main/webapp/img/lightbox-blank.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/pollen-ui-struts2/src/main/webapp/img/lightbox-btn-close.gif
===================================================================
(Binary files differ)
Property changes on: trunk/pollen-ui-struts2/src/main/webapp/img/lightbox-btn-close.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/pollen-ui-struts2/src/main/webapp/img/lightbox-btn-next.gif
===================================================================
(Binary files differ)
Property changes on: trunk/pollen-ui-struts2/src/main/webapp/img/lightbox-btn-next.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/pollen-ui-struts2/src/main/webapp/img/lightbox-btn-prev.gif
===================================================================
(Binary files differ)
Property changes on: trunk/pollen-ui-struts2/src/main/webapp/img/lightbox-btn-prev.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/pollen-ui-struts2/src/main/webapp/img/lightbox-ico-loading.gif
===================================================================
(Binary files differ)
Property changes on: trunk/pollen-ui-struts2/src/main/webapp/img/lightbox-ico-loading.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/pollen-ui-struts2/src/main/webapp/js/jquery.lightbox-0.5.js
===================================================================
--- trunk/pollen-ui-struts2/src/main/webapp/js/jquery.lightbox-0.5.js (rev 0)
+++ trunk/pollen-ui-struts2/src/main/webapp/js/jquery.lightbox-0.5.js 2012-06-18 09:45:51 UTC (rev 3508)
@@ -0,0 +1,474 @@
+/**
+ * %%Ignore-License
+ *
+ * jQuery lightBox plugin
+ * This jQuery plugin was inspired and based on Lightbox 2 by Lokesh Dhakar (http://www.huddletogether.com/projects/lightbox2/)
+ * and adapted to me for use like a plugin from jQuery.
+ * @name jquery-lightbox-0.5.js
+ * @author Leandro Vieira Pinho - http://leandrovieira.com
+ * @version 0.5
+ * @date April 11, 2008
+ * @category jQuery plugin
+ * @copyright (c) 2008 Leandro Vieira Pinho (leandrovieira.com)
+ * @license CCAttribution-ShareAlike 2.5 Brazil - http://creativecommons.org/licenses/by-sa/2.5/br/deed.en_US
+ * @example Visit http://leandrovieira.com/projects/jquery/lightbox/ for more informations about this jQuery plugin
+ */
+
+// Offering a Custom Alias suport - More info: http://docs.jquery.com/Plugins/Authoring#Custom_Alias
+(function($) {
+ /**
+ * $ is an alias to jQuery object
+ *
+ */
+ $.fn.lightBox = function(settings) {
+ // Settings to configure the jQuery lightBox plugin how you like
+ settings = jQuery.extend({
+ // Configuration related to overlay
+ overlayBgColor: '#000', // (string) Background color to overlay; inform a hexadecimal value like: #RRGGBB. Where RR, GG, and BB are the hexadecimal values for the red, green, and blue values of the color.
+ overlayOpacity: 0.8, // (integer) Opacity value to overlay; inform: 0.X. Where X are number from 0 to 9
+ // Configuration related to navigation
+ fixedNavigation: false, // (boolean) Boolean that informs if the navigation (next and prev button) will be fixed or not in the interface.
+ // Configuration related to images
+ imageLoading: '../images/lightbox-ico-loading.gif', // (string) Path and the name of the loading icon
+ imageBtnPrev: '../images/lightbox-btn-prev.gif', // (string) Path and the name of the prev button image
+ imageBtnNext: '../images/lightbox-btn-next.gif', // (string) Path and the name of the next button image
+ imageBtnClose: '../images/lightbox-btn-close.gif', // (string) Path and the name of the close btn
+ imageBlank: '../images/lightbox-blank.gif', // (string) Path and the name of a blank image (one pixel)
+ // Configuration related to container image box
+ containerBorderSize: 10, // (integer) If you adjust the padding in the CSS for the container, #lightbox-container-image-box, you will need to update this value
+ containerResizeSpeed: 400, // (integer) Specify the resize duration of container image. These number are miliseconds. 400 is default.
+ // Configuration related to texts in caption. For example: Image 2 of 8. You can alter either "Image" and "of" texts.
+ txtImage: 'Image', // (string) Specify text "Image"
+ txtOf: 'of', // (string) Specify text "of"
+ // Configuration related to keyboard navigation
+ keyToClose: 'c', // (string) (c = close) Letter to close the jQuery lightBox interface. Beyond this letter, the letter X and the SCAPE key is used to.
+ keyToPrev: 'p', // (string) (p = previous) Letter to show the previous image
+ keyToNext: 'n', // (string) (n = next) Letter to show the next image.
+ // Don�t alter these variables in any way
+ imageArray: [],
+ activeImage: 0
+ },settings);
+ // Caching the jQuery object with all elements matched
+ var jQueryMatchedObj = this; // This, in this context, refer to jQuery object
+ /**
+ * Initializing the plugin calling the start function
+ *
+ * @return boolean false
+ */
+ function _initialize() {
+ _start(this,jQueryMatchedObj); // This, in this context, refer to object (link) which the user have clicked
+ return false; // Avoid the browser following the link
+ }
+ /**
+ * Start the jQuery lightBox plugin
+ *
+ * @param object objClicked The object (link) whick the user have clicked
+ * @param object jQueryMatchedObj The jQuery object with all elements matched
+ */
+ function _start(objClicked,jQueryMatchedObj) {
+ // Hime some elements to avoid conflict with overlay in IE. These elements appear above the overlay.
+ $('embed, object, select').css({ 'visibility' : 'hidden' });
+ // Call the function to create the markup structure; style some elements; assign events in some elements.
+ _set_interface();
+ // Unset total images in imageArray
+ settings.imageArray.length = 0;
+ // Unset image active information
+ settings.activeImage = 0;
+ // We have an image set? Or just an image? Let�s see it.
+ if ( jQueryMatchedObj.length == 1 ) {
+ settings.imageArray.push(new Array(objClicked.getAttribute('href'),objClicked.getAttribute('title')));
+ } else {
+ // Add an Array (as many as we have), with href and title atributes, inside the Array that storage the images references
+ for ( var i = 0; i < jQueryMatchedObj.length; i++ ) {
+ settings.imageArray.push(new Array(jQueryMatchedObj[i].getAttribute('href'),jQueryMatchedObj[i].getAttribute('title')));
+ }
+ }
+ while ( settings.imageArray[settings.activeImage][0] != objClicked.getAttribute('href') ) {
+ settings.activeImage++;
+ }
+ // Call the function that prepares image exibition
+ _set_image_to_view();
+ }
+ /**
+ * Create the jQuery lightBox plugin interface
+ *
+ * The HTML markup will be like that:
+ <div id="jquery-overlay"></div>
+ <div id="jquery-lightbox">
+ <div id="lightbox-container-image-box">
+ <div id="lightbox-container-image">
+ <img src="../fotos/XX.jpg" id="lightbox-image">
+ <div id="lightbox-nav">
+ <a href="#" id="lightbox-nav-btnPrev"></a>
+ <a href="#" id="lightbox-nav-btnNext"></a>
+ </div>
+ <div id="lightbox-loading">
+ <a href="#" id="lightbox-loading-link">
+ <img src="../images/lightbox-ico-loading.gif">
+ </a>
+ </div>
+ </div>
+ </div>
+ <div id="lightbox-container-image-data-box">
+ <div id="lightbox-container-image-data">
+ <div id="lightbox-image-details">
+ <span id="lightbox-image-details-caption"></span>
+ <span id="lightbox-image-details-currentNumber"></span>
+ </div>
+ <div id="lightbox-secNav">
+ <a href="#" id="lightbox-secNav-btnClose">
+ <img src="../images/lightbox-btn-close.gif">
+ </a>
+ </div>
+ </div>
+ </div>
+ </div>
+ *
+ */
+ function _set_interface() {
+ // Apply the HTML markup into body tag
+ $('body').append('<div id="jquery-overlay"></div><div id="jquery-lightbox"><div id="lightbox-container-image-box"><div id="lightbox-container-image"><img id="lightbox-image"><div style="" id="lightbox-nav"><a href="#" id="lightbox-nav-btnPrev"></a><a href="#" id="lightbox-nav-btnNext"></a></div><div id="lightbox-loading"><a href="#" id="lightbox-loading-link"><img src="' + settings.imageLoading + '"></a></div></div></div><div id="lightbox-container-image-data-box"><div id="lightbox-container-image-data"><div id="lightbox-image-details"><span id="lightbox-image-details-caption"></span><span id="lightbox-image-details-currentNumber"></span></div><div id="lightbox-secNav"><a href="#" id="lightbox-secNav-btnClose"><img src="' + settings.imageBtnClose + '"></a></div></div></div></div>');
+ // Get page sizes
+ var arrPageSizes = ___getPageSize();
+ // Style overlay and show it
+ $('#jquery-overlay').css({
+ backgroundColor: settings.overlayBgColor,
+ opacity: settings.overlayOpacity,
+ width: arrPageSizes[0],
+ height: arrPageSizes[1]
+ }).fadeIn();
+ // Get page scroll
+ var arrPageScroll = ___getPageScroll();
+ // Calculate top and left offset for the jquery-lightbox div object and show it
+ $('#jquery-lightbox').css({
+ top: arrPageScroll[1] + (arrPageSizes[3] / 10),
+ left: arrPageScroll[0]
+ }).show();
+ // Assigning click events in elements to close overlay
+ $('#jquery-overlay,#jquery-lightbox').click(function() {
+ _finish();
+ });
+ // Assign the _finish function to lightbox-loading-link and lightbox-secNav-btnClose objects
+ $('#lightbox-loading-link,#lightbox-secNav-btnClose').click(function() {
+ _finish();
+ return false;
+ });
+ // If window was resized, calculate the new overlay dimensions
+ $(window).resize(function() {
+ // Get page sizes
+ var arrPageSizes = ___getPageSize();
+ // Style overlay and show it
+ $('#jquery-overlay').css({
+ width: arrPageSizes[0],
+ height: arrPageSizes[1]
+ });
+ // Get page scroll
+ var arrPageScroll = ___getPageScroll();
+ // Calculate top and left offset for the jquery-lightbox div object and show it
+ $('#jquery-lightbox').css({
+ top: arrPageScroll[1] + (arrPageSizes[3] / 10),
+ left: arrPageScroll[0]
+ });
+ });
+ }
+ /**
+ * Prepares image exibition; doing a image�s preloader to calculate it�s size
+ *
+ */
+ function _set_image_to_view() { // show the loading
+ // Show the loading
+ $('#lightbox-loading').show();
+ if ( settings.fixedNavigation ) {
+ $('#lightbox-image,#lightbox-container-image-data-box,#lightbox-image-details-currentNumber').hide();
+ } else {
+ // Hide some elements
+ $('#lightbox-image,#lightbox-nav,#lightbox-nav-btnPrev,#lightbox-nav-btnNext,#lightbox-container-image-data-box,#lightbox-image-details-currentNumber').hide();
+ }
+ // Image preload process
+ var objImagePreloader = new Image();
+ objImagePreloader.onload = function() {
+ $('#lightbox-image').attr('src',settings.imageArray[settings.activeImage][0]);
+ // Perfomance an effect in the image container resizing it
+ _resize_container_image_box(objImagePreloader.width,objImagePreloader.height);
+ // clear onLoad, IE behaves irratically with animated gifs otherwise
+ objImagePreloader.onload=function(){};
+ };
+ objImagePreloader.src = settings.imageArray[settings.activeImage][0];
+ };
+ /**
+ * Perfomance an effect in the image container resizing it
+ *
+ * @param integer intImageWidth The image�s width that will be showed
+ * @param integer intImageHeight The image�s height that will be showed
+ */
+ function _resize_container_image_box(intImageWidth,intImageHeight) {
+ // Get current width and height
+ var intCurrentWidth = $('#lightbox-container-image-box').width();
+ var intCurrentHeight = $('#lightbox-container-image-box').height();
+ // Get the width and height of the selected image plus the padding
+ var intWidth = (intImageWidth + (settings.containerBorderSize * 2)); // Plus the image�s width and the left and right padding value
+ var intHeight = (intImageHeight + (settings.containerBorderSize * 2)); // Plus the image�s height and the left and right padding value
+ // Diferences
+ var intDiffW = intCurrentWidth - intWidth;
+ var intDiffH = intCurrentHeight - intHeight;
+ // Perfomance the effect
+ $('#lightbox-container-image-box').animate({ width: intWidth, height: intHeight },settings.containerResizeSpeed,function() { _show_image(); });
+ if ( ( intDiffW == 0 ) && ( intDiffH == 0 ) ) {
+ if ( $.browser.msie ) {
+ ___pause(250);
+ } else {
+ ___pause(100);
+ }
+ }
+ $('#lightbox-container-image-data-box').css({ width: intImageWidth });
+ $('#lightbox-nav-btnPrev,#lightbox-nav-btnNext').css({ height: intImageHeight + (settings.containerBorderSize * 2) });
+ };
+ /**
+ * Show the prepared image
+ *
+ */
+ function _show_image() {
+ $('#lightbox-loading').hide();
+ $('#lightbox-image').fadeIn(function() {
+ _show_image_data();
+ _set_navigation();
+ });
+ _preload_neighbor_images();
+ };
+ /**
+ * Show the image information
+ *
+ */
+ function _show_image_data() {
+ $('#lightbox-container-image-data-box').slideDown('fast');
+ $('#lightbox-image-details-caption').hide();
+ if ( settings.imageArray[settings.activeImage][1] ) {
+ $('#lightbox-image-details-caption').html(settings.imageArray[settings.activeImage][1]).show();
+ }
+ // If we have a image set, display 'Image X of X'
+ if ( settings.imageArray.length > 1 ) {
+ $('#lightbox-image-details-currentNumber').html(settings.txtImage + ' ' + ( settings.activeImage + 1 ) + ' ' + settings.txtOf + ' ' + settings.imageArray.length).show();
+ }
+ }
+ /**
+ * Display the button navigations
+ *
+ */
+ function _set_navigation() {
+ $('#lightbox-nav').show();
+
+ // Instead to define this configuration in CSS file, we define here. And it�s need to IE. Just.
+ $('#lightbox-nav-btnPrev,#lightbox-nav-btnNext').css({ 'background' : 'transparent url(' + settings.imageBlank + ') no-repeat' });
+
+ // Show the prev button, if not the first image in set
+ if ( settings.activeImage != 0 ) {
+ if ( settings.fixedNavigation ) {
+ $('#lightbox-nav-btnPrev').css({ 'background' : 'url(' + settings.imageBtnPrev + ') left 15% no-repeat' })
+ .unbind()
+ .bind('click',function() {
+ settings.activeImage = settings.activeImage - 1;
+ _set_image_to_view();
+ return false;
+ });
+ } else {
+ // Show the images button for Next buttons
+ $('#lightbox-nav-btnPrev').unbind().hover(function() {
+ $(this).css({ 'background' : 'url(' + settings.imageBtnPrev + ') left 15% no-repeat' });
+ },function() {
+ $(this).css({ 'background' : 'transparent url(' + settings.imageBlank + ') no-repeat' });
+ }).show().bind('click',function() {
+ settings.activeImage = settings.activeImage - 1;
+ _set_image_to_view();
+ return false;
+ });
+ }
+ }
+
+ // Show the next button, if not the last image in set
+ if ( settings.activeImage != ( settings.imageArray.length -1 ) ) {
+ if ( settings.fixedNavigation ) {
+ $('#lightbox-nav-btnNext').css({ 'background' : 'url(' + settings.imageBtnNext + ') right 15% no-repeat' })
+ .unbind()
+ .bind('click',function() {
+ settings.activeImage = settings.activeImage + 1;
+ _set_image_to_view();
+ return false;
+ });
+ } else {
+ // Show the images button for Next buttons
+ $('#lightbox-nav-btnNext').unbind().hover(function() {
+ $(this).css({ 'background' : 'url(' + settings.imageBtnNext + ') right 15% no-repeat' });
+ },function() {
+ $(this).css({ 'background' : 'transparent url(' + settings.imageBlank + ') no-repeat' });
+ }).show().bind('click',function() {
+ settings.activeImage = settings.activeImage + 1;
+ _set_image_to_view();
+ return false;
+ });
+ }
+ }
+ // Enable keyboard navigation
+ _enable_keyboard_navigation();
+ }
+ /**
+ * Enable a support to keyboard navigation
+ *
+ */
+ function _enable_keyboard_navigation() {
+ $(document).keydown(function(objEvent) {
+ _keyboard_action(objEvent);
+ });
+ }
+ /**
+ * Disable the support to keyboard navigation
+ *
+ */
+ function _disable_keyboard_navigation() {
+ $(document).unbind();
+ }
+ /**
+ * Perform the keyboard actions
+ *
+ */
+ function _keyboard_action(objEvent) {
+ // To ie
+ if ( objEvent == null ) {
+ keycode = event.keyCode;
+ escapeKey = 27;
+ // To Mozilla
+ } else {
+ keycode = objEvent.keyCode;
+ escapeKey = objEvent.DOM_VK_ESCAPE;
+ }
+ // Get the key in lower case form
+ key = String.fromCharCode(keycode).toLowerCase();
+ // Verify the keys to close the ligthBox
+ if ( ( key == settings.keyToClose ) || ( key == 'x' ) || ( keycode == escapeKey ) ) {
+ _finish();
+ }
+ // Verify the key to show the previous image
+ if ( ( key == settings.keyToPrev ) || ( keycode == 37 ) ) {
+ // If we�re not showing the first image, call the previous
+ if ( settings.activeImage != 0 ) {
+ settings.activeImage = settings.activeImage - 1;
+ _set_image_to_view();
+ _disable_keyboard_navigation();
+ }
+ }
+ // Verify the key to show the next image
+ if ( ( key == settings.keyToNext ) || ( keycode == 39 ) ) {
+ // If we�re not showing the last image, call the next
+ if ( settings.activeImage != ( settings.imageArray.length - 1 ) ) {
+ settings.activeImage = settings.activeImage + 1;
+ _set_image_to_view();
+ _disable_keyboard_navigation();
+ }
+ }
+ }
+ /**
+ * Preload prev and next images being showed
+ *
+ */
+ function _preload_neighbor_images() {
+ if ( (settings.imageArray.length -1) > settings.activeImage ) {
+ objNext = new Image();
+ objNext.src = settings.imageArray[settings.activeImage + 1][0];
+ }
+ if ( settings.activeImage > 0 ) {
+ objPrev = new Image();
+ objPrev.src = settings.imageArray[settings.activeImage -1][0];
+ }
+ }
+ /**
+ * Remove jQuery lightBox plugin HTML markup
+ *
+ */
+ function _finish() {
+ $('#jquery-lightbox').remove();
+ $('#jquery-overlay').fadeOut(function() { $('#jquery-overlay').remove(); });
+ // Show some elements to avoid conflict with overlay in IE. These elements appear above the overlay.
+ $('embed, object, select').css({ 'visibility' : 'visible' });
+ }
+ /**
+ / THIRD FUNCTION
+ * getPageSize() by quirksmode.com
+ *
+ * @return Array Return an array with page width, height and window width, height
+ */
+ function ___getPageSize() {
+ var xScroll, yScroll;
+ if (window.innerHeight && window.scrollMaxY) {
+ xScroll = window.innerWidth + window.scrollMaxX;
+ yScroll = window.innerHeight + window.scrollMaxY;
+ } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
+ xScroll = document.body.scrollWidth;
+ yScroll = document.body.scrollHeight;
+ } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
+ xScroll = document.body.offsetWidth;
+ yScroll = document.body.offsetHeight;
+ }
+ var windowWidth, windowHeight;
+ if (self.innerHeight) { // all except Explorer
+ if(document.documentElement.clientWidth){
+ windowWidth = document.documentElement.clientWidth;
+ } else {
+ windowWidth = self.innerWidth;
+ }
+ windowHeight = self.innerHeight;
+ } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
+ windowWidth = document.documentElement.clientWidth;
+ windowHeight = document.documentElement.clientHeight;
+ } else if (document.body) { // other Explorers
+ windowWidth = document.body.clientWidth;
+ windowHeight = document.body.clientHeight;
+ }
+ // for small pages with total height less then height of the viewport
+ if(yScroll < windowHeight){
+ pageHeight = windowHeight;
+ } else {
+ pageHeight = yScroll;
+ }
+ // for small pages with total width less then width of the viewport
+ if(xScroll < windowWidth){
+ pageWidth = xScroll;
+ } else {
+ pageWidth = windowWidth;
+ }
+ arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
+ return arrayPageSize;
+ };
+ /**
+ / THIRD FUNCTION
+ * getPageScroll() by quirksmode.com
+ *
+ * @return Array Return an array with x,y page scroll values.
+ */
+ function ___getPageScroll() {
+ var xScroll, yScroll;
+ if (self.pageYOffset) {
+ yScroll = self.pageYOffset;
+ xScroll = self.pageXOffset;
+ } else if (document.documentElement && document.documentElement.scrollTop) { // Explorer 6 Strict
+ yScroll = document.documentElement.scrollTop;
+ xScroll = document.documentElement.scrollLeft;
+ } else if (document.body) {// all other Explorers
+ yScroll = document.body.scrollTop;
+ xScroll = document.body.scrollLeft;
+ }
+ arrayPageScroll = new Array(xScroll,yScroll);
+ return arrayPageScroll;
+ };
+ /**
+ * Stop the code execution from a escified time in milisecond
+ *
+ */
+ function ___pause(ms) {
+ var date = new Date();
+ curDate = null;
+ do { var curDate = new Date(); }
+ while ( curDate - date < ms);
+ };
+ // Return the jQuery object for chaining. The unbind method is used to avoid click conflict when the plugin is called more than once
+ return this.unbind('click').click(_initialize);
+ };
+})(jQuery); // Call and execute the function immediately passing the jQuery object
\ No newline at end of file
Property changes on: trunk/pollen-ui-struts2/src/main/webapp/js/jquery.lightbox-0.5.js
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/pollen-ui-struts2/src/main/webapp/js/jquery.lightbox-0.5.min.js
===================================================================
--- trunk/pollen-ui-struts2/src/main/webapp/js/jquery.lightbox-0.5.min.js (rev 0)
+++ trunk/pollen-ui-struts2/src/main/webapp/js/jquery.lightbox-0.5.min.js 2012-06-18 09:45:51 UTC (rev 3508)
@@ -0,0 +1,43 @@
+/**
+ * %%Ignore-License
+ * jQuery lightBox plugin
+ * This jQuery plugin was inspired and based on Lightbox 2 by Lokesh Dhakar (http://www.huddletogether.com/projects/lightbox2/)
+ * and adapted to me for use like a plugin from jQuery.
+ * @name jquery-lightbox-0.5.js
+ * @author Leandro Vieira Pinho - http://leandrovieira.com
+ * @version 0.5
+ * @date April 11, 2008
+ * @category jQuery plugin
+ * @copyright (c) 2008 Leandro Vieira Pinho (leandrovieira.com)
+ * @license CCAttribution-ShareAlike 2.5 Brazil - http://creativecommons.org/licenses/by-sa/2.5/br/deed.en_US
+ * @example Visit http://leandrovieira.com/projects/jquery/lightbox/ for more informations about this jQuery plugin
+ */
+(function($){$.fn.lightBox=function(settings){settings=jQuery.extend({overlayBgColor:'#000',overlayOpacity:0.8,fixedNavigation:false,imageLoading:'images/lightbox-ico-loading.gif',imageBtnPrev:'images/lightbox-btn-prev.gif',imageBtnNext:'images/lightbox-btn-next.gif',imageBtnClose:'images/lightbox-btn-close.gif',imageBlank:'images/lightbox-blank.gif',containerBorderSize:10,containerResizeSpeed:400,txtImage:'Image',txtOf:'of',keyToClose:'c',keyToPrev:'p',keyToNext:'n',imageArray:[],activeImage:0},settings);var jQueryMatchedObj=this;function _initialize(){_start(this,jQueryMatchedObj);return false;}
+function _start(objClicked,jQueryMatchedObj){$('embed, object, select').css({'visibility':'hidden'});_set_interface();settings.imageArray.length=0;settings.activeImage=0;if(jQueryMatchedObj.length==1){settings.imageArray.push(new Array(objClicked.getAttribute('href'),objClicked.getAttribute('title')));}else{for(var i=0;i<jQueryMatchedObj.length;i++){settings.imageArray.push(new Array(jQueryMatchedObj[i].getAttribute('href'),jQueryMatchedObj[i].getAttribute('title')));}}
+while(settings.imageArray[settings.activeImage][0]!=objClicked.getAttribute('href')){settings.activeImage++;}
+_set_image_to_view();}
+function _set_interface(){$('body').append('<div id="jquery-overlay"></div><div id="jquery-lightbox"><div id="lightbox-container-image-box"><div id="lightbox-container-image"><img id="lightbox-image"><div style="" id="lightbox-nav"><a href="#" id="lightbox-nav-btnPrev"></a><a href="#" id="lightbox-nav-btnNext"></a></div><div id="lightbox-loading"><a href="#" id="lightbox-loading-link"><img src="'+settings.imageLoading+'"></a></div></div></div><div id="lightbox-container-image-data-box"><div id="lightbox-container-image-data"><div id="lightbox-image-details"><span id="lightbox-image-details-caption"></span><span id="lightbox-image-details-currentNumber"></span></div><div id="lightbox-secNav"><a href="#" id="lightbox-secNav-btnClose"><img src="'+settings.imageBtnClose+'"></a></div></div></div></div>');var arrPageSizes=___getPageSize();$('#jquery-overlay').css({backgroundColor:settings.overlayBgColor,opacity:settings.overlayOpacity,width:arrPageSizes[0],height:arrPageSizes[1]}).fadeIn();var arrPageScroll=___getPageScroll();$('#jquery-lightbox').css({top:arrPageScroll[1]+(arrPageSizes[3]/10),left:arrPageScroll[0]}).show();$('#jquery-overlay,#jquery-lightbox').click(function(){_finish();});$('#lightbox-loading-link,#lightbox-secNav-btnClose').click(function(){_finish();return false;});$(window).resize(function(){var arrPageSizes=___getPageSize();$('#jquery-overlay').css({width:arrPageSizes[0],height:arrPageSizes[1]});var arrPageScroll=___getPageScroll();$('#jquery-lightbox').css({top:arrPageScroll[1]+(arrPageSizes[3]/10),left:arrPageScroll[0]});});}
+function _set_image_to_view(){$('#lightbox-loading').show();if(settings.fixedNavigation){$('#lightbox-image,#lightbox-container-image-data-box,#lightbox-image-details-currentNumber').hide();}else{$('#lightbox-image,#lightbox-nav,#lightbox-nav-btnPrev,#lightbox-nav-btnNext,#lightbox-container-image-data-box,#lightbox-image-details-currentNumber').hide();}
+var objImagePreloader=new Image();objImagePreloader.onload=function(){$('#lightbox-image').attr('src',settings.imageArray[settings.activeImage][0]);_resize_container_image_box(objImagePreloader.width,objImagePreloader.height);objImagePreloader.onload=function(){};};objImagePreloader.src=settings.imageArray[settings.activeImage][0];};function _resize_container_image_box(intImageWidth,intImageHeight){var intCurrentWidth=$('#lightbox-container-image-box').width();var intCurrentHeight=$('#lightbox-container-image-box').height();var intWidth=(intImageWidth+(settings.containerBorderSize*2));var intHeight=(intImageHeight+(settings.containerBorderSize*2));var intDiffW=intCurrentWidth-intWidth;var intDiffH=intCurrentHeight-intHeight;$('#lightbox-container-image-box').animate({width:intWidth,height:intHeight},settings.containerResizeSpeed,function(){_show_image();});if((intDiffW==0)&&(intDiffH==0)){if($.browser.msie){___pause(250);}else{___pause(100);}}
+$('#lightbox-container-image-data-box').css({width:intImageWidth});$('#lightbox-nav-btnPrev,#lightbox-nav-btnNext').css({height:intImageHeight+(settings.containerBorderSize*2)});};function _show_image(){$('#lightbox-loading').hide();$('#lightbox-image').fadeIn(function(){_show_image_data();_set_navigation();});_preload_neighbor_images();};function _show_image_data(){$('#lightbox-container-image-data-box').slideDown('fast');$('#lightbox-image-details-caption').hide();if(settings.imageArray[settings.activeImage][1]){$('#lightbox-image-details-caption').html(settings.imageArray[settings.activeImage][1]).show();}
+if(settings.imageArray.length>1){$('#lightbox-image-details-currentNumber').html(settings.txtImage+' '+(settings.activeImage+1)+' '+settings.txtOf+' '+settings.imageArray.length).show();}}
+function _set_navigation(){$('#lightbox-nav').show();$('#lightbox-nav-btnPrev,#lightbox-nav-btnNext').css({'background':'transparent url('+settings.imageBlank+') no-repeat'});if(settings.activeImage!=0){if(settings.fixedNavigation){$('#lightbox-nav-btnPrev').css({'background':'url('+settings.imageBtnPrev+') left 15% no-repeat'}).unbind().bind('click',function(){settings.activeImage=settings.activeImage-1;_set_image_to_view();return false;});}else{$('#lightbox-nav-btnPrev').unbind().hover(function(){$(this).css({'background':'url('+settings.imageBtnPrev+') left 15% no-repeat'});},function(){$(this).css({'background':'transparent url('+settings.imageBlank+') no-repeat'});}).show().bind('click',function(){settings.activeImage=settings.activeImage-1;_set_image_to_view();return false;});}}
+if(settings.activeImage!=(settings.imageArray.length-1)){if(settings.fixedNavigation){$('#lightbox-nav-btnNext').css({'background':'url('+settings.imageBtnNext+') right 15% no-repeat'}).unbind().bind('click',function(){settings.activeImage=settings.activeImage+1;_set_image_to_view();return false;});}else{$('#lightbox-nav-btnNext').unbind().hover(function(){$(this).css({'background':'url('+settings.imageBtnNext+') right 15% no-repeat'});},function(){$(this).css({'background':'transparent url('+settings.imageBlank+') no-repeat'});}).show().bind('click',function(){settings.activeImage=settings.activeImage+1;_set_image_to_view();return false;});}}
+_enable_keyboard_navigation();}
+function _enable_keyboard_navigation(){$(document).keydown(function(objEvent){_keyboard_action(objEvent);});}
+function _disable_keyboard_navigation(){$(document).unbind();}
+function _keyboard_action(objEvent){if(objEvent==null){keycode=event.keyCode;escapeKey=27;}else{keycode=objEvent.keyCode;escapeKey=objEvent.DOM_VK_ESCAPE;}
+key=String.fromCharCode(keycode).toLowerCase();if((key==settings.keyToClose)||(key=='x')||(keycode==escapeKey)){_finish();}
+if((key==settings.keyToPrev)||(keycode==37)){if(settings.activeImage!=0){settings.activeImage=settings.activeImage-1;_set_image_to_view();_disable_keyboard_navigation();}}
+if((key==settings.keyToNext)||(keycode==39)){if(settings.activeImage!=(settings.imageArray.length-1)){settings.activeImage=settings.activeImage+1;_set_image_to_view();_disable_keyboard_navigation();}}}
+function _preload_neighbor_images(){if((settings.imageArray.length-1)>settings.activeImage){objNext=new Image();objNext.src=settings.imageArray[settings.activeImage+1][0];}
+if(settings.activeImage>0){objPrev=new Image();objPrev.src=settings.imageArray[settings.activeImage-1][0];}}
+function _finish(){$('#jquery-lightbox').remove();$('#jquery-overlay').fadeOut(function(){$('#jquery-overlay').remove();});$('embed, object, select').css({'visibility':'visible'});}
+function ___getPageSize(){var xScroll,yScroll;if(window.innerHeight&&window.scrollMaxY){xScroll=window.innerWidth+window.scrollMaxX;yScroll=window.innerHeight+window.scrollMaxY;}else if(document.body.scrollHeight>document.body.offsetHeight){xScroll=document.body.scrollWidth;yScroll=document.body.scrollHeight;}else{xScroll=document.body.offsetWidth;yScroll=document.body.offsetHeight;}
+var windowWidth,windowHeight;if(self.innerHeight){if(document.documentElement.clientWidth){windowWidth=document.documentElement.clientWidth;}else{windowWidth=self.innerWidth;}
+windowHeight=self.innerHeight;}else if(document.documentElement&&document.documentElement.clientHeight){windowWidth=document.documentElement.clientWidth;windowHeight=document.documentElement.clientHeight;}else if(document.body){windowWidth=document.body.clientWidth;windowHeight=document.body.clientHeight;}
+if(yScroll<windowHeight){pageHeight=windowHeight;}else{pageHeight=yScroll;}
+if(xScroll<windowWidth){pageWidth=xScroll;}else{pageWidth=windowWidth;}
+arrayPageSize=new Array(pageWidth,pageHeight,windowWidth,windowHeight);return arrayPageSize;};function ___getPageScroll(){var xScroll,yScroll;if(self.pageYOffset){yScroll=self.pageYOffset;xScroll=self.pageXOffset;}else if(document.documentElement&&document.documentElement.scrollTop){yScroll=document.documentElement.scrollTop;xScroll=document.documentElement.scrollLeft;}else if(document.body){yScroll=document.body.scrollTop;xScroll=document.body.scrollLeft;}
+arrayPageScroll=new Array(xScroll,yScroll);return arrayPageScroll;};function ___pause(ms){var date=new Date();curDate=null;do{var curDate=new Date();}
+while(curDate-date<ms);};return this.unbind('click').click(_initialize);};})(jQuery);
\ No newline at end of file
Property changes on: trunk/pollen-ui-struts2/src/main/webapp/js/jquery.lightbox-0.5.min.js
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
1
0
r3507 - in trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui: . its
by ymartel@users.chorem.org 18 Jun '12
by ymartel@users.chorem.org 18 Jun '12
18 Jun '12
Author: ymartel
Date: 2012-06-18 11:45:47 +0200 (Mon, 18 Jun 2012)
New Revision: 3507
Url: http://chorem.org/repositories/revision/pollen/3507
Log:
refs #606 : add ITs for free Date poll create
Added:
trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/its/CreateFreeDatePollSIT.java
Modified:
trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/PollenFixtures.java
trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/its/CreateFreeTextPollSIT.java
Modified: trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/PollenFixtures.java
===================================================================
--- trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/PollenFixtures.java 2012-06-18 08:22:04 UTC (rev 3506)
+++ trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/PollenFixtures.java 2012-06-18 09:45:47 UTC (rev 3507)
@@ -26,7 +26,11 @@
import org.apache.commons.logging.LogFactory;
import org.chorem.pollen.PollenConfiguration;
import org.chorem.pollen.bean.PollUri;
+import org.nuiton.util.DateUtil;
+import java.util.Calendar;
+import java.util.Date;
+
/**
* Some fixtures for tests.
*
@@ -79,6 +83,10 @@
return "b9b434acd58d42fca083d473ee021fce";
}
+ public String datePattern() {
+ return "dd/MM/yyyy HH:mm";
+ }
+
public String homeURL() {
return baseUrl() + "home";
}
@@ -139,11 +147,19 @@
return baseUrl() + "poll/create";
}
- public String editPollURL() {
- return baseUrl() + "poll/edit";
- }
-
public String summaryURL() {
return baseUrl() + "poll/summary";
}
+
+ public String date(int year, int month, int day, int hour, int minute) {
+ Calendar instance = Calendar.getInstance();
+ instance.set(year, month, day, hour, minute);
+ Date date = instance.getTime();
+ String dateString = DateUtil.formatDate(date, datePattern());
+ return dateString;
+ }
+
+ public String date(int year, int month, int day) {
+ return date(year, month, day, 0, 0);
+ }
}
Added: trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/its/CreateFreeDatePollSIT.java
===================================================================
--- trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/its/CreateFreeDatePollSIT.java (rev 0)
+++ trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/its/CreateFreeDatePollSIT.java 2012-06-18 09:45:47 UTC (rev 3507)
@@ -0,0 +1,312 @@
+/*
+ * #%L
+ * Pollen :: UI (struts2)
+ * $Id: CreateFreeTextPollSIT.java 3481 2012-06-15 15:12:06Z ymartel $
+ * $HeadURL: http://svn.chorem.org/svn/pollen/trunk/pollen-ui-struts2/src/test/java/org/… $
+ * %%
+ * Copyright (C) 2009 - 2012 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+package org.chorem.pollen.ui.its;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+
+import java.util.List;
+
+/**
+ * Test the well work of a Free Date poll creation page.
+ *
+ * Tested cases :
+ * <ul>
+ * <li>Classic creation with filled mandatory fields (a title and at least 2 choices(OK)</li>
+ * <li>Classic creation with no title (KO)</li>
+ * <li>Classic creation with no choice (KO)</li>
+ * <li>Classic creation with two same choices (KO)</li>
+ * <li>Classic creation with invalid date format for one of the choices (KO)</li>
+ * </ul>
+ *
+ * @author ymartel <martel(a)codelutin.com>
+ *
+ * @since 1.4
+ */
+public class CreateFreeDatePollSIT extends PollenBaseWebDriverIT {
+
+ public CreateFreeDatePollSIT(Class<? extends WebDriver> driverType) {
+ super(driverType);
+ }
+
+ /**
+ * This test create a simple free text poll.
+ * At the end, should be on summary page.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void createSimpleFreeDatePoll() throws Exception {
+
+ // Go on home page
+ gotoUrl(fixtures.createPollURL());
+
+ // Set title
+ WebElement titleElement = findElement(By.name("poll.title"));
+ Assert.assertEquals("input", titleElement.getTagName());
+ Assert.assertTrue(titleElement.isDisplayed());
+ titleElement.sendKeys("My Date Poll");
+
+ // Switch to Date choices
+ List<WebElement> choiceTypesElement = findElements(By.name("poll.choiceType"));
+ Assert.assertEquals(3, choiceTypesElement.size());
+ WebElement dateChoiceTypeElement = choiceTypesElement.get(1);
+ Assert.assertEquals("input", dateChoiceTypeElement.getTagName());
+ Assert.assertEquals("DATE", dateChoiceTypeElement.getAttribute("value"));
+ Assert.assertTrue(dateChoiceTypeElement.isDisplayed());
+ dateChoiceTypeElement.click();
+
+ // Set first choice
+ WebElement choiceOneElement = findElement(By.name("dateChoice_0.name"));
+ Assert.assertEquals("input", choiceOneElement.getTagName());
+ Assert.assertTrue(choiceOneElement.isDisplayed());
+ choiceOneElement.sendKeys(fixtures.date(1431, 05, 30));
+
+ // Set second choice
+ WebElement choiceTwoElement = findElement(By.name("dateChoice_1.name"));
+ Assert.assertEquals("input", choiceTwoElement.getTagName());
+ Assert.assertTrue(choiceTwoElement.isDisplayed());
+ choiceTwoElement.sendKeys(fixtures.date(1789, 8, 26));
+
+ // Submit form
+ WebElement submit = findElement(By.name("action:create"));
+ submit.click();
+
+ // All good, should be on summary page !
+ checkCurrentUrl(fixtures.summaryURL(), false);
+ }
+
+ /**
+ * This test create a free date poll with two choices but no title.
+ * At the end, should be still on create page, with an error message.
+ */
+ @Test
+ public void createSimpleFreeDatePollWithoutTitle() throws Exception {
+
+ // Go on home page
+ gotoUrl(fixtures.createPollURL());
+
+ // Switch to Date choices
+ List<WebElement> choiceTypesElement = findElements(By.name("poll.choiceType"));
+ Assert.assertEquals(3, choiceTypesElement.size());
+ WebElement dateChoiceTypeElement = choiceTypesElement.get(1);
+ Assert.assertEquals("input", dateChoiceTypeElement.getTagName());
+ Assert.assertEquals("DATE", dateChoiceTypeElement.getAttribute("value"));
+ Assert.assertTrue(dateChoiceTypeElement.isDisplayed());
+ dateChoiceTypeElement.click();
+
+ // Set first choice
+ WebElement choiceOneElement = findElement(By.name("dateChoice_0.name"));
+ Assert.assertEquals("input", choiceOneElement.getTagName());
+ Assert.assertTrue(choiceOneElement.isDisplayed());
+ String choiceOneValue = fixtures.date(1431, 05, 30);
+ choiceOneElement.sendKeys(choiceOneValue);
+
+ // Set second choice
+ WebElement choiceTwoElement = findElement(By.name("dateChoice_1.name"));
+ Assert.assertEquals("input", choiceTwoElement.getTagName());
+ Assert.assertTrue(choiceTwoElement.isDisplayed());
+ String choiceTwoValue = fixtures.date(1789, 8, 26);
+ choiceTwoElement.sendKeys(choiceTwoValue);
+
+ // Submit form
+ WebElement submit = findElement(By.name("action:create"));
+ submit.click();
+
+ // Title is missing, should stay on create poll page
+ checkCurrentUrl(fixtures.createPollURL(), false);
+
+ // Check an error message has been displayed
+ WebElement titleError = findElement(By.className("errorMessage"));
+ Assert.assertNotNull(titleError);
+
+ // Check that choice fields are not lost
+ choiceOneElement = findElement(By.name("dateChoice_0.name"));
+ Assert.assertEquals("input", choiceOneElement.getTagName());
+ Assert.assertTrue(choiceOneElement.isDisplayed());
+ Assert.assertEquals(choiceOneValue, choiceOneElement.getAttribute("value"));
+ choiceTwoElement = findElement(By.name("dateChoice_1.name"));
+ Assert.assertEquals("input", choiceTwoElement.getTagName());
+ Assert.assertTrue(choiceTwoElement.isDisplayed());
+ Assert.assertEquals(choiceTwoValue, choiceTwoElement.getAttribute("value"));
+
+ }
+
+ /**
+ * This test create a free date poll without choices.
+ * At the end, should be still on create page, with an error message.
+ */
+ @Test
+ public void createSimpleFreeDatePollWithoutChoice() throws Exception {
+
+ // Go on home page
+ gotoUrl(fixtures.createPollURL());
+
+ // Set title
+ WebElement titleElement = findElement(By.name("poll.title"));
+ Assert.assertEquals("input", titleElement.getTagName());
+ Assert.assertTrue(titleElement.isDisplayed());
+ String pollTitle = "My Date Poll";
+ titleElement.sendKeys(pollTitle);
+
+ // Switch to Date choices
+ List<WebElement> choiceTypesElement = findElements(By.name("poll.choiceType"));
+ Assert.assertEquals(3, choiceTypesElement.size());
+ WebElement dateChoiceTypeElement = choiceTypesElement.get(1);
+ Assert.assertEquals("input", dateChoiceTypeElement.getTagName());
+ Assert.assertEquals("DATE", dateChoiceTypeElement.getAttribute("value"));
+ Assert.assertTrue(dateChoiceTypeElement.isDisplayed());
+ dateChoiceTypeElement.click();
+
+ // Submit form
+ WebElement submit = findElement(By.name("action:create"));
+ submit.click();
+
+ // No choices, should stay on create poll page
+ checkCurrentUrl(fixtures.createPollURL(), false);
+
+ // Check that title field is not lost
+ titleElement = findElement(By.name("poll.title"));
+ Assert.assertEquals("input", titleElement.getTagName());
+ Assert.assertTrue(titleElement.isDisplayed());
+ Assert.assertEquals(pollTitle, titleElement.getAttribute("value"));
+
+ // Check an error message has been displayed for choices
+ WebElement choicesError = findElement(By.id("poll_choices_error"));
+ Assert.assertNotNull(choicesError);
+
+ // Check that we are still on Date choices
+ choiceTypesElement = findElements(By.name("poll.choiceType"));
+ Assert.assertEquals(3, choiceTypesElement.size());
+ dateChoiceTypeElement = choiceTypesElement.get(1);
+ Assert.assertEquals("input", dateChoiceTypeElement.getTagName());
+ Assert.assertEquals("DATE", dateChoiceTypeElement.getAttribute("value"));
+ Assert.assertEquals("true", dateChoiceTypeElement.getAttribute("checked"));
+
+ }
+
+ /**
+ * This test create a free date poll with a same value for two choices.
+ * At the end, should be still on create page, with an error message.
+ *
+ */
+ @Test
+ public void createSimpleFreeDatePollWithTwoSameDate() throws Exception {
+
+ // Go on home page
+ gotoUrl(fixtures.createPollURL());
+
+ // Set title
+ WebElement titleElement = findElement(By.name("poll.title"));
+ Assert.assertEquals("input", titleElement.getTagName());
+ Assert.assertTrue(titleElement.isDisplayed());
+ titleElement.sendKeys("My Date Poll");
+
+ // Switch to Date choices
+ List<WebElement> choiceTypesElement = findElements(By.name("poll.choiceType"));
+ Assert.assertEquals(3, choiceTypesElement.size());
+ WebElement dateChoiceTypeElement = choiceTypesElement.get(1);
+ Assert.assertEquals("input", dateChoiceTypeElement.getTagName());
+ Assert.assertEquals("DATE", dateChoiceTypeElement.getAttribute("value"));
+ Assert.assertTrue(dateChoiceTypeElement.isDisplayed());
+ dateChoiceTypeElement.click();
+
+ // Set first choice
+ WebElement choiceOneElement = findElement(By.name("dateChoice_0.name"));
+ Assert.assertEquals("input", choiceOneElement.getTagName());
+ Assert.assertTrue(choiceOneElement.isDisplayed());
+ String date = fixtures.date(1431, 05, 30);
+ choiceOneElement.sendKeys(date);
+
+ // Set second choice
+ WebElement choiceTwoElement = findElement(By.name("dateChoice_1.name"));
+ Assert.assertEquals("input", choiceTwoElement.getTagName());
+ Assert.assertTrue(choiceTwoElement.isDisplayed());
+ choiceTwoElement.sendKeys(date);
+
+ // Submit form
+ WebElement submit = findElement(By.name("action:create"));
+ submit.click();
+
+ // An error, should stay on create page
+ checkCurrentUrl(fixtures.createPollURL(), false);
+
+ // Check an error message has been displayed for choices
+ WebElement choicesError = findElement(By.className("errorMessage"));
+ Assert.assertNotNull(choicesError);
+ }
+
+ /**
+ * This test create a free date poll with a bas format for one of the choices.
+ * At the end, should be still on create page, with an error message.
+ *
+ */
+ @Test
+ public void createSimpleFreeDatePollWithBadFormatDate() throws Exception {
+
+ // Go on home page
+ gotoUrl(fixtures.createPollURL());
+
+ // Set title
+ WebElement titleElement = findElement(By.name("poll.title"));
+ Assert.assertEquals("input", titleElement.getTagName());
+ Assert.assertTrue(titleElement.isDisplayed());
+ titleElement.sendKeys("My Date Poll");
+
+ // Switch to Date choices
+ List<WebElement> choiceTypesElement = findElements(By.name("poll.choiceType"));
+ Assert.assertEquals(3, choiceTypesElement.size());
+ WebElement dateChoiceTypeElement = choiceTypesElement.get(1);
+ Assert.assertEquals("input", dateChoiceTypeElement.getTagName());
+ Assert.assertEquals("DATE", dateChoiceTypeElement.getAttribute("value"));
+ Assert.assertTrue(dateChoiceTypeElement.isDisplayed());
+ dateChoiceTypeElement.click();
+
+ // Set first choice
+ WebElement choiceOneElement = findElement(By.name("dateChoice_0.name"));
+ Assert.assertEquals("input", choiceOneElement.getTagName());
+ Assert.assertTrue(choiceOneElement.isDisplayed());
+ choiceOneElement.sendKeys(fixtures.date(1431, 05, 30));
+
+ // Set second choice
+ WebElement choiceTwoElement = findElement(By.name("dateChoice_1.name"));
+ Assert.assertEquals("input", choiceTwoElement.getTagName());
+ Assert.assertTrue(choiceTwoElement.isDisplayed());
+ choiceTwoElement.sendKeys("28 08 1789");
+
+ // Submit form
+ WebElement submit = findElement(By.name("action:create"));
+ submit.click();
+
+ // An error, should stay on create page
+ checkCurrentUrl(fixtures.createPollURL(), false);
+
+ // Check an error message has been displayed for choices
+ WebElement choicesError = findElement(By.className("errorMessage"));
+ Assert.assertNotNull(choicesError);
+ }
+
+}
Modified: trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/its/CreateFreeTextPollSIT.java
===================================================================
--- trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/its/CreateFreeTextPollSIT.java 2012-06-18 08:22:04 UTC (rev 3506)
+++ trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/its/CreateFreeTextPollSIT.java 2012-06-18 09:45:47 UTC (rev 3507)
@@ -286,7 +286,7 @@
WebElement startDateElement = findElement(By.name("poll.endDate"));
Assert.assertEquals("input", startDateElement.getTagName());
Assert.assertTrue(startDateElement.isDisplayed());
- //FIXME ymartel 2012/06/14 : review way to get DAte ?
+ //FIXME ymartel 2012/06/14 : review way to get Date ?
Date twoMonthsAgo = DateUtils.addMonths(new Date(), -2);
String formatTwoMonthsAgo = DateUtil.formatDate(twoMonthsAgo, "dd/MM/yyyy HH:mm");
startDateElement.sendKeys(formatTwoMonthsAgo);
@@ -438,8 +438,8 @@
checkCurrentUrl(fixtures.createPollURL(), false);
// Check an error message has been displayed
- WebElement dateError = findElement(By.className("errorMessage"));
- Assert.assertNotNull(dateError);
+ WebElement maxChoicesError = findElement(By.className("errorMessage"));
+ Assert.assertNotNull(maxChoicesError);
// Go on general tab and check that Title and and choice fields values are not lost
WebElement generalClick = findElement(By.xpath("//a[@href=\"#tgeneral\"]"));
@@ -472,6 +472,9 @@
// No choices, should stay on create poll page
checkCurrentUrl(fixtures.createPollURL(), false);
+ // Check an error message has been displayed
+ maxChoicesError = findElement(By.className("errorMessage"));
+ Assert.assertNotNull(maxChoicesError);
}
1
0
r3506 - trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/its
by tchemit@users.chorem.org 18 Jun '12
by tchemit@users.chorem.org 18 Jun '12
18 Jun '12
Author: tchemit
Date: 2012-06-18 10:22:04 +0200 (Mon, 18 Jun 2012)
New Revision: 3506
Url: http://chorem.org/repositories/revision/pollen/3506
Log:
refs #606: fix create form submit action
Modified:
trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/its/CreateFreeTextPollSIT.java
Modified: trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/its/CreateFreeTextPollSIT.java
===================================================================
--- trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/its/CreateFreeTextPollSIT.java 2012-06-18 07:58:19 UTC (rev 3505)
+++ trunk/pollen-ui-struts2/src/test/java/org/chorem/pollen/ui/its/CreateFreeTextPollSIT.java 2012-06-18 08:22:04 UTC (rev 3506)
@@ -90,7 +90,7 @@
choiceTwoElement.sendKeys("Choix numero deux");
// Submit form
- WebElement submit = findElement(By.name("action:save"));
+ WebElement submit = findElement(By.name("action:create"));
submit.click();
// All good, should be on summary page !
@@ -124,7 +124,7 @@
choiceTwoElement.sendKeys(choiceTwoValue);
// Submit form
- WebElement submit = findElement(By.name("action:save"));
+ WebElement submit = findElement(By.name("action:create"));
submit.click();
// Title is missing, should stay on create poll page
@@ -166,7 +166,7 @@
titleElement.sendKeys(pollTitle);
// Submit form
- WebElement submit = findElement(By.name("action:save"));
+ WebElement submit = findElement(By.name("action:create"));
submit.click();
// No choices, should stay on create poll page
@@ -224,7 +224,7 @@
endDateElement.sendKeys(formatMonthAgo);
// Submit form
- WebElement submit = findElement(By.name("action:save"));
+ WebElement submit = findElement(By.name("action:create"));
submit.click();
// No choices, should stay on create poll page
@@ -301,7 +301,7 @@
endDateElement.sendKeys(formatOneMonthAgo);
// Submit form
- WebElement submit = findElement(By.name("action:save"));
+ WebElement submit = findElement(By.name("action:create"));
submit.click();
// No choices, should stay on create poll page
@@ -361,7 +361,7 @@
emailElement.sendKeys("i@minvalid");
// Submit form
- WebElement submit = findElement(By.name("action:save"));
+ WebElement submit = findElement(By.name("action:create"));
submit.click();
// No choices, should stay on create poll page
@@ -431,7 +431,7 @@
maxChoiceElement.sendKeys("-1");
// Submit form
- WebElement submit = findElement(By.name("action:save"));
+ WebElement submit = findElement(By.name("action:create"));
submit.click();
// No choices, should stay on create poll page
@@ -467,7 +467,7 @@
maxChoiceElement.sendKeys("0");
// Submit form
- submit = findElement(By.name("action:save"));
+ submit = findElement(By.name("action:create"));
submit.click();
// No choices, should stay on create poll page
1
0
18 Jun '12
Author: tchemit
Date: 2012-06-18 09:58:19 +0200 (Mon, 18 Jun 2012)
New Revision: 3505
Url: http://chorem.org/repositories/revision/pollen/3505
Log:
continue security stuff
Modified:
trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/SecurityService.java
trunk/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties
trunk/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetPollComments.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/SummaryPoll.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/AbstractPollenAuthorization.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/PollCreatorAccessRequired.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/PollResultAccessRequired.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/PollVoteAccessRequired.java
trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp
Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/SecurityService.java
===================================================================
--- trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/SecurityService.java 2012-06-18 07:55:12 UTC (rev 3504)
+++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/SecurityService.java 2012-06-18 07:58:19 UTC (rev 3505)
@@ -29,8 +29,6 @@
import org.chorem.pollen.PollenTechnicalException;
import org.chorem.pollen.bean.PollUri;
import org.chorem.pollen.business.persistence.Comment;
-import org.chorem.pollen.business.persistence.PersonToList;
-import org.chorem.pollen.business.persistence.PersonToListDAO;
import org.chorem.pollen.business.persistence.Poll;
import org.chorem.pollen.business.persistence.PollAccount;
import org.chorem.pollen.business.persistence.PollAccountDAO;
@@ -38,8 +36,6 @@
import org.chorem.pollen.business.persistence.Vote;
import org.chorem.pollen.common.PollType;
import org.chorem.pollen.services.PollenServiceSupport;
-import org.chorem.pollen.services.exceptions.PollNotFoundException;
-import org.chorem.pollen.services.exceptions.UnauthorizedPollAccessException;
import org.nuiton.topia.TopiaException;
import java.util.Date;
@@ -55,9 +51,8 @@
*/
public class SecurityService extends PollenServiceSupport {
- public boolean isCreator(Poll poll,
- PollUri uriId,
- UserAccount pollenUserAccount) {
+ public boolean isPollCreator(Poll poll, PollUri uriId,
+ UserAccount pollenUserAccount) {
PollAccount creator = poll.getCreator();
@@ -71,6 +66,7 @@
return result;
}
+
/**
* To define meaning of a accountId.
*
@@ -102,114 +98,83 @@
AccountIdRole.CREATOR
);
- public void checkPoll(PollUri uri) throws PollNotFoundException {
+// public void checkPoll(PollUri uri) throws PollNotFoundException {
+//
+// getExistingPoll(uri);
+// }
- getExistingPoll(uri);
- }
+// public void checkPollResult(PollUri uri) throws PollNotFoundException, UnauthorizedPollAccessException {
+//
+// Poll poll = getExistingPoll(uri);
+//
+// if (!poll.isPublicResults()) {
+// throw new UnauthorizedPollAccessException();
+// }
+// }
- public void checkPollResult(PollUri uri) throws PollNotFoundException, UnauthorizedPollAccessException {
+// public void checkPollAccount(PollUri uri) throws PollNotFoundException, UnauthorizedPollAccessException {
+//
+//
+// String accountId = uri.getAccountId();
+//
+// Poll poll = getExistingPoll(uri);
+//
+// PollAccountDAO dao = getDAO(PollAccount.class);
+//
+// String pollId = uri.getPollId();
+//
+// if (poll.getPollType() == PollType.FREE) {
+//
+// // free poll
+// if (accountId != null) {
+//
+// // account Id is given check there is a such vote for this account
+//
+// try {
+//
+// if (!dao.existsByPollVoteAccountId(pollId, accountId)) {
+// throw new UnauthorizedPollAccessException();
+// }
+// } catch (TopiaException e) {
+// throw new PollenTechnicalException(
+// "Could not check pollAccount existence from poll '" +
+// pollId + "' and account '" + accountId + "'", e);
+// }
+// }
+// } else {
+//
+// // check that uri contains a correct poll account for this
+//
+// // Use PersonToList association entity to find coherence between
+// // the poll and votingId
+//
+// try {
+// PollAccount result =
+// dao.getRestrictedPollAccount(pollId, accountId);
+//
+// if (result == null) {
+// throw new UnauthorizedPollAccessException();
+// }
+// } catch (TopiaException e) {
+// throw new PollenTechnicalException(
+// "Could not obtain restricted pollAccount", e);
+// }
+// }
+// }
- Poll poll = getExistingPoll(uri);
+// public void checkPollCreator(PollUri uri) throws PollNotFoundException, UnauthorizedPollAccessException {
+//
+// String accountId = uri.getAccountId();
+//
+// Poll poll = getExistingPoll(uri);
+//
+// String creatorId = poll.getCreator().getAccountId();
+//
+// if (!creatorId.equals(accountId)) {
+// throw new UnauthorizedPollAccessException();
+// }
+// }
- if (!poll.isPublicResults()) {
- throw new UnauthorizedPollAccessException();
- }
- }
-
- public void checkPollAccount(PollUri uri) throws PollNotFoundException, UnauthorizedPollAccessException {
-
-
- String accountId = uri.getAccountId();
-
- Poll poll = getExistingPoll(uri);
-
- PollAccountDAO dao = getDAO(PollAccount.class);
-
- String pollId = uri.getPollId();
-
- if (poll.getPollType() == PollType.FREE) {
-
- // free poll
- if (accountId != null) {
-
- // account Id is given check there is a such vote for this account
-
- try {
-
- if (!dao.existsByPollVoteAccountId(pollId, accountId)) {
- throw new UnauthorizedPollAccessException();
- }
- } catch (TopiaException e) {
- throw new PollenTechnicalException(
- "Could not check pollAccount existence from poll '" +
- pollId + "' and account '" + accountId + "'", e);
- }
- }
- } else {
-
- // check that uri contains a correct poll account for this
-
- // Use PersonToList association entity to find coherence between
- // the poll and votingId
-
- try {
- PollAccount result =
- dao.getRestrictedPollAccount(pollId, accountId);
-
- if (result == null) {
- throw new UnauthorizedPollAccessException();
- }
- } catch (TopiaException e) {
- throw new PollenTechnicalException(
- "Could not obtain restricted pollAccount", e);
- }
- }
- }
-
- public void checkPollCreator(PollUri uri) throws PollNotFoundException, UnauthorizedPollAccessException {
-
- String accountId = uri.getAccountId();
-
- Poll poll = getExistingPoll(uri);
-
- String creatorId = poll.getCreator().getAccountId();
-
- if (!creatorId.equals(accountId)) {
- throw new UnauthorizedPollAccessException();
- }
- }
-
- private boolean isVoterAccountId(PollAccountDAO dao, PollUri uri) {
- try {
-
- return dao.existsByPollVoteAccountId(uri.getPollId(), uri.getAccountId());
-
- } catch (TopiaException e) {
- throw new PollenTechnicalException(
- "Could not check pollAccount existence from poll '" +
- uri.getPollId() + "' and account '" + uri.getAccountId() + "'", e);
- }
- }
-
- private boolean isRestrictPollAccountId(PollAccountDAO dao, PollUri uri) {
- try {
-
- PollAccount result =
- dao.getRestrictedPollAccount(uri.getPollId(), uri.getAccountId());
-
- return result != null;
-
- } catch (TopiaException e) {
- throw new PollenTechnicalException(
- "Could not check pollAccount existence from poll '" +
- uri.getPollId() + "' and account '" + uri.getAccountId() + "'", e);
- }
- }
-
- protected Poll getExistingPoll(PollUri uri) throws PollNotFoundException {
- return newService(PollService.class).getExistingPollByPollId(uri.getPollId());
- }
-
public AccountIdRole getAccountIdRole(Poll poll, String accountId) {
Preconditions.checkNotNull(poll);
@@ -249,8 +214,8 @@
return result;
}
- public String isCanShowResult(Poll poll,
- SecurityService.AccountIdRole accountIdRole) {
+ public String isCanAccessResult(Poll poll,
+ SecurityService.AccountIdRole accountIdRole) {
// check now poll results can be displayed
@@ -282,104 +247,316 @@
return null;
}
- /**
- * Vote is allowed if {@code poll} is running and {@code pollAccount} is
- * defined in the {@code poll} restricted list if it's not a {@link PollType#FREE}
- * poll. The account must be defined previously using
- * {@link PollService#getPollAccountEditable(String, UserAccount, Poll)} to
- * have a proper link between userAccount and pollAccount even if not already
- * created in dabase. The poll creator can't vote. The token is just use
- * for moderate purpose.
- *
- * @param poll Poll
- * @param accountEditable Account to check
- * @return true if vote is allowed, false otherwise
- */
- public boolean isVoteAllowed(Poll poll, PollAccount accountEditable) {
+ public String isCanAccessVote(Poll poll, String accountId, AccountIdRole accountIdRole) {
- Preconditions.checkNotNull(poll);
- Preconditions.checkNotNull(accountEditable);
+ if (AccountIdRole.CREATOR == accountIdRole) {
+ // poll admin can alwyas access vote page
+ return null;
+ }
+
+ boolean pollIsFree = PollType.FREE == poll.getPollType();
+
+ if (pollIsFree && poll.getCreator().getAccountId().equals(accountId)) {
+
+ // on free poll, only the creator (using his creatorId as accountId) can not vote
+ return n_("pollen.security.error.poll.free.creatorId.can.not.vote");
+ }
+ if (!pollIsFree && AccountIdRole.RESTRICTED_VOTER != accountIdRole) {
+
+ // on none free poll, only restricted user can vote
+ return n_("pollen.security.error.poll.not.free.and.access.not.granted");
+ }
+ return null;
+ }
+
+ public boolean isCanVote(Poll poll,
+ String accountId,
+ AccountIdRole accountIdRole) {
+
+
Date now = serviceContext.getCurrentTime();
- boolean result;
- if (poll.getCreator().equals(accountEditable)) {
+ if (!poll.isRunning(now)) {
- // The creator user can't vote
- result = false;
- } else {
+ // poll is not running, can not vote
+ return false;
+ }
- // The poll must be running and account allowed for restricted poll
- result = poll.isRunning(now);
- if (poll.getPollType() != PollType.FREE) {
+ boolean pollIsFree = PollType.FREE == poll.getPollType();
- PersonToListDAO dao = getDAO(PersonToList.class);
- PersonToList personToList =
- dao.findByPollAndAccount(poll, accountEditable);
+ if (pollIsFree && poll.getCreator().getAccountId().equals(accountId)) {
- result &= personToList != null;
- }
+ // on free poll, only the creator (using his creatorId as accountId) can not vote
+ return false;
}
- return result;
+ if (!pollIsFree && AccountIdRole.RESTRICTED_VOTER != accountIdRole) {
+
+ // on none free poll, only restricted user can vote
+ return false;
+ }
+
+ // ok can vote
+ return true;
}
- public boolean isUpdateAllowed(Poll poll, String voteId,
- String accountId, UserAccount userConnected) {
+ public boolean isCanModifyVote(Poll poll, String voteId,
+ String accountId,
+ UserAccount userConnected) {
Date now = serviceContext.getCurrentTime();
- boolean result = false;
+ if (!poll.isRunning(now)) {
+ // poll is not running can not modify anything
+ return false;
+ }
+
+ if (poll.isAnonymous()) {
+
+ // poll is anonymous, no vote can be modify
+ return false;
+ }
+
Vote vote = poll.getVoteByTopiaId(voteId);
- // can only modify a vote if poll is running.
- if (vote != null && poll.isRunning(now)) {
- PollAccount votePollAccount = vote.getPollAccount();
+ if (vote == null) {
- // si le votant du vote correspond au votant actuel (pollAccountId)
- if (accountId != null
- && accountId.equals(votePollAccount.getAccountId())) {
- result = true;
+ // vote not found, can not modify it
+ return false;
+ }
+
+ PollAccount votePollAccount = vote.getPollAccount();
+
+ if (votePollAccount.getAccountId().equals(accountId)) {
+
+ // accountId is voteAccountId, can modifiy the vote
+ return true;
+ }
+
+ if (userConnected != null) {
+
+ if (userConnected.equals(votePollAccount.getUserAccount())) {
+
+ // user conntected is the voter
+ return true;
}
+ }
- // si l'utilisateur du vote correspond à l'utilisateur actuel (user)
- if (userConnected != null) {
- UserAccount voteUserAccount = votePollAccount.getUserAccount();
- result = userConnected.equals(voteUserAccount);
+ // can not modify vote in other cases
+ return false;
+ }
+
+ public boolean isCanDeleteVote(Poll poll,
+ String voteId,
+ String accountId,
+ AccountIdRole accountIdRole,
+ UserAccount userConnected) {
+
+ Date now = serviceContext.getCurrentTime();
+
+ if (!poll.isRunning(now)) {
+
+ // poll is not running can not remove anything
+ return false;
+ }
+
+ if (poll.isAnonymous()) {
+
+ // poll is anonymous, no vote can be delete (?) FIXME Check this
+ return false;
+ }
+
+
+ Vote vote = poll.getVoteByTopiaId(voteId);
+
+ if (vote == null) {
+
+ // vote not found, can not delete it
+ return false;
+ }
+
+ if (accountIdRole == AccountIdRole.CREATOR) {
+
+ // poll admin can delete any vote
+ return true;
+ }
+
+ PollAccount votePollAccount = vote.getPollAccount();
+
+ if (votePollAccount.getAccountId().equals(accountId)) {
+
+ // owner of vote (linked by accountId) can delete his own vote
+ return true;
+ }
+
+ if (userConnected != null) {
+
+ if (userConnected.equals(votePollAccount.getUserAccount())) {
+
+ // owner of vote (linked by userAccount) can delete his own vote
+ return true;
}
}
- return result;
+
+ // can not modify vote in other cases
+ return false;
}
public boolean isCanDeleteComment(Comment comment,
- PollAccount pollAccount,
- UserAccount userAccount,
- boolean isPollCreator) {
+ String accountId,
+ AccountIdRole accountIdRole,
+ UserAccount userAccount) {
- boolean result = false;
+ if (accountIdRole == AccountIdRole.CREATOR) {
+ // poll admin can always delete comments
+ return true;
+ }
+
PollAccount commentAccount = comment.getPollAccount();
- if (isPollCreator) {
+ if (commentAccount.getAccountId().equals(accountId)) {
- // poll creator has admin rights on his poll
- result = true;
- } else if (userAccount != null) {
+ // owner of comment (linked by accountId) can delete his comment
+ return true;
+ }
- // loggued
- boolean isAdmin = userAccount.isAdministrator();
-// boolean isCommentAccount = userAccount.equals(commentAccount.getUserAccount());
+ if (userAccount != null) {
- // pollen admin or comment owner (linked by user account)
- result = isAdmin ||
- userAccount.equals(commentAccount.getUserAccount());
+ if (userAccount.equals(commentAccount.getUserAccount())) {
+ // owner of comment (linked by userAccount) can delete his comment
+ return true;
+ }
+ }
+ return false;
+ }
- } else if (pollAccount != null) {
+ private boolean isVoterAccountId(PollAccountDAO dao, PollUri uri) {
+ try {
- // comment owner (linked by poll account)
- result = pollAccount.equals(commentAccount);
+ return dao.existsByPollVoteAccountId(uri.getPollId(), uri.getAccountId());
+
+ } catch (TopiaException e) {
+ throw new PollenTechnicalException(
+ "Could not check pollAccount existence from poll '" +
+ uri.getPollId() + "' and account '" + uri.getAccountId() + "'", e);
}
- return result;
}
+ private boolean isRestrictPollAccountId(PollAccountDAO dao, PollUri uri) {
+ try {
+
+ PollAccount result =
+ dao.getRestrictedPollAccount(uri.getPollId(), uri.getAccountId());
+
+ return result != null;
+
+ } catch (TopiaException e) {
+ throw new PollenTechnicalException(
+ "Could not check pollAccount existence from poll '" +
+ uri.getPollId() + "' and account '" + uri.getAccountId() + "'", e);
+ }
+ }
+
+// /**
+// * Vote is allowed if {@code poll} is running and {@code pollAccount} is
+// * defined in the {@code poll} restricted list if it's not a {@link PollType#FREE}
+// * poll. The account must be defined previously using
+// * {@link PollService#getPollAccountEditable(String, UserAccount, Poll)} to
+// * have a proper link between userAccount and pollAccount even if not already
+// * created in dabase. The poll creator can't vote. The token is just use
+// * for moderate purpose.
+// *
+// * @param poll Poll
+// * @param accountEditable Account to check
+// * @return true if vote is allowed, false otherwise
+// */
+// public boolean isVoteAllowed(Poll poll, PollAccount accountEditable) {
+//
+// Preconditions.checkNotNull(poll);
+// Preconditions.checkNotNull(accountEditable);
+//
+// Date now = serviceContext.getCurrentTime();
+//
+// boolean result;
+// if (poll.getCreator().equals(accountEditable)) {
+//
+// // The creator user can't vote
+// result = false;
+// } else {
+//
+// // The poll must be running and account allowed for restricted poll
+// result = poll.isRunning(now);
+// if (poll.getPollType() != PollType.FREE) {
+//
+// PersonToListDAO dao = getDAO(PersonToList.class);
+// PersonToList personToList =
+// dao.findByPollAndAccount(poll, accountEditable);
+//
+// result &= personToList != null;
+// }
+// }
+// return result;
+// }
+
+// public boolean isUpdateAllowed(Poll poll, String voteId,
+// String accountId, UserAccount userConnected) {
+//
+// Date now = serviceContext.getCurrentTime();
+//
+// boolean result = false;
+//
+// Vote vote = poll.getVoteByTopiaId(voteId);
+//
+// // can only modify a vote if poll is running.
+// if (vote != null && poll.isRunning(now)) {
+// PollAccount votePollAccount = vote.getPollAccount();
+//
+// // si le votant du vote correspond au votant actuel (pollAccountId)
+// if (accountId != null
+// && accountId.equals(votePollAccount.getAccountId())) {
+// result = true;
+// }
+//
+// // si l'utilisateur du vote correspond à l'utilisateur actuel (user)
+// if (userConnected != null) {
+// UserAccount voteUserAccount = votePollAccount.getUserAccount();
+// result = userConnected.equals(voteUserAccount);
+// }
+// }
+// return result;
+// }
+
+// public boolean isCanDeleteComment(Comment comment,
+// PollAccount pollAccount,
+// UserAccount userAccount,
+// boolean isPollCreator) {
+//
+// boolean result = false;
+//
+// PollAccount commentAccount = comment.getPollAccount();
+//
+// if (isPollCreator) {
+//
+// // poll creator has admin rights on his poll
+// result = true;
+// } else if (userAccount != null) {
+//
+// // loggued
+// boolean isAdmin = userAccount.isAdministrator();
+//// boolean isCommentAccount = userAccount.equals(commentAccount.getUserAccount());
+//
+// // pollen admin or comment owner (linked by user account)
+// result = isAdmin ||
+// userAccount.equals(commentAccount.getUserAccount());
+//
+// } else if (pollAccount != null) {
+//
+// // comment owner (linked by poll account)
+// result = pollAccount.equals(commentAccount);
+// }
+// return result;
+// }
+
}
Modified: trunk/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties
===================================================================
--- trunk/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties 2012-06-18 07:55:12 UTC (rev 3504)
+++ trunk/pollen-services/src/main/resources/i18n/pollen-services_en_GB.properties 2012-06-18 07:58:19 UTC (rev 3505)
@@ -44,6 +44,8 @@
pollen.feed.updateVoteTitle=Vote modified for '%s'
pollen.info.admin.created=Super admin was created with login %1$s
pollen.info.admin.exists=Super admin already exists
+pollen.security.error.poll.free.creatorId.can.not.vote=Using a creator Id does not allow you to vote.
pollen.security.error.poll.not.closed.and.results.not.continuous=The poll is not closed and results are not continuous
pollen.security.error.poll.not.free.and.access.not.granted=You can not access to this non free poll
+pollen.security.error.poll.not.running.can.not.vote=You can not vote (poll is finished or not began).
pollen.security.error.poll.result.private.and.access.not.granted=Results of the poll are private and you do not have credentials to see them
Modified: trunk/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties
===================================================================
--- trunk/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties 2012-06-18 07:55:12 UTC (rev 3504)
+++ trunk/pollen-services/src/main/resources/i18n/pollen-services_fr_FR.properties 2012-06-18 07:58:19 UTC (rev 3505)
@@ -44,6 +44,8 @@
pollen.feed.updateVoteTitle=Vote modifié de '%s'
pollen.info.admin.created=Le super admin a été créé avec l'identifiant %1$s.
pollen.info.admin.exists=Le super admin existe déjà
+pollen.security.error.poll.free.creatorId.can.not.vote=L'utlisation du creatorId ne permet de voter.
pollen.security.error.poll.not.closed.and.results.not.continuous=Vous n'avez pas accès aux résultats de ce sondage (résultats non continus et sondage non fermé)
pollen.security.error.poll.not.free.and.access.not.granted=Vous n'avez pas accès à ce sondage restreint
+pollen.security.error.poll.not.running.can.not.vote=Vous n'êtes pas autorisé à voter (sondage terminé ou pas encore commencé).
pollen.security.error.poll.result.private.and.access.not.granted=Vous n'avez pas accès aux résultats privés de ce sondage
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetPollComments.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetPollComments.java 2012-06-18 07:55:12 UTC (rev 3504)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/json/GetPollComments.java 2012-06-18 07:58:19 UTC (rev 3505)
@@ -112,7 +112,7 @@
Set<String> result = Sets.newHashSet();
//TODO-tchemit-2012-06-03 Should use also pollAccountId (if specified in url)...
boolean canDelete = getSecurityService().isCanDeleteComment(
- comment, null, userAccount, false);
+ comment, null, null, userAccount);
if (canDelete) {
result.add("delete");
}
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java 2012-06-18 07:55:12 UTC (rev 3504)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractVoteAction.java 2012-06-18 07:58:19 UTC (rev 3505)
@@ -27,6 +27,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts2.interceptor.ParameterAware;
+import org.apache.struts2.interceptor.ServletRequestAware;
import org.chorem.pollen.bean.PollResult;
import org.chorem.pollen.bean.PollResultList;
import org.chorem.pollen.business.persistence.Choice;
@@ -41,8 +42,11 @@
import org.chorem.pollen.common.VoteCountingType;
import org.chorem.pollen.services.exceptions.PollAccountNotFound;
import org.chorem.pollen.services.exceptions.PollNotFoundException;
+import org.chorem.pollen.services.impl.SecurityService;
import org.chorem.pollen.ui.actions.PageSkin;
+import org.chorem.pollen.ui.security.PollVoteAccessRequired;
+import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.List;
import java.util.Map;
@@ -54,7 +58,7 @@
* @author fdesbois <fdesbois(a)codelutin.com>
* @since 1.3
*/
-public abstract class AbstractVoteAction extends AbstractPollUriIdAction implements ParameterAware {
+public abstract class AbstractVoteAction extends AbstractPollUriIdAction implements ParameterAware, ServletRequestAware {
private static final long serialVersionUID = 1L;
@@ -141,6 +145,21 @@
*/
private Map<String, String[]> parameters;
+ /**
+ * The accountId role on this page.
+ *
+ * @since 1.4
+ */
+ private SecurityService.AccountIdRole accountIdRole;
+
+ /**
+ * The incoming request (some stuff are store in it from security filters).
+ *
+ * @since 1.4
+ */
+ private transient HttpServletRequest request;
+
+
@Override
public PageSkin getSkin() {
return PageSkin.VOTE;
@@ -151,6 +170,11 @@
this.parameters = parameters;
}
+ @Override
+ public void setServletRequest(HttpServletRequest request) {
+ this.request = request;
+ }
+
public Poll getPoll() {
return poll;
}
@@ -300,15 +324,14 @@
// TODO no pagination for the moment, need to retrieve the correct page depends on current pollAccount
votes = getVoteService().getAllVotes(poll);
- voteAllowed = !moderate && getSecurityService().isVoteAllowed(poll, pollAccount);
+ accountIdRole = (SecurityService.AccountIdRole)
+ request.getAttribute(PollVoteAccessRequired.ACCOUNT_ID_ROLE);
- if (voteAllowed) {
+ voteAllowed = !moderate &&
+ getSecurityService().isCanVote(poll,
+ getAccountId(),
+ accountIdRole);
- // can not vote if accountId from the url is the creator one
- voteAllowed = !poll.getCreator().getAccountId().equals(getUriId().getAccountId());
-
- }
-
// Current vote
if (voteAllowed) {
vote = getVoteService().getVoteEditable(poll, pollAccount);
@@ -319,18 +342,10 @@
feedFileExisting = getPollFeedService().isFeedExists(poll);
- PollAccount pollCreator = poll.getCreator();
- if (getPollenUserAccount() == null) {
+ creatorUser = getSecurityService().isPollCreator(poll,
+ getUriId(),
+ getPollenUserAccount());
- // User is creator if loaded pollAccount is the creator
- creatorUser = pollCreator.equals(pollAccount);
-
- } else {
-
- // User is creator if the userAccount is the same
- creatorUser = getPollenUserAccount().equals(pollCreator.getUserAccount());
- }
-
if (log.isInfoEnabled()) {
Date now = serviceContext.getCurrentTime();
log.info("pollChoiceOrVoteStarted = " + isPollChoiceOrVoteStarted());
@@ -375,8 +390,8 @@
return result;
}
- public boolean isModifAllowed(Vote vote) {
- return getSecurityService().isUpdateAllowed(
+ public boolean isModifyVoteAllowed(Vote vote) {
+ return getSecurityService().isCanModifyVote(
getPoll(),
vote.getTopiaId(),
getAccountId(),
@@ -390,14 +405,20 @@
public boolean isDeleteCommentAllowed(Comment comment) {
return getSecurityService().isCanDeleteComment(
comment,
- getPollAccount(),
- getPollenUserAccount(),
- isCreatorUser());
+ getUriId().getAccountId(),
+ accountIdRole,
+ getPollenUserAccount());
}
public boolean isDeleteVoteAllowed(Vote vote) {
- // can delete a vote if admin or poll creator
- return isUserAdmin() || isCreatorUser();
+ return getSecurityService().isCanDeleteVote(
+ getPoll(),
+ vote.getTopiaId(),
+ getUriId().getAccountId(),
+ accountIdRole,
+ getPollenUserAccount());
+// // can delete a vote if admin or poll creator
+// return isUserAdmin() || isCreatorUser();
}
public String escapeLineBreak(String text) {
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/SummaryPoll.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/SummaryPoll.java 2012-06-18 07:55:12 UTC (rev 3504)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/SummaryPoll.java 2012-06-18 07:58:19 UTC (rev 3505)
@@ -83,7 +83,7 @@
}
public boolean isCanShowResult() {
- String errorMessage = getSecurityService().isCanShowResult(
+ String errorMessage = getSecurityService().isCanAccessResult(
poll, SecurityService.AccountIdRole.CREATOR);
return errorMessage == null;
}
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/AbstractPollenAuthorization.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/AbstractPollenAuthorization.java 2012-06-18 07:55:12 UTC (rev 3504)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/AbstractPollenAuthorization.java 2012-06-18 07:58:19 UTC (rev 3505)
@@ -31,12 +31,12 @@
import org.apache.shiro.web.util.WebUtils;
import org.chorem.pollen.PollenApplicationContext;
import org.chorem.pollen.bean.PollUri;
+import org.chorem.pollen.business.persistence.Poll;
import org.chorem.pollen.business.persistence.UserAccount;
import org.chorem.pollen.services.DefaultPollenServiceContext;
import org.chorem.pollen.services.PollenServiceContext;
import org.chorem.pollen.services.PollenServiceFactory;
-import org.chorem.pollen.services.exceptions.PollNotFoundException;
-import org.chorem.pollen.services.impl.SecurityService;
+import org.chorem.pollen.services.impl.PollService;
import org.chorem.pollen.ui.PollenSession;
import org.chorem.pollen.ui.PollenUIUtils;
import org.nuiton.topia.TopiaContext;
@@ -107,20 +107,62 @@
return result;
}
- protected SecurityService getSecurityService(ServletRequest request) {
- PollenServiceContext serviceContext = getServiceContext(request);
-
- SecurityService securityService =
- serviceContext.newService(SecurityService.class);
- return securityService;
- }
-
protected UserAccount getPollenUserAccount(ServletRequest request) {
PollenSession pollenSession = PollenSession.get(request);
return pollenSession.getUserAccount();
}
+ protected Poll getPollIdSane(PollUri pollUri,
+ PollenServiceContext serviceContext,
+ ServletRequest request) {
+
+ Poll poll = null;
+ String errorMessage = null;
+ if (pollUri == null) {
+
+ // no pollUri in url
+ errorMessage = n_("pollen.security.error.no.pollId");
+
+ } else {
+
+ if (!pollUri.isPollIdNotBlank()) {
+
+ // no pollId in uri
+ errorMessage = n_("pollen.security.error.no.pollId");
+ } else {
+
+ // there is a pollId check that it exists
+
+ PollService pollService =
+ serviceContext.newService(PollService.class);
+
+ poll = pollService.getPollByPollId(pollUri.getPollId());
+
+ if (poll == null) {
+
+ // poll not found
+ errorMessage = n_("pollen.security.error.poll.not.found");
+ }
+
+ if (log.isDebugEnabled()) {
+ log.debug("Can access to this poll " +
+ pollUri.getPollId());
+ }
+
+ }
+ }
+
+ if (errorMessage != null) {
+
+ // something wrong happens
+ poll = null;
+ registerError(request, errorMessage);
+ }
+
+ return poll;
+ }
+
protected PollenServiceContext getServiceContext(ServletRequest request) {
PollenApplicationContext applicationContext =
PollenApplicationContext.get(getServletContext());
@@ -152,7 +194,6 @@
Map<String, String> params = Maps.newHashMap();
params.put("errorMessage", attribute);
WebUtils.issueRedirect(request, response, unauthorizedUrl, params);
-// request.removeAttribute(ERROR_MESSAGE_PARAMETER);
} else {
@@ -164,61 +205,6 @@
return false;
}
- protected boolean isPollIdSane(PollUri pollUri,
- SecurityService securityService,
- ServletRequest request) {
-
- String errorMessage = null;
- if (pollUri == null) {
-
- // no pollUri in url
- errorMessage = n_("pollen.security.error.no.pollId");
-
- } else {
-
- if (!pollUri.isPollIdNotBlank()) {
-
- // no pollId in uri
- errorMessage = n_("pollen.security.error.no.pollId");
- } else {
-
- // there is a pollId check that it exists
-
- try {
- securityService.checkPoll(pollUri);
-
- if (log.isDebugEnabled()) {
- log.debug("Can access to this poll " +
- pollUri.getPollId());
- }
-
- } catch (PollNotFoundException e) {
- if (log.isDebugEnabled()) {
- log.debug("Poll not found!");
- }
- errorMessage = n_("pollen.security.error.poll.not.found");
- }
- }
- }
- boolean isAccessAllowed;
-
- if (errorMessage == null) {
-
- // no error message seems ok
- isAccessAllowed = true;
-
- } else {
-
- // something wrong happens
- isAccessAllowed = false;
-
- registerError(request, errorMessage);
- }
-
- return isAccessAllowed;
- }
-
-
protected void registerError(ServletRequest request, String errorMessage) {
request.setAttribute(ERROR_MESSAGE_PARAMETER, errorMessage);
}
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/PollCreatorAccessRequired.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/PollCreatorAccessRequired.java 2012-06-18 07:55:12 UTC (rev 3504)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/PollCreatorAccessRequired.java 2012-06-18 07:58:19 UTC (rev 3505)
@@ -26,7 +26,6 @@
import org.chorem.pollen.business.persistence.Poll;
import org.chorem.pollen.business.persistence.UserAccount;
import org.chorem.pollen.services.PollenServiceContext;
-import org.chorem.pollen.services.impl.PollService;
import org.chorem.pollen.services.impl.SecurityService;
import javax.servlet.ServletRequest;
@@ -60,9 +59,11 @@
SecurityService securityService =
serviceContext.newService(SecurityService.class);
- // test that poll is sane
- boolean isAccessAllowed = isPollIdSane(pollUri, securityService, request);
+ // get sane poll
+ Poll poll = getPollIdSane(pollUri, serviceContext, request);
+ boolean isAccessAllowed = poll != null;
+
SecurityService.AccountIdRole accountIdRole =
SecurityService.AccountIdRole.UNDEFINED;
@@ -70,10 +71,6 @@
// pollId is sane (poll exists from it)
- // get it
- Poll poll = serviceContext.newService(PollService.class).getPollByPollId(
- pollUri.getPollId());
-
// test if user is admin
boolean isAdmin = adminFilter.isAccessAllowed(request,
response,
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/PollResultAccessRequired.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/PollResultAccessRequired.java 2012-06-18 07:55:12 UTC (rev 3504)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/PollResultAccessRequired.java 2012-06-18 07:58:19 UTC (rev 3505)
@@ -25,7 +25,6 @@
import org.chorem.pollen.bean.PollUri;
import org.chorem.pollen.business.persistence.Poll;
import org.chorem.pollen.services.PollenServiceContext;
-import org.chorem.pollen.services.impl.PollService;
import org.chorem.pollen.services.impl.SecurityService;
import javax.servlet.ServletRequest;
@@ -59,21 +58,16 @@
SecurityService securityService =
serviceContext.newService(SecurityService.class);
- // test that poll is sane
- boolean isAccessAllowed = isPollIdSane(pollUri, securityService, request);
+ // get sane poll
+ Poll poll = getPollIdSane(pollUri, serviceContext, request);
- Poll poll = null;
+ boolean isAccessAllowed = poll != null;
SecurityService.AccountIdRole accountIdRole = null;
if (isAccessAllowed) {
// pollId is sane (poll exists from it)
-
- // get it
- poll = serviceContext.newService(PollService.class).getPollByPollId(
- pollUri.getPollId());
-
// test if user is admin
boolean isAdmin = adminFilter.isAccessAllowed(request,
@@ -109,11 +103,11 @@
if (isAccessAllowed) {
// pollId is sane
- // accountId also
+ // accountId is sane
// check now poll results can be displayed
- String errorMessage = securityService.isCanShowResult(
+ String errorMessage = securityService.isCanAccessResult(
poll, accountIdRole);
if (errorMessage != null) {
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/PollVoteAccessRequired.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/PollVoteAccessRequired.java 2012-06-18 07:55:12 UTC (rev 3504)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/security/PollVoteAccessRequired.java 2012-06-18 07:58:19 UTC (rev 3505)
@@ -24,9 +24,7 @@
import org.chorem.pollen.bean.PollUri;
import org.chorem.pollen.business.persistence.Poll;
-import org.chorem.pollen.common.PollType;
import org.chorem.pollen.services.PollenServiceContext;
-import org.chorem.pollen.services.impl.PollService;
import org.chorem.pollen.services.impl.SecurityService;
import javax.servlet.ServletRequest;
@@ -42,6 +40,8 @@
*/
public class PollVoteAccessRequired extends AbstractPollenAuthorization {
+ public static final String ACCOUNT_ID_ROLE = "accountIdRole";
+
protected final AdminUserRequired adminFilter;
public PollVoteAccessRequired() {
@@ -60,11 +60,10 @@
SecurityService securityService =
serviceContext.newService(SecurityService.class);
- // test that poll is sane
- boolean isAccessAllowed = isPollIdSane(pollUri, securityService,
- request);
+ // get sane poll
+ final Poll poll = getPollIdSane(pollUri, serviceContext, request);
- Poll poll = null;
+ boolean isAccessAllowed = poll != null;
SecurityService.AccountIdRole accountIdRole = null;
@@ -72,10 +71,6 @@
// pollId is sane (poll exists from it)
- // get it
- poll = serviceContext.newService(PollService.class).getPollByPollId(
- pollUri.getPollId());
-
// test if user is admin
boolean isAdmin = adminFilter.isAccessAllowed(request,
response,
@@ -93,9 +88,8 @@
// bad account Id
isAccessAllowed = false;
- registerError(
- request,
- n_("pollen.security.error.bad.accountId"));
+ registerError(request,
+ n_("pollen.security.error.bad.accountId"));
}
}
@@ -109,23 +103,27 @@
if (isAccessAllowed) {
// pollId is sane
- // accountId also
+ // accountId is sane
// check now poll votes can be displayed
- boolean pollIsFree = PollType.FREE == poll.getPollType();
+ String errorMessage = securityService.isCanAccessVote(
+ poll, pollUri.getAccountId(), accountIdRole);
- if (!pollIsFree &&
- !SecurityService.NONE_FREE_ACCOUNT_ID_ROLES.contains(accountIdRole)) {
+ if (errorMessage != null) {
- // on none free poll, only creator or restricted user can have it
+ // can not vote
isAccessAllowed = false;
- registerError(
- request,
- n_("pollen.security.error.poll.not.free.and.access.not.granted"));
+ registerError(request, errorMessage);
}
}
+ if (isAccessAllowed) {
+
+ // store accountIdRole in request
+ request.setAttribute(ACCOUNT_ID_ROLE, accountIdRole);
+ }
+
return isAccessAllowed;
}
Modified: trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp
===================================================================
--- trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp 2012-06-18 07:55:12 UTC (rev 3504)
+++ trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/poll/vote.jsp 2012-06-18 07:58:19 UTC (rev 3505)
@@ -93,7 +93,7 @@
$votingIdField.attr('disabled', $anonymousField.prop('checked'));
- $anonymousField.change(function() {
+ $anonymousField.change(function () {
$votingIdField.attr('disabled', $(this).prop('checked'));
});
@@ -232,8 +232,7 @@
<s:if test="imageType">
<s:iterator value="poll.choice" var="choice">
<s:if test="!isChoiceHidden(#choice)">
- <s:url id="imageUrl" namespace="/io"
- action="getPollChoiceImage"
+ <s:url id="imageUrl" namespace="/io" action="getPollChoiceImage"
escapeAmp="false">
<s:param name="choiceId" value="name"/>
<s:param name="pollId" value="poll.pollId"/>
@@ -277,28 +276,24 @@
<s:if test="!isChoiceHidden(#choice)">
<th>
<s:if test="normalVoteCounting">
- <s:checkbox
- name="vote.choiceVoteToChoice[%{#status.index}].voteValue"
- value="%{vote.choiceVoteToChoice[#status.index].voteValue}"
- theme="simple"/>
+ <s:checkbox theme="simple"
+ name="vote.choiceVoteToChoice[%{#status.index}].voteValue"
+ value="%{vote.choiceVoteToChoice[#status.index].voteValue}"/>
</s:if>
<s:if test="percentageVoteCounting">
- <s:textfield
- name="vote.choiceVoteToChoice[%{#status.index}].voteValue"
- value="%{vote.choiceVoteToChoice[#status.index].voteValue}"
- required="true" size="3" theme="simple"/>
+ <s:textfield required="true" size="3" theme="simple"
+ name="vote.choiceVoteToChoice[%{#status.index}].voteValue"
+ value="%{vote.choiceVoteToChoice[#status.index].voteValue}"/>
</s:if>
<s:if test="condorcetVoteCounting">
- <s:textfield
- name="vote.choiceVoteToChoice[%{#status.index}].voteValue"
- value="%{vote.choiceVoteToChoice[#status.index].voteValue}"
- id="condorcetInput" size="3" theme="simple"/>
+ <s:textfield id="condorcetInput" size="3" theme="simple"
+ name="vote.choiceVoteToChoice[%{#status.index}].voteValue"
+ value="%{vote.choiceVoteToChoice[#status.index].voteValue}"/>
</s:if>
<s:if test="numberVoteCounting">
- <s:textfield
- name="vote.choiceVoteToChoice[%{#status.index}].voteValue"
- value="%{vote.choiceVoteToChoice[#status.index].voteValue}"
- size="3" theme="simple"/>
+ <s:textfield size="3" theme="simple"
+ name="vote.choiceVoteToChoice[%{#status.index}].voteValue"
+ value="%{vote.choiceVoteToChoice[#status.index].voteValue}"/>
</s:if>
</th>
</s:if>
@@ -320,7 +315,7 @@
</s:else>
</s:if>
<s:if test="!poll.anonymous">
- <s:if test="isModifAllowed(#vote)">
+ <s:if test="isModifyVoteAllowed(#vote)">
<s:a action="editVote" namespace="/poll">
<s:param name="pollId" value="%{pollId}"/>
<s:param name="accountId" value="%{#vote.pollAccount.accountId}"/>
@@ -418,7 +413,8 @@
<s:if test="voteAllowed">
<div id="buttons">
<s:if test="poll.anonymousVoteAllowed">
- <s:checkbox key="vote.anonymous" label='%{getText("pollen.common.voteAnonymous")}'/>
+ <s:checkbox key="vote.anonymous"
+ label='%{getText("pollen.common.voteAnonymous")}'/>
<br/>
</s:if>
<s:submit action="vote/%{uriId}" key="pollen.action.pollVote"
@@ -457,9 +453,10 @@
<s:textarea cols="36" key="choice.description"
label="%{getText('pollen.common.description')}"/>
<br/>
+
<div class="cleanBoth">
- <s:submit action="addChoice/%{uriId}" key="pollen.action.addChoice"
- align="center"/>
+ <s:submit action="addChoice/%{uriId}" key="pollen.action.addChoice"
+ align="center"/>
</div>
</s:form>
</div>
@@ -470,7 +467,7 @@
<div id="commentZone">
- <%--Show paginated comments--%>
+ <%--Show paginated comments--%>
<%@include file="displayPollComments.jsp" %>
<div id="commentFormDiv">
1
0
r3504 - in trunk/pollen-ui-struts2/src/main/webapp/WEB-INF: decorators jsp
by tchemit@users.chorem.org 18 Jun '12
by tchemit@users.chorem.org 18 Jun '12
18 Jun '12
Author: tchemit
Date: 2012-06-18 09:55:12 +0200 (Mon, 18 Jun 2012)
New Revision: 3504
Url: http://chorem.org/repositories/revision/pollen/3504
Log:
refs #618: Stay on same url for poll form
Modified:
trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/decorators/layout-default.jsp
trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/home.jsp
Modified: trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/decorators/layout-default.jsp
===================================================================
--- trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/decorators/layout-default.jsp 2012-06-18 07:54:54 UTC (rev 3503)
+++ trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/decorators/layout-default.jsp 2012-06-18 07:55:12 UTC (rev 3504)
@@ -190,7 +190,7 @@
<div class="top_left${pageLogo}"></div>
<ul class="top_middle${pageLogo}">
<li>
- <s:a action="create" namespace="/poll" method="input">
+ <s:a action="create" namespace="/poll">
<s:text name="pollen.menu.createPoll"/>
</s:a>
</li>
Modified: trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/home.jsp
===================================================================
--- trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/home.jsp 2012-06-18 07:54:54 UTC (rev 3503)
+++ trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/home.jsp 2012-06-18 07:55:12 UTC (rev 3504)
@@ -31,7 +31,7 @@
</div>
<div class="center">
- <s:a action="create" namespace="/poll" method="input">
+ <s:a action="create" namespace="/poll">
<img src="<s:url value='/img/smallCreation_%{safeLanguage}.png' />" alt="poll creation"/>
</s:a>
<img src="<s:url value='/img/smallVote_%{safeLanguage}.png' />" alt="vote"/>
1
0
18 Jun '12
Author: tchemit
Date: 2012-06-18 09:54:54 +0200 (Mon, 18 Jun 2012)
New Revision: 3503
Url: http://chorem.org/repositories/revision/pollen/3503
Log:
refs #618: Stay on same url for poll form
Modified:
trunk/pollen-ui-struts2/src/main/resources/config/struts-poll.xml
Modified: trunk/pollen-ui-struts2/src/main/resources/config/struts-poll.xml
===================================================================
--- trunk/pollen-ui-struts2/src/main/resources/config/struts-poll.xml 2012-06-18 07:54:19 UTC (rev 3502)
+++ trunk/pollen-ui-struts2/src/main/resources/config/struts-poll.xml 2012-06-18 07:54:54 UTC (rev 3503)
@@ -40,7 +40,8 @@
</result-types>
<!-- create poll -->
- <action name="create" class="org.chorem.pollen.ui.actions.poll.CreatePoll">
+ <action name="create" class="org.chorem.pollen.ui.actions.poll.CreatePoll"
+ method="execute">
<result name="input">/WEB-INF/jsp/poll/create.jsp</result>
<result type="pollenRedirectAction">
<param name="namespace">/poll</param>
@@ -49,7 +50,8 @@
</action>
<!-- edit poll -->
- <action name="edit/*" class="org.chorem.pollen.ui.actions.poll.EditPoll">
+ <action name="edit/*" class="org.chorem.pollen.ui.actions.poll.EditPoll"
+ method="execute">
<param name="uriId">{1}</param>
<result name="input">/WEB-INF/jsp/poll/create.jsp</result>
<result type="pollenRedirectAction">
@@ -59,7 +61,8 @@
</action>
<!-- clone poll -->
- <action name="clone/*" class="org.chorem.pollen.ui.actions.poll.ClonePoll">
+ <action name="clone/*" class="org.chorem.pollen.ui.actions.poll.ClonePoll"
+ method="execute">
<param name="uriId">{1}</param>
<result name="input">/WEB-INF/jsp/poll/create.jsp</result>
<result type="pollenRedirectAction">
1
0
r3502 - trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll
by tchemit@users.chorem.org 18 Jun '12
by tchemit@users.chorem.org 18 Jun '12
18 Jun '12
Author: tchemit
Date: 2012-06-18 09:54:19 +0200 (Mon, 18 Jun 2012)
New Revision: 3502
Url: http://chorem.org/repositories/revision/pollen/3502
Log:
refs #618: Stay on same url for poll form
Modified:
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollForm.java
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollForm.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollForm.java 2012-06-17 13:23:21 UTC (rev 3501)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/AbstractPollForm.java 2012-06-18 07:54:19 UTC (rev 3502)
@@ -37,6 +37,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts2.interceptor.ParameterAware;
+import org.apache.struts2.interceptor.ServletRequestAware;
import org.chorem.pollen.bean.PollDateChoice;
import org.chorem.pollen.bean.PollImageChoice;
import org.chorem.pollen.bean.PollUri;
@@ -65,6 +66,7 @@
import org.chorem.pollen.ui.converters.DateConverter;
import org.nuiton.util.StringUtil;
+import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.IOException;
import java.util.Collection;
@@ -82,7 +84,7 @@
* @author fdesbois <desbois(a)codelutin.com>
* $Id$
*/
-public abstract class AbstractPollForm extends PollenActionSupport implements Preparable, ParameterAware, FileUploadAware {
+public abstract class AbstractPollForm extends PollenActionSupport implements Preparable, ParameterAware, FileUploadAware, ServletRequestAware {
private static final long serialVersionUID = 1L;
@@ -188,6 +190,13 @@
private PollUri pollUri;
+ /**
+ * The incoming request (some stuff are store in it from security filters).
+ *
+ * @since 1.4
+ */
+ private transient HttpServletRequest request;
+
public abstract boolean isClone();
protected abstract Poll savePoll(Poll poll) throws PollNotFoundException;
@@ -195,82 +204,86 @@
public abstract boolean isEdit();
@Override
+ public void setServletRequest(HttpServletRequest request) {
+ this.request = request;
+ }
+
+ @Override
public void prepare() throws Exception {
prepareFormPage();
- if (parameters.containsKey("poll.title")) {
+ if (isGetMethod()) {
- if (log.isInfoEnabled()) {
- log.info("Starts prepare form...");
- }
+ // do not prepare when coming as GET
+ return;
+ }
- // we are after a submit
+ // we are after a submit
- String pollUid = getNonEmptyParameterValue("poll.pollId");
- String userId = getNonEmptyParameterValue("userId");
- if (StringUtils.isBlank(userId)) {
+ String pollUid = getNonEmptyParameterValue("poll.pollId");
+ String userId = getNonEmptyParameterValue("userId");
+ if (StringUtils.isBlank(userId)) {
- // try to take the one from current user
- UserAccount userAccount = getPollenUserAccount();
- if (userAccount != null) {
- userId = userAccount.getTopiaId();
- }
+ // try to take the one from current user
+ UserAccount userAccount = getPollenUserAccount();
+ if (userAccount != null) {
+ userId = userAccount.getTopiaId();
}
- UserAccount userAccount = null;
- if (StringUtils.isNotBlank(userId)) {
- // load use account to use
- userAccount = getPollService().getEntityById(
- UserAccount.class, userId);
- }
+ }
+ UserAccount userAccount = null;
+ if (StringUtils.isNotBlank(userId)) {
+ // load use account to use
+ userAccount = getPollService().getEntityById(
+ UserAccount.class, userId);
+ }
- // get a copy (or a fresh new poll)
- poll = getPollService().getPollEditable(pollUid, userAccount, false);
+ // get a copy (or a fresh new poll)
+ poll = getPollService().getPollEditable(pollUid, userAccount, false);
- // If vote is started, prepare choices and votingLists is useless
- // because they can't be updated.
- if (!isVoteStarted()) {
+ // If vote is started, prepare choices and votingLists is useless
+ // because they can't be updated.
+ if (!isVoteStarted()) {
- // Retrieve choiceType from parameters, the poll object will be updated after prepare
- String choiceTypeParam = getNonEmptyParameterValue("poll.choiceType");
- ChoiceType pollChoiceType = ChoiceType.valueOf(choiceTypeParam);
- poll.setChoiceType(pollChoiceType);
+ // Retrieve choiceType from parameters, the poll object will be updated after prepare
+ String choiceTypeParam = getNonEmptyParameterValue("poll.choiceType");
+ ChoiceType pollChoiceType = ChoiceType.valueOf(choiceTypeParam);
+ poll.setChoiceType(pollChoiceType);
- // build poll choices
+ // build poll choices
- switch (pollChoiceType) {
+ switch (pollChoiceType) {
- case TEXT:
- choices = buildTextChoices();
- break;
- case DATE:
- choices = buildDateChoices();
- break;
- case IMAGE:
- choices = buildImageChoices();
- break;
- }
- PollType pollType;
- String pollTypeParam = getNonEmptyParameterValue("poll.pollType");
- pollType = PollType.valueOf(pollTypeParam);
- switch (pollType) {
+ case TEXT:
+ choices = buildTextChoices();
+ break;
+ case DATE:
+ choices = buildDateChoices();
+ break;
+ case IMAGE:
+ choices = buildImageChoices();
+ break;
+ }
+ PollType pollType;
+ String pollTypeParam = getNonEmptyParameterValue("poll.pollType");
+ pollType = PollType.valueOf(pollTypeParam);
+ switch (pollType) {
- case FREE:
+ case FREE:
- // empty voting list
- votingLists = Maps.newTreeMap();
- break;
- case RESTRICTED:
+ // empty voting list
+ votingLists = Maps.newTreeMap();
+ break;
+ case RESTRICTED:
- // restricted voting list
- votingLists = buildVotingLists(pollType);
- break;
- case GROUP:
+ // restricted voting list
+ votingLists = buildVotingLists(pollType);
+ break;
+ case GROUP:
- // group voting lists
- votingLists = buildVotingLists(pollType);
- break;
- }
+ // group voting lists
+ votingLists = buildVotingLists(pollType);
+ break;
}
}
}
@@ -278,8 +291,6 @@
@Override
public String input() throws Exception {
- prepareFormPage();
-
UserAccount userAccount = getPollenUserAccount();
String pollUid = pollUri == null ? null : pollUri.getPollId();
PollService service = getPollService();
@@ -413,6 +424,12 @@
@InputConfig(methodName = "inputAfterValidationError")
public String execute() throws Exception {
+ if (isGetMethod()) {
+
+ // input method
+ return input();
+ }
+
// Save choices and votingLists only if vote is not started
if (!isVoteStarted()) {
//TODO-tchemit comment me 2012-06-04 A merge would be nicer but more complex to code
@@ -489,9 +506,18 @@
return SUCCESS;
}
+ protected boolean isGetMethod() {
+ return "GET".equalsIgnoreCase(request.getMethod());
+ }
+
@Override
public void validate() {
+ if (isGetMethod()) {
+
+ // input method
+ return;
+ }
validateInformations();
validateOptions();
1
0
r3501 - trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll
by tchemit@users.chorem.org 17 Jun '12
by tchemit@users.chorem.org 17 Jun '12
17 Jun '12
Author: tchemit
Date: 2012-06-17 15:23:21 +0200 (Sun, 17 Jun 2012)
New Revision: 3501
Url: http://chorem.org/repositories/revision/pollen/3501
Log:
fix svn properties = header
Modified:
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ClonePoll.java
trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/EditPoll.java
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ClonePoll.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ClonePoll.java 2012-06-17 13:22:40 UTC (rev 3500)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ClonePoll.java 2012-06-17 13:23:21 UTC (rev 3501)
@@ -1,8 +1,8 @@
/*
* #%L
* Pollen :: UI (struts2)
- * $Id: SavePoll.java 3467 2012-06-13 15:57:49Z tchemit $
- * $HeadURL: http://svn.chorem.org/svn/pollen/trunk/pollen-ui-struts2/src/main/java/org/… $
+ * $Id$
+ * $HeadURL$
* %%
* Copyright (C) 2009 - 2012 CodeLutin, Tony Chemit
* %%
Property changes on: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/ClonePoll.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/EditPoll.java
===================================================================
--- trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/EditPoll.java 2012-06-17 13:22:40 UTC (rev 3500)
+++ trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/EditPoll.java 2012-06-17 13:23:21 UTC (rev 3501)
@@ -1,8 +1,8 @@
/*
* #%L
* Pollen :: UI (struts2)
- * $Id: SavePoll.java 3467 2012-06-13 15:57:49Z tchemit $
- * $HeadURL: http://svn.chorem.org/svn/pollen/trunk/pollen-ui-struts2/src/main/java/org/… $
+ * $Id$
+ * $HeadURL$
* %%
* Copyright (C) 2009 - 2012 CodeLutin, Tony Chemit
* %%
Property changes on: trunk/pollen-ui-struts2/src/main/java/org/chorem/pollen/ui/actions/poll/EditPoll.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
1
0