Search in sources :

Example 1 with RepoPermission

use of org.olat.course.member.PermissionHelper.RepoPermission in project OpenOLAT by OpenOLAT.

the class EditMembershipController method collectRepoChanges.

public void collectRepoChanges(MemberPermissionChangeEvent e) {
    if (repoEntry == null)
        return;
    RepoPermission repoPermission = PermissionHelper.getPermission(repoEntry, member, memberships);
    Collection<String> selectRepoRights = repoRightsEl.getSelectedKeys();
    boolean repoOwner = selectRepoRights.contains("owner");
    e.setRepoOwner(repoOwner == repoPermission.isOwner() ? null : new Boolean(repoOwner));
    boolean repoTutor = selectRepoRights.contains("tutor");
    e.setRepoTutor(repoTutor == repoPermission.isTutor() ? null : new Boolean(repoTutor));
    boolean repoParticipant = selectRepoRights.contains("participant");
    e.setRepoParticipant(repoParticipant == repoPermission.isParticipant() ? null : new Boolean(repoParticipant));
}
Also used : RepoPermission(org.olat.course.member.PermissionHelper.RepoPermission)

Example 2 with RepoPermission

use of org.olat.course.member.PermissionHelper.RepoPermission in project openolat by klemens.

the class EditMembershipController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    if (formLayout instanceof FormLayoutContainer) {
        FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
        String name = repoEntry == null ? businessGroup.getName() : repoEntry.getDisplayname();
        name = StringHelper.escapeHtml(name);
        String title = translate("edit.member.title", new String[] { name });
        layoutCont.contextPut("editTitle", title);
    }
    // repository entry rights
    if (repoEntry != null) {
        String[] repoValues = new String[] { translate("role.repo.owner"), translate("role.repo.tutor"), translate("role.repo.participant") };
        boolean managed = RepositoryEntryManagedFlag.isManaged(repoEntry, RepositoryEntryManagedFlag.membersmanagement) && !overrideManaged;
        repoRightsEl = uifactory.addCheckboxesVertical("repoRights", null, formLayout, repoRightsKeys, repoValues, 1);
        repoRightsEl.setEnabled(!managed);
        if (member != null) {
            RepoPermission repoPermission = PermissionHelper.getPermission(repoEntry, member, memberships);
            repoRightsEl.select("owner", repoPermission.isOwner());
            repoRightsEl.select("tutor", repoPermission.isTutor());
            repoRightsEl.select("participant", repoPermission.isParticipant());
        }
    }
    // group rights
    FlexiTableColumnModel tableColumnModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
    tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.header.groups", 0));
    tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.header.tutorsCount", 1));
    tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.header.participantsCount", 2));
    tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel(true, "table.header.freePlace", 3, false, null, FlexiColumnModel.ALIGNMENT_LEFT, new TextFlexiCellRenderer(EscapeMode.none)));
    tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.header.tutors", 4));
    tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.header.participants", 5));
    tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.header.waitingList", 6));
    tableDataModel = new EditMemberTableDataModel(Collections.<MemberOption>emptyList(), tableColumnModel);
    FlexiTableElement tableEl = uifactory.addTableElement(getWindowControl(), "groupList", tableDataModel, getTranslator(), formLayout);
    tableEl.setCustomizeColumns(false);
    if (withButtons) {
        FormLayoutContainer buttonLayout = FormLayoutContainer.createButtonLayout("buttonLayout", getTranslator());
        formLayout.add(buttonLayout);
        buttonLayout.setRootForm(mainForm);
        uifactory.addFormSubmitButton("ok", buttonLayout);
        uifactory.addFormCancelButton("cancel", buttonLayout, ureq, getWindowControl());
    }
}
Also used : RepoPermission(org.olat.course.member.PermissionHelper.RepoPermission) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) FlexiTableColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel) TextFlexiCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.TextFlexiCellRenderer) DefaultFlexiColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel) FlexiTableElement(org.olat.core.gui.components.form.flexible.elements.FlexiTableElement)

Example 3 with RepoPermission

use of org.olat.course.member.PermissionHelper.RepoPermission in project openolat by klemens.

the class EditMembershipController method collectRepoChanges.

