use of org.olat.core.gui.translator.Translator in project OpenOLAT by OpenOLAT.
the class AuthenticationProvider method getLinktext.
/**
* [used by velocity]
* @param language
* @return Link text used to display a link to switch to this authentication provider.
*/
public String getLinktext(Locale locale) {
Translator trans = getPackageTranslatorForLocale(locale);
String text = trans.translate("authentication.provider.linkText");
return text;
}
use of org.olat.core.gui.translator.Translator in project OpenOLAT by OpenOLAT.
the class OLATAuthManager method sendConfirmationEmail.
private void sendConfirmationEmail(Identity doer, Identity identity) {
String prefsLanguage = identity.getUser().getPreferences().getLanguage();
Locale locale = I18nManager.getInstance().getLocaleOrDefault(prefsLanguage);
Translator translator = Util.createPackageTranslator(OLATAuthenticationController.class, locale);
ContextEntry ce = BusinessControlFactory.getInstance().createContextEntry(OresHelper.createOLATResourceableInstance("changepw", 0l));
String changePwUrl = BusinessControlFactory.getInstance().getAsURIString(Collections.singletonList(ce), false);
String[] args = new String[] { // 0: changed users username
identity.getName(), // 1: changed users email address
UserManager.getInstance().getUserDisplayEmail(identity, locale), // 2: Name (first and last name) of user who changed the password
userManager.getUserDisplayName(doer.getUser()), // 3: configured support email address
WebappHelper.getMailConfig("mailSupport"), // 4: direct link to change password workflow (e.g. https://xx.xx.xx/olat/url/changepw/0)
changePwUrl };
String subject = translator.translate("mail.pwd.subject", args);
String body = translator.translate("mail.pwd.body", args);
MailContext context = new MailContextImpl(null, null, "[Identity:" + identity.getKey() + "]");
MailBundle bundle = new MailBundle();
bundle.setContext(context);
bundle.setToId(identity);
bundle.setContent(subject, body);
mailManager.sendMessage(bundle);
}
use of org.olat.core.gui.translator.Translator in project OpenOLAT by OpenOLAT.
the class EvaluationFormHandler method getContent.
@Override
public PageRunElement getContent(UserRequest ureq, WindowControl wControl, PageElement element, PageElementRenderingHints hints) {
Controller ctrl = null;
if (element instanceof EvaluationFormPart) {
PortfolioService portfolioService = CoreSpringFactory.getImpl(PortfolioService.class);
// find assignment
EvaluationFormPart eva = (EvaluationFormPart) element;
PageBody body = eva.getBody();
Assignment assignment = portfolioService.getAssignment(body);
if (assignment == null) {
ctrl = getController(ureq, wControl, body, eva);
} else {
ctrl = getControllerForAssignment(ureq, wControl, body, assignment, hints.isOnePage());
}
}
if (ctrl == null) {
Translator translator = Util.createPackageTranslator(PortfolioHomeController.class, ureq.getLocale());
String title = translator.translate("warning.evaluation.not.visible.title");
String text = translator.translate("warning.evaluation.not.visible.text");
ctrl = MessageUIFactory.createWarnMessage(ureq, wControl, title, text);
}
return new PageRunControllerElement(ctrl);
}
use of org.olat.core.gui.translator.Translator in project OpenOLAT by OpenOLAT.
the class ImportAuthorOverviewIdentitiesController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
// add the table
FlexiTableColumnModel tableColumnModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
int colIndex = 0;
if (isAdministrativeUser) {
tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.user.login", colIndex++));
}
List<UserPropertyHandler> userPropertyHandlers = userManager.getUserPropertyHandlersFor(usageIdentifyer, isAdministrativeUser);
List<UserPropertyHandler> resultingPropertyHandlers = new ArrayList<UserPropertyHandler>();
// followed by the users fields
for (int i = 0; i < userPropertyHandlers.size(); i++) {
UserPropertyHandler userPropertyHandler = userPropertyHandlers.get(i);
boolean visible = UserManager.getInstance().isMandatoryUserProperty(usageIdentifyer, userPropertyHandler);
if (visible) {
resultingPropertyHandlers.add(userPropertyHandler);
tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel(userPropertyHandler.i18nColumnDescriptorLabelKey(), colIndex++));
}
}
Translator myTrans = userManager.getPropertyHandlerTranslator(getTranslator());
ImportAuthorOverviewDataModel userTableModel = new ImportAuthorOverviewDataModel(oks, resultingPropertyHandlers, isAdministrativeUser, getLocale(), tableColumnModel);
uifactory.addTableElement(getWindowControl(), "users", userTableModel, myTrans, formLayout);
}
use of org.olat.core.gui.translator.Translator in project OpenOLAT by OpenOLAT.
the class ReminderServiceImpl method sendReminder.
@Override
public MailerResult sendReminder(Reminder reminder, List<Identity> identitiesToRemind) {
RepositoryEntry entry = reminder.getEntry();
ContactList contactList = new ContactList("Infos");
contactList.addAllIdentites(identitiesToRemind);
MailContext context = new MailContextImpl("[RepositoryEntry:" + entry.getKey() + "]");
Locale locale = I18nModule.getDefaultLocale();
Translator trans = Util.createPackageTranslator(ReminderAdminController.class, locale);
String subject = reminder.getEmailSubject();
String body = reminder.getEmailBody();
if (body.contains("$courseurl")) {
body = body.replace("$courseurl", "<a href=\"$courseurl\">$courseurl</a>");
} else {
body = body + "<p>---<br />" + trans.translate("reminder.from.course", new String[] { "<a href=\"$courseurl\">$coursename</a>" }) + "</p>";
}
String metaId = UUID.randomUUID().toString();
String url = Settings.getServerContextPathURI() + "/url/RepositoryEntry/" + entry.getKey();
MailerResult overviewResult = new MailerResult();
ReminderTemplate template = new ReminderTemplate(subject, body, url, entry, locale);
for (Identity identityToRemind : identitiesToRemind) {
String status;
MailBundle bundle = mailManager.makeMailBundle(context, identityToRemind, template, null, metaId, overviewResult);
MailerResult result = mailManager.sendMessage(bundle);
overviewResult.append(result);
List<Identity> failedIdentities = result.getFailedIdentites();
if (failedIdentities != null && failedIdentities.contains(identityToRemind)) {
status = "error";
} else {
status = "ok";
}
reminderDao.markAsSend(reminder, identityToRemind, status);
}
return overviewResult;
}
Aggregations