Search in sources :

Example 1 with EPSecurityCallback

use of org.olat.portfolio.EPSecurityCallback in project OpenOLAT by OpenOLAT.

the class PortfolioConfigForm method doPreview.

private void doPreview(UserRequest ureq) {
    removeAsListenerAndDispose(previewCtr);
    removeAsListenerAndDispose(columnLayoutCtr);
    if (map != null) {
        EPSecurityCallback secCallback = new EPSecurityCallbackImpl(false, true);
        previewCtr = EPUIFactory.createPortfolioStructureMapPreviewController(ureq, getWindowControl(), map, secCallback);
    } else if (binder != null && stackPanel instanceof TooledStackedPanel) {
        BinderSecurityCallback secCallback = BinderSecurityCallbackFactory.getReadOnlyCallback();
        BinderConfiguration bConfig = BinderConfiguration.createTemplateConfig(false);
        previewCtr = new BinderController(ureq, getWindowControl(), (TooledStackedPanel) stackPanel, secCallback, binder, bConfig);
    } else {
        return;
    }
    listenTo(previewCtr);
    columnLayoutCtr = new LayoutMain3ColsController(ureq, getWindowControl(), previewCtr);
    stackPanel.pushController(translate("preview.map"), columnLayoutCtr);
    listenTo(columnLayoutCtr);
}
Also used : TooledStackedPanel(org.olat.core.gui.components.stack.TooledStackedPanel) BinderController(org.olat.modules.portfolio.ui.BinderController) LayoutMain3ColsController(org.olat.core.commons.fullWebApp.LayoutMain3ColsController) EPSecurityCallback(org.olat.portfolio.EPSecurityCallback) BinderSecurityCallback(org.olat.modules.portfolio.BinderSecurityCallback) EPSecurityCallbackImpl(org.olat.portfolio.EPSecurityCallbackImpl) BinderConfiguration(org.olat.modules.portfolio.BinderConfiguration)

Example 2 with EPSecurityCallback

use of org.olat.portfolio.EPSecurityCallback in project OpenOLAT by OpenOLAT.

the class EPArtefactPoolRunController method initMultiArtefactCtrl.

private void initMultiArtefactCtrl(UserRequest ureq, List<AbstractArtefact> artefacts) {
    // decide how to present artefacts depending on users settings
    String userPrefsMode = ePFMgr.getUsersPreferedArtefactViewMode(getIdentity(), EPViewModeController.VIEWMODE_CONTEXT_ARTEFACTPOOL);
    if (previousViewMode != null && !previousViewMode.equals(userPrefsMode)) {
        removeAsListenerAndDispose(artCtrl);
    }
    if (importV2 || (userPrefsMode != null && userPrefsMode.equals(EPViewModeController.VIEWMODE_TABLE))) {
        EPSecurityCallback secCallback = new EPSecurityCallbackImpl(true, true);
        artCtrl = new EPMultipleArtefactsAsTableController(ureq, getWindowControl(), artefacts, null, artefactChooseMode, importV2, secCallback);
        viewModeCtrl.selectTable();
    } else {
        artCtrl = new EPMultipleArtefactPreviewController(ureq, getWindowControl(), artefacts, artefactChooseMode);
        viewModeCtrl.selectDetails();
    }
    previousViewMode = userPrefsMode;
    listenTo(artCtrl);
    previousArtefactsList = artefacts;
}
Also used : EPMultipleArtefactsAsTableController(org.olat.portfolio.ui.artefacts.view.EPMultipleArtefactsAsTableController) EPSecurityCallback(org.olat.portfolio.EPSecurityCallback) EPMultipleArtefactPreviewController(org.olat.portfolio.ui.artefacts.view.EPMultipleArtefactPreviewController) EPSecurityCallbackImpl(org.olat.portfolio.EPSecurityCallbackImpl)

Example 3 with EPSecurityCallback

