public ConfirmEmailLandingPanel(
      String id,
      PageContext context,
      PhetUser user,
      String destination,
      boolean wasPreviouslyConfirmed,
      boolean changedEmail) {
    super(id, context);

    if (changedEmail) {
      add(new LocalizedText("now-subscribed", "newsletter.emailChanged"));
      add(new InvisibleComponent("redirector"));
      add(new InvisibleComponent("now-registered"));
      destination = null;
      PhetSession.get().signOut();
    } else if (user.isNewsletterOnlyAccount() || wasPreviouslyConfirmed) {
      add(new LocalizedText("now-subscribed", "newsletter.nowSubscribed"));
      add(new InvisibleComponent("redirector"));
      add(new InvisibleComponent("now-registered"));
    } else {
      add(new InvisibleComponent("now-subscribed"));

      if (destination != null) {
        Label redirector = new Label("redirector", "");
        redirector.add(
            new AttributeModifier(
                "content",
                true,
                new Model<String>(REDIRECTION_DELAY_SECONDS + ";url=" + destination)));
        add(redirector);
      } else {
        add(new InvisibleComponent("redirector"));
      }

      add(new LocalizedText("now-registered", "newsletter.nowRegistered"));
    }

    if (destination != null) {
      add(new LocalizedText("redirection", "newsletter.redirection"));
    } else {
      add(new InvisibleComponent("redirection"));
    }
  }
Esempio n. 2
0
  public ConfirmEmailSentPanel(String id, PageContext context, PhetUser user) {
    super(id, context);

    // if the user is changing their email
    if (user.getNewEmail() != null) {
      add(
          new LocalizedText(
              "toFinish",
              "newsletter.toFinishChangingEmail",
              new Object[] {HtmlUtils.encode(user.getNewEmail())}));
      add(new LocalizedText("pleaseCheck", "newsletter.pleaseCheckChangingEmail"));
    }

    // show them the "newsletter" option if they are newsletter-only, OR if they are already
    // registered and confirmed.
    else if (user.isNewsletterOnlyAccount() || user.isConfirmed()) {
      add(
          new LocalizedText(
              "toFinish",
              "newsletter.toFinishSubscribing",
              new Object[] {HtmlUtils.encode(user.getEmail())}));
      add(new LocalizedText("pleaseCheck", "newsletter.pleaseCheckSubscribing"));
    } else {
      add(
          new LocalizedText(
              "toFinish",
              "newsletter.toFinishRegistering",
              new Object[] {HtmlUtils.encode(user.getEmail())}));
      add(new LocalizedText("pleaseCheck", "newsletter.pleaseCheckRegistering"));
    }

    add(
        new LocalizedText(
            "trouble",
            "newsletter.troubleshooting",
            new Object[] {
              "<a href=\"mailto:"
                  + WebsiteConstants.HELP_EMAIL
                  + "\">"
                  + WebsiteConstants.HELP_EMAIL
                  + "</a>" // TODO: factor out somewhere
            }));
  }