public GoToMeetingController(
      UserRequest ureq,
      WindowControl wControl,
      GoToMeeting meeting,
      boolean administrator,
      boolean moderator,
      boolean readOnly) {
    super(ureq, wControl);
    this.readOnly = readOnly;
    this.moderator = moderator;
    this.administrator = administrator;

    mainVC = createVelocityContainer("meeting");
    mainVC.contextPut("title", meeting.getName());
    mainVC.contextPut("description", meeting.getDescription());

    if (administrator || moderator) {
      startLink = LinkFactory.createButtonLarge("training.start", mainVC, this);
      startLink.setTarget("_blank");
    }
    registerLink = LinkFactory.createButtonLarge("training.register", mainVC, this);
    confirmLink = LinkFactory.createButtonLarge("training.confirm", mainVC, this);
    confirmLink.setTarget("_blank");
    joinLink = LinkFactory.createButtonLarge("training.join", mainVC, this);
    joinLink.setTarget("_blank");

    openRecordingsLink = LinkFactory.createButton("recordings", mainVC, this);

    GoToError error = new GoToError();
    this.meeting = meetingMgr.getMeeting(meeting, error);
    this.registrant = meetingMgr.getRegistrant(meeting, getIdentity());
    if (error.hasError() && error.getError() != null) {
      mainVC.contextPut("errorMessage", translate(error.getError().i18nKey()));
    }

    List<GoToRecordingsG2T> recordings = meetingMgr.getRecordings(meeting, error);
    openRecordingsLink.setVisible(recordings != null && recordings.size() > 0);

    Date start = meeting.getStartDate();
    Date end = meeting.getEndDate();
    Formatter formatter = Formatter.getInstance(getLocale());
    mainVC.contextPut("start", formatter.formatDateAndTime(start));
    mainVC.contextPut("end", formatter.formatDateAndTime(end));

    putInitialPanel(mainVC);
    updateButtons();
  }
  private void updateButtons() {
    if (readOnly) {
      startLink.setVisible(false);
      registerLink.setVisible(false);
      confirmLink.setVisible(false);
      joinLink.setVisible(false);
    } else {
      Date start = meeting.getStartDate();
      Date end = meeting.getEndDate();
      Date now = new Date();
      boolean canStart = (start.compareTo(now) <= 0 && end.compareTo(now) > 0);

      Calendar cal = Calendar.getInstance();
      cal.setTime(start);
      cal.add(Calendar.MINUTE, -60);
      Date startMinusOne = cal.getTime();
      boolean canCoachStart = (startMinusOne.compareTo(now) <= 0 && end.compareTo(now) > 0);

      boolean ended = (end.compareTo(now) <= 0);
      if (administrator || moderator) {
        if (canCoachStart) {
          startLink.setVisible(true);
          registerLink.setVisible(false);
        } else if (ended) {
          startLink.setVisible(false);
          registerLink.setVisible(false);
        } else if (registrant == null) {
          startLink.setVisible(false);
          registerLink.setVisible(true);
        } else {
          startLink.setVisible(false);
          registerLink.setVisible(false);
        }
        confirmLink.setVisible(false);
        joinLink.setVisible(false);
      } else if (ended) {
        registerLink.setVisible(false);
        confirmLink.setVisible(false);
        joinLink.setVisible(false);
      } else if (canStart) {
        if (registrant == null) {
          registerLink.setVisible(false);
          confirmLink.setVisible(false);
          joinLink.setVisible(true);
        } else {
          registerLink.setVisible(false);
          confirmLink.setVisible(false);
          joinLink.setVisible(true);
        }
      } else {
        if (registrant == null) {
          registerLink.setVisible(true);
          confirmLink.setVisible(false);
          joinLink.setVisible(false);
        } else {
          registerLink.setVisible(false);
          confirmLink.setVisible(true);
          joinLink.setVisible(false);
        }
      }
    }
    mainVC.setDirty(true);
  }