use of org.olat.portfolio.EPSecurityCallback in project OpenOLAT by OpenOLAT.

the class EPMultipleMapController method initOrUpdateMaps.

/**
 */
private void initOrUpdateMaps(UserRequest ureq) {
    if (isLogDebugEnabled()) {
        start = System.currentTimeMillis();
        logDebug("start loading map overview at : ", String.valueOf(start));
    }
    List<PortfolioStructure> allUsersStruct = getUsersStructsToDisplay();
    userMaps = new ArrayList<PortfolioStructureMap>();
    if (allUsersStruct.isEmpty()) {
        vC.contextPut("noMaps", true);
        return;
    } else
        vC.contextRemove("noMaps");
    // remove forward link (maybe it's not needed (last page) )
    if (forwardLink != null)
        vC.remove(forwardLink);
    // now add paging-components if necessary and wanted
    int elementCount = ePFMgr.countStructureElementsFromOthers(getIdentity(), mapOwner, ElementType.DEFAULT_MAP);
    if (pagingAvailable && elementCount > ITEMS_PER_PAGE) {
        vC.contextPut("showPaging", true);
        int additionalPage = ((elementCount % ITEMS_PER_PAGE) > 0) ? 1 : 0;
        int pageCount = (elementCount / ITEMS_PER_PAGE) + additionalPage;
        List<Component> pagingLinks = new ArrayList<Component>();
        for (int i = 1; i < pageCount + 1; i++) {
            Link pageLink = LinkFactory.createCustomLink(PAGING_LINK_PREFIX + i, "switchPage", String.valueOf(i), Link.NONTRANSLATED, vC, this);
            pageLink.setUserObject(new Integer(i));
            pagingLinks.add(pageLink);
            if (i == currentPageNum) {
                pageLink.setEnabled(false);
            }
        }
        vC.contextPut("pageLinks", pagingLinks);
        if (currentPageNum < pageCount) {
            forwardLink = LinkFactory.createCustomLink("forwardLink", "pagingFWD", "table.forward", Link.LINK, vC, this);
            forwardLink.setIconRightCSS("o_icon o_icon_next_page");
        }
    }
    // now display the maps
    List<String> artAmount = new ArrayList<String>(userMaps.size());
    List<Integer> childAmount = new ArrayList<Integer>(userMaps.size());
    List<String> mapStyles = new ArrayList<String>(userMaps.size());
    List<Date> deadLines = new ArrayList<Date>(userMaps.size());
    List<String> restriStats = new ArrayList<String>(userMaps.size());
    List<String> owners = new ArrayList<String>(userMaps.size());
    List<String> amounts = new ArrayList<String>(userMaps.size());
    int i = 1;
    for (PortfolioStructure portfolioStructure : allUsersStruct) {
        if (portfolioStructure.getRoot() == null) {
            // only show maps
            PortfolioStructureMap map = (PortfolioStructureMap) portfolioStructure;
            EPSecurityCallback secCallback = EPSecurityCallbackFactory.getSecurityCallback(ureq, map, ePFMgr);
            userMaps.add(map);
            Link vLink = LinkFactory.createCustomLink(VIEW_LINK_PREFIX + i, "viewMap" + map.getResourceableId(), "view.map", Link.LINK, vC, this);
            vLink.setUserObject(map);
            vLink.setElementCssClass("o_sel_ep_open_map");
            vLink.setIconRightCSS("o_icon o_icon-fw o_icon_start");
            // can always try to delete your own map, but exercise only if the course was deleted
            // remove as update could require hiding it
            vC.remove(vC.getComponent(DELETE_LINK_PREFIX + i));
            // can always try to delete your own map, but exercise only if the course was deleted
            final boolean myMaps = (option.equals(EPMapRunViewOption.MY_DEFAULTS_MAPS) || option.equals(EPMapRunViewOption.MY_EXERCISES_MAPS));
            boolean addDeleteLink = myMaps;
            if ((map instanceof EPStructuredMap) && (((EPStructuredMap) map).getReturnDate() != null)) {
                // it's a portfolio-task that was already handed in, so do not display delete-link
                addDeleteLink = false;
            }
            if (addDeleteLink) {
                final Link dLink = LinkFactory.createCustomLink(DELETE_LINK_PREFIX + i, "delMap" + map.getResourceableId(), "delete.map", Link.LINK, vC, this);
                dLink.setIconLeftCSS("o_icon o_icon-fw o_icon_delete_item");
                dLink.setUserObject(map);
            }
            Link cLink = LinkFactory.createCustomLink(COPY_LINK_PREFIX + i, "copyMap" + map.getResourceableId(), "copy.map", Link.LINK, vC, this);
            cLink.setIconLeftCSS("o_icon o_icon_copy");
            cLink.setUserObject(map);
            // its not allowed to copy maps from a portfolio-task
            if (map instanceof EPStructuredMap) {
                cLink.setVisible(false);
            }
            // remove as update could require hiding it
            vC.remove(vC.getComponent(SHARE_LINK_PREFIX + i));
            if (myMaps && secCallback.canShareMap()) {
                Link shareLink = LinkFactory.createCustomLink(SHARE_LINK_PREFIX + i, "shareMap" + map.getResourceableId(), "map.share", Link.LINK, vC, this);
                shareLink.setIconLeftCSS("o_icon o_icon-fw o_icon_share");
                shareLink.setUserObject(map);
                boolean shared = ePFMgr.isMapShared(map);
                if (shared || (map instanceof EPStructuredMap && ((EPStructuredMap) map).getTargetResource() != null)) {
                    shareLink.setCustomDisplayText(translate("map.share.shared"));
                }
            }
            if (isLogDebugEnabled()) {
                logDebug("  in loop : got share state at: ", String.valueOf(System.currentTimeMillis()));
            }
            // get deadline + link to course
            if (map instanceof EPStructuredMap) {
                EPStructuredMap structMap = (EPStructuredMap) map;
                Date deadLine = structMap.getDeadLine();
                deadLines.add(deadLine);
                EPTargetResource resource = structMap.getTargetResource();
                RepositoryEntry repoEntry = RepositoryManager.getInstance().lookupRepositoryEntry(resource.getOLATResourceable(), false);
                if (repoEntry != null) {
                    vC.contextPut("courseName" + i, StringHelper.escapeHtml(repoEntry.getDisplayname()));
                    String url = Settings.getServerContextPathURI();
                    url += "/url/RepositoryEntry/" + repoEntry.getKey() + "/CourseNode/" + resource.getSubPath();
                    vC.contextPut("courseLink" + i, url);
                }
                if (isLogDebugEnabled()) {
                    logDebug("  in loop : looked up course at : ", String.valueOf(System.currentTimeMillis()));
                }
                // get some stats about the restrictions if available
                String[] stats = ePFMgr.getRestrictionStatisticsOfMap(structMap);
                int toCollect = 0;
                if (stats != null) {
                    try {
                        toCollect = Integer.parseInt(stats[1]) - Integer.parseInt(stats[0]);
                    } catch (Exception e) {
                        // do nothing
                        toCollect = 0;
                    }
                }
                if (toCollect != 0) {
                    restriStats.add(String.valueOf(toCollect));
                } else {
                    restriStats.add(null);
                }
                if (isLogDebugEnabled()) {
                    logDebug("  in loop : calculated restriction statistics at : ", String.valueOf(System.currentTimeMillis()));
                }
            } else {
                deadLines.add(null);
                restriStats.add(null);
            }
            // show owner on shared maps
            if (!secCallback.isOwner()) {
                owners.add(ePFMgr.getAllOwnersAsString(map));
            } else
                owners.add(null);
            String artCount = String.valueOf(ePFMgr.countArtefactsInMap(map));
            artAmount.add(artCount);
            Integer childs = ePFMgr.countStructureChildren(map);
            childAmount.add(childs);
            amounts.add(translate("map.contains", new String[] { childs.toString(), artCount }));
            mapStyles.add(ePFMgr.getValidStyleName(map));
            if (isLogDebugEnabled()) {
                logDebug("  in loop : got map details (artefact-amount, child-struct-amount, style) at : ", String.valueOf(System.currentTimeMillis()));
            }
            i++;
        }
    }
    vC.contextPut("owners", owners);
    vC.contextPut("deadLines", deadLines);
    vC.contextPut("restriStats", restriStats);
    vC.contextPut("mapStyles", mapStyles);
    vC.contextPut("childAmount", childAmount);
    vC.contextPut("artefactAmount", artAmount);
    vC.contextPut("amounts", amounts);
    vC.contextPut("userMaps", userMaps);
    if (isLogDebugEnabled()) {
        long now = System.currentTimeMillis();
        logDebug("finished processing all maps at : ", String.valueOf(now));
        logDebug("Total processing time for " + (i - 1) + " maps was : ", String.valueOf(now - start));
    }
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) EPTargetResource(org.olat.portfolio.model.structel.EPTargetResource) ArrayList(java.util.ArrayList) RepositoryEntry(org.olat.repository.RepositoryEntry) Date(java.util.Date) EPStructuredMap(org.olat.portfolio.model.structel.EPStructuredMap) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) EPSecurityCallback(org.olat.portfolio.EPSecurityCallback) Component(org.olat.core.gui.components.Component) Link(org.olat.core.gui.components.link.Link)