public void collectRepoChanges(MemberPermissionChangeEvent e) {
    if (repoEntry == null)
        return;
    RepoPermission repoPermission = PermissionHelper.getPermission(repoEntry, member, memberships);
    Collection<String> selectRepoRights = repoRightsEl.getSelectedKeys();
    boolean repoOwner = selectRepoRights.contains("owner");
    e.setRepoOwner(repoOwner == repoPermission.isOwner() ? null : new Boolean(repoOwner));
    boolean repoTutor = selectRepoRights.contains("tutor");
    e.setRepoTutor(repoTutor == repoPermission.isTutor() ? null : new Boolean(repoTutor));
    boolean repoParticipant = selectRepoRights.contains("participant");
    e.setRepoParticipant(repoParticipant == repoPermission.isParticipant() ? null : new Boolean(repoParticipant));
}
Also used : RepoPermission(org.olat.course.member.PermissionHelper.RepoPermission)

Example 4 with RepoPermission

use of org.olat.course.member.PermissionHelper.RepoPermission in project OpenOLAT by OpenOLAT.

the class EditMembershipController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    if (formLayout instanceof FormLayoutContainer) {
        FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
        String name = repoEntry == null ? businessGroup.getName() : repoEntry.getDisplayname();
        name = StringHelper.escapeHtml(name);
        String title = translate("edit.member.title", new String[] { name });
        layoutCont.contextPut("editTitle", title);
    }
    // repository entry rights
    if (repoEntry != null) {
        String[] repoValues = new String[] { translate("role.repo.owner"), translate("role.repo.tutor"), translate("role.repo.participant") };
        boolean managed = RepositoryEntryManagedFlag.isManaged(repoEntry, RepositoryEntryManagedFlag.membersmanagement) && !overrideManaged;
        repoRightsEl = uifactory.addCheckboxesVertical("repoRights", null, formLayout, repoRightsKeys, repoValues, 1);
        repoRightsEl.setEnabled(!managed);
        if (member != null) {
            RepoPermission repoPermission = PermissionHelper.getPermission(repoEntry, member, memberships);
            repoRightsEl.select("owner", repoPermission.isOwner());
            repoRightsEl.select("tutor", repoPermission.isTutor());
            repoRightsEl.select("participant", repoPermission.isParticipant());
        }
    }
    // group rights
    FlexiTableColumnModel tableColumnModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
    tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.header.groups", 0));
    tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.header.tutorsCount", 1));
    tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.header.participantsCount", 2));
    tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel(true, "table.header.freePlace", 3, false, null, FlexiColumnModel.ALIGNMENT_LEFT, new TextFlexiCellRenderer(EscapeMode.none)));
    tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.header.tutors", 4));
    tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.header.participants", 5));
    tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.header.waitingList", 6));
    tableDataModel = new EditMemberTableDataModel(Collections.<MemberOption>emptyList(), tableColumnModel);
    FlexiTableElement tableEl = uifactory.addTableElement(getWindowControl(), "groupList", tableDataModel, getTranslator(), formLayout);
    tableEl.setCustomizeColumns(false);
    if (withButtons) {
        FormLayoutContainer buttonLayout = FormLayoutContainer.createButtonLayout("buttonLayout", getTranslator());
        formLayout.add(buttonLayout);
        buttonLayout.setRootForm(mainForm);
        uifactory.addFormSubmitButton("ok", buttonLayout);
        uifactory.addFormCancelButton("cancel", buttonLayout, ureq, getWindowControl());
    }
}
Also used : RepoPermission(org.olat.course.member.PermissionHelper.RepoPermission) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) FlexiTableColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel) TextFlexiCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.TextFlexiCellRenderer) DefaultFlexiColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel) FlexiTableElement(org.olat.core.gui.components.form.flexible.elements.FlexiTableElement)

Aggregations

RepoPermission (org.olat.course.member.PermissionHelper.RepoPermission)4 FlexiTableElement (org.olat.core.gui.components.form.flexible.elements.FlexiTableElement)2 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)2 DefaultFlexiColumnModel (org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel)2 FlexiTableColumnModel (org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel)2 TextFlexiCellRenderer (org.olat.core.gui.components.form.flexible.impl.elements.table.TextFlexiCellRenderer)2