示例#1
0
 /**
  * org.olat.lms.course.run.userview.UserCourseEnvironment,
  * org.olat.lms.course.run.userview.NodeEvaluation, java.lang.String)
  */
 @Override
 public NodeRunConstructionResult createNodeRunConstructionResult(
     final UserRequest ureq,
     final WindowControl wControl,
     final UserCourseEnvironment userCourseEnv,
     final NodeEvaluation ne,
     final String nodecmd) {
   final RepositoryEntry entry = getReferencedRepositoryEntry();
   // create business path courseID:nodeID
   // userCourseEnv.getCourseEnvironment().getCourseResourceableId();
   // getIdent();
   final Long courseId = userCourseEnv.getCourseEnvironment().getCourseResourceableId();
   final String nodeId = this.getIdent();
   final boolean isAdmin = ureq.getUserSession().getRoles().isOLATAdmin();
   final boolean isGuest = ureq.getUserSession().getRoles().isGuestOnly();
   final SubscriptionContext subscriptionContext =
       CourseModule.createSubscriptionContext(userCourseEnv.getCourseEnvironment(), this);
   final FeedSecurityCallback callback =
       new FeedNodeSecurityCallback(ne, isAdmin, isGuest, subscriptionContext);
   ThreadLocalUserActivityLogger.addLoggingResourceInfo(LoggingResourceable.wrap(this));
   final FeedMainController blogCtr =
       BlogUIFactory.getInstance(ureq.getLocale())
           .createMainController(
               entry.getOlatResource(), ureq, wControl, callback, courseId, nodeId);
   blogCtr.activate(ureq, nodecmd);
   final Controller wrapperCtrl =
       TitledWrapperHelper.getWrapper(ureq, wControl, blogCtr, this, "o_blog_icon");
   final NodeRunConstructionResult result = new NodeRunConstructionResult(wrapperCtrl);
   return result;
 }
示例#2
0
 @Override
 protected void doDispose() {
   ThreadLocalUserActivityLogger.log(
       LearningResourceLoggingAction.LEARNING_RESOURCE_CLOSE, getClass());
   cpTree = null;
   ctm = null;
   myContent = null;
   rootContainer = null;
   cpComponent = null;
 }