Example 4 with EPSecurityCallback

use of org.olat.portfolio.EPSecurityCallback in project OpenOLAT by OpenOLAT.

the class CollaborationTools method createPortfolioController.

/**
 * @param ureq
 * @param wControl
 * @param mapProperty The property is mandatory!
 * @return
 */
private Controller createPortfolioController(UserRequest ureq, WindowControl wControl, TooledStackedPanel stackPanel, Property mapProperty) {
    Long key = mapProperty.getLongValue();
    String version = mapProperty.getStringValue();
    Controller ctrl;
    if ("2".equals(version)) {
        PortfolioService portfolioService = CoreSpringFactory.getImpl(PortfolioService.class);
        Binder binder = portfolioService.getBinderByKey(key);
        portfolioService.updateBinderUserInformations(binder, ureq.getIdentity());
        BinderSecurityCallback secCallback = BinderSecurityCallbackFactory.getCallbackForBusinessGroup();
        BinderController binderCtrl = new BinderController(ureq, wControl, stackPanel, secCallback, binder, BinderConfiguration.createBusinessGroupConfig());
        ctrl = binderCtrl;
    } else {
        PortfolioStructureMap map = (PortfolioStructureMap) CoreSpringFactory.getImpl(EPFrontendManager.class).loadPortfolioStructureByKey(key);
        EPSecurityCallback secCallback = new EPSecurityCallbackImpl(true, true);
        ctrl = EPUIFactory.createMapViewController(ureq, wControl, map, secCallback);
    }
    return ctrl;
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) Binder(org.olat.modules.portfolio.Binder) PortfolioService(org.olat.modules.portfolio.PortfolioService) BinderController(org.olat.modules.portfolio.ui.BinderController) EPSecurityCallback(org.olat.portfolio.EPSecurityCallback) BinderSecurityCallback(org.olat.modules.portfolio.BinderSecurityCallback) WeeklyCalendarController(org.olat.commons.calendar.ui.WeeklyCalendarController) EPCreateMapController(org.olat.portfolio.ui.structel.EPCreateMapController) OpenMeetingsRunController(org.olat.modules.openmeetings.ui.OpenMeetingsRunController) ChatToolController(org.olat.instantMessaging.ui.ChatToolController) CourseLinkProviderController(org.olat.course.run.calendar.CourseLinkProviderController) BinderController(org.olat.modules.portfolio.ui.BinderController) FolderRunController(org.olat.core.commons.modules.bc.FolderRunController) ContactFormController(org.olat.modules.co.ContactFormController) Controller(org.olat.core.gui.control.Controller) CalendarController(org.olat.commons.calendar.ui.CalendarController) InfoGroupRunController(org.olat.group.ui.run.InfoGroupRunController) EPSecurityCallbackImpl(org.olat.portfolio.EPSecurityCallbackImpl)

