Search in sources :

Example 86 with Message

use of org.olat.modules.fo.Message in project openolat by klemens.

the class SelectThreadStepForm method loadModel.

private void loadModel() {
    Identity identity = guestOnly ? null : getIdentity();
    Message messageToMove = (Message) getFromRunContext(SendMailStepForm.MESSAGE_TO_MOVE);
    messageToMove = messageToMove.getThreadtop() == null ? messageToMove : messageToMove.getThreadtop();
    List<ForumThread> threads = forumManager.getForumThreads(forum, identity);
    if (!foCallback.mayEditMessageAsModerator()) {
        for (Iterator<ForumThread> threadIt = threads.iterator(); threadIt.hasNext(); ) {
            ForumThread next = threadIt.next();
            if (Status.getStatus(next.getStatusCode()).isHidden()) {
                threadIt.remove();
            } else if (messageToMove.getKey().equals(next.getKey())) {
                threadIt.remove();
            }
        }
    }
    threadTableModel.setObjects(threads);
    threadTableModel.sort(new SortKey(ThreadListCols.thread.name(), true));
    threadTable.reloadData();
    threadTable.reset();
}
Also used : Message(org.olat.modules.fo.Message) ForumThread(org.olat.modules.fo.model.ForumThread) SortKey(org.olat.core.commons.persistence.SortKey) Identity(org.olat.core.id.Identity)

Example 87 with Message

use of org.olat.modules.fo.Message in project openolat by klemens.

the class SelectThreadStepForm method doSelect.

private void doSelect(UserRequest ureq, ForumThread row) {
    long parentMessageKey = row.getKey();
    Message parentMessage = forumManager.getMessageById(parentMessageKey);
    Boolean newThread = (Boolean) getFromRunContext(SendMailStepForm.NEW_THREAD);
    if (newThread != null && newThread) {
        return;
    } else {
        addToRunContext(SendMailStepForm.PARENT_MESSAGE, parentMessage);
        formOK(ureq);
    }
}
Also used : Message(org.olat.modules.fo.Message)

Example 88 with Message

use of org.olat.modules.fo.Message in project openolat by klemens.

the class MessageListController method doEditMessage.

private void doEditMessage(UserRequest ureq, MessageView message) {
    // user has clicked on button 'edit'
    boolean userIsMsgCreator = message.isAuthor();
    boolean children = forumManager.countMessageChildren(message.getKey()) > 0;
    if (foCallback.mayEditMessageAsModerator() || (userIsMsgCreator && !children)) {
        Message reloadedMessage = forumManager.loadMessage(message.getKey());
        if (reloadedMessage == null) {
            showWarning("error.message.deleted");
            reloadModel(ureq, null);
        } else {
            editMessageCtrl = new MessageEditController(ureq, getWindowControl(), forum, foCallback, reloadedMessage, null, EditMode.edit);
            listenTo(editMessageCtrl);
            String title = translate("msg.update");
            cmc = new CloseableModalController(getWindowControl(), "close", editMessageCtrl.getInitialComponent(), true, title);
            listenTo(editMessageCtrl);
            cmc.activate();
        }
    } else if ((userIsMsgCreator) && (children == true)) {
        // user is author of the current message but it has already at least
        // one child
        showWarning("may.not.save.msg.as.author");
    } else {
        // user isn't author of the current message
        showInfo("may.not.edit.msg");
    }
}
Also used : ErrorEditMessage(org.olat.modules.fo.ui.events.ErrorEditMessage) Message(org.olat.modules.fo.Message) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)

Example 89 with Message

use of org.olat.modules.fo.Message in project openolat by klemens.

the class MessageListController method doArchiveThread.

private void doArchiveThread(UserRequest ureq, Message currMsg) {
    Message m = currMsg.getThreadtop();
    Long topMessageId = (m == null) ? currMsg.getKey() : m.getKey();
    VFSContainer forumContainer = forumManager.getForumContainer(forum.getKey());
    ForumDownloadResource download = new ForumDownloadResource("Forum", forum, foCallback, topMessageId, forumContainer, getLocale());
    ureq.getDispatchResult().setResultingMediaResource(download);
}
Also used : ForumDownloadResource(org.olat.modules.fo.archiver.formatters.ForumDownloadResource) ErrorEditMessage(org.olat.modules.fo.ui.events.ErrorEditMessage) Message(org.olat.modules.fo.Message) VFSContainer(org.olat.core.util.vfs.VFSContainer)

