use of org.olat.user.UserManager in project OpenOLAT by OpenOLAT.
the class ListRenderer method render.
/**
* Render contents of directory to a html table.
*
* @param dir
* @param secCallback
* @param ubu
* @param translator
* @param iframePostEnabled
* @return Render results.
*/
public void render(FolderComponent fc, StringOutput sb, URLBuilder ubu, Translator translator, boolean iframePostEnabled) {
if (lockManager == null) {
lockManager = CoreSpringFactory.getImpl(VFSLockManager.class);
}
if (userManager == null) {
userManager = CoreSpringFactory.getImpl(UserManager.class);
}
LicenseModule licenseModule = CoreSpringFactory.getImpl(LicenseModule.class);
LicenseHandler licenseHandler = CoreSpringFactory.getImpl(FolderLicenseHandler.class);
licensesEnabled = licenseModule.isEnabled(licenseHandler);
List<VFSItem> children = fc.getCurrentContainerChildren();
// folder empty?
if (children.size() == 0) {
sb.append("<div class=\"o_bc_empty\"><i class='o_icon o_icon_warn'></i> ").append(translator.translate("NoFiles")).append("</div>");
return;
}
boolean canVersion = FolderConfig.versionsEnabled(fc.getCurrentContainer());
String sortOrder = fc.getCurrentSortOrder();
boolean sortAsc = fc.isCurrentSortAsc();
String sortCss = (sortAsc ? "o_orderby_asc" : "o_orderby_desc");
sb.append("<table class=\"table table-condensed table-striped table-hover o_bc_table\">").append("<thead><tr><th><a class='o_orderby ").append(sortCss, FolderComponent.SORT_NAME.equals(sortOrder)).append("' ");
ubu.buildHrefAndOnclick(sb, null, iframePostEnabled, false, false, new NameValuePair(PARAM_SORTID, FolderComponent.SORT_NAME)).append(">").append(translator.translate("header.Name")).append("</a>").append("</th>");
sb.append("<th><a class='o_orderby ").append(sortCss, FolderComponent.SORT_SIZE.equals(sortOrder)).append("' ");
ubu.buildHrefAndOnclick(sb, null, iframePostEnabled, false, false, new NameValuePair(PARAM_SORTID, FolderComponent.SORT_SIZE)).append(">").append(translator.translate("header.Size")).append("</a>").append("</th><th><a class='o_orderby ").append(sortCss, FolderComponent.SORT_DATE.equals(sortOrder)).append("' ");
ubu.buildHrefAndOnclick(sb, null, iframePostEnabled, false, false, new NameValuePair(PARAM_SORTID, FolderComponent.SORT_DATE)).append(">").append(translator.translate("header.Modified")).append("</a>");
if (licensesEnabled) {
sb.append("<th>").append(translator.translate("header.license")).append("</th>");
}
if (canVersion) {
sb.append("</th><th><a class='o_orderby ").append(sortCss, FolderComponent.SORT_REV.equals(sortOrder)).append("' ");
// file size column
ubu.buildHrefAndOnclick(sb, null, iframePostEnabled, false, false, new NameValuePair(PARAM_SORTID, FolderComponent.SORT_REV)).append("><i class=\"o_icon o_icon_version o_icon-lg\" title=\"").append(translator.translate("versions")).append("\"></i></a>");
}
sb.append("</th><th><a class='o_orderby ").append(sortCss, FolderComponent.SORT_LOCK.equals(sortOrder)).append("' ");
ubu.buildHrefAndOnclick(sb, null, iframePostEnabled, false, false, new NameValuePair(PARAM_SORTID, FolderComponent.SORT_LOCK)).append("><i class=\"o_icon o_icon_locked o_icon-lg\" title=\"").append(translator.translate("lock.title")).append("\"></i></a>").append("</th><th><i class=\"o_icon o_icon_edit_metadata o_icon-lg\" title=\"").append(translator.translate("mf.edit")).append("\"></i></th></tr></thead>");
// render directory contents
String currentContainerPath = fc.getCurrentContainerPath();
if (currentContainerPath.length() > 0 && currentContainerPath.charAt(0) == '/') {
currentContainerPath = currentContainerPath.substring(1);
}
sb.append("<tbody>");
for (int i = 0; i < children.size(); i++) {
VFSItem child = children.get(i);
appendRenderedFile(fc, child, currentContainerPath, sb, ubu, translator, iframePostEnabled, canVersion, i);
}
sb.append("</tbody></table>");
}
use of org.olat.user.UserManager in project OpenOLAT by OpenOLAT.
the class MailHelper method getMailFooter.
/**
* Create a mail footer for the given locale and sender.
*
* @param locale Defines language of footer text. If null, the systems default
* locale is used
* @param sender Details about sender embedded in mail footer. If null no such
* details are attached to the footer
* @return The mail footer as string
*/
public static String getMailFooter(Locale locale, Identity sender) {
if (locale == null) {
locale = I18nModule.getDefaultLocale();
}
Translator trans = getTranslator(locale);
if (sender == null) {
// mail sent by plattform configured sender address
return trans.translate("footer.no.userdata", new String[] { Settings.getServerContextPathURI() });
}
// mail sent by a system user
User user = sender.getUser();
// FXOLAT-356: separate context for mail footer
// username / server-url are always first [0], [1].
UserManager um = UserManager.getInstance();
List<UserPropertyHandler> userPropertyHandlers = um.getUserPropertyHandlersFor(MailHelper.class.getCanonicalName(), false);
List<String> userPropList = new ArrayList<String>(userPropertyHandlers.size() + 2);
String email = UserManager.getInstance().getUserDisplayEmail(sender, locale);
userPropList.add(email);
userPropList.add(Settings.getServerContextPathURI());
for (Iterator<UserPropertyHandler> iterator = userPropertyHandlers.iterator(); iterator.hasNext(); ) {
userPropList.add(iterator.next().getUserProperty(user, locale));
}
// add empty strings to prevent non-replaced wildcards like "{5}" etc. in emails.
while (userPropList.size() < 15) {
userPropList.add("");
}
String[] userPropArr = userPropList.toArray(new String[userPropList.size()]);
for (int i = userPropArr.length; i-- > 0; ) {
if (userPropArr[i] == null) {
userPropArr[i] = "";
}
}
return trans.translate("footer.with.userdata", userPropArr);
}
use of org.olat.user.UserManager in project OpenOLAT by OpenOLAT.
the class CourseLogsArchiveController method event.
public void event(UserRequest ureq, Controller source, Event event) {
if (source == logFileChooserForm) {
if (event == Event.DONE_EVENT) {
final boolean logAdminChecked = logFileChooserForm.logAdminChecked();
final boolean logUserChecked = logFileChooserForm.logUserChecked();
final boolean logStatisticChecked = logFileChooserForm.logStatChecked();
final Date begin = logFileChooserForm.getBeginDate();
final Date end = logFileChooserForm.getEndDate();
if (end != null) {
// shift time from beginning to end of day
end.setTime(end.getTime() + 24 * 60 * 60 * 1000);
}
UserManager um = UserManager.getInstance();
final String charset = um.getUserCharset(ureq.getIdentity());
ICourse course = CourseFactory.loadCourse(ores);
final String courseTitle = course.getCourseTitle();
final String targetDir = CourseFactory.getOrCreateDataExportDirectory(ureq.getIdentity(), courseTitle).getPath();
final Long resId = ores.getResourceableId();
final Locale theLocale = ureq.getLocale();
final String email = ureq.getIdentity().getUser().getProperty(UserConstants.EMAIL, ureq.getLocale());
AsyncExportManager.getInstance().asyncArchiveCourseLogFiles(ureq.getIdentity(), new Runnable() {
@Override
public void run() {
showExportFinished();
}
}, resId, targetDir, begin, end, logAdminChecked, logUserChecked, logStatisticChecked, charset, theLocale, email);
showExportOngoing(true);
} else if (event == Event.DONE_EVENT) {
myPanel.setContent(myContent);
}
}
}
use of org.olat.user.UserManager in project OpenOLAT by OpenOLAT.
the class BulkAssessmentTask method renderFeedback.
public static String renderFeedback(List<BulkAssessmentFeedback> feedbacks, Translator translator) {
UserManager userManager = CoreSpringFactory.getImpl(UserManager.class);
StringBuilder sb = new StringBuilder();
for (BulkAssessmentFeedback feedback : feedbacks) {
String errorKey = feedback.getErrorKey();
String msg = translator.translate(errorKey);
String assessedName;
if (feedback.getAssessedIdentity() != null) {
assessedName = userManager.getUserDisplayName(feedback.getAssessedIdentity());
} else {
assessedName = feedback.getAssessedId();
}
sb.append(assessedName).append(": ").append(msg).append("\n");
}
return sb.toString();
}
use of org.olat.user.UserManager in project OpenOLAT by OpenOLAT.
the class Wiki method getRecentChanges.
protected String getRecentChanges(Locale locale) {
if (locale == null)
throw new AssertException("param was null which is not allowed");
final int MAX_RESULTS = 5;
List<WikiPage> pages = new ArrayList<>(wikiPages.values());
Collections.sort(pages, WikiPageSort.MODTIME_ORDER);
StringBuilder sb = new StringBuilder(512);
int counter = 0;
Formatter f = Formatter.getInstance(locale);
UserManager userManager = CoreSpringFactory.getImpl(UserManager.class);
for (Iterator<WikiPage> iter = pages.iterator(); iter.hasNext(); ) {
if (counter > MAX_RESULTS)
break;
WikiPage page = iter.next();
if (!page.getPageName().startsWith("O_") && !page.getPageName().startsWith(WikiPage.WIKI_MENU_PAGE)) {
sb.append("* [[");
sb.append(page.getPageName());
sb.append("]] ");
sb.append(f.formatDateAndTime(new Date(page.getModificationTime())));
sb.append(" Author: ");
long author = page.getModifyAuthor();
if (author != 0) {
String authorFullname = userManager.getUserDisplayName(author);
if (StringHelper.containsNonWhitespace(authorFullname)) {
sb.append(" Author: ").append(authorFullname);
} else {
sb.append("???");
}
}
sb.append("\n");
counter++;
}
}
return sb.toString();
}
Aggregations