Search in sources :

Example 11 with FolderRunController

use of org.olat.core.commons.modules.bc.FolderRunController in project OpenOLAT by OpenOLAT.

the class CollaborationTools method createFolderController.

/**
 * Creates a folder run controller with all rights enabled for everybody
 *
 * @param ureq
 * @param wControl
 * @param subsContext
 * @return Copnfigured FolderRunController
 */
public FolderRunController createFolderController(UserRequest ureq, WindowControl wControl, BusinessGroup businessGroup, boolean isAdmin, final SubscriptionContext subsContext) {
    // do not use a global translator since in the fututre a collaborationtools
    // may be shared among users
    Translator trans = Util.createPackageTranslator(this.getClass(), ureq.getLocale());
    OlatRootFolderImpl rootContainer = getSecuredFolder(businessGroup, subsContext, ureq.getIdentity(), isAdmin);
    OlatNamedContainerImpl namedContainer = new OlatNamedContainerImpl(trans.translate("folder"), rootContainer);
    FolderRunController frc = new FolderRunController(namedContainer, true, true, true, ureq, wControl);
    return frc;
}
Also used : OlatNamedContainerImpl(org.olat.core.commons.modules.bc.vfs.OlatNamedContainerImpl) OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) Translator(org.olat.core.gui.translator.Translator) FolderRunController(org.olat.core.commons.modules.bc.FolderRunController)

Example 12 with FolderRunController

use of org.olat.core.commons.modules.bc.FolderRunController in project OpenOLAT by OpenOLAT.

the class TaskFolderCallback 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 (log.isDebug())
        log.debug("event source=" + source + " " + event.toString());
    if (source == btfButton) {
        // check if there are already assigned tasks
        CoursePropertyManager cpm = PersistingCoursePropertyManager.getInstance(course);
        List<Property> assignedProps = cpm.listCourseNodeProperties(node, null, null, TaskController.PROP_ASSIGNED);
        if (assignedProps.size() == 0) {
            // no task assigned
            String relPath = TACourseNode.getTaskFolderPathRelToFolderRoot(course, node);
            OlatRootFolderImpl rootFolder = new OlatRootFolderImpl(relPath, null);
            OlatNamedContainerImpl namedFolder = new OlatNamedContainerImpl(translate("taskfolder"), rootFolder);
            namedFolder.setLocalSecurityCallback(getTaskFolderSecCallback(relPath));
            frc = new FolderRunController(namedFolder, false, ureq, getWindowControl());
            // listenTo(frc);
            frc.addControllerListener(this);
            CloseableModalController cmc = new CloseableModalController(getWindowControl(), translate("folder.close"), frc.getInitialComponent());
            cmc.activate();
        } else {
            // already assigned task => open dialog with warn
            String[] args = new String[] { new Integer(assignedProps.size()).toString() };
            dialogBoxController = activateOkCancelDialog(ureq, "", getTranslator().translate("taskfolder.overwriting.confirm", args), dialogBoxController);
        }
    } else if (source == vfButton) {
        // switch to new dialog
        OlatNamedContainerImpl namedContainer = TACourseNode.getNodeFolderContainer(node, course.getCourseEnvironment());
        Quota quota = QuotaManager.getInstance().getCustomQuota(namedContainer.getRelPath());
        if (quota == null) {
            Quota defQuota = QuotaManager.getInstance().getDefaultQuota(QuotaConstants.IDENTIFIER_DEFAULT_NODES);
            quota = QuotaManager.getInstance().createQuota(namedContainer.getRelPath(), defQuota.getQuotaKB(), defQuota.getUlLimitKB());
        }
        SubscriptionContext subContext = SolutionFileUploadNotificationHandler.getSubscriptionContext(course.getCourseEnvironment(), node);
        VFSSecurityCallback secCallback = new FullAccessWithQuotaCallback(quota, subContext);
        namedContainer.setLocalSecurityCallback(secCallback);
        FolderRunController folderCtrl = new FolderRunController(namedContainer, false, ureq, getWindowControl());
        CloseableModalController cmc = new CloseableModalController(getWindowControl(), translate("close"), folderCtrl.getInitialComponent());
        cmc.activate();
    } else if (source == editScoringConfigButton) {
        scoringController.setDisplayOnly(false);
        editScoring.contextPut("isOverwriting", new Boolean(true));
    }
}
Also used : CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) OlatNamedContainerImpl(org.olat.core.commons.modules.bc.vfs.OlatNamedContainerImpl) OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) FullAccessWithQuotaCallback(org.olat.core.util.vfs.callbacks.FullAccessWithQuotaCallback) Quota(org.olat.core.util.vfs.Quota) FolderRunController(org.olat.core.commons.modules.bc.FolderRunController) SubscriptionContext(org.olat.core.commons.services.notifications.SubscriptionContext) Property(org.olat.properties.Property) VFSSecurityCallback(org.olat.core.util.vfs.callbacks.VFSSecurityCallback) CoursePropertyManager(org.olat.course.properties.CoursePropertyManager) PersistingCoursePropertyManager(org.olat.course.properties.PersistingCoursePropertyManager)

