Search in sources :

Example 6 with RepositoryEntryAllowToLeaveOptions

use of org.olat.repository.RepositoryEntryAllowToLeaveOptions in project openolat by klemens.

the class RepositoryAdminController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    FormLayoutContainer searchCont = FormLayoutContainer.createDefaultFormLayout("search", getTranslator());
    searchCont.setFormContextHelp("Modules: Repository");
    searchCont.setFormTitle(translate("repository.admin.title"));
    formLayout.add(searchCont);
    searchCont.setRootForm(mainForm);
    boolean searchEnabled = repositoryModule.isMyCoursesSearchEnabled();
    String[] values = new String[] { translate("on") };
    myCourseSearchEl = uifactory.addCheckboxesHorizontal("my.course.search.enabled", searchCont, keys, values);
    myCourseSearchEl.addActionListener(FormEvent.ONCHANGE);
    myCourseSearchEl.select(keys[0], searchEnabled);
    boolean commentEnabled = repositoryModule.isCommentEnabled();
    commentEl = uifactory.addCheckboxesHorizontal("my.course.comment.enabled", searchCont, keys, values);
    commentEl.addActionListener(FormEvent.ONCHANGE);
    commentEl.select(keys[0], commentEnabled);
    boolean ratingEnabled = repositoryModule.isRatingEnabled();
    ratingEl = uifactory.addCheckboxesHorizontal("my.course.rating.enabled", searchCont, keys, values);
    ratingEl.addActionListener(FormEvent.ONCHANGE);
    ratingEl.select(keys[0], ratingEnabled);
    FormLayoutContainer leaveCont = FormLayoutContainer.createDefaultFormLayout("leave", getTranslator());
    leaveCont.setFormTitle(translate("repository.admin.leave.title"));
    formLayout.add(leaveCont);
    leaveCont.setRootForm(mainForm);
    String[] leaveValues = new String[] { translate("rentry.leave.atanytime"), translate("rentry.leave.afterenddate"), translate("rentry.leave.never") };
    leaveEl = uifactory.addDropdownSingleselect("leave.courses", "repository.admin.leave.label", leaveCont, leaveKeys, leaveValues, null);
    leaveEl.addActionListener(FormEvent.ONCHANGE);
    RepositoryEntryAllowToLeaveOptions leaveOption = repositoryModule.getAllowToLeaveDefaultOption();
    if (leaveOption != null) {
        leaveEl.select(leaveOption.name(), true);
    } else {
        leaveEl.select(RepositoryEntryAllowToLeaveOptions.atAnyTime.name(), true);
    }
    lifecycleAdminCtrl = new RepositoryLifecycleAdminController(ureq, getWindowControl(), mainForm);
    listenTo(lifecycleAdminCtrl);
    formLayout.add(lifecycleAdminCtrl.getInitialFormItem());
}
Also used : RepositoryEntryAllowToLeaveOptions(org.olat.repository.RepositoryEntryAllowToLeaveOptions) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)

Example 7 with RepositoryEntryAllowToLeaveOptions

use of org.olat.repository.RepositoryEntryAllowToLeaveOptions in project openolat by klemens.

the class RepositoryServiceImpl method isParticipantAllowedToLeave.

@Override
public boolean isParticipantAllowedToLeave(RepositoryEntry re) {
    boolean allowed = false;
    RepositoryEntryAllowToLeaveOptions setting = re.getAllowToLeaveOption();
    if (setting == RepositoryEntryAllowToLeaveOptions.atAnyTime) {
        allowed = true;
    } else if (setting == RepositoryEntryAllowToLeaveOptions.afterEndDate) {
        RepositoryEntryLifecycle lifecycle = re.getLifecycle();
        if (lifecycle == null || lifecycle.getValidTo() == null) {
            allowed = false;
        } else {
            Calendar cal = Calendar.getInstance();
            cal.set(Calendar.HOUR, 0);
            cal.set(Calendar.MINUTE, 0);
            cal.set(Calendar.SECOND, 0);
            cal.set(Calendar.MILLISECOND, 0);
            Date now = cal.getTime();
            if (now.compareTo(lifecycle.getValidTo()) >= 0) {
                allowed = true;
            } else {
                allowed = false;
            }
        }
    } else {
        allowed = false;
    }
    return allowed;
}
Also used : RepositoryEntryLifecycle(org.olat.repository.model.RepositoryEntryLifecycle) Calendar(java.util.Calendar) RepositoryEntryAllowToLeaveOptions(org.olat.repository.RepositoryEntryAllowToLeaveOptions) Date(java.util.Date)

Example 8 with RepositoryEntryAllowToLeaveOptions

use of org.olat.repository.RepositoryEntryAllowToLeaveOptions in project openolat by klemens.

the class PublishStep01AccessForm method formOK.

