Search in sources :

Example 36 with AccessRights

use of org.olat.modules.portfolio.model.AccessRights in project openolat by klemens.

the class SharedBindersController method doSelectBinder.

private BinderController doSelectBinder(UserRequest ureq, SharedItemRow row) {
    Binder binder = portfolioService.getBinderByKey(row.getBinderKey());
    if (binder == null) {
        showWarning("warning.portfolio.not.found");
        return null;
    } else {
        removeAsListenerAndDispose(binderCtrl);
        portfolioService.updateBinderUserInformations(binder, getIdentity());
        row.setRecentLaunch(new Date());
        OLATResourceable binderOres = OresHelper.createOLATResourceableInstance("Binder", binder.getKey());
        WindowControl swControl = addToHistory(ureq, binderOres, null);
        List<AccessRights> rights = portfolioService.getAccessRights(binder, getIdentity());
        BinderSecurityCallback secCallback = BinderSecurityCallbackFactory.getCallbackForCoach(binder, rights);
        BinderConfiguration config = BinderConfiguration.createConfig(binder);
        binderCtrl = new BinderController(ureq, swControl, stackPanel, secCallback, binder, config);
        String displayName = StringHelper.escapeHtml(binder.getTitle());
        stackPanel.pushController(displayName, binderCtrl);
        return binderCtrl;
    }
}
Also used : AccessRights(org.olat.modules.portfolio.model.AccessRights) AssessedBinder(org.olat.modules.portfolio.model.AssessedBinder) Binder(org.olat.modules.portfolio.Binder) OLATResourceable(org.olat.core.id.OLATResourceable) BinderController(org.olat.modules.portfolio.ui.BinderController) BinderSecurityCallback(org.olat.modules.portfolio.BinderSecurityCallback) WindowControl(org.olat.core.gui.control.WindowControl) Date(java.util.Date) BinderConfiguration(org.olat.modules.portfolio.BinderConfiguration)

Example 37 with AccessRights

use of org.olat.modules.portfolio.model.AccessRights in project openolat by klemens.

the class PortfolioNotificationsHandler method createSubscriptionInfo.

@Override
public SubscriptionInfo createSubscriptionInfo(Subscriber subscriber, Locale locale, Date compareDate) {
    SubscriptionInfo si = null;
    Publisher publisher = subscriber.getPublisher();
    Binder binder = binderDao.loadByKey(publisher.getResId());
    if (isInkoveValid(binder, compareDate, publisher)) {
        BinderSecurityCallback secCallback = null;
        Identity identity = subscriber.getIdentity();
        if (binderDao.isMember(binder, identity, PortfolioRoles.owner.name())) {
            secCallback = BinderSecurityCallbackFactory.getCallbackForOwnedBinder(binder);
        } else {
            List<AccessRights> rights = portfolioService.getAccessRights(binder, identity);
            if (rights.size() > 0) {
                secCallback = BinderSecurityCallbackFactory.getCallbackForCoach(binder, rights);
            }
        }
        if (secCallback != null) {
            si = new SubscriptionInfo(subscriber.getKey(), publisher.getType(), getTitleItemForBinder(binder), null);
            List<SubscriptionListItem> allItems = getAllItems(binder, secCallback, compareDate, locale);
            for (SubscriptionListItem item : allItems) {
                // only a type of icon
                SubscriptionListItem clonedItem = new SubscriptionListItem(item.getDescription(), item.getDescriptionTooltip(), item.getLink(), item.getBusinessPath(), item.getDate(), "o_ep_icon");
                si.addSubscriptionListItem(clonedItem);
            }
        }
    }
    if (si == null) {
        // no info, return empty
        si = NotificationsManager.getInstance().getNoSubscriptionInfo();
    }
    return si;
}
Also used : AccessRights(org.olat.modules.portfolio.model.AccessRights) Binder(org.olat.modules.portfolio.Binder) SubscriptionListItem(org.olat.core.commons.services.notifications.model.SubscriptionListItem) SubscriptionInfo(org.olat.core.commons.services.notifications.SubscriptionInfo) Publisher(org.olat.core.commons.services.notifications.Publisher) BinderSecurityCallback(org.olat.modules.portfolio.BinderSecurityCallback) Identity(org.olat.core.id.Identity)

Example 38 with AccessRights

use of org.olat.modules.portfolio.model.AccessRights in project openolat by klemens.

the class EvaluationFormHandler method getControllerForAssignment.

