Skip to content

Commit

Permalink
SAK-29632: Account validation forms for new users - '...the following…
Browse files Browse the repository at this point in the history
… site(s)' - determine plural on page load
  • Loading branch information
bbailla2 committed Jul 2, 2015
1 parent 9630543 commit d9c43cc
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ validate.acceptTerms=You must accept the terms and conditions.
validate.welcome1=Welcome to {0}!
validate.welcome1.reset=Reset your password in {0}
validate.welcome=You have been invited to join the following site(s) in {0}:
validate.welcome.single=You have been invited to join the following site in {0}:
validate.welcome.plural=You have been invited to join the following sites in {0}:
validate.welcome.reset=You have access to the following site(s) in {0}:
validate.welcome.request=To activate your new {0} account, please complete the form below.
validate.welcome2=A new account has been reserved for you with user ID {3}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,20 +117,10 @@ else if (sendLegacyLinksEnabled())
u.getDisplayId()
};

UIMessage.make(tofill, "welcome", "validate.welcome", args);
UIMessage.make(tofill, "welcome2", "validate.welcome2", args);
UIMessage.make(tofill, "username.new", "username.new");
UIOutput.make(tofill, "eid", u.getDisplayId());
UIMessage.make(tofill, "wait.1", "validate.wait.newUser.1", args);
String linkText = messageLocator.getMessage("validate.wait.newUser.2", args);
String transferMembershipsURL = getViewURL("transferMemberships", va);
UILink.make(tofill, "wait.2", linkText, transferMembershipsURL);
UIMessage.make(tofill, "validate.alreadyhave", "validate.alreadyhave", args);

//we need to know which sites they're a member of:
Set<String> groups = authzGroupService.getAuthzGroupsIsAllowed(EntityReference.getIdFromRef(va.getUserId()), "site.visit", null);
Iterator<String> git = groups.iterator();
List existingSites = new ArrayList();
List<String> existingSites = new ArrayList<>();
while (git.hasNext())
{
String groupRef = git.next();
Expand All @@ -152,6 +142,17 @@ else if (sendLegacyLinksEnabled())
}
}

String welcomeMessage = existingSites.size() == 1 ? "validate.welcome.single" : "validate.welcome.plural";
UIMessage.make(tofill, "welcome", welcomeMessage, args);
UIMessage.make(tofill, "welcome2", "validate.welcome2", args);
UIMessage.make(tofill, "username.new", "username.new");
UIOutput.make(tofill, "eid", u.getDisplayId());
UIMessage.make(tofill, "wait.1", "validate.wait.newUser.1", args);
String linkText = messageLocator.getMessage("validate.wait.newUser.2", args);
String transferMembershipsURL = getViewURL("transferMemberships", va);
UILink.make(tofill, "wait.2", linkText, transferMembershipsURL);
UIMessage.make(tofill, "validate.alreadyhave", "validate.alreadyhave", args);

//details form
UIForm detailsForm = UIForm.make(tofill, "setDetailsForm");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,16 +140,10 @@ else if (sendLegacyLinksEnabled())
String activationURL = getViewURL("newUser", va);
String linkText = messageLocator.getMessage("validate.wait.transfer.2", new Object[]{u.getDisplayId()});

UIMessage.make(tofill, "welcome", "validate.welcome", args);
UIMessage.make(tofill, "welcome2.1", "validate.wait.transfer.1", args);
UILink.make(tofill, "welcome2.2", linkText, activationURL);
UIMessage.make(tofill, "transferInstructions", "validate.loginexisting.transfer", args);
UIMessage.make(tofill, "validate.alreadyhave", "validate.alreadyhave", args);

//we need to know which sites they're a member of:
Set<String> groups = authzGroupService.getAuthzGroupsIsAllowed(EntityReference.getIdFromRef(va.getUserId()), "site.visit", null);
Iterator<String> git= groups.iterator();
List existingSites = new ArrayList();
List<String> existingSites = new ArrayList<>();
while (git.hasNext())
{
String groupRef = git.next();
Expand All @@ -171,6 +165,13 @@ else if (sendLegacyLinksEnabled())
}
}

String welcomeMessage = existingSites.size() == 1 ? "validate.welcome.single" : "validate.welcome.plural";
UIMessage.make(tofill, "welcome", welcomeMessage, args);
UIMessage.make(tofill, "welcome2.1", "validate.wait.transfer.1", args);
UILink.make(tofill, "welcome2.2", linkText, activationURL);
UIMessage.make(tofill, "transferInstructions", "validate.loginexisting.transfer", args);
UIMessage.make(tofill, "validate.alreadyhave", "validate.alreadyhave", args);

Object[] displayIdArgs = new Object[]{u.getDisplayId()};
UIForm claimForm = UIForm.make(tofill, "claimAccountForm");
UIMessage.make(claimForm, "validate.loginexisting", "validate.loginexisting.accountReserved", displayIdArgs);
Expand Down

0 comments on commit d9c43cc

Please sign in to comment.