Search in sources :

Example 1 with Status

use of org.olat.modules.fo.Status in project OpenOLAT by OpenOLAT.

the class MessageListController method doHideThread.

/**
 * Sets the hidden status to the thread message.
 * @param ureq
 * @param msg
 * @param hidden
 */
private void doHideThread() {
    if (thread != null) {
        thread = forumManager.getMessageById(thread.getKey());
        Status status = Status.getStatus(thread.getStatusCode());
        status.setHidden(true);
        thread.setStatusCode(Status.getStatusCode(status));
        thread = forumManager.updateMessage(thread, false);
        // before sending async event
        DBFactory.getInstance().commit();
        hideThreadButton.setVisible(false);
        showThreadButton.setVisible(true && !guestOnly);
        mainVC.setDirty(true);
        ForumChangedEvent event = new ForumChangedEvent(ForumChangedEvent.HIDE, thread.getKey(), null, getIdentity());
        CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(event, forumOres);
        ThreadLocalUserActivityLogger.log(ForumLoggingAction.FORUM_THREAD_HIDE, getClass(), LoggingResourceable.wrap(thread));
    }
}
Also used : Status(org.olat.modules.fo.Status) ForumChangedEvent(org.olat.modules.fo.ForumChangedEvent)

Example 2 with Status

use of org.olat.modules.fo.Status in project OpenOLAT by OpenOLAT.

the class MessageListController method updateButtons.

private void updateButtons(Link activeLink) {
    allButton.setCustomEnabledLinkCSS(activeButton(allButton, activeLink));
    allFlatButton.setCustomEnabledLinkCSS(activeButton(allFlatButton, activeLink));
    oneButton.setCustomEnabledLinkCSS(activeButton(oneButton, activeLink));
    markedButton.setCustomEnabledLinkCSS(activeButton(markedButton, activeLink));
    newButton.setCustomEnabledLinkCSS(activeButton(newButton, activeLink));
    archiveThreadButton.setVisible(thread != null && foCallback.mayArchiveForum());
    if (thread == null || guestOnly || !foCallback.mayEditMessageAsModerator()) {
        closeThreadButton.setVisible(false);
        openThreadButton.setVisible(false);
        hideThreadButton.setVisible(false);
        showThreadButton.setVisible(false);
        stickyButton.setVisible(false);
        removeStickyButton.setVisible(false);
    } else {
        Status status = Status.getStatus(thread.getStatusCode());
        boolean isClosed = status.isClosed();
        boolean isHidden = status.isHidden();
        boolean isSticky = status.isSticky();
        closeThreadButton.setVisible(!isClosed);
        openThreadButton.setVisible(isClosed);
        hideThreadButton.setVisible(!isHidden);
        showThreadButton.setVisible(isHidden);
        stickyButton.setVisible(foCallback.mayEditMessageAsModerator() && thread != null && !isSticky);
        removeStickyButton.setVisible(foCallback.mayEditMessageAsModerator() && thread != null && isSticky);
    }
}
Also used : Status(org.olat.modules.fo.Status)

Example 3 with Status

use of org.olat.modules.fo.Status in project OpenOLAT by OpenOLAT.

the class MessageListController method doOpenThread.

private void doOpenThread() {
    if (thread != null) {
        thread = forumManager.getMessageById(thread.getKey());
        Status status = Status.getStatus(thread.getStatusCode());
        status.setClosed(false);
        thread.setStatusCode(Status.getStatusCode(status));
        thread = forumManager.updateMessage(thread, true);
        // before sending async event
        DBFactory.getInstance().commit();
        closeThreadButton.setVisible(true && !guestOnly);
        openThreadButton.setVisible(false);
        mainVC.setDirty(true);
        ForumChangedEvent event = new ForumChangedEvent(ForumChangedEvent.OPEN, thread.getKey(), null, getIdentity());
        CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(event, forumOres);
        ThreadLocalUserActivityLogger.log(ForumLoggingAction.FORUM_THREAD_REOPEN, getClass(), LoggingResourceable.wrap(thread));
    }
}
Also used : Status(org.olat.modules.fo.Status) ForumChangedEvent(org.olat.modules.fo.ForumChangedEvent)

Example 4 with Status

use of org.olat.modules.fo.Status in project OpenOLAT by OpenOLAT.

the class StatusTypeCellRenderer method render.

@Override
public void render(Renderer renderer, StringOutput target, Object cellValue, int row, FlexiTableComponent source, URLBuilder ubu, Translator translator) {
    if (cellValue instanceof Number) {
        int status = ((Number) cellValue).intValue();
        Status messageStatus = Status.getStatus(status);
        boolean isSticky = messageStatus.isSticky();
        boolean isClosed = messageStatus.isClosed();
        target.append("<i class='o_icon o_forum_");
        if (isSticky && isClosed) {
            target.append("status_sticky_closed");
        } else if (isSticky) {
            target.append("status_sticky");
        } else if (isClosed) {
            target.append("status_closed");
        } else if (messageStatus.isHidden()) {
            target.append("status_hidden");
        } else {
            target.append("status_thread");
        }
        target.append("_icon'> </i>");
    }
}
Also used : Status(org.olat.modules.fo.Status)

Example 5 with Status

use of org.olat.modules.fo.Status in project OpenOLAT by OpenOLAT.

the class ForumManager method persistMessageInAnotherLocation.

/**
 * Persist message in another location.
 */
private Message persistMessageInAnotherLocation(Message oldMessage, Forum forum, Message top, Message parent) {
    // 1) take the new top messages forum to create a new child
    Message message = createMessage(forum, oldMessage.getCreator(), oldMessage.isGuest());
    ((MessageImpl) message).setCreationDate(oldMessage.getCreationDate());
    message.setLastModified(oldMessage.getLastModified());
    message.setModifier(oldMessage.getModifier());
    message.setTitle(oldMessage.getTitle());
    message.setBody(oldMessage.getBody());
    message.setPseudonym(oldMessage.getPseudonym());
    // 2) set the thread top to the new top message
    message.setThreadtop(top);
    // 3) maintain the hierarchy, parent and top message can be equal
    message.setParent(parent);
    Status status = Status.getStatus(oldMessage.getStatusCode());
    if (status != null) {
        status.setMoved(true);
        message.setStatusCode(Status.getStatusCode(status));
    }
    // 4) save the new massage in the new destination
    message = saveMessage(message);
    return message;
}
Also used : Status(org.olat.modules.fo.Status) Message(org.olat.modules.fo.Message) MessageImpl(org.olat.modules.fo.model.MessageImpl) ReadMessageImpl(org.olat.modules.fo.model.ReadMessageImpl)

Aggregations

Status (org.olat.modules.fo.Status)16 ForumChangedEvent (org.olat.modules.fo.ForumChangedEvent)10 Message (org.olat.modules.fo.Message)2 MessageImpl (org.olat.modules.fo.model.MessageImpl)2 ReadMessageImpl (org.olat.modules.fo.model.ReadMessageImpl)2