Example 13 with FolderRunController

use of org.olat.core.commons.modules.bc.FolderRunController in project OpenOLAT by OpenOLAT.

the class ReturnboxFullAccessCallback method init.

protected void init(UserRequest ureq) {
    myContent = createVelocityContainer("dropboxscoring");
    taskLaunchButton = LinkFactory.createButton("task.launch", myContent, this);
    cancelTaskButton = LinkFactory.createButton("task.cancel", myContent, this);
    cancelTaskButton.setVisible(!userCourseEnv.isCourseReadOnly());
    putInitialPanel(myContent);
    ModuleConfiguration modConfig = node.getModuleConfiguration();
    Boolean bValue = (Boolean) modConfig.get(TACourseNode.CONF_TASK_ENABLED);
    myContent.contextPut("hasTask", (bValue != null) ? bValue : new Boolean(false));
    // configured value
    Boolean hasDropbox = (Boolean) modConfig.get(TACourseNode.CONF_DROPBOX_ENABLED);
    Boolean hasDropboxValue = (hasDropbox != null) ? hasDropbox : new Boolean(true);
    myContent.contextPut("hasDropbox", hasDropboxValue);
    Boolean hasReturnbox = (Boolean) modConfig.get(TACourseNode.CONF_RETURNBOX_ENABLED);
    myContent.contextPut("hasReturnbox", (hasReturnbox != null) ? hasReturnbox : hasDropboxValue);
    // dropbox display
    Identity assessee = userCourseEnv.getIdentityEnvironment().getIdentity();
    String assesseeName = assessee.getName();
    UserManager userManager = CoreSpringFactory.getImpl(UserManager.class);
    String assesseeFullName = StringHelper.escapeHtml(userManager.getUserDisplayName(assessee));
    // notification
    if (hasNotification) {
        subsContext = DropboxFileUploadNotificationHandler.getSubscriptionContext(userCourseEnv.getCourseEnvironment(), node);
        if (subsContext != null) {
            String path = DropboxController.getDropboxPathRelToFolderRoot(userCourseEnv.getCourseEnvironment(), node);
            contextualSubscriptionCtr = AbstractTaskNotificationHandler.createContextualSubscriptionController(ureq, this.getWindowControl(), path, subsContext, DropboxController.class);
            myContent.put("subscription", contextualSubscriptionCtr.getInitialComponent());
            myContent.contextPut("hasNotification", Boolean.TRUE);
        }
    } else {
        myContent.contextPut("hasNotification", Boolean.FALSE);
    }
    OlatRootFolderImpl rootDropbox = new OlatRootFolderImpl(getDropboxFilePath(assesseeName), null);
    rootDropbox.setLocalSecurityCallback(getDropboxVfsSecurityCallback());
    OlatNamedContainerImpl namedDropbox = new OlatNamedContainerImpl(assesseeFullName, rootDropbox);
    namedDropbox.setLocalSecurityCallback(getDropboxVfsSecurityCallback());
    dropboxFolderRunController = new FolderRunController(namedDropbox, false, ureq, getWindowControl());
    listenTo(dropboxFolderRunController);
    myContent.put("dropbox", dropboxFolderRunController.getInitialComponent());
    Identity assessedIdentity = userCourseEnv.getIdentityEnvironment().getIdentity();
    // returnbox display
    OlatRootFolderImpl rootReturnbox = new OlatRootFolderImpl(getReturnboxFilePath(assesseeName), null);
    VFSSecurityCallback secCallback = getReturnboxVfsSecurityCallback(rootReturnbox.getRelPath(), assessedIdentity);
    rootReturnbox.setLocalSecurityCallback(secCallback);
    OlatNamedContainerImpl namedReturnbox = new OlatNamedContainerImpl(assesseeFullName, rootReturnbox);
    namedReturnbox.setLocalSecurityCallback(secCallback);
    returnboxFolderRunController = new FolderRunController(namedReturnbox, false, ureq, getWindowControl());
    returnboxFolderRunController.disableSubscriptionController();
    listenTo(returnboxFolderRunController);
    myContent.put("returnbox", returnboxFolderRunController.getInitialComponent());
    // insert Status Pull-Down Menu depending on user role == author
    boolean isAuthor = ureq.getUserSession().getRoles().isAuthor();
    boolean isTutor = userCourseEnv.getCourseEnvironment().getCourseGroupManager().isIdentityCourseCoach(ureq.getIdentity());
    if (((AssessableCourseNode) node).hasStatusConfigured() && (isAuthor || isTutor)) {
        myContent.contextPut("hasStatusPullDown", Boolean.TRUE);
        statusForm = new StatusForm(ureq, getWindowControl(), userCourseEnv.isCourseReadOnly());
        listenTo(statusForm);
        // get identity not from request (this would be an author)
        StatusManager.getInstance().loadStatusFormData(statusForm, node, userCourseEnv);
        myContent.put("statusForm", statusForm.getInitialComponent());
    }
    assignedTask = TaskController.getAssignedTask(assessedIdentity, userCourseEnv.getCourseEnvironment(), node);
    if (assignedTask != null) {
        myContent.contextPut("assignedtask", assignedTask);
        myContent.contextPut("taskIcon", CSSHelper.createFiletypeIconCssClassFor(assignedTask));
        if (!(assignedTask.toLowerCase().endsWith(".html") || assignedTask.toLowerCase().endsWith(".htm") || assignedTask.toLowerCase().endsWith(".txt"))) {
            taskLaunchButton.setTarget("_blank");
        }
    }
}
Also used : OlatNamedContainerImpl(org.olat.core.commons.modules.bc.vfs.OlatNamedContainerImpl) ModuleConfiguration(org.olat.modules.ModuleConfiguration) OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) UserManager(org.olat.user.UserManager) FolderRunController(org.olat.core.commons.modules.bc.FolderRunController) Identity(org.olat.core.id.Identity) VFSSecurityCallback(org.olat.core.util.vfs.callbacks.VFSSecurityCallback)

