Exemplo n.º 1
0
  /**
   * Append the calendars of a list of groups. The groups must have their calendar tool enabled,
   * this routine doesn't check it.
   *
   * @param ureq
   * @param groups
   * @param isOwner
   * @param calendars
   */
  private void addCalendars(
      List<BusinessGroup> groups,
      boolean isOwner,
      boolean isParticipant,
      List<KalendarRenderWrapper> calendars,
      Map<CalendarKey, CalendarUserConfiguration> configMap) {

    Map<Long, Long> groupKeyToAccess =
        CoreSpringFactory.getImpl(CollaborationManager.class).lookupCalendarAccess(groups);
    for (BusinessGroup bGroup : groups) {
      KalendarRenderWrapper groupCalendarWrapper = calendarManager.getGroupCalendar(bGroup);
      groupCalendarWrapper.setPrivateEventsVisible(true);
      // set calendar access
      int iCalAccess = CollaborationTools.CALENDAR_ACCESS_OWNERS;
      Long lCalAccess = groupKeyToAccess.get(bGroup.getKey());
      if (lCalAccess != null) {
        iCalAccess = lCalAccess.intValue();
      }
      if (iCalAccess == CollaborationTools.CALENDAR_ACCESS_OWNERS && !isOwner) {
        groupCalendarWrapper.setAccess(KalendarRenderWrapper.ACCESS_READ_ONLY);
      } else {
        groupCalendarWrapper.setAccess(KalendarRenderWrapper.ACCESS_READ_WRITE);
      }
      CalendarUserConfiguration config = configMap.get(groupCalendarWrapper.getCalendarKey());
      if (config != null) {
        groupCalendarWrapper.setConfiguration(config);
      }
      if (isOwner || isParticipant) {
        groupCalendarWrapper.setPrivateEventsVisible(true);
      }
      calendars.add(groupCalendarWrapper);
    }
  }
  /**
   * Index a forum in a group.
   *
   * @param parentResourceContext
   * @param businessGroup
   * @param indexWriter
   * @throws IOException
   */
  @Override
  public void doIndex(
      final SearchResourceContext parentResourceContext,
      final Object businessObj,
      final OlatFullIndexer indexWriter)
      throws IOException, InterruptedException {
    if (!(businessObj instanceof BusinessGroup)) {
      throw new AssertException("businessObj must be BusinessGroup");
    }
    final BusinessGroup businessGroup = (BusinessGroup) businessObj;

    final NarrowedPropertyManager npm = NarrowedPropertyManager.getInstance(businessGroup);
    final ForumManager fom = ForumManager.getInstance();

    final Property forumKeyProperty =
        npm.findProperty(
            null, null, CollaborationTools.PROP_CAT_BG_COLLABTOOLS, CollaborationTools.KEY_FORUM);
    // Check if forum-property exist
    if (forumKeyProperty != null) {
      final Long forumKey = forumKeyProperty.getLongValue();
      final Forum forum = fom.loadForum(forumKey);
      final SearchResourceContext forumSearchResourceContext =
          new SearchResourceContext(parentResourceContext);
      forumSearchResourceContext.setBusinessControlFor(
          BusinessGroupMainRunController.ORES_TOOLFORUM);
      forumSearchResourceContext.setDocumentType(TYPE);
      forumSearchResourceContext.setDocumentContext(businessGroup.getKey() + " " + forumKey);
      forumSearchResourceContext.setParentContextType(GroupDocument.TYPE);
      forumSearchResourceContext.setParentContextName(businessGroup.getName());
      doIndexAllMessages(forumSearchResourceContext, forum, indexWriter);
    }
  }
  @Override
  public SubscriptionContext getSubscriptionContext(
      KalendarRenderWrapper kalendarRenderWrapper, OLATResourceable course) {
    String caller = kalendarRenderWrapper.getKalendar().getType();

    SubscriptionContext subsContext = null;
    if (caller.equals(CalendarController.CALLER_COURSE)
        || caller.equals(CalendarManager.TYPE_COURSE)) {
      subsContext =
          new SubscriptionContext(
              OresHelper.calculateTypeName(CalendarManager.class)
                  + "."
                  + CalendarManager.TYPE_COURSE,
              course.getResourceableId(),
              CalendarController.ACTION_CALENDAR_COURSE);
    } else if (caller.equals(CalendarController.CALLER_COLLAB)
        || caller.equals(CalendarManager.TYPE_GROUP)) {
      BusinessGroup businessGroup = getBusinessGroup(kalendarRenderWrapper);
      if (businessGroup != null) {
        subsContext =
            new SubscriptionContext(
                OresHelper.calculateTypeName(CalendarManager.class)
                    + "."
                    + CalendarManager.TYPE_GROUP,
                businessGroup.getResourceableId(),
                CalendarController.ACTION_CALENDAR_GROUP);
      }
    }
    return subsContext;
  }
