use of org.olat.course.nodes.dialog.DialogElement in project OpenOLAT by OpenOLAT.
the class DialogElementListController method loadModel.
protected void loadModel() {
RepositoryEntry entry = userCourseEnv.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
List<DialogElement> elements = dialogElementsManager.getDialogElements(entry, courseNode.getIdent());
List<DialogElementRow> rows = new ArrayList<>(elements.size());
for (DialogElement element : elements) {
DialogElementRow row = new DialogElementRow(element, userPropertyHandlers, getLocale());
int msgCount = forumManager.countMessagesByForumID(element.getForum().getKey());
int newMsg = msgCount - forumManager.countReadMessagesByUserAndForum(getIdentity(), element.getForum().getKey());
row.setNumOfMessages(msgCount);
row.setNumOfUnreadMessages(newMsg);
VFSLeaf item = dialogElementsManager.getDialogLeaf(element);
if (item != null) {
DownloadLink downloadLink = uifactory.addDownloadLink("file_" + (++counter), row.getFilename(), null, item, flc);
row.setDownloadLink(downloadLink);
}
rows.add(row);
}
tableModel.setObjects(rows);
tableEl.reset(true, true, true);
}
use of org.olat.course.nodes.dialog.DialogElement in project OpenOLAT by OpenOLAT.
the class DialogElementListController method doDelete.
private void doDelete(DialogElementRow rowToDelete) {
DialogElement elementToDelete = dialogElementsManager.getDialogElementByKey(rowToDelete.getDialogElementKey());
// archive data to personal folder
File exportDir = CourseFactory.getOrCreateDataExportDirectory(getIdentity(), courseNode.getShortTitle());
courseNode.doArchiveElement(elementToDelete, exportDir, getLocale());
dialogElementsManager.deleteDialogElement(elementToDelete);
// do logging
ThreadLocalUserActivityLogger.log(CourseLoggingAction.DIALOG_ELEMENT_FILE_DELETED, getClass(), LoggingResourceable.wrapUploadFile(elementToDelete.getFilename()));
}
use of org.olat.course.nodes.dialog.DialogElement in project openolat by klemens.
the class DialogCourseNodeRunController method doCopySelectedFile.
private void doCopySelectedFile(String fileUrl) {
VFSContainer courseContainer = userCourseEnv.getCourseEnvironment().getCourseFolderContainer();
VFSLeaf vl = (VFSLeaf) courseContainer.resolve(fileUrl);
DialogElement newElement = dialogElmsMgr.createDialogElement(entry, getIdentity(), vl.getName(), vl.getSize(), courseNode.getIdent());
// copy file
VFSContainer dialogContainer = dialogElmsMgr.getDialogContainer(newElement);
VFSLeaf copyVl = dialogContainer.createChildLeaf(vl.getName());
if (copyVl == null) {
copyVl = (VFSLeaf) dialogContainer.resolve(vl.getName());
}
VFSManager.copyContent(vl, copyVl);
// inform subscription manager about new element
if (subsContext != null) {
notificationsManager.markPublisherNews(subsContext, getIdentity(), true);
}
filesCtrl.loadModel();
}
use of org.olat.course.nodes.dialog.DialogElement in project openolat by klemens.
the class DialogCourseNodeRunController method doFinalizeUploadFile.
private void doFinalizeUploadFile(VFSLeaf file) {
// everything when well so save the property
DialogElement element = dialogElmsMgr.createDialogElement(entry, getIdentity(), file.getName(), file.getSize(), courseNode.getIdent());
VFSContainer dialogContainer = dialogElmsMgr.getDialogContainer(element);
VFSManager.copyContent(file.getParentContainer(), dialogContainer);
// inform subscription manager about new element
if (subsContext != null) {
notificationsManager.markPublisherNews(subsContext, getIdentity(), true);
}
filesCtrl.loadModel();
}
use of org.olat.course.nodes.dialog.DialogElement in project openolat by klemens.
the class DialogElementListController method formInnerEvent.
@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
if (source == tableEl) {
if (event instanceof SelectionEvent) {
SelectionEvent se = (SelectionEvent) event;
DialogElementRow row = tableModel.getObject(se.getIndex());
if ("forum".equals(se.getCommand())) {
fireEvent(ureq, new SelectRowEvent(row));
} else if ("delete".equals(se.getCommand())) {
doConfirmDelete(ureq, row);
}
}
} else if (source instanceof FormLink) {
FormLink link = (FormLink) source;
String cmd = link.getCmd();
if ("download".equals(cmd)) {
doFileDelivery(ureq, (DialogElement) link.getUserObject());
}
}
super.formInnerEvent(ureq, source, event);
}
Aggregations