use of org.olat.repository.RepositoryEntryAllowToLeaveOptions in project OpenOLAT by OpenOLAT.
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());
}
use of org.olat.repository.RepositoryEntryAllowToLeaveOptions in project OpenOLAT by OpenOLAT.
the class AuthoringEditAccessController method event.
@Override
protected void event(UserRequest ureq, Controller source, Event event) {
if (source == propPupForm) {
if (event == Event.DONE_EVENT) {
// inform user about inconsistent configuration: doesn't make sense to set a repositoryEntry canReference=true if it is only accessible to owners
if (!entry.getCanReference() && propPupForm.canReference() && (propPupForm.getAccess() < RepositoryEntry.ACC_OWNERS_AUTHORS && !propPupForm.isMembersOnly())) {
showError("warn.config.reference.no.access");
}
int access = propPupForm.getAccess();
int numOfBookingConfigs = acCtr.getNumOfBookingConfigurations();
entry = repositoryManager.setAccessAndProperties(entry, access, propPupForm.isMembersOnly(), propPupForm.canCopy(), propPupForm.canReference(), propPupForm.canDownload());
if (entry == null) {
showWarning("repositoryentry.not.existing");
fireEvent(ureq, Event.CLOSE_EVENT);
} else {
boolean managedBookings = RepositoryEntryManagedFlag.isManaged(entry, RepositoryEntryManagedFlag.bookings);
if (access == RepositoryEntry.ACC_USERS || access == RepositoryEntry.ACC_USERS_GUESTS) {
if ((!managedBookings && acModule.isEnabled()) || numOfBookingConfigs > 0) {
editproptabpubVC.put("accesscontrol", acCtr.getInitialComponent());
editproptabpubVC.contextPut("isGuestAccess", Boolean.valueOf(access == RepositoryEntry.ACC_USERS_GUESTS));
}
} else {
editproptabpubVC.remove(acCtr.getInitialComponent());
}
// inform anybody interested about this change
MultiUserEvent modifiedEvent = new EntryChangedEvent(entry, getIdentity(), Change.modifiedAccess, "authoring");
CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(modifiedEvent, entry);
CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(modifiedEvent, RepositoryService.REPOSITORY_EVENT_ORES);
fireEvent(ureq, Event.CHANGED_EVENT);
}
}
} else if (source == leaveForm) {
if (event == Event.DONE_EVENT) {
RepositoryEntryAllowToLeaveOptions leaveSetting = leaveForm.getSelectedLeaveSetting();
entry = repositoryManager.setLeaveSetting(entry, leaveSetting);
if (entry == null) {
showWarning("repositoryentry.not.existing");
fireEvent(ureq, Event.CLOSE_EVENT);
} else {
MultiUserEvent modifiedEvent = new EntryChangedEvent(entry, getIdentity(), Change.modifiedAccess, "authorings");
CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(modifiedEvent, entry);
CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(modifiedEvent, RepositoryService.REPOSITORY_EVENT_ORES);
fireEvent(ureq, Event.CHANGED_EVENT);
}
}
} else if (acCtr == source) {
if (event == Event.CHANGED_EVENT) {
fireEvent(ureq, Event.CHANGED_EVENT);
}
}
}
use of org.olat.repository.RepositoryEntryAllowToLeaveOptions in project OpenOLAT by OpenOLAT.
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;
}
use of org.olat.repository.RepositoryEntryAllowToLeaveOptions in project openolat by klemens.
the class AuthoringEditAccessController method event.
@Override
protected void event(UserRequest ureq, Controller source, Event event) {
if (source == propPupForm) {
if (event == Event.DONE_EVENT) {
// inform user about inconsistent configuration: doesn't make sense to set a repositoryEntry canReference=true if it is only accessible to owners
if (!entry.getCanReference() && propPupForm.canReference() && (propPupForm.getAccess() < RepositoryEntry.ACC_OWNERS_AUTHORS && !propPupForm.isMembersOnly())) {
showError("warn.config.reference.no.access");
}
int access = propPupForm.getAccess();
int numOfBookingConfigs = acCtr.getNumOfBookingConfigurations();
entry = repositoryManager.setAccessAndProperties(entry, access, propPupForm.isMembersOnly(), propPupForm.canCopy(), propPupForm.canReference(), propPupForm.canDownload());
if (entry == null) {
showWarning("repositoryentry.not.existing");
fireEvent(ureq, Event.CLOSE_EVENT);
} else {
boolean managedBookings = RepositoryEntryManagedFlag.isManaged(entry, RepositoryEntryManagedFlag.bookings);
if (access == RepositoryEntry.ACC_USERS || access == RepositoryEntry.ACC_USERS_GUESTS) {
if ((!managedBookings && acModule.isEnabled()) || numOfBookingConfigs > 0) {
editproptabpubVC.put("accesscontrol", acCtr.getInitialComponent());
editproptabpubVC.contextPut("isGuestAccess", Boolean.valueOf(access == RepositoryEntry.ACC_USERS_GUESTS));
}
} else {
editproptabpubVC.remove(acCtr.getInitialComponent());
}
// inform anybody interested about this change
MultiUserEvent modifiedEvent = new EntryChangedEvent(entry, getIdentity(), Change.modifiedAccess, "authoring");
CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(modifiedEvent, entry);
CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(modifiedEvent, RepositoryService.REPOSITORY_EVENT_ORES);
fireEvent(ureq, Event.CHANGED_EVENT);
}
}
} else if (source == leaveForm) {
if (event == Event.DONE_EVENT) {
RepositoryEntryAllowToLeaveOptions leaveSetting = leaveForm.getSelectedLeaveSetting();
entry = repositoryManager.setLeaveSetting(entry, leaveSetting);
if (entry == null) {
showWarning("repositoryentry.not.existing");
fireEvent(ureq, Event.CLOSE_EVENT);
} else {
MultiUserEvent modifiedEvent = new EntryChangedEvent(entry, getIdentity(), Change.modifiedAccess, "authorings");
CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(modifiedEvent, entry);
CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(modifiedEvent, RepositoryService.REPOSITORY_EVENT_ORES);
fireEvent(ureq, Event.CHANGED_EVENT);
}
}
} else if (acCtr == source) {
if (event == Event.CHANGED_EVENT) {
fireEvent(ureq, Event.CHANGED_EVENT);
}
}
}
use of org.olat.repository.RepositoryEntryAllowToLeaveOptions in project openolat by klemens.
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);
}
}
Aggregations