Example 5 with EPSecurityCallback

use of org.olat.portfolio.EPSecurityCallback in project OpenOLAT by OpenOLAT.

the class CollaborationTools method createPortfolioController.

/**
 * return an controller for the wiki tool
 * @param ureq
 * @param wControl
 * @return
 */
public Controller createPortfolioController(final UserRequest ureq, final WindowControl wControl, final TooledStackedPanel stackPanel, final BusinessGroup group) {
    final NarrowedPropertyManager npm = NarrowedPropertyManager.getInstance(ores);
    Property mapProperty = npm.findProperty(null, null, PROP_CAT_BG_COLLABTOOLS, KEY_PORTFOLIO);
    if (mapProperty != null) {
        return createPortfolioController(ureq, wControl, stackPanel, mapProperty);
    } else {
        return coordinatorManager.getCoordinator().getSyncer().doInSync(ores, new SyncerCallback<Controller>() {

            @Override
            public Controller execute() {
                Controller ctrl;
                Property mapKeyProperty = npm.findProperty(null, null, PROP_CAT_BG_COLLABTOOLS, KEY_PORTFOLIO);
                if (mapKeyProperty == null) {
                    PortfolioV2Module moduleV2 = CoreSpringFactory.getImpl(PortfolioV2Module.class);
                    if (moduleV2.isEnabled()) {
                        PortfolioService portfolioService = CoreSpringFactory.getImpl(PortfolioService.class);
                        Binder binder = portfolioService.createNewBinder(group.getName(), group.getDescription(), null, null);
                        CoreSpringFactory.getImpl(BinderUserInformationsDAO.class).updateBinderUserInformationsInSync(binder, ureq.getIdentity());
                        mapKeyProperty = npm.createPropertyInstance(null, null, PROP_CAT_BG_COLLABTOOLS, KEY_PORTFOLIO, null, binder.getKey(), "2", null);
                        BinderSecurityCallback secCallback = BinderSecurityCallbackFactory.getCallbackForBusinessGroup();
                        BinderController binderCtrl = new BinderController(ureq, wControl, stackPanel, secCallback, binder, BinderConfiguration.createBusinessGroupConfig());
                        List<ContextEntry> entries = BusinessControlFactory.getInstance().createCEListFromResourceType("Toc");
                        binderCtrl.activate(ureq, entries, null);
                        ctrl = binderCtrl;
                        ThreadLocalUserActivityLogger.addLoggingResourceInfo(LoggingResourceable.wrap(binder));
                        ThreadLocalUserActivityLogger.log(PortfolioLoggingAction.PORTFOLIO_BINDER_CREATED, getClass());
                    } else {
                        EPFrontendManager ePFMgr = CoreSpringFactory.getImpl(EPFrontendManager.class);
                        PortfolioStructureMap map = ePFMgr.createAndPersistPortfolioDefaultMap(group.getName(), group.getDescription());
                        Translator pT = Util.createPackageTranslator(EPCreateMapController.class, ureq.getLocale());
                        // add a page, as each map should have at least one per default!
                        ePFMgr.createAndPersistPortfolioPage(map, pT.translate("new.page.title"), pT.translate("new.page.desc"));
                        mapKeyProperty = npm.createPropertyInstance(null, null, PROP_CAT_BG_COLLABTOOLS, KEY_PORTFOLIO, null, map.getKey(), null, null);
                        EPSecurityCallback secCallback = new EPSecurityCallbackImpl(true, true);
                        ctrl = EPUIFactory.createMapViewController(ureq, wControl, map, secCallback);
                    }
                    npm.saveProperty(mapKeyProperty);
                } else {
                    ctrl = createPortfolioController(ureq, wControl, stackPanel, mapProperty);
                }
                return ctrl;
            }
        });
    }
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) PortfolioV2Module(org.olat.modules.portfolio.PortfolioV2Module) BinderSecurityCallback(org.olat.modules.portfolio.BinderSecurityCallback) WeeklyCalendarController(org.olat.commons.calendar.ui.WeeklyCalendarController) EPCreateMapController(org.olat.portfolio.ui.structel.EPCreateMapController) OpenMeetingsRunController(org.olat.modules.openmeetings.ui.OpenMeetingsRunController) ChatToolController(org.olat.instantMessaging.ui.ChatToolController) CourseLinkProviderController(org.olat.course.run.calendar.CourseLinkProviderController) BinderController(org.olat.modules.portfolio.ui.BinderController) FolderRunController(org.olat.core.commons.modules.bc.FolderRunController) ContactFormController(org.olat.modules.co.ContactFormController) Controller(org.olat.core.gui.control.Controller) CalendarController(org.olat.commons.calendar.ui.CalendarController) InfoGroupRunController(org.olat.group.ui.run.InfoGroupRunController) EPSecurityCallbackImpl(org.olat.portfolio.EPSecurityCallbackImpl) EPFrontendManager(org.olat.portfolio.manager.EPFrontendManager) Binder(org.olat.modules.portfolio.Binder) PortfolioService(org.olat.modules.portfolio.PortfolioService) BinderController(org.olat.modules.portfolio.ui.BinderController) Translator(org.olat.core.gui.translator.Translator) EPCreateMapController(org.olat.portfolio.ui.structel.EPCreateMapController) EPSecurityCallback(org.olat.portfolio.EPSecurityCallback) ArrayList(java.util.ArrayList) List(java.util.List) NarrowedPropertyManager(org.olat.properties.NarrowedPropertyManager) Property(org.olat.properties.Property)

