wiki:Modules/Forum

Forum

Introduction

Forum (MainEntry)
  |- Subforum (MainEntry)
  |    |- Topic (Entry)
  |         |- Posting (Entry)
  |               |- Posting (Entry)
  |    |- Topic (Entry)
  |- Topic (Entry)
      |- Posting (Entry)
Forum (MainEntry)
  |- Topic

MainEntries

MainEntries are the forums. A forum defines the rights of all entries beneath. A mainentry can hold entries and/or other forums (also called subforum). Moderators can only be assigned to a mainentry, not an entry.

Entries

An entry right after a mainentry is called a topic. An answer/reply to a topic is called posting. Postings can - based on the implementation - hold a virtually unlimited number of other postings, but no forums (mainentries).

Package

Forum

Parameter prefix

Forum

Forum.getMainEntries

This function gets all forums

Authorities

FORUM_VIEW

Parameter

Required

none

Optional

forumMainEntriesView.parentthe id of the parent-forum; the function returns all forums which have this parent (id). If this parameter is missing -1 is assumed as value - therefore returning all forums of the first level.

Return Tree

<FORUM>
        <MAINENTRY depth="0">
                <ID>1113914445471</ID>
                <MESSAGE />
                <PARENT>-1</PARENT>
                <TITLE>Kommentare</TITLE>
                <ORDER>0</ORDER>
                <TOPICS>0</TOPICS>
                <SUBENTRIES>0</SUBENTRIES>
                <SUBMAINENTRIES>0</SUBMAINENTRIES>
                <CREATE>
                        <DATE>19.04.2005 14:41</DATE>
                        <LDATE>1113914480171</LDATE>
                        <USER>
                                <NAME>admin</NAME>
                                <IP>127.0.0.1</IP>
                                <ID>2</ID>
                        </USER>
                </CREATE>
                <CHANGE>
                        <DATE>19.04.2005 14:41</DATE>
                        <LDATE>1113914480171</LDATE>
                        <USER>
                                <NAME>admin</NAME>
                                <IP>127.0.0.1</IP>
                                <ID>2</ID>
                        </USER>
                </CHANGE>
                <LASTENTRYID>-1</LASTENTRYID>
        </MAINENTRY>
        ...
        <PATH />
</FORUM>

JSP

ForumgetMainEntries?.jsp:

<%@page language="java" import="corinis.*,corinis.modules.*,corinis.util.*" %>
<%
    Core core = new Core (pageContext);
    Forum f = (Forum)core.getModule(Forum.class);
%>
<HTML>
<BODY>
<%      
        core.addDom(f.getMainEntries());
        core.addDom(f.getEntries());
        out.print(HTMLModify.unfixEntities(core.parseDomHtml("implementation/ForumgetMainEntries.xsl")));
           
%> 
</BODY>
</HTML>        

XSL

Note that this xsl is valid for getMainEntries AND getEntries

