use of org.olat.core.id.context.BusinessControl in project OpenOLAT by OpenOLAT.
the class ReturnboxFullAccessCallback method event.
/**
* @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest, org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event)
*/
@Override
public void event(UserRequest ureq, Controller source, Event event) {
if (source == dropboxFolderRunController) {
if (event instanceof FolderEvent) {
FolderEvent folderEvent = (FolderEvent) event;
if (folderEvent.getCommand().equals(FolderEvent.DELETE_EVENT)) {
UserNodeAuditManager am = userCourseEnv.getCourseEnvironment().getAuditManager();
// log entry for this file
Identity coach = ureq.getIdentity();
Identity student = userCourseEnv.getIdentityEnvironment().getIdentity();
am.appendToUserNodeLog(node, coach, student, "FILE DELETED: " + folderEvent.getFilename());
}
}
} else if (source == returnboxFolderRunController) {
if (event instanceof FolderEvent) {
FolderEvent folderEvent = (FolderEvent) event;
if (folderEvent.getCommand().equals(FolderEvent.UPLOAD_EVENT) || folderEvent.getCommand().equals(FolderEvent.NEW_FILE_EVENT)) {
UserNodeAuditManager am = userCourseEnv.getCourseEnvironment().getAuditManager();
// log entry for this file
Identity coach = ureq.getIdentity();
Identity student = userCourseEnv.getIdentityEnvironment().getIdentity();
if (node instanceof AssessableCourseNode) {
AssessableCourseNode acn = (AssessableCourseNode) node;
AssessmentEvaluation eval = acn.getUserScoreEvaluation(userCourseEnv);
if (eval.getAssessmentStatus() == null || eval.getAssessmentStatus() == AssessmentEntryStatus.notStarted) {
eval = new AssessmentEvaluation(eval, AssessmentEntryStatus.inProgress);
acn.updateUserScoreEvaluation(eval, userCourseEnv, coach, false, Role.coach);
}
}
am.appendToUserNodeLog(node, coach, student, "FILE UPLOADED: " + folderEvent.getFilename());
String toMail = UserManager.getInstance().getUserDisplayEmail(student, ureq.getLocale());
OLATResourceable ores = OresHelper.createOLATResourceableInstance(CourseNode.class, Long.valueOf(node.getIdent()));
ContextEntry ce = BusinessControlFactory.getInstance().createContextEntry(ores);
BusinessControl bc = BusinessControlFactory.getInstance().createBusinessControl(ce, getWindowControl().getBusinessControl());
String link = BusinessControlFactory.getInstance().getAsURIString(bc, true);
log.debug("DEBUG : Returnbox notification email with link=" + link);
String subject = translate("returnbox.email.subject");
String body = translate("returnbox.email.body", new String[] { userCourseEnv.getCourseEnvironment().getCourseTitle(), node.getShortTitle(), folderEvent.getFilename(), link });
MailContext context = new MailContextImpl(getWindowControl().getBusinessControl().getAsString());
MailBundle bundle = new MailBundle();
bundle.setContext(context);
bundle.setToId(student);
bundle.setContent(subject, body);
MailerResult result = CoreSpringFactory.getImpl(MailManager.class).sendMessage(bundle);
if (result.getReturnCode() > 0) {
am.appendToUserNodeLog(node, coach, student, "MAIL SEND FAILED TO:" + toMail + "; MailReturnCode: " + result.getReturnCode());
log.warn("Could not send email 'returnbox notification' to " + student + "with email=" + toMail);
} else {
log.info("Send email 'returnbox notification' to " + student + "with email=" + toMail);
}
}
} else if (FolderCommand.FOLDERCOMMAND_FINISHED == event) {
if (node instanceof AssessableCourseNode) {
AssessableCourseNode acn = (AssessableCourseNode) node;
AssessmentEvaluation eval = acn.getUserScoreEvaluation(userCourseEnv);
if (eval == null) {
eval = AssessmentEvaluation.EMPTY_EVAL;
}
if (eval.getAssessmentStatus() == null || eval.getAssessmentStatus() == AssessmentEntryStatus.notStarted) {
eval = new AssessmentEvaluation(eval, AssessmentEntryStatus.inProgress);
acn.updateUserScoreEvaluation(eval, userCourseEnv, getIdentity(), false, Role.coach);
fireEvent(ureq, Event.CHANGED_EVENT);
}
}
}
} else if (source == statusForm) {
if (event == Event.DONE_EVENT) {
// get identity not from request (this would be an author)
StatusManager.getInstance().saveStatusFormData(statusForm, node, userCourseEnv);
}
} else if (source == dialogBoxController) {
if (DialogBoxUIFactory.isYesEvent(event) && assignedTask != null) {
// cancel task assignment, and show "no task assigned to user"
removeAssignedTask(userCourseEnv, userCourseEnv.getIdentityEnvironment().getIdentity());
// update UI
myContent.contextPut("assignedtask", null);
}
}
}
use of org.olat.core.id.context.BusinessControl in project OpenOLAT by OpenOLAT.
the class SearchResourceContext method getResourceUrl.
/**
* @return Returns the resourcePath.
*/
public String getResourceUrl() {
BusinessControl bControl = myBusinessControl == null ? parentBusinessControl : myBusinessControl;
String resourceUrl = BusinessControlFactory.getInstance().getAsString(bControl);
if (filePath != null) {
// It is a file resource => Append file path
StringBuilder buf = new StringBuilder(resourceUrl);
buf.append(FILEPATH_PREFIX).append(filePath).append(ENDTAG);
resourceUrl = buf.toString();
}
return resourceUrl;
}
use of org.olat.core.id.context.BusinessControl in project OpenOLAT by OpenOLAT.
the class EventsModel method event.
/**
* @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
* org.olat.core.gui.components.Component,
* org.olat.core.gui.control.Event)
*/
@Override
public void event(UserRequest ureq, Component source, Event event) {
if (source == showAllLink) {
// activate homes tab in top navigation and active calendar menu item
String resourceUrl = "[HomeSite:" + ureq.getIdentity().getKey() + "][calendar:0]";
BusinessControl bc = BusinessControlFactory.getInstance().createFromString(resourceUrl);
WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(bc, getWindowControl());
NewControllerFactory.getInstance().launch(ureq, bwControl);
} else if (event == ComponentUtil.VALIDATE_EVENT && dirty) {
List<KalendarEvent> events = getMatchingEvents(ureq, getWindowControl());
tableController.setTableDataModel(new EventsModel(events));
}
}
use of org.olat.core.id.context.BusinessControl in project OpenOLAT by OpenOLAT.
the class SearchControllerFactory method createSearchController.
@Override
public SearchInputController createSearchController(UserRequest ureq, WindowControl wControl) {
String resourceUrl = null;
BusinessControl bc = wControl.getBusinessControl();
if (bc != null) {
resourceUrl = bc.getAsString();
}
return new ResultsSearchController(ureq, wControl, resourceUrl);
}
use of org.olat.core.id.context.BusinessControl in project OpenOLAT by OpenOLAT.
the class BlogArtefactHandler method prefillBlogArtefact.
private void prefillBlogArtefact(AbstractArtefact artefact, Feed feed, Item item) {
VFSContainer itemContainer = FeedManager.getInstance().getItemContainer(item);
artefact.setFileSourceContainer(itemContainer);
artefact.setTitle(item.getTitle());
artefact.setDescription(item.getDescription());
VFSLeaf itemXml = (VFSLeaf) itemContainer.resolve(BlogArtefact.BLOG_FILE_NAME);
if (itemXml != null) {
InputStream in = itemXml.getInputStream();
String xml = FileUtils.load(in, "UTF-8");
artefact.setFulltextContent(xml);
FileUtils.closeSafely(in);
}
String origBPath = artefact.getBusinessPath();
String artSource = "";
BusinessControl bc = BusinessControlFactory.getInstance().createFromString(origBPath);
if (origBPath.contains(CourseNode.class.getSimpleName())) {
// blog-post from inside a course, rebuild "course-name - feed-name"
OLATResourceable ores = bc.popLauncherContextEntry().getOLATResourceable();
RepositoryEntry repoEntry = RepositoryManager.getInstance().lookupRepositoryEntry(ores.getResourceableId());
artSource = repoEntry.getDisplayname();
if (feed != null) {
artSource += " - " + feed.getTitle();
}
} else if (origBPath.contains(RepositoryEntry.class.getSimpleName())) {
// blog-post from blog-LR, only get name itself
if (feed != null) {
artSource = feed.getTitle();
}
} else {
// collecting a post from live-blog, [Identity:xy]
if (feed != null) {
artSource = feed.getTitle();
}
}
artefact.setSource(artSource);
}
Aggregations