Aggregations

EPSecurityCallback (org.olat.portfolio.EPSecurityCallback)14 EPSecurityCallbackImpl (org.olat.portfolio.EPSecurityCallbackImpl)10 BinderController (org.olat.modules.portfolio.ui.BinderController)8 Controller (org.olat.core.gui.control.Controller)6 BinderSecurityCallback (org.olat.modules.portfolio.BinderSecurityCallback)6 PortfolioStructureMap (org.olat.portfolio.model.structel.PortfolioStructureMap)6 ArrayList (java.util.ArrayList)4 CalendarController (org.olat.commons.calendar.ui.CalendarController)4 WeeklyCalendarController (org.olat.commons.calendar.ui.WeeklyCalendarController)4 LayoutMain3ColsController (org.olat.core.commons.fullWebApp.LayoutMain3ColsController)4 FolderRunController (org.olat.core.commons.modules.bc.FolderRunController)4 CourseLinkProviderController (org.olat.course.run.calendar.CourseLinkProviderController)4 InfoGroupRunController (org.olat.group.ui.run.InfoGroupRunController)4 ChatToolController (org.olat.instantMessaging.ui.ChatToolController)4 ContactFormController (org.olat.modules.co.ContactFormController)4 OpenMeetingsRunController (org.olat.modules.openmeetings.ui.OpenMeetingsRunController)4 Binder (org.olat.modules.portfolio.Binder)4 PortfolioService (org.olat.modules.portfolio.PortfolioService)4 EPCreateMapController (org.olat.portfolio.ui.structel.EPCreateMapController)4 Date (java.util.Date)2