<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:template match="/">
    <table class="text" width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr class="pfadbez">
        <td>&#160;</td>
        <td>NAME</td>
        <td>TEXT</td>
        <td>CREATEDATUM</td>
        <td>THREADS</td>
        <td>ENTRIES</td>
      </tr>
      <xsl:apply-templates select="/CORINIS/FORUM/MAINENTRY"/>
      <xsl:if test="/CORINIS/FORUM/ENTRY">
        <xsl:apply-templates select="/CORINIS/FORUM/ENTRY"/>
      </xsl:if>
    </table>
  </xsl:template>
  
  <xsl:template match="MAINENTRY">
    <tr>                
      <td>
        <xsl:if test="@locked">
          locked
        </xsl:if>
        <xsl:if test="STICKY != '-1'">
          sticky
        </xsl:if>
        <xsl:choose>
          <xsl:when test="not (@newentry) or not(@unread)">
            read
          </xsl:when>
          <xsl:otherwise>
            unread
          </xsl:otherwise>
        </xsl:choose>
        
        FORUM                   
      </td>
      <td>
        &#160;&#160;&#160;
        <a>
          <xsl:attribute name="href">
            ForumgetMainEntries.jsp?Forum_parent=<xsl:value-of select="ID"/>
          </xsl:attribute>
          <xsl:attribute name="title">Forum</xsl:attribute>
          <xsl:value-of select="TITLE"/>
        </a>
      </td>
      <td>
        <xsl:value-of select="MESSAGE"/>
      </td>
      <td>
        <xsl:value-of select="CREATE/DATE"/>
      </td>
      <td>
        <xsl:value-of select="TOPICS"/>
      </td>
      <td>
        <xsl:value-of select="SUBENTRIES"/>
      </td>
    </tr>
  </xsl:template>
  
  <xsl:template match="ENTRY">
    <tr>
      <td>
        <xsl:if test="@locked">
          locked
        </xsl:if>
        <xsl:if test="STICKY != '-1'">
          sticky
        </xsl:if>
        <xsl:choose>
          <xsl:when test="not (@newentry) or not(@unread)">
            read
          </xsl:when>
          <xsl:otherwise>
            unread
          </xsl:otherwise>
        </xsl:choose>
        
        ENTRY   
      </td>
      <td>
        <xsl:call-template name="loop">
          <xsl:with-param name="loopI">0</xsl:with-param>
          <xsl:with-param name="loopE">
            <xsl:value-of select="@depth"/>
          </xsl:with-param>
        </xsl:call-template>
         
        <a>
          <xsl:attribute name="href">
            ForumgetEntries.jsp?Forum_parent=<xsl:value-of select="ID"/>
          </xsl:attribute>
          <xsl:attribute name="title">
            <xsl:text>TEXT</xsl:text>
          </xsl:attribute>
          <xsl:value-of select="TITLE"/>
        </a>
      </td>
      <td>
        <xsl:value-of select="MESSAGE"/>
      </td>
      <td>
        <xsl:value-of select="CREATE/DATE"/>
      </td>
      <td>&#160;</td>
      <td>
        <xsl:value-of select="POSTINGS"/>
      </td>
    </tr>
    <xsl:apply-templates select="ENTRY"/>
  </xsl:template>
  
  
  <xsl:template name="loop">
    <xsl:param name="loopI"/>
    <xsl:param name="loopE"/>
    <xsl:variable name="tempI">
      <xsl:value-of select="$loopI"/>
    </xsl:variable>
    <!-- this is what the loop does -->&#160;
    <!-- this is the exit condition -->
    <xsl:if test="not($tempI = $loopE)">
      <xsl:call-template name="loop">
        <xsl:with-param name="loopI" select="$tempI + 1"/>
        <xsl:with-param name="loopE" select="$loopE"/>
      </xsl:call-template>
    </xsl:if>
  </xsl:template>
</xsl:stylesheet>

Additional Information

Since the tree of Forum.getEntries and Forum.getMainEntries are very similar, we use only one xsl to parse both return trees in one step (see both core.addDom calls above).

Forum.getEntries

Gets all entries/postings within a forum

Authority

FORUM_VIEW

Parameter

Required

forumEntriesView.parentthe id of the forum for which all entries should be returned

Return tree

The return tree also contains the parent-forum (mainentry). The entries have the attribute "depth" where depth=1 is a topic.

