[xwiki-users] Forum system that integrates with XWiki?

Trevor Cox xwiki at skahasoftware.com
Mon Jul 17 03:08:10 CEST 2006


I have integrated a mailing list with XWiki. The mailing list is built 
with procmail, which invokes a command line Java program to extract the 
email addresses from the XWiki database and forward each message. All 
the emails are archived in a IMAP folder which is viewed by this 
template code:


<h3 class="heading-1">Mail Archive</h3>

#set($user = "xxx")
#set($pass = "xxx")
#set($fldr = "${context.database}.listname")

#set($store = $xwiki.mail.getStore("imap"))
$store.connect("localhost", $user, $pass)
#set($fldr = $store.getFolder($fldr))
$fldr.open(1)

#set($msgnum = $parameterParser.getInt("msg",0))
#if($msgnum != 0)

<a href="?">Message Index</a>

\\

#set($mail = $fldr.getMessage($msgnum))

From:
#foreach($from in $mail.getHeader("from")) $xwiki.getFormEncoded($from) #end
\\
To:
#foreach($from in $mail.getHeader("to")) $xwiki.getFormEncoded($from) #end
\\
Subject: $xwiki.getFormEncoded($mail.subject) \\
Message:

 #if($mail.isMimeType("text/plain") || $mail.isMimeType("text/html"))
  $mail.getContent()
 #else
  (Unable to display)
 #end

#else

The following mail was sent to the list
during the past year:

#set($count = $fldr.messageCount)
Showing $count of $count messages:

<table class="wiki-table" cellpadding="0" cellspacing="0" border="0">
<tr class="table-odd">
<th>Subject</th><th>From</th><th>Date</th>
</tr>
#foreach ($i in [$fldr.messageCount..1])
#set($mail = $fldr.getMessage($i))
<tr>
<td>
<a 
href="?msg=$mail.getMessageNumber()">$xwiki.getFormEncoded($mail.subject)</a>
</td><td>
#set($froms = $mail.getHeader("from"))
#foreach($from in $froms) $xwiki.getFormEncoded($from) #end
</td><td>
#if($!mail.sentDate)
$formatter.formatShortDateTime($!mail.sentDate)
#end
</td>
</tr>
#end
</table>

#end

$store.close()



Adrian Hall wrote:

> Would you care to share the code?
>
>  
>
> Thanks,
>
>  
>
> -Adrian
>


-- 
Trevor Cox
skahasoftware.com
Vancouver, Canada





More information about the users mailing list