Search in sources :

Example 1 with UserRequest

use of org.olat.core.gui.UserRequest in project OpenOLAT by OpenOLAT.

the class CourseSite method createController.

@Override
protected MainLayoutController createController(UserRequest ureq, WindowControl wControl, SiteConfiguration config) {
    RepositoryManager rm = RepositoryManager.getInstance();
    RepositoryService rs = CoreSpringFactory.getImpl(RepositoryService.class);
    RepositoryEntry entry = rm.lookupRepositoryEntryBySoftkey(repositorySoftKey, false);
    if (entry == null) {
        return getAlternativeController(ureq, wControl, config);
    }
    MainLayoutController c;
    ICourse course = CourseFactory.loadCourse(entry);
    UserSession usess = ureq.getUserSession();
    // course-launch-state depending course-settings
    RepositoryEntrySecurity reSecurity = rm.isAllowed(ureq, entry);
    boolean isAllowedToLaunch = reSecurity.canLaunch();
    boolean hasAccess = false;
    if (isAllowedToLaunch) {
        // either check with securityCallback or use access-settings from course-nodes
        if (siteSecCallback != null) {
            hasAccess = siteSecCallback.isAllowedToLaunchSite(ureq);
        } else if (usess.isInAssessmentModeProcess() && !usess.matchLockResource(course)) {
            hasAccess = false;
        } else {
            // check within course: accessibility of course root node
            CourseNode rootNode = course.getRunStructure().getRootNode();
            UserCourseEnvironmentImpl uce = new UserCourseEnvironmentImpl(ureq.getUserSession().getIdentityEnvironment(), course.getCourseEnvironment());
            NodeEvaluation nodeEval = rootNode.eval(uce.getConditionInterpreter(), new TreeEvaluation(), new VisibleTreeFilter());
            boolean mayAccessWholeTreeUp = NavigationHandler.mayAccessWholeTreeUp(nodeEval);
            hasAccess = mayAccessWholeTreeUp && nodeEval.isVisible();
        }
    }
    // load course (admins always see content) or alternative controller if course is not launchable
    if (hasAccess || usess.getRoles().isOLATAdmin()) {
        rs.incrementLaunchCounter(entry);
        // build up the context path for linked course
        WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(ureq, entry, new StateSite(this), wControl, true);
        CourseRuntimeController runCtr = new CourseRuntimeController(ureq, bwControl, entry, reSecurity, new RuntimeControllerCreator() {

            @Override
            public Controller create(UserRequest uureq, WindowControl wwControl, TooledStackedPanel toolbarPanel, RepositoryEntry re, RepositoryEntrySecurity security, AssessmentMode assessmentMode) {
                return new RunMainController(uureq, wwControl, toolbarPanel, CourseFactory.loadCourse(re), re, security, assessmentMode);
            }
        }, false, true);
        // Configure run controller
        // a: don't show close link, is opened as site not tab
        runCtr.setCourseCloseEnabled(false);
        // b: don't show toolbar
        if (!showToolController) {
            runCtr.setToolControllerEnabled(false);
        }
        c = runCtr;
    } else {
        // access restricted (not in group / author) -> show controller
        // defined in olat_extensions (type autoCreator)
        c = getAlternativeController(ureq, wControl, config);
    }
    return c;
}
Also used : TooledStackedPanel(org.olat.core.gui.components.stack.TooledStackedPanel) AssessmentMode(org.olat.course.assessment.AssessmentMode) StateSite(org.olat.core.id.context.StateSite) VisibleTreeFilter(org.olat.course.run.userview.VisibleTreeFilter) RunMainController(org.olat.course.run.RunMainController) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) WindowControl(org.olat.core.gui.control.WindowControl) MainLayoutController(org.olat.core.gui.control.generic.layout.MainLayoutController) RunMainController(org.olat.course.run.RunMainController) CourseRuntimeController(org.olat.course.run.CourseRuntimeController) Controller(org.olat.core.gui.control.Controller) RuntimeControllerCreator(org.olat.repository.ui.RepositoryEntryRuntimeController.RuntimeControllerCreator) UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl) RepositoryEntrySecurity(org.olat.repository.model.RepositoryEntrySecurity) CourseRuntimeController(org.olat.course.run.CourseRuntimeController) UserSession(org.olat.core.util.UserSession) TreeEvaluation(org.olat.course.run.userview.TreeEvaluation) MainLayoutController(org.olat.core.gui.control.generic.layout.MainLayoutController) RepositoryManager(org.olat.repository.RepositoryManager) CourseNode(org.olat.course.nodes.CourseNode) NodeEvaluation(org.olat.course.run.userview.NodeEvaluation) UserRequest(org.olat.core.gui.UserRequest) RepositoryService(org.olat.repository.RepositoryService)

