--- /dev/null
+<% /**
+*Copyright © Igor Barma, Alexandre Desoubeaux, Christian Martel, Eric Brun, Mathieu Amblard, Gwenael Gevet, Pierre Guillot, 2012
+*
+*This file is part of the work and learning management system Pentila Nero.
+*
+*Pentila Nero is free software. You can redistribute it and/or modify since
+*you respect the terms of either (at least one of the both license) :
+*- under the terms of the GNU Affero General Public License as
+*published by the Free Software Foundation, either version 3 of the
+*License, or (at your option) any later version.
+*- the CeCILL-C as published by CeCILL-C; either version 1 of the
+*License, or any later version
+*- the GNU Lesser General Public License as published by the
+*Free Software Foundation, either version 3 of the license,
+*or (at your option) any later version.
+*
+*There are special exceptions to the terms and conditions of the
+*licenses as they are applied to this software. View the full text of
+*the exception in file LICENSE-PROJECT.txt in the directory of this software
+*distribution.
+*
+*Pentila Nero is distributed in the hope that it will be useful,
+*but WITHOUT ANY WARRANTY; without even the implied warranty of
+*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+*Licenses for more details.
+*
+*You should have received a copy of the GNU Affero General Public License
+*and the CeCILL-C and the GNU Lesser General Public License along with
+*Pentila Nero. If not, see :
+*<http://www.gnu.org/licenses/> and
+*<http://www.cecill.info/licences.fr.html>.
+*/ %>
+<%@page import="com.pentila.entSavoie.messageBoards.service.MBMessageInfosLocalServiceUtil"%>
+<%@page import="com.pentila.entSavoie.messageBoards.model.MBMessageInfos"%>
+<%@page import="java.util.Date"%>
+<%@page import="com.liferay.portal.util.PortalUtil"%>
+<%@page import="com.pentila.entSavoie.portlets.forum.JSPPortlet"%>
+<%@page import="com.liferay.portal.kernel.util.HttpUtil"%>
+<%@page import="com.liferay.portal.model.CompanyConstants"%>
+<%@page import="java.text.SimpleDateFormat"%>
+<%@page import="java.text.DateFormat"%>
+<%@page import="com.pentila.entSavoie.utils.JSPPortletUtil"%>
+<%@page import="com.pentila.entSavoie.utils.PortletConstant"%>
+<%@page import="com.liferay.portal.kernel.workflow.WorkflowConstants"%>
+<%@page import="java.util.List"%>
+
+<%@page import="com.liferay.portal.kernel.dao.orm.QueryUtil"%>
+<%@page import="com.liferay.portal.model.User"%>
+<%@page import="com.liferay.portal.service.ExtUserLocalServiceUtil"%>
+<%@page import="com.liferay.portlet.messageboards.model.MBMessage"%>
+<%@page import="com.liferay.portlet.messageboards.service.MBMessageLocalServiceUtil"%>
+<%@page import="com.liferay.portlet.messageboards.service.MBThreadLocalServiceUtil"%>
+<%@page import="com.liferay.portlet.messageboards.model.MBThread"%>
+<%@page import="com.liferay.portal.kernel.util.ParamUtil"%>
+
+<%@ include file="./initAjax.jsp" %>
+
+<%
+final JSONObject ret = JSONFactoryUtil.createJSONObject();
+final JSONArray entities = JSONFactoryUtil.createJSONArray();
+
+final long groupId = ParamUtil.getLong(renderRequest, "groupId");
+
+DateFormat dfThread = new SimpleDateFormat("dd/MM/yyyy HH:mm");
+
+int start = ParamUtil.getInteger(renderRequest, "start");
+int limit = ParamUtil.getInteger(renderRequest, "limit", 10) + start;
+
+List<MBThread> listThread = MBThreadLocalServiceUtil.getGroupThreads(groupId, user.getUserId(), WorkflowConstants.STATUS_ANY, true, start, limit);
+
+ret.put("total", MBThreadLocalServiceUtil.getGroupThreadsCount(groupId, user.getUserId(), WorkflowConstants.STATUS_ANY, true));
+
+for (MBThread thread: listThread) {
+ JSONObject curr = JSONFactoryUtil.createJSONObject();
+ curr.put("id", thread.getThreadId());
+ curr.put("type", "Thread");
+ curr.put("messageCount", thread.getMessageCount());
+ curr.put("viewCount", thread.getViewCount());
+ // Premier message du fil de discussion
+ MBMessage rootMessage = MBMessageLocalServiceUtil.getMessage(thread.getRootMessageId());
+
+ MBMessageInfos mbmi = null;
+ boolean isAnonymous = false;
+
+ try {
+ mbmi = MBMessageInfosLocalServiceUtil.getMessageInfosByMessageId(rootMessage.getMessageId());
+ isAnonymous = mbmi.getIsAnonymous();
+ }
+ catch (Exception e){
+ continue;
+ }
+
+ // Titre du premier message
+ curr.put("name", rootMessage.getSubject());
+ curr.put("rootMessageId", rootMessage.getMessageId());
+ // Corps du message
+ curr.put("description", rootMessage.getBody());
+ // Nom du createur du fil de discussion et date de creation
+ curr.put("creator", rootMessage.getUserName());
+ curr.put("createdDate", dfThread.format(rootMessage.getCreateDate()));
+
+ // Pieces jointes
+ final JSONArray attachements = JSONFactoryUtil.createJSONArray();
+ String[] attachementsFiles = rootMessage.getAttachmentsFiles();
+ for (int i = 0; i < attachementsFiles.length; i++) {
+ final JSONObject fileDescriptor = JSPPortletUtil.formatAttachment(themeDisplay, attachementsFiles[i], rootMessage.getMessageId(), PortletConstant.FORUM);
+ attachements.put(fileDescriptor);
+ }
+ curr.put("attachements", attachements.toString());
+
+ // Dernier utilisateur ayant post�
+ curr.put("lastPostUser", PortalUtil.getUserName(thread.getLastPostByUserId(), messages.getString("Utilisateur-supprime")));
+ curr.put("lastPostDate", dfThread.format(thread.getLastPostDate()));
+ curr.put("priority", thread.getPriority());
+ curr.put("hideEdit", true);
+ curr.put("hideDelete", true);
+ curr.put("hideMoveThread", true);
+ curr.put("isSubscribed", true);
+
+ int nbMessageNew = JSPPortlet.countNewMessageByThread(user.getUserId(), thread);
+ curr.put("nbMessageNew", nbMessageNew);
+ curr.put("groupId", groupId);
+ curr.put("anonymous", isAnonymous);
+ entities.put(curr);
+}
+
+ret.put("entities", entities);
+%>
+<%= ret.toString() %>