@Override
protected void formOK(UserRequest ureq) {
    RepositoryEntryAllowToLeaveOptions setting;
    if (leaveEl.isOneSelected()) {
        setting = RepositoryEntryAllowToLeaveOptions.valueOf(leaveEl.getSelectedKey());
    } else {
        setting = RepositoryEntryAllowToLeaveOptions.atAnyTime;
    }
    boolean membersOnly = (usersSwitch.getSelectedKey().equals(YES_KEY) && publishedForUsers.getSelectedKey().equals(MEMBERSONLY_KEY));
    CourseAccessAndProperties accessProperties = new CourseAccessAndProperties(entry, setting, getAccess(), membersOnly, canCopy.isSelected(0), canReference.isSelected(0), canDownload.isSelected(0));
    accessProperties.setOfferAccess(offerAccess);
    accessProperties.setDeletedOfferAccess(deletedOfferAccess);
    if (confirmationEmailEl.isVisible()) {
        accessProperties.setConfirmationEmail(confirmationEmailEl.isAtLeastSelected(1));
    } else {
        accessProperties.setConfirmationEmail(null);
    }
    addToRunContext("accessAndProperties", accessProperties);
    fireEvent(ureq, StepsEvent.ACTIVATE_NEXT);
}
Also used : RepositoryEntryAllowToLeaveOptions(org.olat.repository.RepositoryEntryAllowToLeaveOptions)

Example 9 with RepositoryEntryAllowToLeaveOptions

use of org.olat.repository.RepositoryEntryAllowToLeaveOptions in project OpenOLAT by OpenOLAT.

the class AuthoringEditAllowToLeaveOptionController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    setFormTitle("rentry.leaving.title");
    String[] leaveValues = new String[] { translate("rentry.leave.atanytime"), translate("rentry.leave.afterenddate"), translate("rentry.leave.never") };
    final boolean managedLeaving = RepositoryEntryManagedFlag.isManaged(entry, RepositoryEntryManagedFlag.membersmanagement);
    leaveEl = uifactory.addDropdownSingleselect("entry.leave", "rentry.leave.option", formLayout, leaveKeys, leaveValues, null);
    boolean found = false;
    for (String leaveKey : leaveKeys) {
        if (leaveKey.equals(entry.getAllowToLeaveOption().name())) {
            leaveEl.select(leaveKey, true);
            found = true;
        }
    }
    if (!found) {
        if (managedLeaving) {
            leaveEl.select(RepositoryEntryAllowToLeaveOptions.never.name(), true);
        } else {
            RepositoryEntryAllowToLeaveOptions defaultOption = repositoryModule.getAllowToLeaveDefaultOption();
            leaveEl.select(defaultOption.name(), true);
        }
    }
    leaveEl.setEnabled(!managedLeaving);
    if (!managedLeaving) {
        uifactory.addFormSubmitButton("submit", formLayout);
    }
}
Also used : RepositoryEntryAllowToLeaveOptions(org.olat.repository.RepositoryEntryAllowToLeaveOptions)

Example 10 with RepositoryEntryAllowToLeaveOptions

use of org.olat.repository.RepositoryEntryAllowToLeaveOptions in project OpenOLAT by OpenOLAT.

the class PublishStep01AccessForm method formOK.

@Override
protected void formOK(UserRequest ureq) {
    RepositoryEntryAllowToLeaveOptions setting;
    if (leaveEl.isOneSelected()) {
        setting = RepositoryEntryAllowToLeaveOptions.valueOf(leaveEl.getSelectedKey());
    } else {
        setting = RepositoryEntryAllowToLeaveOptions.atAnyTime;
    }
    boolean membersOnly = (usersSwitch.getSelectedKey().equals(YES_KEY) && publishedForUsers.getSelectedKey().equals(MEMBERSONLY_KEY));
    CourseAccessAndProperties accessProperties = new CourseAccessAndProperties(entry, setting, getAccess(), membersOnly, canCopy.isSelected(0), canReference.isSelected(0), canDownload.isSelected(0));
    accessProperties.setOfferAccess(offerAccess);
    accessProperties.setDeletedOfferAccess(deletedOfferAccess);
    if (confirmationEmailEl.isVisible()) {
        accessProperties.setConfirmationEmail(confirmationEmailEl.isAtLeastSelected(1));
    } else {
        accessProperties.setConfirmationEmail(null);
    }
    addToRunContext("accessAndProperties", accessProperties);
    fireEvent(ureq, StepsEvent.ACTIVATE_NEXT);
}
Also used : RepositoryEntryAllowToLeaveOptions(org.olat.repository.RepositoryEntryAllowToLeaveOptions)

Aggregations

RepositoryEntryAllowToLeaveOptions (org.olat.repository.RepositoryEntryAllowToLeaveOptions)12 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)4 Calendar (java.util.Calendar)2 Date (java.util.Date)2 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)2 HelpTooltip (org.olat.core.gui.components.helpTooltip.HelpTooltip)2 MultiUserEvent (org.olat.core.util.event.MultiUserEvent)2 EntryChangedEvent (org.olat.repository.controllers.EntryChangedEvent)2 RepositoryEntryLifecycle (org.olat.repository.model.RepositoryEntryLifecycle)2 AccessMethodHandler (org.olat.resource.accesscontrol.method.AccessMethodHandler)2 AccessMethod (org.olat.resource.accesscontrol.model.AccessMethod)2