/**
   * Constructor for the course logs archive controller
   *
   * @param ureq
   * @param wControl
   * @param course
   */
  public CourseLogsArchiveController(
      UserRequest ureq, WindowControl wControl, OLATResourceable ores) {
    super(ureq, wControl);
    this.ores = ores;
    this.myPanel = new Panel("myPanel");
    myPanel.addListener(this);

    myContent = createVelocityContainer("start_courselogs");

    Identity identity = ureq.getIdentity();
    Roles roles = ureq.getUserSession().getRoles();

    RepositoryEntry re = RepositoryManager.getInstance().lookupRepositoryEntry(ores, false);
    boolean isOLATAdmin = ureq.getUserSession().getRoles().isOLATAdmin();
    boolean isOresOwner = RepositoryManager.getInstance().isOwnerOfRepositoryEntry(identity, re);
    boolean isOresInstitutionalManager =
        RepositoryManager.getInstance().isInstitutionalRessourceManagerFor(identity, roles, re);
    boolean aLogV = isOresOwner || isOresInstitutionalManager;
    boolean uLogV = isOLATAdmin;
    boolean sLogV = isOresOwner || isOresInstitutionalManager;

    if (AsyncExportManager.getInstance().asyncArchiveCourseLogOngoingFor(ureq.getIdentity())) {
      // then show the ongoing feedback
      showExportOngoing(false);
    } else if (isOLATAdmin || aLogV || uLogV || sLogV) {
      myContent.contextPut("hasLogArchiveAccess", true);
      logFileChooserForm = new LogFileChooserForm(ureq, wControl, isOLATAdmin, aLogV, uLogV, sLogV);
      listenTo(logFileChooserForm);
      myContent.put("logfilechooserform", logFileChooserForm.getInitialComponent());
      ICourse course = CourseFactory.loadCourse(ores);
      myContent.contextPut(
          "body", translate("course.logs.existingarchiveintro", course.getCourseTitle()));
      showFileButton = LinkFactory.createButton("showfile", myContent, this);
      File exportDir =
          CourseFactory.getDataExportDirectory(ureq.getIdentity(), course.getCourseTitle());
      boolean exportDirExists = false;
      if (exportDir != null && exportDir.exists() && exportDir.isDirectory()) {
        exportDirExists = true;
      }
      myContent.contextPut("hascourselogarchive", new Boolean(exportDirExists));
      myPanel.setContent(myContent);
    } else {
      myContent.contextPut("hasLogArchiveAccess", new Boolean(false));
      myPanel.setContent(myContent);
    }

    putInitialPanel(myPanel);
  }
  /**
   * @param ureq
   * @param wControl
   * @param cancelbutton
   */
  public ReadyToDeleteController(UserRequest ureq, WindowControl wControl) {

    super(ureq, wControl);

    Translator fallbackTrans =
        Util.createPackageTranslator(UserSearchController.class, ureq.getLocale());
    setTranslator(
        Util.createPackageTranslator(
            ReadyToDeleteController.class, ureq.getLocale(), fallbackTrans));
    //	use the PropertyHandlerTranslator	as tableCtr translator
    propertyHandlerTranslator =
        UserManager.getInstance().getPropertyHandlerTranslator(getTranslator());

    myContent = createVelocityContainer("panel");
    readyToDeletePanel = new Panel("readyToDeletePanel");
    readyToDeletePanel.addListener(this);
    myContent.put("panel", readyToDeletePanel);

    Roles roles = ureq.getUserSession().getRoles();
    isAdministrativeUser =
        CoreSpringFactory.getImpl(BaseSecurityModule.class).isUserAllowedAdminProps(roles);
    // (roles.isAuthor() || roles.isGroupManager() || roles.isUserManager() || roles.isOLATAdmin());

    initializeTableController(ureq);
    initializeContent();
    putInitialPanel(myContent);
  }
 /*
  * (non-Javadoc)
  * @see org.olat.core.gui.control.GuiStack#pushModalDialog(java.lang.String, org.olat.core.gui.components.Component)
  */
 @Override
 public void pushModalDialog(Component content) {
   // wrap the component into a modal foreground dialog with alpha-blended-background
   VelocityContainer inset =
       new VelocityContainer("simpleinset", VELOCITY_ROOT + "/simpleinset.html", null, null);
   inset.put("cont", content);
   contentPanel.pushContent(inset);
 }
 private void doStartPage(UserRequest ureq) {
   Controller startPageInner = new TUStartController(ureq, getWindowControl(), config);
   startPage =
       TitledWrapperHelper.getWrapper(
           ureq, getWindowControl(), startPageInner, courseNode, "o_tu_icon");
   listenTo(startPage);
   main.setContent(startPage.getInitialComponent());
 }
  public void event(UserRequest ureq, Controller source, Event event) {
    if (source == logFileChooserForm) {
      if (event == Event.DONE_EVENT) {
        final boolean logAdminChecked = logFileChooserForm.logAdminChecked();
        final boolean logUserChecked = logFileChooserForm.logUserChecked();
        final boolean logStatisticChecked = logFileChooserForm.logStatChecked();

        final Date begin = logFileChooserForm.getBeginDate();
        final Date end = logFileChooserForm.getEndDate();

        if (end != null) {
          // shift time from beginning to end of day
          end.setTime(end.getTime() + 24 * 60 * 60 * 1000);
        }

        UserManager um = UserManager.getInstance();
        final String charset = um.getUserCharset(ureq.getIdentity());

        ICourse course = CourseFactory.loadCourse(ores);
        final String courseTitle = course.getCourseTitle();
        final String targetDir =
            CourseFactory.getOrCreateDataExportDirectory(ureq.getIdentity(), courseTitle).getPath();

        final Long resId = ores.getResourceableId();
        final Locale theLocale = ureq.getLocale();
        final String email =
            ureq.getIdentity().getUser().getProperty(UserConstants.EMAIL, ureq.getLocale());

        AsyncExportManager.getInstance()
            .asyncArchiveCourseLogFiles(
                ureq.getIdentity(),
                new Runnable() {

                  @Override
                  public void run() {
                    showExportFinished();
                  }
                },
                resId,
                targetDir,
                begin,
                end,
                logAdminChecked,
                logUserChecked,
                logStatisticChecked,
                charset,
                theLocale,
                email);

        showExportOngoing(true);
      } else if (event == Event.DONE_EVENT) {
        myPanel.setContent(myContent);
      }
    }
  }
 private void initializeContent() {
   updateUserList();
   VelocityContainer readyToDeleteContent = createVelocityContainer("readyToDelete");
   readyToDeleteContent.put("readyToDelete", tableCtr.getInitialComponent());
   readyToDeleteContent.contextPut(
       "header",
       translate(
           "ready.to.delete.header",
           Integer.toString(UserDeletionManager.getInstance().getDeleteEmailDuration())));
   readyToDeletePanel.setContent(readyToDeleteContent);
 }
  private void showExportOngoing(final boolean thisCourse) {
    VelocityContainer vcOngoing = createVelocityContainer("courselogs_ongoing");
    if (thisCourse) {
      vcOngoing.contextPut("body", translate("course.logs.ongoing"));
    } else {
      // more generic message that makes also sense in other courses
      vcOngoing.contextPut("body", translate("course.logs.busy"));
    }
    myPanel.setContent(vcOngoing);

    // initialize polling
    // myPanel.put("updatecontrol", new JSAndCSSComponent("intervall", this.getClass(), 3000));
  }
  protected void showExportFinished() {
    ICourse course = CourseFactory.loadCourse(ores);
    VelocityContainer vcFeedback = createVelocityContainer("courselogs_feedback");
    showFileButton = LinkFactory.createButton("showfile", vcFeedback, this);
    vcFeedback.contextPut("body", translate("course.logs.feedback", course.getCourseTitle()));
    myPanel.setContent(vcFeedback);

    // note: polling can't be switched off unfortunatelly
    //       this is due to the fact that the jsandcsscomponent can only modify
    //       certain parts of the page and it would require a full page refresh
    //       to get rid of the poller - and that's not possible currently

    showInfo("course.logs.finished", course.getCourseTitle());
  }
  private void doLaunch(UserRequest ureq) {
    boolean iniframe = config.getBooleanSafe(TUConfigForm.CONFIG_IFRAME);
    // create the possibility to float
    CloneableController controller;
    if (iniframe) {
      // Do not dispose this controller if the course is closed...
      IframeTunnelController ifC = new IframeTunnelController(ureq, getWindowControl(), config);
      controller = ifC;
    } else {
      TunnelController tuC = new TunnelController(ureq, getWindowControl(), config);
      controller = tuC;
    }
    listenTo(controller);

    // create clone wrapper layout
    CloneLayoutControllerCreatorCallback clccc =
        new CloneLayoutControllerCreatorCallback() {
          public ControllerCreator createLayoutControllerCreator(
              UserRequest ureq, final ControllerCreator contentControllerCreator) {
            return BaseFullWebappPopupLayoutFactory.createAuthMinimalPopupLayout(
                ureq,
                new ControllerCreator() {
                  @SuppressWarnings("synthetic-access")
                  public Controller createController(UserRequest lureq, WindowControl lwControl) {
                    // wrapp in column layout, popup window needs a layout controller
                    Controller ctr = contentControllerCreator.createController(lureq, lwControl);
                    LayoutMain3ColsController layoutCtr =
                        new LayoutMain3ColsController(
                            lureq, lwControl, null, null, ctr.getInitialComponent(), null);
                    layoutCtr.setCustomCSS(
                        CourseFactory.getCustomCourseCss(lureq.getUserSession(), courseEnv));
                    layoutCtr.addDisposableChildController(ctr);
                    return layoutCtr;
                  }
                });
          }
        };

    Controller ctrl =
        TitledWrapperHelper.getWrapper(
            ureq, getWindowControl(), controller, courseNode, "o_tu_icon");
    if (ctrl instanceof CloneableController) {
      cloneC = new CloneController(ureq, getWindowControl(), (CloneableController) ctrl, clccc);
      listenTo(cloneC);
      main.setContent(cloneC.getInitialComponent());
    } else {
      throw new AssertException("Controller must be cloneable");
    }
  }
  /**
   * @param ureq
   * @param wControl
   * @param fallBackTranslator
   * @param tableDataModel => See class-description!
   * @param sortedItems
   */
  public PortletManualSortingConfigurator(
      UserRequest ureq,
      WindowControl wControl,
      Translator fallBackTranslator,
      PortletDefaultTableDataModel<T> tableDataModel,
      List<PortletEntry<T>> sortedItems) {
    super(ureq, wControl, fallBackTranslator);
    this.tableDataModel = tableDataModel;
    this.sortedItems = sortedItems; // select the items in table!!!

    mainVC = createVelocityContainer("manualSorting");
    tablePanel = new Panel("table");
    mainVC.put("table", tablePanel);

    TableGuiConfiguration tableConfig = new TableGuiConfiguration();
    tableConfig.setMultiSelect(true);
    tableConfig.setSortingEnabled(true);
    tableConfig.setTableEmptyMessage("manual.sorting.no.entries.found");
    tableController = new TableController(tableConfig, ureq, getWindowControl(), getTranslator());
    listenTo(tableController);
    int maxNumColumns = tableDataModel.getColumnCount();
    int columnCounter = 0;
    tableController.addColumnDescriptor(
        new DefaultColumnDescriptor(
            "table.manual.sorting.title", columnCounter++, null, getLocale()));
    if (maxNumColumns == 2) {
      tableController.addColumnDescriptor(
          new DefaultColumnDescriptor(
              "table.manual.sorting.date", columnCounter++, null, getLocale()));
    } else {
      DefaultColumnDescriptor descCol =
          new DefaultColumnDescriptor(
              "table.manual.sorting.description", columnCounter++, null, getLocale());
      descCol.setEscapeHtml(EscapeMode.antisamy);
      tableController.addColumnDescriptor(descCol);
    }
    if (maxNumColumns == 4) {
      tableController.addColumnDescriptor(
          new DefaultColumnDescriptor(
              "table.manual.sorting.type", columnCounter++, null, getLocale()));
    }
    tableController.addMultiSelectAction("action.choose", ACTION_MULTISELECT_CHOOSE);
    tableController.addMultiSelectAction("action.cancel", ACTION_MULTISELECT_CANCEL);
    tableController.setTableDataModel(tableDataModel);
    tablePanel.setContent(tableController.getInitialComponent());

    putInitialPanel(mainVC);
  }
 private void doEditNodeAssessment(UserRequest ureq, AssessableCourseNode courseNode) {
   if (mayEdit) {
     ICourse course = CourseFactory.loadCourse(ores);
     UserCourseInformationsManager userCourseInformationsManager =
         CoreSpringFactory.getImpl(UserCourseInformationsManager.class);
     Date initialLaunchDate =
         userCourseInformationsManager.getInitialLaunchDate(
             ores.getResourceableId(),
             assessedUserCourseEnvironment.getIdentityEnvironment().getIdentity());
     AssessedIdentityWrapper assessedIdentityWrapper =
         AssessmentHelper.wrapIdentity(
             assessedUserCourseEnvironment, initialLaunchDate, courseNode);
     assessmentEditCtr =
         new AssessmentEditController(
             ureq, getWindowControl(), stackPanel, course, courseNode, assessedIdentityWrapper);
     listenTo(assessmentEditCtr);
     main.setContent(assessmentEditCtr.getInitialComponent());
   } else {
     throw new OLATSecurityException(
         "doEditNodeAssessment() called but controller configured with mayEdit=false");
   }
 }
  private void doIdentityAssessmentOverview(UserRequest ureq, boolean initTable) {
    if (identityOverviewVC == null) {
      identityOverviewVC = createVelocityContainer("identityoverview");

      if (headers) {
        backLink = LinkFactory.createLinkBack(identityOverviewVC, this);
        Identity assessedIdentity =
            assessedUserCourseEnvironment.getIdentityEnvironment().getIdentity();
        identityOverviewVC.contextPut("user", assessedIdentity.getUser());
      }
    }
    if (initTable) {
      assessedUserCourseEnvironment.getScoreAccounting().evaluateAll();
      assessmentOverviewCtr =
          new IdentityAssessmentOverviewController(
              ureq, getWindowControl(), assessedUserCourseEnvironment, mayEdit, false, true);
      listenTo(assessmentOverviewCtr);
      identityOverviewVC.put(
          "assessmentOverviewTable", assessmentOverviewCtr.getInitialComponent());
    }
    main.setContent(identityOverviewVC);
  }
 /*
  * (non-Javadoc)
  * @see org.olat.core.gui.control.GuiStack#popContent()
  */
 @Override
 public void popContent() {
   contentPanel.popContent();
 }
 /*
  * (non-Javadoc)
  * @see org.olat.core.gui.control.GuiStack#pushContent(org.olat.core.gui.components.Component)
  */
 @Override
 public void pushContent(Component newContent) {
   contentPanel.pushContent(newContent);
 }
 public GuiStackSimpleImpl(Component initialComponent) {
   contentPanel = new Panel("simpleguistack");
   contentPanel.setContent(initialComponent);
 }