Search in sources :

Example 71 with Translator

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;
}
Also used : Translator(org.olat.core.gui.translator.Translator)

Example 72 with Translator

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);
}
Also used : Locale(java.util.Locale) MailContextImpl(org.olat.core.util.mail.MailContextImpl) Translator(org.olat.core.gui.translator.Translator) MailContext(org.olat.core.util.mail.MailContext) MailBundle(org.olat.core.util.mail.MailBundle) ContextEntry(org.olat.core.id.context.ContextEntry)

Example 73 with Translator

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);
}
Also used : Assignment(org.olat.modules.portfolio.Assignment) PageRunControllerElement(org.olat.modules.portfolio.ui.editor.PageRunControllerElement) EvaluationFormPart(org.olat.modules.portfolio.model.EvaluationFormPart) PortfolioService(org.olat.modules.portfolio.PortfolioService) Translator(org.olat.core.gui.translator.Translator) MultiEvaluationFormController(org.olat.modules.portfolio.ui.MultiEvaluationFormController) Controller(org.olat.core.gui.control.Controller) EvaluationFormController(org.olat.modules.forms.ui.EvaluationFormController) PortfolioHomeController(org.olat.modules.portfolio.ui.PortfolioHomeController) PageBody(org.olat.modules.portfolio.PageBody)

Example 74 with Translator

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);
}
Also used : Translator(org.olat.core.gui.translator.Translator) ArrayList(java.util.ArrayList) FlexiTableColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel) DefaultFlexiColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler)

Example 75 with Translator

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;
}
Also used : Locale(java.util.Locale) MailContextImpl(org.olat.core.util.mail.MailContextImpl) MailContext(org.olat.core.util.mail.MailContext) Translator(org.olat.core.gui.translator.Translator) MailerResult(org.olat.core.util.mail.MailerResult) RepositoryEntry(org.olat.repository.RepositoryEntry) ContactList(org.olat.core.util.mail.ContactList) Identity(org.olat.core.id.Identity) MailBundle(org.olat.core.util.mail.MailBundle)

Aggregations

Translator (org.olat.core.gui.translator.Translator)586 Identity (org.olat.core.id.Identity)62 Date (java.util.Date)54 Controller (org.olat.core.gui.control.Controller)54 RepositoryEntry (org.olat.repository.RepositoryEntry)54 Locale (java.util.Locale)52 PackageTranslator (org.olat.core.gui.translator.PackageTranslator)46 ArrayList (java.util.ArrayList)40 TabbableController (org.olat.core.gui.control.generic.tabbable.TabbableController)40 NodeEditController (org.olat.course.editor.NodeEditController)40 TitleItem (org.olat.core.commons.services.notifications.model.TitleItem)36 Roles (org.olat.core.id.Roles)36 NodeRunConstructionResult (org.olat.course.run.navigation.NodeRunConstructionResult)36 SubscriptionListItem (org.olat.core.commons.services.notifications.model.SubscriptionListItem)32 Publisher (org.olat.core.commons.services.notifications.Publisher)30 SubscriptionInfo (org.olat.core.commons.services.notifications.SubscriptionInfo)30 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)30 MailBundle (org.olat.core.util.mail.MailBundle)28 ICourse (org.olat.course.ICourse)26 UserPropertyHandler (org.olat.user.propertyhandlers.UserPropertyHandler)26