Exemplo n.º 4
0
 public Bookmark(Mark mark, BusinessGroup group) {
   this.mark = mark;
   title = group.getName();
   description = group.getDescription();
   statusCode = -1;
   creationDate = group.getCreationDate();
   displayrestype = group.getResourceableTypeName();
 }
Exemplo n.º 5
0
  @Test
  public void assignTask_businessGroup() {
    // prepare
    Identity coach = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-2");
    Identity participant1 = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-3");
    Identity participant2 = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-4");
    Identity participant3 = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-5");
    Identity participant4 = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-6");

    BusinessGroup businessGroup1 =
        businessGroupDao.createAndPersist(
            coach, "gdao", "gdao-desc", -1, -1, false, false, false, false, false);
    BusinessGroup businessGroup2 =
        businessGroupDao.createAndPersist(
            coach, "gdao", "gdao-desc", -1, -1, false, false, false, false, false);

    businessGroupRelationDao.addRole(participant1, businessGroup1, GroupRole.participant.name());
    businessGroupRelationDao.addRole(participant2, businessGroup1, GroupRole.participant.name());
    businessGroupRelationDao.addRole(participant3, businessGroup2, GroupRole.participant.name());
    businessGroupRelationDao.addRole(participant4, businessGroup2, GroupRole.participant.name());
    dbInstance.commit();

    RepositoryEntry re = JunitTestHelper.createAndPersistRepositoryEntry("", false);
    businessGroupRelationDao.addRelationToResource(businessGroup1, re);
    businessGroupRelationDao.addRelationToResource(businessGroup2, re);

    GTACourseNode node = new GTACourseNode();
    node.getModuleConfiguration().setStringValue(GTACourseNode.GTASK_TYPE, GTAType.group.name());
    List<Long> groupKeys = new ArrayList<>(2);
    groupKeys.add(businessGroup1.getKey());
    groupKeys.add(businessGroup2.getKey());
    node.getModuleConfiguration().setList(GTACourseNode.GTASK_GROUPS, groupKeys);
    TaskList tasks = gtaManager.createIfNotExists(re, node);
    File taskFile = new File("bg.txt");
    Assert.assertNotNull(tasks);
    dbInstance.commit();

    // group 1 select a task
    AssignmentResponse response = gtaManager.selectTask(businessGroup1, tasks, node, taskFile);
    dbInstance.commitAndCloseSession();
    Assert.assertEquals(AssignmentResponse.Status.ok, response.getStatus());

    // only remind group 2
    List<Identity> toRemind = assignTaskRuleSPI.getPeopleToRemind(re, node);
    Assert.assertEquals(2, toRemind.size());
    Assert.assertTrue(toRemind.contains(participant3));
    Assert.assertTrue(toRemind.contains(participant4));
  }
  public List<Group> getCoachedBaseGroups(boolean withRepo, boolean withBusinessGroups) {
    List<Group> groups;
    if (isCoach()) {
      boolean repoCoach = false;
      groups = new ArrayList<Group>();
      if (withBusinessGroups && sizeCoachedGroups() > 0) {
        for (BusinessGroup businessGroup : getCoachedGroups()) {
          groups.add(businessGroup.getBaseGroup());
        }
      }

      if (withRepo && repoCoach) {
        // TODO groups
      }
    } else {
      groups = Collections.emptyList();
    }
    return groups;
  }
  /**
   * Index a forum in a group.
   *
   * @param parentResourceContext
   * @param businessGroup
   * @param indexWriter
   * @throws IOException
   */
  public void doIndex(
      SearchResourceContext parentResourceContext, Object businessObj, OlatFullIndexer indexWriter)
      throws IOException, InterruptedException {
    if (!(businessObj instanceof BusinessGroup))
      throw new AssertException("businessObj must be BusinessGroup");
    BusinessGroup businessGroup = (BusinessGroup) businessObj;

    NarrowedPropertyManager npm = NarrowedPropertyManager.getInstance(businessGroup);
    ForumManager fom = ForumManager.getInstance();

    Property forumKeyProperty =
        npm.findProperty(
            null, null, CollaborationTools.PROP_CAT_BG_COLLABTOOLS, CollaborationTools.KEY_FORUM);
    // Check if forum-property exist
    if (forumKeyProperty != null) {
      Long forumKey = forumKeyProperty.getLongValue();
      Forum forum = fom.loadForum(forumKey);
      SearchResourceContext forumSearchResourceContext =
          new SearchResourceContext(parentResourceContext);
      forumSearchResourceContext.setBusinessControlFor(
          BusinessGroupMainRunController.ORES_TOOLFORUM);
      forumSearchResourceContext.setDocumentType(TYPE);
      forumSearchResourceContext.setParentContextType(GroupDocument.TYPE);
      forumSearchResourceContext.setParentContextName(businessGroup.getName());
      if (forum == null) { // fxdiff: FXOLAT-104 warn about missing forums
        logError(
            "found a forum-key "
                + forumKey
                + " for businessgroup "
                + businessGroup.getName()
                + " ["
                + businessGroup.getKey()
                + "] to index a forum that could not be "
                + "found by key! skip indexing, check if forum should still be enabled. context: "
                + forumSearchResourceContext.getResourceUrl(),
            null);
        return;
      }
      doIndexAllMessages(forumSearchResourceContext, forum, indexWriter);
    }
  }
  /**
   * Perform a search for the given search value in the search result providers and clear any GUI
   * errors that might be on the page
   *
   * @param searchValue
   * @param ureq
   */
  private void doSearchGroups(String searchValue, UserRequest ureq) {
    if (StringHelper.containsNonWhitespace(searchValue)) {
      SearchBusinessGroupParams param1s = new SearchBusinessGroupParams();
      param1s.setNameOrDesc(searchValue);
      List<BusinessGroup> group1s = businessGroupService.findBusinessGroups(param1s, null, 0, -1);
      filterGroups(group1s);

      SearchBusinessGroupParams param2s = new SearchBusinessGroupParams();
      param2s.setCourseTitle(searchValue);
      List<BusinessGroup> group2s = businessGroupService.findBusinessGroups(param2s, null, 0, -1);
      filterGroups(group2s);

      List<BusinessGroup> groups = new ArrayList<BusinessGroup>(group1s.size() + group2s.size());
      groups.addAll(group1s);
      groups.addAll(group2s);

      List<Long> groupKeysWithRelations = PersistenceHelper.toKeys(groups);
      List<BGRepositoryEntryRelation> resources =
          businessGroupService.findRelationToRepositoryEntries(groupKeysWithRelations, 0, -1);

      List<GroupWrapper> groupWrappers = new ArrayList<GroupWrapper>();
      for (BusinessGroup group : groups) {
        StringBuilder sb = new StringBuilder();
        for (BGRepositoryEntryRelation resource : resources) {
          if (resource.getGroupKey().equals(group.getKey())) {
            if (sb.length() > 0) sb.append(", ");
            sb.append(resource.getRepositoryEntryDisplayName());
          }
        }

        GroupWrapper wrapper = new GroupWrapper(group, sb.toString());
        wrapper.setTutor(createSelection("tutor_" + group.getKey()));
        wrapper.setParticipant(createSelection("participant_" + group.getKey()));
        groupWrappers.add(wrapper);
      }

      table.reset();
      tableDataModel.setObjects(groupWrappers);
      errorComp.clearError();
    }
  }
  /**
   * @see
   *     org.olat.core.gui.components.form.flexible.impl.FormBasicController#validateFormLogic(org.olat.core.gui.UserRequest)
   */
  @Override
  public boolean validateFormLogic(UserRequest ureq) {
    // 1) Check valid group names
    if (!StringHelper.containsNonWhitespace(businessGroupName.getValue())) {
      businessGroupName.setErrorKey("form.legende.mandatory", new String[] {});
      return false;
    }

    if (bulkMode) {
      // check all names to be valid and check that at least one is entered
      // e.g. find "," | " , " | ",,," errors => no group entered
      String selectionAsCsvStr = businessGroupName.getValue();
      String[] activeSelection =
          selectionAsCsvStr != null ? selectionAsCsvStr.split(",") : new String[] {};
      validNames = new HashSet<String>();
      Set<String> wrongNames = new HashSet<String>();
      boolean nameTooLong = false;
      for (int i = 0; i < activeSelection.length; i++) {
        String currentName = activeSelection[i].trim();
        if (currentName.getBytes().length > BusinessGroup.MAX_GROUP_NAME_LENGTH) {
          nameTooLong = true;
        } else if ((currentName).matches(BusinessGroup.VALID_GROUPNAME_REGEXP)) {
          validNames.add(currentName);
        } else {
          wrongNames.add(currentName);
        }
      }
      if (validNames.size() == 0 && wrongNames.size() == 0 && !nameTooLong) {
        // no valid name and no invalid names, this is no names
        businessGroupName.setErrorKey("create.form.error.illegalName", new String[] {});
        return false;
      } else if (nameTooLong) {
        businessGroupName.setErrorKey(
            "create.form.error.nameTooLong",
            new String[] {BusinessGroup.MAX_GROUP_NAME_LENGTH + ""});
        return false;
      } else if (wrongNames.size() == 1) {
        // one invalid name
        businessGroupName.setErrorKey("create.form.error.illegalName", new String[] {});
        return false;
      } else if (wrongNames.size() > 1) {
        // two or more invalid names
        String[] args = new String[] {StringHelper.formatAsCSVString(wrongNames)};
        businessGroupName.setErrorKey("create.form.error.illegalNames", args);
        return false;
      }
    } else {
      String groupName = businessGroupName.getValue();
      if (groupName.getBytes().length > BusinessGroup.MAX_GROUP_NAME_LENGTH) {
        businessGroupName.setErrorKey(
            "create.form.error.nameTooLong",
            new String[] {BusinessGroup.MAX_GROUP_NAME_LENGTH + ""});
        return false;
      } else if (!(groupName).matches(BusinessGroup.VALID_GROUPNAME_REGEXP)) {
        businessGroupName.setErrorKey("create.form.error.illegalName", new String[] {});
        return false;
      }
      if (businessGroupName.hasError()) {
        return false; // auto-validations from form, return false, because of that
                      // clearError()-calls everywhere...
      }
    }
    // all group name tests passed
    businessGroupName.clearError();

    // 2) Check valid description
    if (businessGroupDescription.getValue().length() > 4000) {
      businessGroupDescription.setErrorKey("input.toolong", new String[] {"4000"});
      return false;
    }
    businessGroupDescription.clearError();

    // 3) Check auto close settings
    boolean disableWaitingListOk = true;
    if (businessGroup != null) {
      int waitingPartipiciantSize =
          businessGroupService.countMembers(businessGroup, GroupRoles.waiting.name());
      if ((businessGroup.getWaitingListEnabled()).booleanValue()
          && !isWaitingListEnabled()
          && (waitingPartipiciantSize > 0)) {
        enableAutoCloseRanks.setErrorKey("form.error.disableNonEmptyWaitingList", new String[] {});
        disableWaitingListOk = false;
        setEnableWaitingList(true);
        return false;
      }
    }
    enableAutoCloseRanks.clearError();

    if (disableWaitingListOk) {
      // 4) Check min / max settings
      String maxValue = null;
      if (StringHelper.containsNonWhitespace(businessGroupMaximumMembers.getValue())) {
        maxValue = businessGroupMaximumMembers.getValue();
      }
      String minValue = null;
      if (StringHelper.containsNonWhitespace(businessGroupMinimumMembers.getValue())) {
        minValue = businessGroupMinimumMembers.getValue();
      }
      if (isWaitingListEnabled() && (maxValue == null || minValue == "")) {
        enableWaitingList.setErrorKey("create.form.error.enableWaitinglist", new String[] {});
        return false;
      }
      enableWaitingList.clearError();

      // 5) Check auto close - waiting list dependency
      if (isAutoCloseRanksEnabled() && !isWaitingListEnabled()) {
        enableAutoCloseRanks.setErrorKey("create.form.error.enableAutoCloseRanks", new String[] {});
        return false;
      }
      enableAutoCloseRanks.clearError();

      // 6) Check min/max validity
      if (!businessGroupMaximumMembers
          .getValue()
          .matches("^\\p{Space}*(\\p{Digit}*)\\p{Space}*$")) {
        businessGroupMaximumMembers.setErrorKey("create.form.error.numberOrNull", new String[] {});
        return false;
      }
      if (!businessGroupMinimumMembers
          .getValue()
          .matches("^\\p{Space}*(\\p{Digit}*)\\p{Space}*$")) {
        businessGroupMaximumMembers.setErrorKey("create.form.error.numberOrNull", new String[] {});
        return false;
      }
      businessGroupMaximumMembers.clearError();
    }
    // group name duplication test passed
    businessGroupName.clearError();

    // all checks passed
    return true;
  }
  /**
   * @see
   *     org.olat.core.gui.components.form.flexible.impl.FormBasicController#initForm(org.olat.core.gui.components.form.flexible.FormItemContainer,
   *     org.olat.core.gui.control.Controller, org.olat.core.gui.UserRequest)
   */
  @Override
  protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    // Create the business group name input text element
    if (bulkMode) {
      businessGroupName =
          uifactory.addTextElement(
              "create.form.title.bgnames",
              "create.form.title.bgnames",
              10 * BusinessGroup.MAX_GROUP_NAME_LENGTH,
              "",
              formLayout);
      businessGroupName.setExampleKey("create.form.message.example.group", null);
    } else {
      businessGroupName =
          uifactory.addTextElement(
              "create.form.title.bgname",
              "create.form.title.bgname",
              BusinessGroup.MAX_GROUP_NAME_LENGTH,
              "",
              formLayout);
      businessGroupName.setNotLongerThanCheck(
          BusinessGroup.MAX_GROUP_NAME_LENGTH, "create.form.error.nameTooLong");
      businessGroupName.setRegexMatchCheck(
          BusinessGroup.VALID_GROUPNAME_REGEXP, "create.form.error.illegalName");
    }
    businessGroupName.setElementCssClass("o_sel_group_edit_title");
    businessGroupName.setMandatory(true);
    businessGroupName.setEnabled(
        !BusinessGroupManagedFlag.isManaged(businessGroup, BusinessGroupManagedFlag.title));

    formLayout.setElementCssClass("o_sel_group_edit_group_form");

    // Create the business group description input rich text element
    businessGroupDescription =
        uifactory.addRichTextElementForStringDataMinimalistic(
            "create.form.title.description",
            "create.form.title.description",
            "",
            10,
            -1,
            formLayout,
            getWindowControl());
    businessGroupDescription.setEnabled(
        !BusinessGroupManagedFlag.isManaged(businessGroup, BusinessGroupManagedFlag.description));

    if (businessGroup != null && !bulkMode) {
      // link to group direct jump in business path
      BusinessControlFactory bcf = BusinessControlFactory.getInstance();
      List<ContextEntry> entries =
          bcf.createCEListFromString("[BusinessGroup:" + businessGroup.getKey() + "]");
      String url = bcf.getAsURIString(entries, true);
      StaticTextElement urlEl =
          uifactory.addStaticTextElement("create.form.businesspath", url, formLayout);
      urlEl.setElementCssClass("o_sel_group_url");
      // link to group visiting card
      bcf = BusinessControlFactory.getInstance();
      entries = bcf.createCEListFromString("[GroupCard:" + businessGroup.getKey() + "]");
      url = bcf.getAsURIString(entries, true);
      StaticTextElement cardEl =
          uifactory.addStaticTextElement("create.form.groupcard", url, formLayout);
      cardEl.setElementCssClass("o_sel_group_card_url");
    }

    uifactory.addSpacerElement("myspacer", formLayout, true);

    // Minimum members input
    businessGroupMinimumMembers =
        uifactory.addTextElement(
            "create.form.title.min", "create.form.title.min", 5, "", formLayout);
    businessGroupMinimumMembers.setDisplaySize(6);
    businessGroupMinimumMembers.setVisible(false); // currently the minimum feature is not enabled
    businessGroupMinimumMembers.setElementCssClass("o_sel_group_edit_min_members");

    // Maximum members input
    businessGroupMaximumMembers =
        uifactory.addTextElement(
            "create.form.title.max", "create.form.title.max", 5, "", formLayout);
    businessGroupMaximumMembers.setDisplaySize(6);
    businessGroupMaximumMembers.setElementCssClass("o_sel_group_edit_max_members");

    // Checkboxes
    enableWaitingList =
        uifactory.addCheckboxesHorizontal(
            "create.form.enableWaitinglist", null, formLayout, waitingListKeys, waitingListValues);
    enableWaitingList.setElementCssClass("o_sel_group_edit_waiting_list");
    enableAutoCloseRanks =
        uifactory.addCheckboxesHorizontal(
            "create.form.enableAutoCloseRanks", null, formLayout, autoCloseKeys, autoCloseValues);
    enableAutoCloseRanks.setElementCssClass("o_sel_group_edit_auto_close_ranks");

    // Enable only if specification of min and max members is possible
    businessGroupMinimumMembers.setVisible(false); // currently the minimum feature is not enabled
    businessGroupMaximumMembers.setVisible(true);
    enableWaitingList.setVisible(true);
    enableAutoCloseRanks.setVisible(true);

    boolean managedSettings =
        BusinessGroupManagedFlag.isManaged(businessGroup, BusinessGroupManagedFlag.settings);
    businessGroupMinimumMembers.setEnabled(!managedSettings);
    businessGroupMaximumMembers.setEnabled(!managedSettings);
    enableWaitingList.setEnabled(!managedSettings);
    enableAutoCloseRanks.setEnabled(!managedSettings);

    if ((businessGroup != null) && (!bulkMode)) {
      businessGroupName.setValue(businessGroup.getName());
      businessGroupDescription.setValue(businessGroup.getDescription());
      Integer minimumMembers = businessGroup.getMinParticipants();
      Integer maximumMembers = businessGroup.getMaxParticipants();
      businessGroupMinimumMembers.setValue(
          minimumMembers == null || minimumMembers.intValue() <= 0
              ? ""
              : minimumMembers.toString());
      businessGroupMaximumMembers.setValue(
          maximumMembers == null || maximumMembers.intValue() < 0 ? "" : maximumMembers.toString());
      if (businessGroup.getWaitingListEnabled() != null) {
        enableWaitingList.select(
            "create.form.enableWaitinglist", businessGroup.getWaitingListEnabled());
      }
      if (businessGroup.getAutoCloseRanksEnabled() != null) {
        enableAutoCloseRanks.select(
            "create.form.enableAutoCloseRanks", businessGroup.getAutoCloseRanksEnabled());
      }
    }

    if (!embbeded) {
      // Create submit and cancel buttons
      final FormLayoutContainer buttonLayout =
          FormLayoutContainer.createButtonLayout("buttonLayout", getTranslator());
      formLayout.add(buttonLayout);
      FormSubmit submit = uifactory.addFormSubmitButton("finish", buttonLayout);
      submit.setEnabled(
          !BusinessGroupManagedFlag.isManaged(businessGroup, BusinessGroupManagedFlag.details));
      uifactory.addFormCancelButton("cancel", buttonLayout, ureq, getWindowControl());
    }

    if ((businessGroup != null) && (!bulkMode)) {
      // managed group information
      boolean managed =
          StringHelper.containsNonWhitespace(businessGroup.getExternalId())
              || businessGroup.getManagedFlags().length > 0;
      if (managed) {
        uifactory.addSpacerElement("managedspacer", formLayout, false);

        String extId = businessGroup.getExternalId() == null ? "" : businessGroup.getExternalId();
        StaticTextElement externalIdEl =
            uifactory.addStaticTextElement("create.form.externalid", extId, formLayout);
        externalIdEl.setElementCssClass("o_sel_group_external_id");

        FormLayoutContainer flagsFlc =
            FormLayoutContainer.createHorizontalFormLayout("flc_flags", getTranslator());
        flagsFlc.setLabel("create.form.managedflags", null);
        formLayout.add(flagsFlc);

        String flags =
            businessGroup.getManagedFlagsString() == null
                ? ""
                : businessGroup.getManagedFlagsString().trim();
        String flagsFormatted = null;
        if (flags.length() > 0) {
          // use translator from REST admin package to import managed flags context help strings
          Translator managedTrans =
              Util.createPackageTranslator(RestapiAdminController.class, ureq.getLocale());
          StringBuffer flagList = new StringBuffer();
          flagList.append("<p class=\"o_important\">");
          flagList.append(translate("create.form.managedflags.intro"));
          flagList.append("</div>");
          flagList.append("<ul>");
          for (String flag : flags.split(",")) {
            flagList.append("<li>");
            flagList.append(managedTrans.translate("managed.flags.group." + flag));
            flagList.append("</li>");
          }

          flagsFormatted = flagList.toString();

        } else {
          flagsFormatted = flags;
        }

        StaticTextElement flagsEl =
            uifactory.addStaticTextElement("create.form.managedflags", flagsFormatted, flagsFlc);
        flagsEl.showLabel(false);
        flagsEl.setElementCssClass("o_sel_group_managed_flags");
      }
    }
  }
