Author: tchemit Date: 2012-08-24 17:47:45 +0200 (Fri, 24 Aug 2012) New Revision: 3627 Url: http://chorem.org/repositories/revision/pollen/3627 Log: refs #742: Option to allow all users to show voting of others users (improve help for VotePollVisibility) Modified: trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PollVoteVisibility.java trunk/pollen-persistence/src/main/resources/i18n/pollen-persistence_en_GB.properties trunk/pollen-persistence/src/main/resources/i18n/pollen-persistence_fr_FR.properties trunk/pollen-services/src/main/java/org/chorem/pollen/PollenUserSecurityContext.java trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/SecurityService.java Modified: trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PollVoteVisibility.java =================================================================== --- trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PollVoteVisibility.java 2012-08-24 15:46:34 UTC (rev 3626) +++ trunk/pollen-persistence/src/main/java/org/chorem/pollen/business/persistence/PollVoteVisibility.java 2012-08-24 15:47:45 UTC (rev 3627) @@ -39,18 +39,25 @@ * <p/> * This means every votes are anonymous. */ - NOBODY(n_("pollen.pollVoteVisibilty.nobody")), + NOBODY(n_("pollen.pollVoteVisibilty.nobody"), + n_("pollen.pollVoteVisibilty.nobody.help")), /** Only creator (or Pollen adin) can see votes. */ - CREATOR_ONLY(n_("pollen.pollVoteVisibilty.creatorOnly")), + CREATOR_ONLY(n_("pollen.pollVoteVisibilty.creatorOnly"), + n_("pollen.pollVoteVisibilty.creatorOnly.help")), /** Only participant of poll can see votes. */ - PARTICIPANT_ONLY(n_("pollen.pollVoteVisibilty.participantOnly")), + PARTICIPANT_ONLY(n_("pollen.pollVoteVisibilty.participantOnly"), + n_("pollen.pollVoteVisibilty.participantOnly.help")), /** Every body can see votes. */ - EVERYBODY(n_("pollen.pollVoteVisibilty.everybody")); + EVERYBODY(n_("pollen.pollVoteVisibilty.everybody"), + n_("pollen.pollVoteVisibilty.everybody.help")); private final String i18nKey; - PollVoteVisibility(String i18nKey) { + private final String i18nHelpKey; + + PollVoteVisibility(String i18nKey, String i18nHelpKey) { this.i18nKey = i18nKey; + this.i18nHelpKey = i18nHelpKey; } @Override @@ -58,6 +65,10 @@ return i18nKey; } + public String getI18nHelpKey() { + return i18nHelpKey; + } + public static PollVoteVisibility valueOf(int ordinal) { PollVoteVisibility result = null; Modified: trunk/pollen-persistence/src/main/resources/i18n/pollen-persistence_en_GB.properties =================================================================== --- trunk/pollen-persistence/src/main/resources/i18n/pollen-persistence_en_GB.properties 2012-08-24 15:46:34 UTC (rev 3626) +++ trunk/pollen-persistence/src/main/resources/i18n/pollen-persistence_en_GB.properties 2012-08-24 15:47:45 UTC (rev 3627) @@ -27,6 +27,10 @@ pollen.pollCommentVisibilty.everybody=Use comments on poll pollen.pollCommentVisibilty.nobody=No usage of comments on poll pollen.pollVoteVisibilty.creatorOnly=Visible for creator +pollen.pollVoteVisibilty.creatorOnly.help=On poll's creator or administrator can see votes pollen.pollVoteVisibilty.everybody=Public vote +pollen.pollVoteVisibilty.everybody.help=Everybody can see votes pollen.pollVoteVisibilty.nobody=Anonymous poll +pollen.pollVoteVisibilty.nobody.help=Poll is anonymous, nobody can see votes pollen.pollVoteVisibilty.participantOnly=Visible for participant +pollen.pollVoteVisibilty.participantOnly.help=Only poll's participants can see votes Modified: trunk/pollen-persistence/src/main/resources/i18n/pollen-persistence_fr_FR.properties =================================================================== --- trunk/pollen-persistence/src/main/resources/i18n/pollen-persistence_fr_FR.properties 2012-08-24 15:46:34 UTC (rev 3626) +++ trunk/pollen-persistence/src/main/resources/i18n/pollen-persistence_fr_FR.properties 2012-08-24 15:47:45 UTC (rev 3627) @@ -27,6 +27,10 @@ pollen.pollCommentVisibilty.everybody=Utiliser les commentaires pollen.pollCommentVisibilty.nobody=Interdir les commentaires sur le sondage pollen.pollVoteVisibilty.creatorOnly=Visible pour le créateur +pollen.pollVoteVisibilty.creatorOnly.help=Seule le créateur ou un administrateur peut voir les votes pollen.pollVoteVisibilty.everybody=Vote publique +pollen.pollVoteVisibilty.everybody.help=Tout le monde peut voir les votes pollen.pollVoteVisibilty.nobody=Sondage anonyme +pollen.pollVoteVisibilty.nobody.help=Le sondage est anonyme, personne ne peut voir les votes pollen.pollVoteVisibilty.participantOnly=Visible pour les participants +pollen.pollVoteVisibilty.participantOnly.help=Seul les participants du sondage peuvent voir les votes Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/PollenUserSecurityContext.java =================================================================== --- trunk/pollen-services/src/main/java/org/chorem/pollen/PollenUserSecurityContext.java 2012-08-24 15:46:34 UTC (rev 3626) +++ trunk/pollen-services/src/main/java/org/chorem/pollen/PollenUserSecurityContext.java 2012-08-24 15:47:45 UTC (rev 3627) @@ -174,6 +174,10 @@ } } + public boolean isConnected() { + return userAccount != null; + } + /** * To define a security role for a given pollen user which can be * identified by his user account or a accountId. 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-08-24 15:46:34 UTC (rev 3626) +++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/SecurityService.java 2012-08-24 15:47:45 UTC (rev 3627) @@ -408,7 +408,9 @@ break; case PARTICIPANT_ONLY: - if (userSecurityContext.isRestrictedVoter() || + if (userSecurityContext.isAdmin() || + userSecurityContext.isCreator() || + userSecurityContext.isRestrictedVoter() || userSecurityContext.isVoter()) { // only participant or voter can see votes result = allVotes; @@ -422,7 +424,38 @@ } if (result == null) { + + // no votes authorized + result = Lists.newArrayList(); + + if (!poll.isAnonymous() && userSecurityContext.isVoter()) { + + // but can still see his own vote + + if (userSecurityContext.isWithAccountId()) { + + // find back his vote by accountId + String accountId = userSecurityContext.getAccountId(); + for (Vote vote : allVotes) { + if (accountId.equals(vote.getPollAccount().getAccountId())) { + result.add(vote); + break; + } + } + } else { + + // user is connected, find back his vote by userAccount + UserAccount userAccount = userSecurityContext.getUserAccount(); + for (Vote vote : allVotes) { + if (userAccount.equals(vote.getPollAccount().getUserAccount())) { + result.add(vote); + break; + } + } + } + + } } return result; }