示例#3
0
  /**
   * @param ureq
   * @param te
   */
  public void switchToPage(final UserRequest ureq, final TreeEvent te) {
    // all treeevents receiced here are event clicked only
    // if (!te.getCommand().equals(TreeEvent.COMMAND_TREENODE_CLICKED)) throw
    // new AssertException("error");

    // switch to the new page
    final String nodeId = te.getNodeId();
    final TreeNode tn = ctm.getNodeById(nodeId);
    final String identifierRes = (String) tn.getUserObject();

    // security check
    if (identifierRes.indexOf("../") != -1) {
      throw new AssertException(
          "a non-normalized url encountered in a manifest item:" + identifierRes);
    }

    // Check if path ends with .html, .htm or .xhtml. We do this by searching for "htm"
    // and accept positions of this string at length-3 or length-4
    // Check also for XML resources that use XSLT for rendering
    if (identifierRes.toLowerCase().lastIndexOf(FILE_SUFFIX_HTM) >= (identifierRes.length() - 4)
        || identifierRes.toLowerCase().endsWith(FILE_SUFFIX_XML)) {
      // display html files inline or in an iframe
      if (cpContentCtr != null) {
        cpContentCtr.setCurrentURI(identifierRes);
      }
      if (cpComponent != null) {
        cpComponent.setCurrentURI(identifierRes);
      }

    } else {
      // Also display pdf and other files in the iframe if it has been
      // initialized. Delegates displaying to the browser (and its plugins).
      if (cpContentCtr != null) {
        cpContentCtr.setCurrentURI(identifierRes);
      } else {
        // if an entry in a manifest points e.g. to a pdf file and the iframe
        // controller has not been initialized display it non-inline
        final VFSItem currentItem = rootContainer.resolve(identifierRes);
        MediaResource mr;
        if (currentItem == null || !(currentItem instanceof VFSLeaf)) {
          mr = new NotFoundMediaResource(identifierRes);
        } else {
          mr = new VFSMediaResource((VFSLeaf) currentItem);
        }
        ureq.getDispatchResult().setResultingMediaResource(mr);
        // Prevent 'don't reload' warning
        cpTree.setDirty(false);
      }
    }
    ThreadLocalUserActivityLogger.log(
        CourseLoggingAction.CP_GET_FILE, getClass(), LoggingResourceable.wrapCpNode(identifierRes));
  }
 @Override
 protected void event(final UserRequest ureq, final Controller source, final Event event) {
   if (source == copyForm) {
     if (event == Event.DONE_EVENT) {
       groupNamesForm =
           new GroupNamesForm(ureq, wControl, this.originalGroup.getMaxParticipants());
       groupNamesForm.addControllerListener(this);
       setNextWizardStep(
           trans.translate("bgcopywizard.multiple.groupnames.title"),
           groupNamesForm.getInitialComponent());
     }
   } else if (source == groupNamesForm) {
     if (event == Event.DONE_EVENT) {
       final List groupNames = this.groupNamesForm.getGroupNamesList();
       final StringBuilder okGroups = new StringBuilder();
       final StringBuilder nokGroups = new StringBuilder();
       final Integer max = this.groupNamesForm.getGroupMax();
       final Iterator iter = groupNames.iterator();
       while (iter.hasNext()) {
         final String groupName = (String) iter.next();
         final BusinessGroup newGroup = doCopyGroup(groupName, max);
         if (newGroup == null) {
           nokGroups.append("<li>");
           nokGroups.append(groupName);
           nokGroups.append("</li>");
         } else {
           okGroups.append("<li>");
           okGroups.append(groupName);
           okGroups.append("</li>");
           // do logging
           ThreadLocalUserActivityLogger.log(
               GroupLoggingAction.BG_GROUP_COPIED,
               getClass(),
               LoggingResourceable.wrap(originalGroup),
               LoggingResourceable.wrap(newGroup));
         }
       }
       if (nokGroups.length() > 0) {
         final String warning =
             trans.translate(
                 "bgcopywizard.multiple.groupnames.douplicates",
                 new String[] {okGroups.toString(), nokGroups.toString()});
         getWindowControl().setWarning(warning);
       }
       // in all cases quit workflow
       fireEvent(ureq, Event.DONE_EVENT);
     }
   }
 }
示例#5
0
 /**
  * adjust the cp menu tree with the page selected with a link clicked in the content
  *
  * @param ureq
  * @param newUri
  */
 public void selectTreeNode(final UserRequest ureq, final String newUri) {
   final TreeNode newNode = ctm.lookupTreeNodeByHref(newUri);
   if (newNode != null) { // user clicked on a link which is listed in the
     // toc
     if (cpTree != null) {
       cpTree.setSelectedNodeId(newNode.getIdent());
     } else {
       // for the case the tree is outside this controller (e.g. in the
       // course), we fire an event with the chosen node)
       fireEvent(ureq, new TreeNodeEvent(newNode));
     }
   }
   ThreadLocalUserActivityLogger.log(
       CourseLoggingAction.CP_GET_FILE, getClass(), LoggingResourceable.wrapCpNode(newUri));
 }