Example 2 with UserRequest

use of org.olat.core.gui.UserRequest in project OpenOLAT by OpenOLAT.

the class PublishController method doAddAccessRights.

private void doAddAccessRights(UserRequest ureq) {
    removeAsListenerAndDispose(addMembersWizard);
    Step start = new AddMember_1_ChooseMemberStep(ureq, binder);
    StepRunnerCallback finish = new StepRunnerCallback() {

        @Override
        public Step execute(UserRequest uureq, WindowControl wControl, StepsRunContext runContext) {
            AccessRightsContext rightsContext = (AccessRightsContext) runContext.get("rightsContext");
            MailTemplate mailTemplate = (MailTemplate) runContext.get("mailTemplate");
            addMembers(rightsContext, mailTemplate);
            return StepsMainRunController.DONE_MODIFIED;
        }
    };
    addMembersWizard = new StepsMainRunController(ureq, getWindowControl(), start, finish, null, translate("add.member"), "o_sel_course_member_import_1_wizard");
    listenTo(addMembersWizard);
    getWindowControl().pushAsModalDialog(addMembersWizard.getInitialComponent());
}
Also used : AccessRightsContext(org.olat.modules.portfolio.ui.wizard.AccessRightsContext) MailTemplate(org.olat.core.util.mail.MailTemplate) StepsMainRunController(org.olat.core.gui.control.generic.wizard.StepsMainRunController) AddMember_1_ChooseMemberStep(org.olat.modules.portfolio.ui.wizard.AddMember_1_ChooseMemberStep) Step(org.olat.core.gui.control.generic.wizard.Step) AddMember_1_ChooseMemberStep(org.olat.modules.portfolio.ui.wizard.AddMember_1_ChooseMemberStep) WindowControl(org.olat.core.gui.control.WindowControl) StepsRunContext(org.olat.core.gui.control.generic.wizard.StepsRunContext) StepRunnerCallback(org.olat.core.gui.control.generic.wizard.StepRunnerCallback) UserRequest(org.olat.core.gui.UserRequest)

Example 3 with UserRequest

use of org.olat.core.gui.UserRequest in project OpenOLAT by OpenOLAT.

the class EditorMainController method launchPublishingWizard.