<FORUM>
   <POSTINGS>
      <ENTRY depth="1">
        <ID>1113998171744</ID>
        <MAINENTRYID>1113914445472</MAINENTRYID>
        <MESSAGE>ein neuer Beitrag</MESSAGE>
        <PARENT>1113914445521</PARENT>
        <TITLE>neuer Beitrag</TITLE>
        <ATTACH>-1</ATTACH>
        <POSTINGS>0</POSTINGS>
        <STICKY>160</STICKY>
        <CREATE>
          <DATE>20.04.2005 14:27</DATE>
          <LDATE>1114000070890</LDATE>
          <USER>
            <NAME>admin</NAME>
            <IP>127.0.0.1</IP>
            <ID>2</ID>
          </USER>
        </CREATE>
        <CHANGE>
          <DATE>20.04.2005 14:27</DATE>
          <LDATE>1114000070890</LDATE>
          <USER>
            <NAME>admin</NAME>
            <IP>127.0.0.1</IP>
            <ID>2</ID>
          </USER>
        </CHANGE>
        <LASTENTRYID>1113998171744</LASTENTRYID>
      </ENTRY>
      <PATH>
        <PATH>
          <TITLE>Beiträge</TITLE>
          <ID>1113914445472</ID>
          <PATH ENTRY="true">
            <TITLE>Beitrag</TITLE>
            <ID>1113914445521</ID>
          </PATH>
        </PATH>
      </PATH>
    </POSTINGS>
    <LIMIT>-1</LIMIT>
    <ENTRY depth="0">
      <ID>1113914445521</ID>
      <MAINENTRYID>1113914445472</MAINENTRYID>
      <MESSAGE>this is a topic</MESSAGE>
      <PARENT>1113914445472</PARENT>
      <TITLE>Beitrag</TITLE>
      <ATTACH>-1</ATTACH>
      <POSTINGS>3</POSTINGS>
      <STICKY>-1</STICKY>
      <CREATE>
        <DATE>19.04.2005 15:25</DATE>
        <LDATE>1113917101218</LDATE>
        <USER>
          <NAME>admin</NAME>
          <IP>127.0.0.1</IP>
          <ID>2</ID>
        </USER>
      </CREATE>
      <CHANGE>
        <DATE>20.04.2005 14:27</DATE>
        <LDATE>1114000070890</LDATE>
        <USER>
          <NAME>admin</NAME>
          <IP>127.0.0.1</IP>
          <ID>2</ID>
        </USER>
      </CHANGE>
      <LASTENTRYID>1113998171744</LASTENTRYID>
    </ENTRY>
  </FORUM> 

JSP

ForumgetEntries?.jsp

<%@page language="java" import="corinis.*,corinis.modules.*,corinis.util.*" %>
<%
    Core core = new Core (pageContext);
    Forum f = (Forum)core.getModule(Forum.class);
%>
<HTML>
<BODY>
<%
        core.addDom(f.getEntries());
        out.print(core.parseDomHtml("implementation/ForumgetMainEntries.xsl"));    
%> 
</BODY>
</HTML>        

XSL

see getMainEntries

Forum.getMainEntry

Returns a forum

Authority

FORUM_VIEW

Parameter

Required

forumMainEntriesView.mainIdThe id of the forum

Return tree

<FORUM>
    <MAINENTRY depth="0">
      <ID>1116943201263</ID>
      <MESSAGE>asdf</MESSAGE>
      <PARENT>-1</PARENT>
      <TITLE>asdf</TITLE>
      <ORDER>0</ORDER>
      <TOPICS>1</TOPICS>
      <SUBENTRIES>2</SUBENTRIES>
      <SUBMAINENTRIES>2</SUBMAINENTRIES>
      <CREATE>
        <DATE>24.05.2005 16:08</DATE>
        <LDATE>1116943702532</LDATE>
        <USER>
          <NAME>hansi</NAME>
          <IP>127.0.0.1</IP>
          <ID>1115638983565</ID>
        </USER>
      </CREATE>
      <CHANGE>
        <DATE>03.06.2005 11:13</DATE>
        <LDATE>1117789980343</LDATE>
        <USER>
          <NAME>admin</NAME>
          <IP>127.0.0.1</IP>
          <ID>2</ID>
        </USER>
      </CHANGE>
      <LASTENTRYID>1117789869424</LASTENTRYID>
    </MAINENTRY>
  </FORUM> 

Forum.getEntry

Gets one entry.

Authority

FORUM_VIEW

Parameters

Required

forumEntriesView.idthe id of the entry

Return tree