Exemplo n.º 11
0
  @Override
  public List<CalendarFileInfos> getListOfCalendarsFiles(Identity identity) {
    List<CalendarFileInfos> aggregatedFiles = new ArrayList<>();

    Map<CalendarKey, CalendarUserConfiguration> configMap =
        calendarManager.getCalendarUserConfigurationsMap(identity);

    // personal calendar
    CalendarKey personalCalendarKey =
        new CalendarKey(identity.getName(), CalendarManager.TYPE_USER);
    CalendarUserConfiguration personalCalendarConfig = configMap.get(personalCalendarKey);
    if (calendarModule.isEnablePersonalCalendar()
        && (personalCalendarConfig == null || personalCalendarConfig.isInAggregatedFeed())) {
      File iCalFile =
          calendarManager.getCalendarICalFile(CalendarManager.TYPE_USER, identity.getName());
      if (iCalFile != null) {
        aggregatedFiles.add(
            new CalendarFileInfos(identity.getName(), CalendarManager.TYPE_USER, iCalFile));
      }

      // reload every hour
      List<CalendarFileInfos> importedCalendars =
          importCalendarManager.getImportedCalendarInfosForIdentity(identity, true);
      aggregatedFiles.addAll(importedCalendars);
    }

    // group calendars
    if (calendarModule.isEnableGroupCalendar()) {
      SearchBusinessGroupParams groupParams = new SearchBusinessGroupParams(identity, true, true);
      groupParams.addTools(CollaborationTools.TOOL_CALENDAR);
      List<BusinessGroup> groups =
          businessGroupService.findBusinessGroups(groupParams, null, 0, -1);
      for (BusinessGroup group : groups) {
        String calendarId = group.getKey().toString();
        CalendarKey key = new CalendarKey(calendarId, CalendarManager.TYPE_GROUP);
        CalendarUserConfiguration calendarConfig = configMap.get(key);
        if (calendarConfig == null || calendarConfig.isInAggregatedFeed()) {
          File iCalFile =
              calendarManager.getCalendarICalFile(CalendarManager.TYPE_GROUP, calendarId);
          if (iCalFile != null) {
            aggregatedFiles.add(
                new CalendarFileInfos(calendarId, CalendarManager.TYPE_GROUP, iCalFile));
          }
        }
      }
    }

    if (calendarModule.isEnableCourseElementCalendar()
        || calendarModule.isEnableCourseToolCalendar()) {
      List<Object[]> resources = getCourses(identity);
      for (Object[] resource : resources) {
        RepositoryEntry courseEntry = (RepositoryEntry) resource[0];
        String calendarId = courseEntry.getOlatResource().getResourceableId().toString();
        CalendarKey key = new CalendarKey(calendarId, CalendarManager.TYPE_COURSE);
        CalendarUserConfiguration calendarConfig = configMap.get(key);
        if (calendarConfig == null || calendarConfig.isInAggregatedFeed()) {
          File iCalFile =
              calendarManager.getCalendarICalFile(CalendarManager.TYPE_COURSE, calendarId);
          if (iCalFile != null) {
            aggregatedFiles.add(
                new CalendarFileInfos(calendarId, CalendarManager.TYPE_COURSE, iCalFile));
          }
        }
      }
    }

    return aggregatedFiles;
  }
 public GroupWrapper(BusinessGroup group, String courses) {
   groupKey = group.getKey();
   groupName = group.getName();
   description = group.getDescription();
   this.courses = courses;
 }