use of org.olat.resource.accesscontrol.method.AccessMethodHandler in project OpenOLAT by OpenOLAT.
the class AccessConfigurationController method addMethod.
protected void addMethod(UserRequest ureq, AccessMethod method) {
boolean confirmationEmail = confirmationEmailEl.isVisible() && confirmationEmailEl.isAtLeastSelected(1);
Offer offer = acService.createOffer(resource, displayName);
offer.setConfirmationEmail(confirmationEmail);
OfferAccess link = acService.createOfferAccess(offer, method);
removeAsListenerAndDispose(newMethodCtrl);
AccessMethodHandler handler = acModule.getAccessMethodHandler(link.getMethod().getType());
if (handler != null) {
newMethodCtrl = handler.createConfigurationController(ureq, getWindowControl(), link);
}
if (newMethodCtrl != null) {
listenTo(newMethodCtrl);
String title = handler.getMethodName(getLocale());
cmc = new CloseableModalController(getWindowControl(), translate("close"), newMethodCtrl.getInitialComponent(), true, title);
cmc.activate();
listenTo(cmc);
} else {
OfferAccess newLink = acService.saveOfferAccess(link);
addConfiguration(newLink);
}
}
use of org.olat.resource.accesscontrol.method.AccessMethodHandler in project OpenOLAT by OpenOLAT.
the class AccessConfigurationController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
// contextHelptexts for Label
HelpTooltip acMethodsLabelHelp = new HelpTooltip("acMethodsLabelHelp", "Legen Sie fest unter welchen Bedingungen Benutzer diese Ressource buchen können.", "Course Settings#_buchungsmethode", getLocale());
((FormLayoutContainer) formLayout).put("acMethodsLabelHelp", acMethodsLabelHelp);
if (editable) {
List<AccessMethod> methods = acService.getAvailableMethods(getIdentity(), ureq.getUserSession().getRoles());
for (AccessMethod method : methods) {
AccessMethodHandler handler = acModule.getAccessMethodHandler(method.getType());
if (handler.isPaymentMethod() && !allowPaymentMethod) {
continue;
}
String title = handler.getMethodName(getLocale());
FormLink add = uifactory.addFormLink("create." + handler.getType(), title, null, formLayout, Link.LINK | Link.NONTRANSLATED);
add.setUserObject(method);
add.setIconLeftCSS(("o_icon " + method.getMethodCssClass() + "_icon o_icon-lg").intern());
addMethods.add(add);
formLayout.add(add.getName(), add);
}
((FormLayoutContainer) formLayout).contextPut("methods", addMethods);
}
String[] onValues = new String[] { "" };
confirmationEmailEl = uifactory.addCheckboxesHorizontal("confirmation.email", formLayout, onKeys, onValues);
confirmationEmailEl.addActionListener(FormEvent.ONCHANGE);
confirmationEmailEl.setVisible(false);
String confPage = velocity_root + "/configuration_list.html";
confControllerContainer = FormLayoutContainer.createCustomFormLayout("conf-controllers", getTranslator(), confPage);
confControllerContainer.setRootForm(mainForm);
formLayout.add(confControllerContainer);
loadConfigurations();
confControllerContainer.contextPut("confControllers", confControllers);
boolean confirmationEmail = false;
for (AccessInfo info : confControllers) {
Offer offer = info.getLink().getOffer();
confirmationEmail |= offer.isConfirmationEmail();
}
if (confirmationEmail) {
confirmationEmailEl.select(onKeys[0], true);
}
if (!embbed) {
setFormTitle("accesscontrol.title");
if (editable) {
final FormLayoutContainer buttonGroupLayout = FormLayoutContainer.createButtonLayout("buttonLayout", getTranslator());
buttonGroupLayout.setRootForm(mainForm);
formLayout.add(buttonGroupLayout);
formLayout.add("buttonLayout", buttonGroupLayout);
uifactory.addFormSubmitButton("save", buttonGroupLayout);
}
}
confControllerContainer.contextPut("emptyConfigGrantsFullAccess", Boolean.valueOf(emptyConfigGrantsFullAccess));
}
use of org.olat.resource.accesscontrol.method.AccessMethodHandler in project OpenOLAT by OpenOLAT.
the class TransactionDetailsController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
String page = velocity_root + "/transaction_details.html";
FormLayoutContainer detailsLayout = FormLayoutContainer.createCustomFormLayout("transaction-details-layout", getTranslator(), page);
formLayout.add(detailsLayout);
detailsLayout.setRootForm(mainForm);
AccessTransaction transaction = wrapper.getTransaction();
DetailsForm detailsForm = new DetailsForm(ureq, getWindowControl(), transaction, mainForm);
detailsLayout.add("simple", detailsForm.getInitialFormItem());
AccessMethod method = transaction.getMethod();
AccessMethodHandler handler = acModule.getAccessMethodHandler(method.getType());
FormController controller = handler.createTransactionDetailsController(ureq, getWindowControl(), order, wrapper.getPart(), method, mainForm);
if (controller != null) {
uifactory.addSpacerElement("details-spacer", detailsLayout, false);
detailsLayout.add("custom", controller.getInitialFormItem());
}
}
use of org.olat.resource.accesscontrol.method.AccessMethodHandler in project OpenOLAT by OpenOLAT.
the class AuthoringEntryDataSource method processViewModel.
private List<AuthoringEntryRow> processViewModel(List<RepositoryEntryAuthorView> repoEntries) {
Set<String> newNames = new HashSet<>();
List<OLATResource> resourcesWithAC = new ArrayList<>(repoEntries.size());
for (RepositoryEntryAuthorView entry : repoEntries) {
if (entry.isOfferAvailable()) {
resourcesWithAC.add(entry.getOlatResource());
}
final String author = entry.getAuthor();
if (StringHelper.containsNonWhitespace(author)) {
newNames.add(author);
}
}
Map<String, String> fullNames = userManager.getUserDisplayNamesByUserName(newNames);
List<OLATResourceAccess> resourcesWithOffer = acService.filterResourceWithAC(resourcesWithAC);
Collection<OLATResourceable> resources = repoEntries.stream().map(RepositoryEntryAuthorView::getOlatResource).collect(Collectors.toList());
List<ResourceLicense> licenses = licenseService.loadLicenses(resources);
List<AuthoringEntryRow> items = new ArrayList<>();
for (RepositoryEntryAuthorView entry : repoEntries) {
String fullname = fullNames.get(entry.getAuthor());
if (fullname == null) {
fullname = entry.getAuthor();
}
AuthoringEntryRow row = new AuthoringEntryRow(entry, fullname);
// bookmark
row.setMarked(entry.isMarked());
// access control
List<PriceMethod> types = new ArrayList<>();
if (entry.isMembersOnly()) {
// members only always show lock icon
types.add(new PriceMethod("", "o_ac_membersonly_icon", uifactory.getTranslator().translate("cif.access.membersonly.short")));
} else {
// collect access control method icons
OLATResource resource = entry.getOlatResource();
for (OLATResourceAccess resourceAccess : resourcesWithOffer) {
if (resource.getKey().equals(resourceAccess.getResource().getKey())) {
for (PriceMethodBundle bundle : resourceAccess.getMethods()) {
String type = (bundle.getMethod().getMethodCssClass() + "_icon").intern();
String price = bundle.getPrice() == null || bundle.getPrice().isEmpty() ? "" : PriceFormat.fullFormat(bundle.getPrice());
AccessMethodHandler amh = acModule.getAccessMethodHandler(bundle.getMethod().getType());
String displayName = amh.getMethodName(uifactory.getTranslator().getLocale());
types.add(new PriceMethod(price, type, displayName));
}
}
}
}
if (!types.isEmpty()) {
row.setAccessTypes(types);
}
// license
for (ResourceLicense license : licenses) {
OLATResource resource = entry.getOlatResource();
if (license.getResId().equals(resource.getResourceableId()) && license.getResName().equals(resource.getResourceableTypeName())) {
row.setLicense(license);
}
}
uifactory.forgeLinks(row);
items.add(row);
}
return items;
}
use of org.olat.resource.accesscontrol.method.AccessMethodHandler in project OpenOLAT by OpenOLAT.
the class PublishStep01AccessForm method editMethod.
private void editMethod(UserRequest ureq, AccessInfo infos) {
OfferAccess link = infos.getLink();
removeAsListenerAndDispose(editMethodCtrl);
AccessMethodHandler methodHandler = acModule.getAccessMethodHandler(link.getMethod().getType());
if (methodHandler != null) {
editMethodCtrl = methodHandler.editConfigurationController(ureq, getWindowControl(), link);
}
if (editMethodCtrl != null) {
listenTo(editMethodCtrl);
String title = methodHandler.getMethodName(getLocale());
cmc = new CloseableModalController(getWindowControl(), translate("close"), editMethodCtrl.getInitialComponent(), true, title);
cmc.activate();
listenTo(cmc);
}
}
Aggregations