wiki:Develop/Forum

Forum - Developer

For the implementation documententaion see Modules/Forum

This page describes how the forum works. We found this useful since the forum is a bit of a tricky / more complicated module.

The Forum module is a Subclass to CascadingMainEntries.

There are 3 tables which are used by the forum:

  • corinisforummainentries: all mainentries (i.g. forums)
  • corinisforumentries: all entries (i.g. topics/postings)
  • corinisforumhistory: saves all viewed mainentries per user

While the CascadingMainEntries class is only using corinisforummainentries (since it has only 1 - the MainEntries View), the forum class is using all three tables.

Tables

corinisforummainentries Besides others it has following fields:

  • ID: The ID of the mainentry
  • PARENT: The parent of the mainentry, -1 if it is a root element
  • SUBMAINENTRIES: The number of mainentries under this mainentry (child mainentries)
  • SUBENTRIES: The number of entries under this mainentry (postings/topics for this forum)
  • TOPICS: The number of topics under this mainentry (first level of postings under the forum)

corinisforumentries Besides others it has following fields:

  • ID: The ID of the entry
  • MAINID: The ID of the corresponding mainentry (forum)
  • PARENT: The PARENTID of the parentelement - this is either another entry or a mainentry (in this case parentid <> any id in the entrytable)
  • POSTINGS: The number of postings under this entry (subentries)

corinisforumhistory

  • ID: id of the element
  • USERID: userid
  • ENTRYDATE: date when viewed

Each id/userid combination is unique - so it stores the latest view of this element

Forum class / methods described

  • setupModule: When setting up the forum, all counters (subentries, submainentries, postings, topics,..) are deleted and newly counted; also all usernames (createusername, changeusername) are newly set according to id
  • CorrectNrOfPostings?: Will be called whenever a posting is added/deleted - to correct the postingcount
  • setXXXXFields: These methods are mostly overrided abstract methods from CascadingMainEntries. They will build a tree and fill it with the corresponding values and return it (either the return tree (for gets), the insert tree (for creates), the update tree (for modifies)

Sticky The sticky value allows it to make entries sticky - meaning they come first. If the sticky value is set (other than -1) - the entry with the lowest sticky-value comes first...

History The Forumhistory saves all mainentries a user have viewed. This is not only for tracking-purposes but above all to make it possible to mark new and unread items. An entry is added when the method getEntries() ist called - i.g. all entries for a mainEntry (=Forum) are viewed. Then an entry with the id (of the forum), userid and entrydate (date of view = now) is created in forumHistory.

In the reInit() Method of Forum there is the Method getHistorylastvisited() which will load all entries for the current user out of forumHistory into a local Hashtable. Since the method is called in reInit() it will be called everytime a user loads a .jsp (in the forum module). In the setGetMainEntryFieldValues and setGetEntryFieldValues methods (i.g. when the return Tree for a getFunction is built) the creation / changedate of every entry/mainentry will be checked. If the id isn't in the Hashtable it is a new Entry and the newEntry Attribute will be set to true in the return tree. If the id already exist in the forumhistory table (for the current user), the user already have viewed the entry at least once. Now it will be checked if the changedate of the entry is newer than the date saved in forumhistory (meaning that the entry has been changed after the last view). In this case the unread Attribute will be set to true in the return tree.