private Controller getControllerForAssignment(UserRequest ureq, WindowControl wControl, PageBody body, Assignment assignment, boolean onePage) {
    PortfolioService portfolioService = CoreSpringFactory.getImpl(PortfolioService.class);
    // find the evaluation form
    RepositoryEntry re = assignment.getFormEntry();
    Page page = assignment.getPage();
    PageStatus pageStatus = page.getPageStatus();
    Controller ctrl = null;
    List<AccessRights> accessRights = portfolioService.getAccessRights(page);
    boolean anonym = assignment.isAnonymousExternalEvaluation();
    if (pageStatus == null || pageStatus == PageStatus.draft) {
        if (hasRole(PortfolioRoles.owner, ureq.getIdentity(), accessRights)) {
            ctrl = new EvaluationFormController(ureq, wControl, ureq.getIdentity(), body, re, false, false);
        }
    } else if (assignment.isOnlyAutoEvaluation()) {
        // only the auto evaluation is shown
        if (hasRole(PortfolioRoles.owner, ureq.getIdentity(), accessRights)) {
            boolean readOnly = (pageStatus == PageStatus.published) || (pageStatus == PageStatus.closed) || (pageStatus == PageStatus.deleted);
            ctrl = new EvaluationFormController(ureq, wControl, ureq.getIdentity(), body, re, readOnly, false);
        } else if (hasRole(PortfolioRoles.coach, ureq.getIdentity(), accessRights)) {
            Identity owner = getOwner(accessRights);
            ctrl = new EvaluationFormController(ureq, wControl, owner, body, re, true, false);
        } else if (hasRole(PortfolioRoles.reviewer, ureq.getIdentity(), accessRights) || hasRole(PortfolioRoles.invitee, ureq.getIdentity(), accessRights)) {
            if (assignment.isReviewerSeeAutoEvaluation()) {
                Identity owner = getOwner(accessRights);
                ctrl = new EvaluationFormController(ureq, wControl, owner, body, re, true, false);
            }
        }
    } else {
        if (hasRole(PortfolioRoles.owner, ureq.getIdentity(), accessRights)) {
            boolean readOnly = (pageStatus == PageStatus.published) || (pageStatus == PageStatus.closed) || (pageStatus == PageStatus.deleted) || onePage;
            Identity owner = getOwner(accessRights);
            List<Identity> coachesAndReviewers = getCoachesAndReviewers(accessRights);
            if (coachesAndReviewers.size() > 0) {
                ctrl = new MultiEvaluationFormController(ureq, wControl, owner, coachesAndReviewers, body, re, false, readOnly, onePage, anonym);
            } else {
                ctrl = new EvaluationFormController(ureq, wControl, ureq.getIdentity(), body, re, readOnly, false);
            }
        } else if (hasRole(PortfolioRoles.coach, ureq.getIdentity(), accessRights)) {
            Identity owner = getOwner(accessRights);
            List<Identity> coachesAndReviewers = getCoachesAndReviewers(accessRights);
            boolean readOnly = (pageStatus == PageStatus.draft) || (pageStatus == PageStatus.closed) || (pageStatus == PageStatus.deleted) || onePage;
            ctrl = new MultiEvaluationFormController(ureq, wControl, owner, coachesAndReviewers, body, re, false, readOnly, onePage, anonym);
        } else if (hasRole(PortfolioRoles.reviewer, ureq.getIdentity(), accessRights) || hasRole(PortfolioRoles.invitee, ureq.getIdentity(), accessRights)) {
            boolean readOnly = (pageStatus == PageStatus.draft) || (pageStatus == PageStatus.closed) || (pageStatus == PageStatus.deleted) || onePage;
            if (assignment.isReviewerSeeAutoEvaluation()) {
                Identity owner = getOwner(accessRights);
                List<Identity> reviewers = Collections.singletonList(ureq.getIdentity());
                ctrl = new MultiEvaluationFormController(ureq, wControl, owner, reviewers, body, re, true, readOnly, onePage, anonym);
            } else {
                ctrl = new EvaluationFormController(ureq, wControl, ureq.getIdentity(), body, re, readOnly, !readOnly);
            }
        }
    }
    return ctrl;
}
Also used : PageStatus(org.olat.modules.portfolio.PageStatus) MultiEvaluationFormController(org.olat.modules.portfolio.ui.MultiEvaluationFormController) Page(org.olat.modules.portfolio.Page) RepositoryEntry(org.olat.repository.RepositoryEntry) MultiEvaluationFormController(org.olat.modules.portfolio.ui.MultiEvaluationFormController) Controller(org.olat.core.gui.control.Controller) EvaluationFormController(org.olat.modules.forms.ui.EvaluationFormController) PortfolioHomeController(org.olat.modules.portfolio.ui.PortfolioHomeController) AccessRights(org.olat.modules.portfolio.model.AccessRights) MultiEvaluationFormController(org.olat.modules.portfolio.ui.MultiEvaluationFormController) EvaluationFormController(org.olat.modules.forms.ui.EvaluationFormController) PortfolioService(org.olat.modules.portfolio.PortfolioService) ArrayList(java.util.ArrayList) List(java.util.List) Identity(org.olat.core.id.Identity)

Aggregations

AccessRights (org.olat.modules.portfolio.model.AccessRights)38 Identity (org.olat.core.id.Identity)24 ArrayList (java.util.ArrayList)16 Invitation (org.olat.basesecurity.Invitation)14 Binder (org.olat.modules.portfolio.Binder)12 Page (org.olat.modules.portfolio.Page)12 BinderSecurityCallback (org.olat.modules.portfolio.BinderSecurityCallback)10 Test (org.junit.Test)6 Controller (org.olat.core.gui.control.Controller)6 BinderConfiguration (org.olat.modules.portfolio.BinderConfiguration)6 Section (org.olat.modules.portfolio.Section)6 SynchedBinder (org.olat.modules.portfolio.model.SynchedBinder)6 WindowControl (org.olat.core.gui.control.WindowControl)4 OLATResourceable (org.olat.core.id.OLATResourceable)4 EvaluationFormController (org.olat.modules.forms.ui.EvaluationFormController)4 PortfolioService (org.olat.modules.portfolio.PortfolioService)4 BinderController (org.olat.modules.portfolio.ui.BinderController)4 MultiEvaluationFormController (org.olat.modules.portfolio.ui.MultiEvaluationFormController)4 PortfolioHomeController (org.olat.modules.portfolio.ui.PortfolioHomeController)4 Date (java.util.Date)2