private void launchPublishingWizard(UserRequest ureq, ICourse course, boolean requestOnClose) {
    // ignore enter
    if (publishStepsController != null)
        return;
    /*
		 * start follwoing steps -> cancel wizardf does not touch data
		 * (M) Mandatory (O) Optional
		 * - (M)Step 00  -> show selection tree to choose changed nodes to be published
		 * ...........-> calculate errors & warnings
		 * ...........(next|finish) available if no errors or nothing to publish
		 * - (O)Step 00A -> review errors & warnings
		 * ...........(previous|next|finish) available
		 * - (O)Step 00B -> review publish changes that will happen
		 * ...........(previous|next|finish) available
		 * - (O)Step 01  -> change general access to course
		 * ...........(previous|finish) available
		 * - FinishCallback -> apply course nodes change set
		 * .................-> apply general access changes.
		 */
    Step start = new PublishStep00(ureq, cetm, course);
    /*
		 * callback executed in case wizard is finished.
		 */
    StepRunnerCallback finish = new StepRunnerCallback() {

        @Override
        public Step execute(UserRequest ureq1, WindowControl wControl1, StepsRunContext runContext) {
            // all information to do now is within the runContext saved
            boolean hasChanges = false;
            PublishProcess publishManager = (PublishProcess) runContext.get("publishProcess");
            PublishEvents publishEvents = publishManager.getPublishEvents();
            if (runContext.containsKey("validPublish") && ((Boolean) runContext.get("validPublish")).booleanValue()) {
                @SuppressWarnings("unchecked") Collection<String> selectedNodeIds = (Collection<String>) runContext.get("publishSetCreatedFor");
                hasChanges = (selectedNodeIds != null) && (selectedNodeIds.size() > 0);
                if (hasChanges) {
                    publishManager.applyPublishSet(ureq1.getIdentity(), ureq1.getLocale(), false);
                }
            }
            if (runContext.containsKey("accessAndProperties")) {
                CourseAccessAndProperties accessAndProperties = (CourseAccessAndProperties) runContext.get("accessAndProperties");
                // fires an EntryChangedEvent for repository entry notifying
                // about modification.
                publishManager.changeAccessAndProperties(getIdentity(), accessAndProperties);
                hasChanges = true;
            }
            CourseCatalog courseCatalog = (CourseCatalog) runContext.get("categories");
            if (courseCatalog != null) {
                publishManager.publishToCatalog(courseCatalog.getChoiceValue(), courseCatalog.getCategoryLabels());
            }
            if (publishEvents.getPostPublishingEvents().size() > 0) {
                for (MultiUserEvent event : publishEvents.getPostPublishingEvents()) {
                    CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(event, ores);
                }
            }
            // signal correct completion and tell if changes were made or not.
            return hasChanges ? StepsMainRunController.DONE_MODIFIED : StepsMainRunController.DONE_UNCHANGED;
        }
    };
    publishStepsController = new StepsMainRunController(ureq, getWindowControl(), start, finish, null, translate("publish.wizard.title"), "o_sel_course_publish_wizard");
    listenTo(publishStepsController);
    publishStepsController.getRunContext().put("requestOnClose", requestOnClose);
    getWindowControl().pushAsModalDialog(publishStepsController.getInitialComponent());
}
Also used : Step(org.olat.core.gui.control.generic.wizard.Step) CheckList_1_CheckboxStep(org.olat.course.nodes.cl.ui.wizard.CheckList_1_CheckboxStep) WindowControl(org.olat.core.gui.control.WindowControl) StepsRunContext(org.olat.core.gui.control.generic.wizard.StepsRunContext) Collection(java.util.Collection) StepsMainRunController(org.olat.core.gui.control.generic.wizard.StepsMainRunController) MultiUserEvent(org.olat.core.util.event.MultiUserEvent) StepRunnerCallback(org.olat.core.gui.control.generic.wizard.StepRunnerCallback) CheckListStepRunnerCallback(org.olat.course.nodes.cl.ui.wizard.CheckListStepRunnerCallback) UserRequest(org.olat.core.gui.UserRequest)

Example 4 with UserRequest

use of org.olat.core.gui.UserRequest in project OpenOLAT by OpenOLAT.

the class ParticipantLectureBlocksController method doPrint.