Example 14 with FolderRunController

use of org.olat.core.commons.modules.bc.FolderRunController in project OpenOLAT by OpenOLAT.

the class ReturnboxController method initReturnbox.

protected void initReturnbox(UserRequest ureq, WindowControl wControl, CourseNode node, UserCourseEnvironment userCourseEnv, boolean previewMode) {
    // returnbox display
    myContent = createVelocityContainer("returnbox");
    OlatRootFolderImpl rootFolder = new OlatRootFolderImpl(getReturnboxPathFor(userCourseEnv.getCourseEnvironment(), node, ureq.getIdentity()), null);
    String fullName = StringHelper.escapeHtml(userManager.getUserDisplayName(getIdentity()));
    OlatNamedContainerImpl namedContainer = new OlatNamedContainerImpl(fullName, rootFolder);
    namedContainer.setLocalSecurityCallback(new ReadOnlyCallback());
    returnboxFolderRunController = new FolderRunController(namedContainer, false, ureq, wControl);
    returnboxFolderRunController.addControllerListener(this);
    myContent.put("returnbox", returnboxFolderRunController.getInitialComponent());
    // notification
    if (!previewMode && !ureq.getUserSession().getRoles().isGuestOnly()) {
        // offer subscription, but not to guests
        subsContext = ReturnboxFileUploadNotificationHandler.getSubscriptionContext(userCourseEnv.getCourseEnvironment(), node, ureq.getIdentity());
        if (subsContext != null) {
            contextualSubscriptionCtr = AbstractTaskNotificationHandler.createContextualSubscriptionController(ureq, wControl, getReturnboxPathFor(userCourseEnv.getCourseEnvironment(), node, ureq.getIdentity()), subsContext, ReturnboxController.class);
            myContent.put("subscription", contextualSubscriptionCtr.getInitialComponent());
            myContent.contextPut("hasNotification", Boolean.TRUE);
        }
    } else {
        myContent.contextPut("hasNotification", Boolean.FALSE);
    }
    putInitialPanel(myContent);
}
Also used : OlatNamedContainerImpl(org.olat.core.commons.modules.bc.vfs.OlatNamedContainerImpl) OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) ReadOnlyCallback(org.olat.core.util.vfs.callbacks.ReadOnlyCallback) FolderRunController(org.olat.core.commons.modules.bc.FolderRunController)

