Index: main/waeup.sirp/trunk/src/waeup/sirp/browser/browser.txt
===================================================================
--- main/waeup.sirp/trunk/src/waeup/sirp/browser/browser.txt	(revision 5432)
+++ main/waeup.sirp/trunk/src/waeup/sirp/browser/browser.txt	(revision 5433)
@@ -72,4 +72,35 @@
   Content-Type: text/xml; charset=UTF-8
   X-Powered-By: Zope (www.zope.org), Python (www.python.org)
+
+Contact Form
+============
+
+Let's enter the contact form::
+
+  >>> browser.open('http://localhost/myuniversity/contactadmin')
+  >>> print browser.contents
+  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
+  ...<h2>Contact</h2>
+  ...
+
+We fill in a wrong email address::
+
+  >>> browser.getControl(name='email').value = "xx@yy"
+  >>> browser.getControl(name='descr').value = "test message"
+  >>> browser.getControl('Submit').click()
+  >>> print browser.contents      
+  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
+  ...<li class="message">Error: xx@yy is not a valid email address!</li>
+  ...
+
+Now we fill the form properly::
+
+  >>> browser.getControl(name='email').value = "xx@yy.zz"
+  >>> browser.getControl(name='descr').value = "test message"
+  >>> browser.getControl('Submit').click()
+  >>> print browser.contents      
+  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
+  ...<li class="message">Your message has been sent.</li>
+  ...
 
 
Index: main/waeup.sirp/trunk/src/waeup/sirp/browser/layout.py
===================================================================
--- main/waeup.sirp/trunk/src/waeup/sirp/browser/layout.py	(revision 5432)
+++ main/waeup.sirp/trunk/src/waeup/sirp/browser/layout.py	(revision 5433)
@@ -121,4 +121,10 @@
         return usertitle
 
+    def getUserId(self):
+        """Return id of current user.
+        """
+        userid = self.request.principal.id
+        return userid
+
     def update(self):
         yui.reset_fonts_grids.need()
Index: main/waeup.sirp/trunk/src/waeup/sirp/browser/pages.py
===================================================================
--- main/waeup.sirp/trunk/src/waeup/sirp/browser/pages.py	(revision 5432)
+++ main/waeup.sirp/trunk/src/waeup/sirp/browser/pages.py	(revision 5433)
@@ -8,4 +8,8 @@
 import re
 import sys
+import time
+import re
+import smtplib
+from email.mime.text import MIMEText
 from hurry import yui
 from hurry.workflow.interfaces import NoTransitionAvailableError
@@ -300,4 +304,59 @@
         self.hitlist = search(query=self.query, view=self)
         return
+        
+#
+# Contact forms...
+#
+class ContactAdminForm(WAeUPPage):
+    grok.context(IUniversity)
+    grok.name('contactadmin')
+    grok.template('contactadminform')
+    grok.require('waeup.Public')
+    pnav = 3 
+    
+    def title(self):
+        """Return True if the calling user is authenticated.
+        """
+        userid = self.request.principal.id
+        if userid != 'zope.anybody':
+            tt = u'Contact' 
+        else:
+            tt = u'Enquiries'         
+        return tt     
+        
+    def update(self, *args, **kw):
+        form = self.request.form
+        if not ('fullname' in form and 'email' in form and 'descr' in form):
+            return
+        self.fullname = fullname = form['fullname']
+        email = form['email']
+        self.descr = descr = form['descr']
+        regno =form['regno']
+        if not (fullname and email and descr):
+            self.flash('Error: All fields must be filled!')
+            return        
+        if not re.match("^[a-zA-Z0-9._%-]+@[a-zA-Z0-9._%-]+.[a-zA-Z]{2,6}$", email):
+            self.flash('Error: %s is not a valid email address!' % email)
+            return
+        if regno == 'zope.anybody':
+            regno = 'Anonymous User'
+        text = """Fullname: %s
+Member ID: %s
+Description: %s
+"""
+        msg = MIMEText(text % (fullname,regno,descr))
+        msg['From'] = '%s <%s>' % (fullname,email)
+        
+        # These parameters should be part of the portal configuration.
+        msg['To'] = 'contact@waeup.org'
+        msg['Subject'] = 'WAeUP Contact'
+        #server = smtplib.SMTP('smtp_server')
+        #server.login('user_name','secret_password')
+        server = smtplib.SMTP('localhost')
+        server.sendmail(email,'contact@waeup.org',msg.as_string())
+        
+        server.quit()
+        self.flash('Your message has been sent.')
+        return 
 
 #