private void doPrint(UserRequest ureq) {
    ControllerCreator printControllerCreator = (lureq, lwControl) -> {
        lwControl.getWindowBackOffice().getChiefController().addBodyCssClass("o_lectures_print");
        Controller printCtrl = new ParticipantLectureBlocksController(lureq, lwControl, entry, assessedIdentity, false, false);
        listenTo(printCtrl);
        return printCtrl;
    };
    ControllerCreator layoutCtrlr = BaseFullWebappPopupLayoutFactory.createPrintPopupLayout(printControllerCreator);
    openInNewBrowserWindow(ureq, layoutCtrlr);
}
Also used : FlexiTableElement(org.olat.core.gui.components.form.flexible.elements.FlexiTableElement) RepositoryService(org.olat.repository.RepositoryService) Date(java.util.Date) BooleanCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.BooleanCellRenderer) LectureBlockAuditLog(org.olat.modules.lecture.LectureBlockAuditLog) DefaultFlexiColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel) Autowired(org.springframework.beans.factory.annotation.Autowired) StaticFlexiCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.StaticFlexiCellRenderer) FlexiTableFilter(org.olat.core.gui.components.form.flexible.elements.FlexiTableFilter) Map(java.util.Map) SortKey(org.olat.core.commons.persistence.SortKey) ContactList(org.olat.core.util.mail.ContactList) FlexiTableColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) LectureBlock(org.olat.modules.lecture.LectureBlock) ParticipantCols(org.olat.modules.lecture.ui.ParticipantLectureBlocksDataModel.ParticipantCols) WindowControl(org.olat.core.gui.control.WindowControl) Component(org.olat.core.gui.components.Component) SelectionEvent(org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent) LectureService(org.olat.modules.lecture.LectureService) List(java.util.List) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) Identity(org.olat.core.id.Identity) ContactFormController(org.olat.modules.co.ContactFormController) LecturesCompulsoryRenderer(org.olat.modules.lecture.ui.component.LecturesCompulsoryRenderer) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) FormEvent(org.olat.core.gui.components.form.flexible.impl.FormEvent) LectureBlockAndRollCall(org.olat.modules.lecture.model.LectureBlockAndRollCall) Action(org.olat.modules.lecture.LectureBlockAuditLog.Action) HashMap(java.util.HashMap) RepositoryEntry(org.olat.repository.RepositoryEntry) FormItem(org.olat.core.gui.components.form.flexible.FormItem) ArrayList(java.util.ArrayList) Event(org.olat.core.gui.control.Event) FormBasicController(org.olat.core.gui.components.form.flexible.impl.FormBasicController) CalendarUtils(org.olat.commons.calendar.CalendarUtils) Calendar(java.util.Calendar) FormItemContainer(org.olat.core.gui.components.form.flexible.FormItemContainer) GroupRoles(org.olat.basesecurity.GroupRoles) DateFlexiCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.DateFlexiCellRenderer) StringHelper(org.olat.core.util.StringHelper) LectureBlockRollCall(org.olat.modules.lecture.LectureBlockRollCall) LectureBlockRollCallStatusCellRenderer(org.olat.modules.lecture.ui.component.LectureBlockRollCallStatusCellRenderer) FlexiTableDataModelFactory(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableDataModelFactory) LectureBlockStatus(org.olat.modules.lecture.LectureBlockStatus) ContactMessage(org.olat.core.util.mail.ContactMessage) Formatter(org.olat.core.util.Formatter) LectureModule(org.olat.modules.lecture.LectureModule) Link(org.olat.core.gui.components.link.Link) Controller(org.olat.core.gui.control.Controller) ControllerCreator(org.olat.core.gui.control.creator.ControllerCreator) UserManager(org.olat.user.UserManager) BaseFullWebappPopupLayoutFactory(org.olat.core.commons.fullWebApp.popup.BaseFullWebappPopupLayoutFactory) NewControllerFactory(org.olat.NewControllerFactory) DB(org.olat.core.commons.persistence.DB) FlexiTableSortOptions(org.olat.core.gui.components.form.flexible.elements.FlexiTableSortOptions) UserRequest(org.olat.core.gui.UserRequest) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) ContactFormController(org.olat.modules.co.ContactFormController) FormBasicController(org.olat.core.gui.components.form.flexible.impl.FormBasicController) Controller(org.olat.core.gui.control.Controller) ControllerCreator(org.olat.core.gui.control.creator.ControllerCreator)

Example 5 with UserRequest