<FORUM>
  <ENTRY depth="0" newentry="true" unread="true">
    <ID>1117025449971</ID>
    <MAINENTRYID>1116943201263</MAINENTRYID>
    <MESSAGE>beitrag</MESSAGE>
    <PARENT>1116943201263</PARENT>
    <TITLE>beitrag</TITLE>
    <ATTACH>-1</ATTACH>
    <POSTINGS>1</POSTINGS>
    <STICKY>0</STICKY>
    <CREATE>
      <DATE>25.05.2005 14:51</DATE>
      <LDATE>1117025497062</LDATE>
      <USER>
        <NAME>admin</NAME>
        <IP>127.0.0.1</IP>
        <ID>2</ID>
      </USER>
    </CREATE>
    <CHANGE>
      <DATE>03.06.2005 11:13</DATE>
      <LDATE>1117789980328</LDATE>
      <USER>
        <NAME>admin</NAME>
        <IP>127.0.0.1</IP>
        <ID>2</ID>
      </USER>
    </CHANGE>
    <LASTENTRYID>1117789869424</LASTENTRYID>
  </ENTRY>
</FORUM>

XSL

see getMainEntries

Forum.luckunlcokMainEntry

Locks or unlocks a forum respectively.

Authority

FORUM_LOCK QM Authority for the forum

Parameters

Required

forumMainEntriesView.mainIdThe id of the forum
forumMainEntriesView.lockunLockMainEntryRequired to perform the function

Return tree

returnTree Standard return tree?

Forum.lockunlockEntry

Locks or unlocks a Posting respectively.

Authority

FORUM_LOCK QM Authority for the entry

Parameters

Required

forumEntriesView.idThe id of the entry
forumEntriesView.lockunLockEntryRequired to perform the function

Return tree

returnTree Standard return tree?

Forum.createMainEntry

Creates a forum

Authority

FORUM_MAINCREATE

Parameters

Required

forumMainEntriesView.titleThe title of the forum
forumMainEntriesView.messageposting / description
forumMainEntriesView.createMainEntryRequired to perform the function

Return tree

returnTree Standard return tree?

Forum.createEntry

Creates an entry

Authority

FORUM_CREATE

Parameters

Required

forumEntriesView.parentThe parent of the entry
forumEntriesView.messageposting / description
forumEntriesView.createMainEntryRequired to perform the function

Optional

forumEntriesView.titlethe title of the posting
forumEntriesView.stickyA sticky value

Return tree

returnTree Standard return tree?

Forum.deleteMainEntry

Deletes a forum

Authority

FORUM_MAINDELETE

Parameters

Required

forumMainEntriesView.mainIdThe id of the forum to delete
forumMainEntriesView.deleteMainEntryRequired to perform the function

Return tree

returnTree Standard return tree?

Forum.deleteEntry

Deletes an entry

Authority

FORUM_DELETE

Parameters

Required

forumEntriesView.idThe id of the entry to be deleted
forumEntriesView.deleteEntryRequired to perform the function

Return tree

returnTree Standard return tree?

Forum.modifyMainEntry

Modifies a forum

Authority

FORUM_MAINMODIFY

Parameters

Required

forumMainEntriesView.mainIdThe id of the forum to be modified
forumMainEntriesView.modifyMainEntryRequired to perform the function

Optional

forumMainEntriesView.titleThe title of the forum
forumMainEntriesView.messageposting / description
forumMainEntriesView.lockedlocked (T) or not locked (F)

Return tree

returnTree Standard return tree?

Forum.modifyEntry

Creates a forum

Authority

FORUM_MODIFY

Parameters

Required

forumEntriesView.idThe id of the entry to be modified
forumEntriesView.modifyEntryRequired to perform the function

Optional

forumEntriesView.titleThe title of the entry
forumEntriesView.messageposting / description
forumEntriesView.lockedlocked (T) or unlocked (F)
forumEntriesView.stickya sticky value

Return tree

returnTree Standard return tree?