Example 90 with Message

use of org.olat.modules.fo.Message in project openolat by klemens.

the class MessageListController method doExportForumItem.

private void doExportForumItem(UserRequest ureq, MessageView messageToMove) {
    if (foCallback.mayEditMessageAsModerator()) {
        StepRunnerCallback finish = new FinishCallback();
        Translator trans = Util.createPackageTranslator(Step_1_SelectCourse.class, getLocale());
        Step start = new Step_1_SelectCourse(ureq);
        Message message = forumManager.getMessageById(messageToMove.getKey());
        String wizardTitle = trans.translate("title.wizard.movethread", new String[] { message.getTitle() });
        exportCtrl = new StepsMainRunController(ureq, getWindowControl(), start, finish, null, wizardTitle, "o_sel_bulk_assessment_wizard");
        StepsRunContext runContext = exportCtrl.getRunContext();
        // can be threadtop message
        runContext.put(SendMailStepForm.MESSAGE_TO_MOVE, message);
        // starting thread
        runContext.put(SendMailStepForm.START_THREADTOP, message.getThreadtop() == null ? message : message.getThreadtop());
        // get start course
        PropertyManager propertyManager = PropertyManager.getInstance();
        Long forumResourceableId = forum.getResourceableId();
        Property forumproperty = propertyManager.getPropertyByLongValue(forumResourceableId, FOCourseNode.FORUM_KEY);
        if (forumproperty != null) {
            Long resourcetypeId = forumproperty.getResourceTypeId();
            String resourcetypeName = forumproperty.getResourceTypeName();
            OLATResourceable olatResourceable = olatManager.findResourceable(resourcetypeId, resourcetypeName);
            RepositoryEntry startCourse = repositoryManager.lookupRepositoryEntry(olatResourceable, false);
            if (startCourse != null) {
                runContext.put(SendMailStepForm.START_COURSE, startCourse);
            }
        }
        listenTo(exportCtrl);
        getWindowControl().pushAsModalDialog(exportCtrl.getInitialComponent());
    } else {
        showWarning("may.not.move.message");
    }
}
Also used : ErrorEditMessage(org.olat.modules.fo.ui.events.ErrorEditMessage) Message(org.olat.modules.fo.Message) OLATResourceable(org.olat.core.id.OLATResourceable) PropertyManager(org.olat.properties.PropertyManager) Step(org.olat.core.gui.control.generic.wizard.Step) RepositoryEntry(org.olat.repository.RepositoryEntry) StepsRunContext(org.olat.core.gui.control.generic.wizard.StepsRunContext) Step_1_SelectCourse(org.olat.modules.fo.export.Step_1_SelectCourse) Translator(org.olat.core.gui.translator.Translator) StepsMainRunController(org.olat.core.gui.control.generic.wizard.StepsMainRunController) Property(org.olat.properties.Property) StepRunnerCallback(org.olat.core.gui.control.generic.wizard.StepRunnerCallback) FinishCallback(org.olat.modules.fo.export.FinishCallback)

Aggregations

Message (org.olat.modules.fo.Message)108 Identity (org.olat.core.id.Identity)18 OLATResourceable (org.olat.core.id.OLATResourceable)16 ErrorEditMessage (org.olat.modules.fo.ui.events.ErrorEditMessage)16 Forum (org.olat.modules.fo.Forum)14 ForumManager (org.olat.modules.fo.manager.ForumManager)12 Date (java.util.Date)8 HttpResponse (org.apache.http.HttpResponse)8 Test (org.junit.Test)8 VFSContainer (org.olat.core.util.vfs.VFSContainer)8 ICourse (org.olat.course.ICourse)8 FOCourseNode (org.olat.course.nodes.FOCourseNode)8 RepositoryEntry (org.olat.repository.RepositoryEntry)8 File (java.io.File)6 ArrayList (java.util.ArrayList)6 Path (javax.ws.rs.Path)6 Produces (javax.ws.rs.Produces)6 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)6 VFSItem (org.olat.core.util.vfs.VFSItem)6 PublisherData (org.olat.core.commons.services.notifications.PublisherData)5