From ee445f5dddba724540b5c3a3ff4f9c43615f40ba Mon Sep 17 00:00:00 2001 From: quasi Date: Tue, 11 Jun 2013 06:36:58 +0000 Subject: [PATCH] MyForums Portlet MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GeƤndert: * Inkompatible Verwendung des Tags forum:forum entfernt. Stattdessen lautet das Tag nun forum:forumShortcut git-svn-id: https://svn.libreccm.org/ccm/trunk@2202 8810af33-2d31-482b-a856-94f89814c4df --- .../forum/portlet/MyForumsPortlet.java | 65 +++++++++---------- 1 file changed, 29 insertions(+), 36 deletions(-) diff --git a/ccm-forum/src/com/arsdigita/forum/portlet/MyForumsPortlet.java b/ccm-forum/src/com/arsdigita/forum/portlet/MyForumsPortlet.java index 4e6a1fbf7..237df5378 100644 --- a/ccm-forum/src/com/arsdigita/forum/portlet/MyForumsPortlet.java +++ b/ccm-forum/src/com/arsdigita/forum/portlet/MyForumsPortlet.java @@ -42,19 +42,18 @@ import com.arsdigita.portal.Portlet; import com.arsdigita.portal.apportlet.AppPortlet; /** - * portlet with no attributes that displays links to all forums that user has + * portlet with no attributes that displays links to all forums that user has * read access to - * - * + * + * * @author chris.gilbert@westsussex.gov.uk * @version $Id: MyForumsPortlet.java,v 1.4 2006/07/13 10:19:28 cgyg9330 Exp $ */ public class MyForumsPortlet extends Portlet { public static final String BASE_DATA_OBJECT_TYPE = - "com.arsdigita.forum.MyForumsPortlet"; + "com.arsdigita.forum.MyForumsPortlet"; - protected String getBaseDataObjectType() { return BASE_DATA_OBJECT_TYPE; } @@ -63,61 +62,55 @@ public class MyForumsPortlet extends Portlet { super(dataObject); } - - protected AbstractPortletRenderer doGetPortletRenderer() { return new MyForumsPortletRenderer(this); } - - } -class MyForumsPortletRenderer - extends AbstractPortletRenderer - implements Constants { +class MyForumsPortletRenderer + extends AbstractPortletRenderer + implements Constants { private MyForumsPortlet m_portlet; - public MyForumsPortletRenderer(MyForumsPortlet - portlet) { + public MyForumsPortletRenderer(MyForumsPortlet portlet) { m_portlet = portlet; } protected void generateBodyXML(PageState pageState, - Element parent) { - Element content = parent.newChildElement(FORUM_XML_PREFIX + ":myForumsPortlet", - FORUM_XML_NS); + Element parent) { + Element content = parent.newChildElement(FORUM_XML_PREFIX + ":myForumsPortlet", + FORUM_XML_NS); + - Party party = Kernel.getContext().getParty(); if (party == null) { - party = Kernel.getPublicUser(); + party = Kernel.getPublicUser(); } - + DataCollection forums = SessionManager.getSession().retrieve(Forum.BASE_DATA_OBJECT_TYPE); forums.addOrder("lower(" + Forum.TITLE + ")"); PermissionService.filterObjects(forums, PrivilegeDescriptor.READ, party.getOID()); - + while (forums.next()) { - Forum forum = (Forum)DomainObjectFactory.newInstance(forums.getDataObject()); - Element forumEl = content.newChildElement(FORUM_XML_PREFIX + ":forum", FORUM_XML_NS); + Forum forum = (Forum) DomainObjectFactory.newInstance(forums.getDataObject()); + Element forumEl = content.newChildElement(FORUM_XML_PREFIX + ":forumShortcut", FORUM_XML_NS); URL url = URL.there(forum, "/", null); forumEl.addAttribute("url", url.toString()); - forumEl.addAttribute("title", forum.getTitle()); - // display last forum update info - ThreadCollection threads = forum.getThreads(); - threads.addOrder(MessageThread.LAST_UPDATE); - if (threads.next()) { - MessageThread lastUpdatedThread = threads.getMessageThread(); - forumEl.addAttribute("lastUpdated", new DateFormatter().format(lastUpdatedThread.getLatestUpdateDate())); - threads.close(); - } else { - forumEl.addAttribute("lastUpdated", ""); - } + forumEl.addAttribute("title", forum.getTitle()); + // display last forum update info + ThreadCollection threads = forum.getThreads(); + threads.addOrder(MessageThread.LAST_UPDATE); + if (threads.next()) { + MessageThread lastUpdatedThread = threads.getMessageThread(); + forumEl.addAttribute("lastUpdated", new DateFormatter().format(lastUpdatedThread.getLatestUpdateDate())); + threads.close(); + } else { + forumEl.addAttribute("lastUpdated", ""); + } + - } } - }