/** * Constructor for the course logs archive controller * * @param ureq * @param wControl * @param course */ public CourseLogsArchiveController( UserRequest ureq, WindowControl wControl, OLATResourceable ores) { super(ureq, wControl); this.ores = ores; this.myPanel = new Panel("myPanel"); myPanel.addListener(this); myContent = createVelocityContainer("start_courselogs"); Identity identity = ureq.getIdentity(); Roles roles = ureq.getUserSession().getRoles(); RepositoryEntry re = RepositoryManager.getInstance().lookupRepositoryEntry(ores, false); boolean isOLATAdmin = ureq.getUserSession().getRoles().isOLATAdmin(); boolean isOresOwner = RepositoryManager.getInstance().isOwnerOfRepositoryEntry(identity, re); boolean isOresInstitutionalManager = RepositoryManager.getInstance().isInstitutionalRessourceManagerFor(identity, roles, re); boolean aLogV = isOresOwner || isOresInstitutionalManager; boolean uLogV = isOLATAdmin; boolean sLogV = isOresOwner || isOresInstitutionalManager; if (AsyncExportManager.getInstance().asyncArchiveCourseLogOngoingFor(ureq.getIdentity())) { // then show the ongoing feedback showExportOngoing(false); } else if (isOLATAdmin || aLogV || uLogV || sLogV) { myContent.contextPut("hasLogArchiveAccess", true); logFileChooserForm = new LogFileChooserForm(ureq, wControl, isOLATAdmin, aLogV, uLogV, sLogV); listenTo(logFileChooserForm); myContent.put("logfilechooserform", logFileChooserForm.getInitialComponent()); ICourse course = CourseFactory.loadCourse(ores); myContent.contextPut( "body", translate("course.logs.existingarchiveintro", course.getCourseTitle())); showFileButton = LinkFactory.createButton("showfile", myContent, this); File exportDir = CourseFactory.getDataExportDirectory(ureq.getIdentity(), course.getCourseTitle()); boolean exportDirExists = false; if (exportDir != null && exportDir.exists() && exportDir.isDirectory()) { exportDirExists = true; } myContent.contextPut("hascourselogarchive", new Boolean(exportDirExists)); myPanel.setContent(myContent); } else { myContent.contextPut("hasLogArchiveAccess", new Boolean(false)); myPanel.setContent(myContent); } putInitialPanel(myPanel); }
/** * @see * org.olat.repository.handlers.RepositoryHandler#getLaunchController(org.olat.core.id.OLATResourceable, * java.lang.String, org.olat.core.gui.UserRequest, org.olat.core.gui.control.WindowControl) */ @Override public MainLayoutController createLaunchController( final OLATResourceable res, final String initialViewIdentifier, final UserRequest ureq, final WindowControl wControl) { final RepositoryEntry repoEntry = RepositoryManager.getInstance().lookupRepositoryEntry(res, false); final boolean isAdmin = ureq.getUserSession().getRoles().isOLATAdmin(); final boolean isOwner = RepositoryManager.getInstance().isOwnerOfRepositoryEntry(ureq.getIdentity(), repoEntry); final FeedSecurityCallback callback = new FeedResourceSecurityCallback(isAdmin, isOwner); final Controller blogCtr = BlogUIFactory.getInstance(ureq.getLocale()) .createMainController(res, ureq, wControl, callback); final LayoutMain3ColsController layoutCtr = new LayoutMain3ColsController( ureq, wControl, null, null, blogCtr.getInitialComponent(), null); layoutCtr.addDisposableChildController(blogCtr); return layoutCtr; }
@Override public String createTitleInfo(Subscriber subscriber, Locale locale) { try { Long resId = subscriber.getPublisher().getResId(); String displayName = RepositoryManager.getInstance().lookupDisplayNameByOLATResourceableId(resId); Translator trans = Util.createPackageTranslator(AssessmentNotificationsHandler.class, locale); String title = trans.translate("notifications.title", new String[] {displayName}); return title; } catch (Exception e) { log.error( "Error while creating assessment notifications for subscriber: " + subscriber.getKey(), e); checkPublisher(subscriber.getPublisher()); return "-"; } }
/** * @see org.olat.course.nodes.GenericCourseNode#archiveNodeData(java.util.Locale, * org.olat.course.ICourse, java.io.File, java.lang.String) */ @Override public boolean archiveNodeData( final Locale locale, final ICourse course, final File exportDirectory, final String charset) { final String repoRef = (String) this.getModuleConfiguration().get("reporef"); final OLATResourceable ores = RepositoryManager.getInstance() .lookupRepositoryEntryBySoftkey(repoRef, true) .getOlatResource(); if (WikiManager.getInstance().getOrLoadWiki(ores).getAllPagesWithContent().size() > 0) { // OK, there is somthing to archive final VFSContainer exportContainer = new LocalFolderImpl(exportDirectory); VFSContainer wikiExportContainer = (VFSContainer) exportContainer.resolve(WikiManager.WIKI_RESOURCE_FOLDER_NAME); if (wikiExportContainer == null) { wikiExportContainer = exportContainer.createChildContainer(WikiManager.WIKI_RESOURCE_FOLDER_NAME); } final String exportDirName = getShortTitle() + "_" + Formatter.formatDatetimeFilesystemSave(new Date(System.currentTimeMillis())); final VFSContainer destination = wikiExportContainer.createChildContainer(exportDirName); if (destination == null) { Tracing.logError( "archiveNodeData: Could not create destination directory: wikiExportContainer=" + wikiExportContainer + ", exportDirName=" + exportDirName, getClass()); } final VFSContainer container = WikiManager.getInstance().getWikiContainer(ores, WikiManager.WIKI_RESOURCE_FOLDER_NAME); if (container != null) { // the container could be null if the wiki is an old empty one - so nothing to // archive final VFSContainer parent = container.getParentContainer(); final VFSLeaf wikiZip = WikiToZipUtils.getWikiAsZip(parent); destination.copyFrom(wikiZip); } return true; } // empty wiki, no need to archive return false; }
@Override protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) { fic = FormLayoutContainer.createCustomFormLayout( "cc01", this.getTranslator(), this.velocity_root + "/CcStep01_form.html"); formLayout.add(fic); // load course ICourse course = CourseFactory.loadCourse(getRepoEntry()); // show catalog selection tree if (course != null) { cic = new CatalogInsertController( ureq, getWindowControl(), RepositoryManager.getInstance().lookupRepositoryEntry(course, false), getCourseConfig()); cic.addControllerListener(this); fic.put("cc", cic.getInitialComponent()); } cic.init(); }
/** * @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 == onCommand) { // toggle on Preferences prefs = ureq.getUserSession().getGuiPreferences(); prefs.put(CourseGlossaryToolLinkController.class, guiPrefsKey, Boolean.TRUE); prefs.save(); // update gui mainVC.remove(onCommand); offCommand = LinkFactory.createLink("command.glossary.off", mainVC, this); offCommand.setTitle("command.glossary.off.alt"); offCommand.setCustomEnabledLinkCSS("b_toolbox_toggle"); // notify textmarker controller glossMarkupItmCtr.setTextMarkingEnabled(true); fireEvent(ureq, new Event("glossaryOn")); } else if (source == offCommand) { // toggle off Preferences prefs = ureq.getUserSession().getGuiPreferences(); prefs.put(CourseGlossaryToolLinkController.class, guiPrefsKey, Boolean.FALSE); prefs.save(); // update gui mainVC.remove(offCommand); onCommand = LinkFactory.createLink("command.glossary.on", mainVC, this); onCommand.setTitle("command.glossary.on.alt"); onCommand.setCustomEnabledLinkCSS("b_toolbox_toggle"); // notify textmarker controller glossMarkupItmCtr.setTextMarkingEnabled(false); fireEvent(ureq, new Event("glossaryOff")); } else if (source == mainVC && event.getCommand().equals("command.glossary")) { // start glossary in window final CourseConfig cc = courseEnvir.getCourseConfig(); // do not cache cc, not save // if glossary had been opened from LR as Tab before, warn user: DTabs dts = Windows.getWindows(ureq).getWindow(ureq).getDTabs(); RepositoryEntry repoEntry = RepositoryManager.getInstance() .lookupRepositoryEntryBySoftkey(cc.getGlossarySoftKey(), false); DTab dt = dts.getDTab(repoEntry.getOlatResource()); if (dt != null) { List<ContextEntry> entries = BusinessControlFactory.getInstance() .createCEListFromResourceType(allowGlossaryEditing ? "true" : "false"); dts.activate(ureq, dt, entries); } else { ControllerCreator ctrlCreator = new ControllerCreator() { public Controller createController(UserRequest lureq, WindowControl lwControl) { GlossaryMainController glossaryController = CourseGlossaryFactory.createCourseGlossaryMainRunController( lwControl, lureq, cc, allowGlossaryEditing); listenTo(glossaryController); if (glossaryController == null) { // happens in the unlikely event of a user who is in a course and // now // tries to access the glossary String text = translate("error.noglossary"); return MessageUIFactory.createInfoMessage(lureq, lwControl, null, text); } else { // use a one-column main layout LayoutMain3ColsController layoutCtr = new LayoutMain3ColsController( lureq, lwControl, null, null, glossaryController.getInitialComponent(), null); // dispose glossary on layout dispose layoutCtr.addDisposableChildController(glossaryController); return layoutCtr; } } }; ControllerCreator layoutCtrlr = BaseFullWebappPopupLayoutFactory.createAuthMinimalPopupLayout(ureq, ctrlCreator); // open in new browser window openInNewBrowserWindow(ureq, layoutCtrlr); return; // immediate return after opening new browser window! } } }