use of org.olat.modules.reminder.model.ReminderRules in project openolat by klemens.
the class CourseReminderEditController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
FormLayoutContainer generalCont = FormLayoutContainer.createVerticalFormLayout("general", getTranslator());
generalCont.setRootForm(mainForm);
generalCont.setFormContextHelp("Course Reminders");
formLayout.add(generalCont);
String key = reminder.getKey() == null ? "" : reminder.getKey().toString();
uifactory.addStaticTextElement("reminder.id", key, generalCont);
String desc = reminder.getDescription();
descriptionEl = uifactory.addTextElement("reminder.description", "reminder.description", 128, desc, generalCont);
descriptionEl.setMandatory(true);
descriptionEl.setElementCssClass("o_sel_course_reminder_desc");
String sendTime = getSendTimeDescription();
uifactory.addStaticTextElement("send.time.description.label", sendTime, generalCont);
// rules
String rulePage = velocity_root + "/edit_rules.html";
rulesCont = FormLayoutContainer.createCustomFormLayout("rules", getTranslator(), rulePage);
rulesCont.setRootForm(mainForm);
formLayout.add(rulesCont);
rulesCont.contextPut("rules", ruleEls);
String configuration = reminder.getConfiguration();
if (StringHelper.containsNonWhitespace(configuration)) {
ReminderRules rules = reminderManager.toRules(configuration);
if (rules.getRules() != null) {
for (ReminderRule rule : rules.getRules()) {
if (rule != null) {
RuleSPI ruleSpy = reminderModule.getRuleSPIByType(rule.getType());
RuleElement ruleEl = initRuleForm(ureq, ruleSpy, rule);
ruleEls.add(ruleEl);
}
}
}
}
if (ruleEls.isEmpty()) {
doInitDefaultRule(ureq);
}
// email content
FormLayoutContainer contentCont = FormLayoutContainer.createVerticalFormLayout("contents", getTranslator());
contentCont.setRootForm(mainForm);
formLayout.add(contentCont);
// email subject
String subject = reminder.getEmailSubject();
subjectEl = uifactory.addTextElement("reminder.subject", "reminder.subject", 128, subject, contentCont);
subjectEl.setMandatory(true);
subjectEl.setElementCssClass("o_sel_course_reminder_subject");
String emailContent = reminder == null ? null : reminder.getEmailBody();
if (!StringHelper.containsNonWhitespace(emailContent)) {
emailContent = translate("reminder.def.body");
}
emailEl = uifactory.addRichTextElementForStringDataMinimalistic("email.content", "email.content", emailContent, 10, 60, contentCont, getWindowControl());
emailEl.setMandatory(true);
String buttonPage = velocity_root + "/edit_rules_buttons.html";
FormLayoutContainer buttonLayout = FormLayoutContainer.createCustomFormLayout("buttons", getTranslator(), buttonPage);
buttonLayout.setRootForm(mainForm);
formLayout.add(buttonLayout);
uifactory.addFormSubmitButton("save", buttonLayout);
uifactory.addFormCancelButton("cancel", buttonLayout, ureq, getWindowControl());
}
use of org.olat.modules.reminder.model.ReminderRules in project openolat by klemens.
the class CourseReminderEditController method formOK.
@Override
protected void formOK(UserRequest ureq) {
String description = descriptionEl.getValue();
reminder.setDescription(description);
ReminderRules rules = new ReminderRules();
for (RuleElement ruleEl : ruleEls) {
ReminderRule rule = ruleEl.getEditor().getConfiguration();
if (rule != null) {
rules.getRules().add(rule);
}
}
String configuration = reminderManager.toXML(rules);
reminder.setConfiguration(configuration);
String emailSubject = subjectEl.getValue();
reminder.setEmailSubject(emailSubject);
String emailBody = emailEl.getValue();
reminder.setEmailBody(emailBody);
reminder = reminderManager.save(reminder);
fireEvent(ureq, Event.DONE_EVENT);
}
Aggregations