示例#6
0
  /**
   * @param ureq
   * @param cpRoot
   * @param showMenu
   * @param activateFirstPage
   */
  CPDisplayController(
      final UserRequest ureq,
      final WindowControl wControl,
      final VFSContainer rootContainer,
      final boolean showMenu,
      final boolean activateFirstPage,
      final String initialUri,
      final OLATResourceable ores) {
    super(ureq, wControl);
    this.rootContainer = rootContainer;

    // wrapper velocity container for page content
    this.myContent = createVelocityContainer("cpDisplay");
    // the cp component, added to the velocity

    if (!ureq.getUserSession().getRoles().isGuestOnly()) {
      final SearchServiceUIFactory searchServiceUIFactory =
          (SearchServiceUIFactory) CoreSpringFactory.getBean(SearchServiceUIFactory.class);
      searchCtrl =
          searchServiceUIFactory.createInputController(ureq, wControl, DisplayOption.BUTTON, null);
      myContent.put("search_input", searchCtrl.getInitialComponent());
    }

    // TODO:gs:a
    // may add an additional config for disabling, enabling IFrame style or not in CP mode
    // but always disable IFrame display when in screenreader mode (no matter whether style gets
    // ugly)
    if (getWindowControl().getWindowBackOffice().getWindowManager().isForScreenReader()) {
      cpComponent = new HtmlStaticPageComponent("", rootContainer);
      cpComponent.addListener(this);
      myContent.put("cpContent", cpComponent);
    } else {
      cpContentCtr =
          new IFrameDisplayController(ureq, getWindowControl(), rootContainer, null, ores);
      cpContentCtr.setAllowDownload(true);
      listenTo(cpContentCtr);
      myContent.put("cpContent", cpContentCtr.getInitialComponent());
    }

    // even if we do not show the menu, we need to build parse the manifest and
    // find the first node to display at startup
    final VFSItem mani = rootContainer.resolve("imsmanifest.xml");
    if (mani == null || !(mani instanceof VFSLeaf)) {
      throw new OLATRuntimeException(
          "error.manifest.missing",
          null,
          this.getClass().getPackage().getName(),
          "CP " + rootContainer + " has no imsmanifest",
          null);
    }
    // initialize tree model in any case
    ctm = new CPManifestTreeModel((VFSLeaf) mani);

    if (showMenu) {
      // the menu is only initialized when needed.
      cpTree = new MenuTree("cpDisplayTree");
      cpTree.setTreeModel(ctm);
      cpTree.addListener(this);
    }

    LoggingResourceable nodeInfo = null;
    if (activateFirstPage) {
      // set content to first accessible child or root node if no children
      // available
      TreeNode node = ctm.getRootNode();
      if (node == null) {
        throw new OLATRuntimeException(
            CPDisplayController.class,
            "root node of content packaging was null, file:" + rootContainer,
            null);
      }
      while (node != null && !node.isAccessible()) {
        if (node.getChildCount() > 0) {
          node = (TreeNode) node.getChildAt(0);
        } else {
          node = null;
        }
      }
      if (node != null) { // node.isAccessible
        final String nodeUri = (String) node.getUserObject();
        if (cpContentCtr != null) {
          cpContentCtr.setCurrentURI(nodeUri);
        }
        if (cpComponent != null) {
          cpComponent.setCurrentURI(nodeUri);
        }
        if (showMenu) {
          cpTree.setSelectedNodeId(node.getIdent());
        }
        // activate the selected node in the menu (skips the root node that is
        // empty anyway and saves one user click)
        selNodeId = node.getIdent();

        nodeInfo = LoggingResourceable.wrapCpNode(nodeUri);
      }
    } else if (initialUri != null) {
      // set page
      if (cpContentCtr != null) {
        cpContentCtr.setCurrentURI(initialUri);
      }
      if (cpComponent != null) {
        cpComponent.setCurrentURI(initialUri);
      }
      // update menu
      final TreeNode newNode = ctm.lookupTreeNodeByHref(initialUri);
      if (newNode != null) { // user clicked on a link which is listed in the
        // toc
        if (cpTree != null) {
          cpTree.setSelectedNodeId(newNode.getIdent());
        } else {
          selNodeId = newNode.getIdent();
        }
      }
      nodeInfo = LoggingResourceable.wrapCpNode(initialUri);
    }
    // Note: the ores has a typename of ICourse - see
    // CPCourseNode.createNodeRunConstructorResult
    // which has the following line:
    // OresHelper.createOLATResourceableInstance(ICourse.class,
    // userCourseEnv.getCourseEnvironment().getCourseResourceableId());
    // therefore we use OresHelper.calculateTypeName(ICourse.class) here
    if (ores != null
        && nodeInfo != null
        && !OresHelper.calculateTypeName(ICourse.class).equals(ores.getResourceableTypeName())) {
      addLoggingResourceable(LoggingResourceable.wrap(ores, OlatResourceableType.cp));
      ThreadLocalUserActivityLogger.log(
          LearningResourceLoggingAction.LEARNING_RESOURCE_OPEN, getClass(), nodeInfo);
    }

    putInitialPanel(myContent);
  }