Example 15 with FolderRunController

use of org.olat.core.commons.modules.bc.FolderRunController in project OpenOLAT by OpenOLAT.

the class CourseLogsArchiveController 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)
 */
public void event(UserRequest ureq, Component source, Event event) {
    if (source == showFileButton) {
        ICourse course = CourseFactory.loadCourse(ores);
        String personalFolderDir = CourseFactory.getPersonalDirectory(ureq.getIdentity()).getPath();
        String targetDir = CourseFactory.getOrCreateDataExportDirectory(ureq.getIdentity(), course.getCourseTitle()).getPath();
        String relPath = "";
        if (targetDir.startsWith(personalFolderDir)) {
            // that should always be the case
            relPath = targetDir.substring(personalFolderDir.length()).replace("\\", "/");
            targetDir = targetDir.substring(0, personalFolderDir.length());
        }
        VFSContainer targetFolder = new LocalFolderImpl(new File(targetDir));
        FolderRunController bcrun = new FolderRunController(targetFolder, true, ureq, getWindowControl());
        Component folderComponent = bcrun.getInitialComponent();
        if (relPath.length() != 0) {
            if (!relPath.endsWith("/")) {
                relPath = relPath + "/";
            }
            bcrun.activatePath(ureq, relPath);
        }
        String personalFolder = Util.createPackageTranslator(HomeMainController.class, ureq.getLocale(), null).translate("menu.bc");
        removeAsListenerAndDispose(cmc);
        cmc = new CloseableModalController(getWindowControl(), translate("close"), folderComponent, true, personalFolder);
        listenTo(cmc);
        cmc.activate();
    }
}
Also used : CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) VFSContainer(org.olat.core.util.vfs.VFSContainer) FolderRunController(org.olat.core.commons.modules.bc.FolderRunController) ICourse(org.olat.course.ICourse) Component(org.olat.core.gui.components.Component) HomeMainController(org.olat.home.HomeMainController) File(java.io.File) LocalFolderImpl(org.olat.core.util.vfs.LocalFolderImpl)

Aggregations

FolderRunController (org.olat.core.commons.modules.bc.FolderRunController)22 OlatNamedContainerImpl (org.olat.core.commons.modules.bc.vfs.OlatNamedContainerImpl)16 OlatRootFolderImpl (org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl)14 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)12 VFSContainer (org.olat.core.util.vfs.VFSContainer)6 ReadOnlyCallback (org.olat.core.util.vfs.callbacks.ReadOnlyCallback)6 VFSSecurityCallback (org.olat.core.util.vfs.callbacks.VFSSecurityCallback)6 Quota (org.olat.core.util.vfs.Quota)4 FullAccessWithQuotaCallback (org.olat.core.util.vfs.callbacks.FullAccessWithQuotaCallback)4 ICourse (org.olat.course.ICourse)4 File (java.io.File)2 List (java.util.List)2 IdentitiesAddEvent (org.olat.admin.securitygroup.gui.IdentitiesAddEvent)2 IdentitiesRemoveEvent (org.olat.admin.securitygroup.gui.IdentitiesRemoveEvent)2 CustomLinkTreeModel (org.olat.core.commons.controllers.linkchooser.CustomLinkTreeModel)2 LayoutMain3ColsController (org.olat.core.commons.fullWebApp.LayoutMain3ColsController)2 GlossaryMainController (org.olat.core.commons.modules.glossary.GlossaryMainController)2 SubscriptionContext (org.olat.core.commons.services.notifications.SubscriptionContext)2 Component (org.olat.core.gui.components.Component)2 ChiefController (org.olat.core.gui.control.ChiefController)2