Index: main/waeup.sirp/trunk/src/waeup/sirp/browser/templates/contactadminform.pt
===================================================================
--- main/waeup.sirp/trunk/src/waeup/sirp/browser/templates/contactadminform.pt	(revision 5433)
+++ main/waeup.sirp/trunk/src/waeup/sirp/browser/templates/contactadminform.pt	(revision 5433)
@@ -0,0 +1,40 @@
+<form id="form1" name="form1" method="post">
+<input type="hidden" name="regno" type="text" id="regno"
+     tal:attributes="value layout/getUserId"/>
+<table width="100%" border="0" cellspacing="5" cellpadding="0">
+<tr>
+  <td width="150px">
+     <strong>Full Name: </strong>
+  </td>
+  <td tal:condition="not:layout/isAuthenticated">
+     <input name="fullname" type="text" id="fullname" tal:attributes="value view/fullname|nothing" />
+  </td>
+  <td tal:condition="layout/isAuthenticated"> 
+    <span tal:content="layout/getUserTitle" />
+    <input type="hidden" name="fullname" type="text" id="fullname"
+       tal:attributes="value layout/getUserTitle"/>
+  </td>  
+</tr>
+<tr>
+  <td>
+     <strong>Email: </strong>
+  </td>
+  <td>
+     <input name="email" type="text" id="email" />
+  </td>
+</tr>
+<tr>
+  <td valign="top">
+     <strong>Text: </strong>
+  </td>
+  <td>
+     <textarea name="descr" rows="10" cols="60" id="descr"><span tal:replace="view/descr|nothing" /></textarea>
+     
+  </td>
+</tr>
+<tr>
+  <td>&nbsp;</td>
+  <td><input name="Submit" type="submit" class="standalone" value="Submit" /></td>
+</tr>
+</table>
+</form>
Index: main/waeup.sirp/trunk/src/waeup/sirp/browser/templates/sitelayout.pt
===================================================================
--- main/waeup.sirp/trunk/src/waeup/sirp/browser/templates/sitelayout.pt	(revision 5432)
+++ main/waeup.sirp/trunk/src/waeup/sirp/browser/templates/sitelayout.pt	(revision 5433)
@@ -52,4 +52,9 @@
 	    <ul id="user-navigation"
 		tal:condition="layout/isAuthenticated">
+	      <li>
+		<a href="#"
+		   tal:attributes="href python: view.url(layout.site,
+		   '@@contactadmin')">Contact</a>
+	      </li>
 	      <li>
 		<a href="#"
Index: main/waeup.sirp/trunk/src/waeup/sirp/browser/viewlets.py
===================================================================
--- main/waeup.sirp/trunk/src/waeup/sirp/browser/viewlets.py	(revision 5432)
+++ main/waeup.sirp/trunk/src/waeup/sirp/browser/viewlets.py	(revision 5433)
@@ -529,17 +529,29 @@
         return self.view.application_url('faculties')
 
-class SearchTab(PrimaryNavTab):
-    """Search tab in primary navigation.
-    """
-    grok.order(3)
-    grok.require('waeup.View')
+    
+class ContactTab(PrimaryNavTab):
+    """Contact tab in primary navigation.
+    """
+    grok.order(4)
+    grok.require('waeup.Anonymous')
     grok.template('primarynavtab')
-
+    
     pnav = 2
-    tab_title = u'Search'
+    def tab_title(self):
+        """Display tab only for anonymous. Authenticated users can call the 
+        form from the user navigation bar.
+        """
+        userid = self.request.principal.id
+        if userid != 'zope.anybody':
+            tt = u'' 
+        else:
+            tt = u'Enquiries'         
+        return tt 
 
     @property
     def link_target(self):
-        return self.view.application_url('@@search')
+        return self.view.application_url('contactadmin')        
+
+
 
 #
Index: main/waeup.sirp/trunk/src/waeup/sirp/permissions.py
===================================================================
--- main/waeup.sirp/trunk/src/waeup/sirp/permissions.py	(revision 5432)
+++ main/waeup.sirp/trunk/src/waeup/sirp/permissions.py	(revision 5433)
@@ -13,4 +13,9 @@
     """
     grok.name('waeup.Public')
+    
+class Anonymous(grok.Permission):
+    """Only-anonymous-can-do-this-permission.
+    """
+    grok.name('waeup.Anonymous')    
 
 class ViewPermission(grok.Permission):