use of org.olat.core.gui.UserRequest in project OpenOLAT by OpenOLAT.

the class NotesPortletRunController method event.

/**
 * @see org.olat.core.gui.control.ControllerEventListener#dispatchEvent(org.olat.core.gui.UserRequest, org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event)
 */
public void event(UserRequest ureq, Controller source, Event event) {
    super.event(ureq, source, event);
    if (source == tableCtr) {
        if (event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
            TableEvent te = (TableEvent) event;
            String actionid = te.getActionId();
            if (actionid.equals(CMD_LAUNCH)) {
                int rowid = te.getRowId();
                final NotePortletEntry pe = (NotePortletEntry) notesListModel.getObject(rowid);
                final Note note = pe.getValue();
                // will not be disposed on course run dispose, popus up as new browserwindow
                ControllerCreator ctrlCreator = new ControllerCreator() {

                    public Controller createController(UserRequest lureq, WindowControl lwControl) {
                        Controller nc = new NoteController(lureq, lwControl, note);
                        // use on column layout
                        LayoutMain3ColsController layoutCtr = new LayoutMain3ColsController(lureq, lwControl, nc);
                        // dispose content on layout dispose
                        layoutCtr.addDisposableChildController(nc);
                        return layoutCtr;
                    }
                };
                // wrap the content controller into a full header layout
                ControllerCreator layoutCtrlr = BaseFullWebappPopupLayoutFactory.createAuthMinimalPopupLayout(ureq, ctrlCreator);
                // open in new browser window
                PopupBrowserWindow pbw = getWindowControl().getWindowBackOffice().getWindowManager().createNewPopupBrowserWindowFor(ureq, layoutCtrlr);
                pbw.open(ureq);
            // 
            }
        }
    }
}
Also used : TableEvent(org.olat.core.gui.components.table.TableEvent) PopupBrowserWindow(org.olat.core.gui.control.generic.popup.PopupBrowserWindow) LayoutMain3ColsController(org.olat.core.commons.fullWebApp.LayoutMain3ColsController) WindowControl(org.olat.core.gui.control.WindowControl) LayoutMain3ColsController(org.olat.core.commons.fullWebApp.LayoutMain3ColsController) AbstractPortletRunController(org.olat.core.gui.control.generic.portal.AbstractPortletRunController) Controller(org.olat.core.gui.control.Controller) TableController(org.olat.core.gui.components.table.TableController) ControllerCreator(org.olat.core.gui.control.creator.ControllerCreator) UserRequest(org.olat.core.gui.UserRequest)

Aggregations

UserRequest (org.olat.core.gui.UserRequest)314 WindowControl (org.olat.core.gui.control.WindowControl)154 Identity (org.olat.core.id.Identity)92 ControllerCreator (org.olat.core.gui.control.creator.ControllerCreator)74 RestSecurityHelper.getUserRequest (org.olat.restapi.security.RestSecurityHelper.getUserRequest)68 Path (javax.ws.rs.Path)64 StepsMainRunController (org.olat.core.gui.control.generic.wizard.StepsMainRunController)64 Controller (org.olat.core.gui.control.Controller)62 RepositoryEntry (org.olat.repository.RepositoryEntry)58 Step (org.olat.core.gui.control.generic.wizard.Step)56 StepRunnerCallback (org.olat.core.gui.control.generic.wizard.StepRunnerCallback)56 StepsRunContext (org.olat.core.gui.control.generic.wizard.StepsRunContext)56 ArrayList (java.util.ArrayList)46 ICourse (org.olat.course.ICourse)44 Produces (javax.ws.rs.Produces)40 List (java.util.List)36 LayoutMain3ColsController (org.olat.core.commons.fullWebApp.LayoutMain3ColsController)36 PUT (javax.ws.rs.PUT)32 UserRequestImpl (org.olat.core.gui.UserRequestImpl)30 RestSecurityHelper.getIdentity (org.olat.restapi.security.RestSecurityHelper.getIdentity)30