You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by an...@apache.org on 2006/12/18 16:43:45 UTC

svn commit: r488305 - in /lenya/trunk/src: modules-core/usecase/java/src/org/apache/lenya/cms/usecase/ modules/notification/config/cocoon-xconf/ modules/notification/java/src/org/apache/lenya/inbox/ modules/notification/java/src/org/apache/lenya/inbox/...

Author: andreas
Date: Mon Dec 18 07:43:43 2006
New Revision: 488305

URL: http://svn.apache.org/viewvc?view=rev&rev=488305
Log:
Improved and extended notification and inbox

Added:
    lenya/trunk/src/modules/notification/config/cocoon-xconf/inboxmodule.xconf
    lenya/trunk/src/modules/notification/java/src/org/apache/lenya/inbox/AbstractInboxMessage.java
    lenya/trunk/src/modules/notification/java/src/org/apache/lenya/inbox/InboxMessage.java
    lenya/trunk/src/modules/notification/java/src/org/apache/lenya/inbox/InboxModule.java
    lenya/trunk/src/modules/notification/java/src/org/apache/lenya/inbox/xml/XmlSourceInboxMessage.java
    lenya/trunk/src/modules/notification/java/test/org/apache/lenya/inbox/
    lenya/trunk/src/modules/notification/java/test/org/apache/lenya/inbox/InboxTest.java
    lenya/trunk/src/modules/notification/java/test/org/apache/lenya/notification/AbstractNotificationTest.java
Modified:
    lenya/trunk/src/modules-core/usecase/java/src/org/apache/lenya/cms/usecase/AbstractUsecase.java
    lenya/trunk/src/modules-core/usecase/java/src/org/apache/lenya/cms/usecase/UsecaseResolver.java
    lenya/trunk/src/modules/notification/java/src/org/apache/lenya/inbox/Inbox.java
    lenya/trunk/src/modules/notification/java/src/org/apache/lenya/inbox/usecases/Inbox.java
    lenya/trunk/src/modules/notification/java/src/org/apache/lenya/inbox/xml/XmlSourceInbox.java
    lenya/trunk/src/modules/notification/java/src/org/apache/lenya/notification/EmailNotifier.java
    lenya/trunk/src/modules/notification/java/test/org/apache/lenya/notification/NotificationTest.java
    lenya/trunk/src/modules/notification/resources/i18n/cmsui.xml
    lenya/trunk/src/modules/notification/resources/i18n/cmsui_de.xml
    lenya/trunk/src/modules/notification/usecases/currentMessage.jx
    lenya/trunk/src/modules/notification/usecases/inbox.jx
    lenya/trunk/src/modules/notification/usecases/messageList.jx
    lenya/trunk/src/pubs/default/modules/defaultusecases/java/src/org/apache/lenya/defaultpub/cms/usecases/Publish.java
    lenya/trunk/src/webapp/global-sitemap.xmap
    lenya/trunk/src/webapp/lenya/xslt/menu/menu2xhtml.xsl

Modified: lenya/trunk/src/modules-core/usecase/java/src/org/apache/lenya/cms/usecase/AbstractUsecase.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules-core/usecase/java/src/org/apache/lenya/cms/usecase/AbstractUsecase.java?view=diff&rev=488305&r1=488304&r2=488305
==============================================================================
--- lenya/trunk/src/modules-core/usecase/java/src/org/apache/lenya/cms/usecase/AbstractUsecase.java (original)
+++ lenya/trunk/src/modules-core/usecase/java/src/org/apache/lenya/cms/usecase/AbstractUsecase.java Mon Dec 18 07:43:43 2006
@@ -276,7 +276,7 @@
                 } else {
                     getSession().rollback();
                 }
-            } catch (RepositoryException e1) {
+            } catch (Exception e1) {
                 getLogger().error("Exception during commit or rollback: ", e1);
                 addErrorMessage("Exception during commit or rollback: " + e1.getMessage()
                         + " (see logfiles for details)");

Modified: lenya/trunk/src/modules-core/usecase/java/src/org/apache/lenya/cms/usecase/UsecaseResolver.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules-core/usecase/java/src/org/apache/lenya/cms/usecase/UsecaseResolver.java?view=diff&rev=488305&r1=488304&r2=488305
==============================================================================
--- lenya/trunk/src/modules-core/usecase/java/src/org/apache/lenya/cms/usecase/UsecaseResolver.java (original)
+++ lenya/trunk/src/modules-core/usecase/java/src/org/apache/lenya/cms/usecase/UsecaseResolver.java Mon Dec 18 07:43:43 2006
@@ -17,8 +17,6 @@
  */
 package org.apache.lenya.cms.usecase;
 
-import java.util.TreeSet;
-
 import org.apache.avalon.framework.service.ServiceException;
 
 /**

Added: lenya/trunk/src/modules/notification/config/cocoon-xconf/inboxmodule.xconf
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/notification/config/cocoon-xconf/inboxmodule.xconf?view=auto&rev=488305
==============================================================================
--- lenya/trunk/src/modules/notification/config/cocoon-xconf/inboxmodule.xconf (added)
+++ lenya/trunk/src/modules/notification/config/cocoon-xconf/inboxmodule.xconf Mon Dec 18 07:43:43 2006
@@ -0,0 +1,27 @@
+<?xml version="1.0"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<!-- $Id: usecases-workflow-deactivate.xconf 348547 2005-11-23 20:13:01Z chestnut $ -->
+<!--
+    This file defines the publication specific use-cases
+-->
+
+  <xconf xpath="/cocoon/input-modules" unless="/cocoon/input-modules/component-instance[@name = 'inbox']">
+    <component-instance logger="core.modules.input.inbox" name="inbox"
+      class="org.apache.lenya.inbox.InboxModule"/>
+  </xconf>

Added: lenya/trunk/src/modules/notification/java/src/org/apache/lenya/inbox/AbstractInboxMessage.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/notification/java/src/org/apache/lenya/inbox/AbstractInboxMessage.java?view=auto&rev=488305
==============================================================================
--- lenya/trunk/src/modules/notification/java/src/org/apache/lenya/inbox/AbstractInboxMessage.java (added)
+++ lenya/trunk/src/modules/notification/java/src/org/apache/lenya/inbox/AbstractInboxMessage.java Mon Dec 18 07:43:43 2006
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.lenya.inbox;
+
+import org.apache.lenya.notification.Message;
+import org.apache.lenya.util.Assert;
+
+/**
+ * Inbox message implementation.
+ */
+public abstract class AbstractInboxMessage implements InboxMessage {
+
+    private boolean markedAsRead;
+    private Message message;
+    private String id;
+    
+    /**
+     * @param id The ID.
+     * @param message The message to wrap.
+     * @param markedAsRead if the message is marked as read.
+     */
+    public AbstractInboxMessage(String id, Message message, boolean markedAsRead) {
+        Assert.notNull("id", id);
+        this.id = id;
+        Assert.notNull("message", message);
+        this.message = message;
+        this.markedAsRead = markedAsRead;
+    }
+    
+    public boolean isMarkedAsRead() {
+        return this.markedAsRead;
+    }
+
+    public Message getMessage() {
+        return this.message;
+    }
+
+    public void markAsRead(boolean marked) {
+        this.markedAsRead = marked;
+        changed();
+    }
+
+    protected abstract void changed();
+
+    public String getId() {
+        return this.id;
+    }
+
+}

Modified: lenya/trunk/src/modules/notification/java/src/org/apache/lenya/inbox/Inbox.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/notification/java/src/org/apache/lenya/inbox/Inbox.java?view=diff&rev=488305&r1=488304&r2=488305
==============================================================================
--- lenya/trunk/src/modules/notification/java/src/org/apache/lenya/inbox/Inbox.java (original)
+++ lenya/trunk/src/modules/notification/java/src/org/apache/lenya/inbox/Inbox.java Mon Dec 18 07:43:43 2006
@@ -27,16 +27,23 @@
     /**
      * @return All messages in this inbox.
      */
-    Message[] getMessages();
+    InboxMessage[] getMessages();
     
     /**
      * @param message The message to add.
+     * @return The inbox message which wraps the message.
      */
-    void add(Message message);
+    InboxMessage add(Message message);
 
     /**
      * @param message The message to remove.
      */
-    void remove(Message message);
-
+    void remove(InboxMessage message);
+    
+    /**
+     * @param id The ID.
+     * @return The message with this ID.
+     */
+    InboxMessage getMessage(String id);
+    
 }

Added: lenya/trunk/src/modules/notification/java/src/org/apache/lenya/inbox/InboxMessage.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/notification/java/src/org/apache/lenya/inbox/InboxMessage.java?view=auto&rev=488305
==============================================================================
--- lenya/trunk/src/modules/notification/java/src/org/apache/lenya/inbox/InboxMessage.java (added)
+++ lenya/trunk/src/modules/notification/java/src/org/apache/lenya/inbox/InboxMessage.java Mon Dec 18 07:43:43 2006
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.lenya.inbox;
+
+import org.apache.lenya.notification.Message;
+
+/**
+ * A message entry in an inbox.
+ */
+public interface InboxMessage {
+    
+    /**
+     * Marks this message as read.
+     * @param marked A boolean value.
+     */
+    void markAsRead(boolean marked);
+    
+    /**
+     * @return if this message is marked as read.
+     */
+    boolean isMarkedAsRead();
+    
+    /**
+     * @return The message which is wrapped by this inbox message.
+     */
+    Message getMessage();
+    
+    /**
+     * @return The ID of this message.
+     */
+    String getId();
+
+}

Added: lenya/trunk/src/modules/notification/java/src/org/apache/lenya/inbox/InboxModule.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/notification/java/src/org/apache/lenya/inbox/InboxModule.java?view=auto&rev=488305
==============================================================================
--- lenya/trunk/src/modules/notification/java/src/org/apache/lenya/inbox/InboxModule.java (added)
+++ lenya/trunk/src/modules/notification/java/src/org/apache/lenya/inbox/InboxModule.java Mon Dec 18 07:43:43 2006
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.lenya.inbox;
+
+import java.util.Map;
+
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.avalon.framework.service.Serviceable;
+import org.apache.cocoon.components.modules.input.AbstractInputModule;
+import org.apache.cocoon.environment.ObjectModelHelper;
+import org.apache.cocoon.environment.Request;
+import org.apache.lenya.ac.User;
+import org.apache.lenya.cms.repository.RepositoryUtil;
+import org.apache.lenya.cms.repository.Session;
+
+/**
+ * <p>Inbox module.</p>
+ * <p>Attributes:</p>
+ * <ul>
+ * <li><strong>newMessageCount</strong> - the number of unread messages as string</li>
+ * </ul>
+ */
+public class InboxModule extends AbstractInputModule implements Serviceable {
+
+    protected static final String NEW_MESSAGE_COUNT = "newMessageCount";
+    protected ServiceManager manager;
+
+    public Object getAttribute(String name, Configuration modeConf, Map objectModel) throws ConfigurationException {
+        
+        Object value = null;
+        if (name.equals(NEW_MESSAGE_COUNT)) {
+            InboxManager inboxManager = null;
+            try {
+                inboxManager = (InboxManager) this.manager.lookup(InboxManager.ROLE);
+                Request request = ObjectModelHelper.getRequest(objectModel);
+                Session session = RepositoryUtil.getSession(manager, request);
+                User user = session.getIdentity().getUser();
+                Inbox inbox = inboxManager.getInbox(user);
+                
+                int count = 0;
+                InboxMessage[] messages = inbox.getMessages();
+                for (int i = 0; i < messages.length; i++) {
+                    if (!messages[i].isMarkedAsRead()) {
+                        count++;
+                    }
+                }
+                value = Integer.toString(count);
+                
+            } catch (Exception e) {
+                throw new ConfigurationException("Attribute [" + name + "]: ", e);
+            }
+            finally {
+                if (inboxManager != null) {
+                    this.manager.release(inboxManager);
+                }
+            }
+        }
+        return value;
+    }
+
+    public void service(ServiceManager manager) throws ServiceException {
+        this.manager = manager;
+    }
+
+    
+    
+}

Modified: lenya/trunk/src/modules/notification/java/src/org/apache/lenya/inbox/usecases/Inbox.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/notification/java/src/org/apache/lenya/inbox/usecases/Inbox.java?view=diff&rev=488305&r1=488304&r2=488305
==============================================================================
--- lenya/trunk/src/modules/notification/java/src/org/apache/lenya/inbox/usecases/Inbox.java (original)
+++ lenya/trunk/src/modules/notification/java/src/org/apache/lenya/inbox/usecases/Inbox.java Mon Dec 18 07:43:43 2006
@@ -20,6 +20,7 @@
 import org.apache.lenya.ac.User;
 import org.apache.lenya.cms.usecase.AbstractUsecase;
 import org.apache.lenya.inbox.InboxManager;
+import org.apache.lenya.inbox.InboxMessage;
 
 /**
  * Show and manage an inbox.
@@ -50,6 +51,14 @@
 
     protected void doExecute() throws Exception {
         super.doExecute();
+        
+        String id = getParameterAsString("messageId");
+        if (id != null) {
+            org.apache.lenya.inbox.Inbox inbox = (org.apache.lenya.inbox.Inbox) getParameter("inbox");
+            InboxMessage message = inbox.getMessage(id);
+            message.markAsRead(true);
+            setExitParameter("messageId", id);
+        }
     }
 
 }

Modified: lenya/trunk/src/modules/notification/java/src/org/apache/lenya/inbox/xml/XmlSourceInbox.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/notification/java/src/org/apache/lenya/inbox/xml/XmlSourceInbox.java?view=diff&rev=488305&r1=488304&r2=488305
==============================================================================
--- lenya/trunk/src/modules/notification/java/src/org/apache/lenya/inbox/xml/XmlSourceInbox.java (original)
+++ lenya/trunk/src/modules/notification/java/src/org/apache/lenya/inbox/xml/XmlSourceInbox.java Mon Dec 18 07:43:43 2006
@@ -23,12 +23,15 @@
 import javax.xml.parsers.ParserConfigurationException;
 
 import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.axis.components.uuid.UUIDGen;
+import org.apache.axis.components.uuid.UUIDGenFactory;
 import org.apache.lenya.ac.AccessControlException;
 import org.apache.lenya.ac.Group;
 import org.apache.lenya.ac.Identifiable;
 import org.apache.lenya.ac.User;
 import org.apache.lenya.cms.cocoon.source.SourceUtil;
 import org.apache.lenya.inbox.Inbox;
+import org.apache.lenya.inbox.InboxMessage;
 import org.apache.lenya.notification.Message;
 import org.apache.lenya.notification.Notifier;
 import org.apache.lenya.util.Assert;
@@ -54,19 +57,28 @@
         this.user = user;
     }
 
-    public synchronized void add(Message message) {
-        messages().add(message);
+    public synchronized InboxMessage add(Message message) {
+        InboxMessage msg = new XmlSourceInboxMessage(this, generateId(), message, false);
+        messages().add(msg);
         save();
+        return msg;
     }
 
-    public synchronized void remove(Message message) {
+    protected String generateId() {
+        UUIDGen generator = UUIDGenFactory.getUUIDGen();
+        String id = generator.nextUUID();
+        return id;
+    }
+
+    public synchronized void remove(InboxMessage message) {
+        Assert.isTrue("contained", messages().contains(message));
         messages().remove(message);
         save();
     }
 
-    public Message[] getMessages() {
+    public InboxMessage[] getMessages() {
         List messages = messages();
-        return (Message[]) messages.toArray(new Message[messages.size()]);
+        return (InboxMessage[]) messages.toArray(new InboxMessage[messages.size()]);
     }
 
     private List messages;
@@ -95,6 +107,15 @@
 
                 Element[] messageElements = helper.getChildren(xml.getDocumentElement(), "message");
                 for (int i = 0; i < messageElements.length; i++) {
+                    
+                    String id;
+                    if (messageElements[i].hasAttribute("id")) {
+                        id = messageElements[i].getAttribute("id");
+                    }
+                    else {
+                        id = generateId();
+                    }
+                    
                     String senderId = messageElements[i].getAttribute("sender");
                     User sender = getUser(senderId);
 
@@ -108,13 +129,13 @@
                             + groupElements.length];
 
                     for (int u = 0; u < userElements.length; u++) {
-                        String id = userElements[u].getAttribute("id");
-                        recipients[u] = getUser(id);
+                        String userId = userElements[u].getAttribute("id");
+                        recipients[u] = getUser(userId);
                     }
 
                     for (int g = 0; g < groupElements.length; g++) {
-                        String id = groupElements[g].getAttribute("id");
-                        recipients[userElements.length + g] = getGroup(id);
+                        String groupId = groupElements[g].getAttribute("id");
+                        recipients[userElements.length + g] = getGroup(groupId);
                     }
 
                     Element bodyElement = helper.getFirstChild(messageElements[i], "body");
@@ -135,10 +156,17 @@
                         subjectParams[p] = DocumentHelper
                                 .getSimpleElementText(subjectParamElements[p]);
                     }
+                    
+                    String readString = "false";
+                    if (messageElements[i].hasAttribute("read")) {
+                        readString = messageElements[i].getAttribute("read");
+                    }
+                    boolean read = Boolean.valueOf(readString).booleanValue();
 
                     Message message = new Message(subject, subjectParams, body, bodyParams, sender,
                             recipients);
-                    this.messages.add(message);
+                    InboxMessage msg = new XmlSourceInboxMessage(this, id, message, read);
+                    this.messages.add(msg);
                 }
             }
 
@@ -188,17 +216,20 @@
     protected NamespaceHelper buildXml() throws ParserConfigurationException {
         NamespaceHelper helper = new NamespaceHelper(Notifier.NAMESPACE, "", "inbox");
 
-        Message[] messages = getMessages();
+        InboxMessage[] messages = getMessages();
         for (int i = 0; i < messages.length; i++) {
+            
+            Message message = messages[i].getMessage();
+            
             Element messageElement = helper.createElement("message");
             helper.getDocument().getDocumentElement().appendChild(messageElement);
-            User sender = (User) messages[i].getSender();
+            User sender = (User) message.getSender();
             messageElement.setAttribute("sender", sender.getId());
 
             Element recipientsElement = helper.createElement("recipients");
             messageElement.appendChild(recipientsElement);
 
-            Identifiable[] recipients = messages[i].getRecipients();
+            Identifiable[] recipients = message.getRecipients();
             for (int r = 0; r < recipients.length; r++) {
                 if (recipients[r] instanceof User) {
                     Element userElement = helper.createElement("user");
@@ -213,9 +244,9 @@
 
             Element subjectElement = helper.createElement("subject");
             messageElement.appendChild(subjectElement);
-            Element subjectTextElement = helper.createElement("text", messages[i].getSubject());
+            Element subjectTextElement = helper.createElement("text", message.getSubject());
             subjectElement.appendChild(subjectTextElement);
-            String[] subjectParams = messages[i].getSubjectParameters();
+            String[] subjectParams = message.getSubjectParameters();
             for (int p = 0; p < subjectParams.length; p++) {
                 Element paramElement = helper.createElement("param", subjectParams[p]);
                 subjectElement.appendChild(paramElement);
@@ -223,14 +254,27 @@
 
             Element bodyElement = helper.createElement("body");
             messageElement.appendChild(bodyElement);
-            Element bodyTextElement = helper.createElement("text", messages[i].getBody());
+            Element bodyTextElement = helper.createElement("text", message.getBody());
             bodyElement.appendChild(bodyTextElement);
-            String[] bodyParams = messages[i].getBodyParameters();
+            String[] bodyParams = message.getBodyParameters();
             for (int p = 0; p < bodyParams.length; p++) {
                 Element paramElement = helper.createElement("param", bodyParams[p]);
                 bodyElement.appendChild(paramElement);
             }
+            
+            messageElement.setAttribute("read", Boolean.toString(messages[i].isMarkedAsRead()));
+            messageElement.setAttribute("id", messages[i].getId());
         }
         return helper;
+    }
+
+    public InboxMessage getMessage(String id) {
+        InboxMessage[] messages = getMessages();
+        for (int i = 0; i < messages.length; i++) {
+            if (messages[i].getId().equals(id)) {
+                return messages[i];
+            }
+        }
+        throw new RuntimeException("No message found with ID [" + id + "]");
     }
 }

Added: lenya/trunk/src/modules/notification/java/src/org/apache/lenya/inbox/xml/XmlSourceInboxMessage.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/notification/java/src/org/apache/lenya/inbox/xml/XmlSourceInboxMessage.java?view=auto&rev=488305
==============================================================================
--- lenya/trunk/src/modules/notification/java/src/org/apache/lenya/inbox/xml/XmlSourceInboxMessage.java (added)
+++ lenya/trunk/src/modules/notification/java/src/org/apache/lenya/inbox/xml/XmlSourceInboxMessage.java Mon Dec 18 07:43:43 2006
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.lenya.inbox.xml;
+
+import org.apache.lenya.inbox.AbstractInboxMessage;
+import org.apache.lenya.notification.Message;
+
+/**
+ * XML source inbox message.
+ */
+public class XmlSourceInboxMessage extends AbstractInboxMessage {
+
+    private XmlSourceInbox inbox;
+
+    /**
+     * @param inbox The inbox this message belongs to.
+     * @param id The ID.
+     * @param message The message to wrap.
+     * @param markedAsRead if the message is marked as read.
+     */
+    public XmlSourceInboxMessage(XmlSourceInbox inbox, String id, Message message,
+            boolean markedAsRead) {
+        super(id, message, markedAsRead);
+        this.inbox = inbox;
+    }
+
+    protected void changed() {
+        this.inbox.save();
+    }
+
+}

Modified: lenya/trunk/src/modules/notification/java/src/org/apache/lenya/notification/EmailNotifier.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/notification/java/src/org/apache/lenya/notification/EmailNotifier.java?view=diff&rev=488305&r1=488304&r2=488305
==============================================================================
--- lenya/trunk/src/modules/notification/java/src/org/apache/lenya/notification/EmailNotifier.java (original)
+++ lenya/trunk/src/modules/notification/java/src/org/apache/lenya/notification/EmailNotifier.java Mon Dec 18 07:43:43 2006
@@ -17,9 +17,13 @@
  */
 package org.apache.lenya.notification;
 
+import javax.mail.MessagingException;
+import javax.mail.internet.AddressException;
+
 import org.apache.avalon.framework.configuration.Configurable;
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.avalon.framework.service.ServiceException;
 import org.apache.cocoon.mail.MailSender;
 import org.apache.lenya.ac.Identifiable;
 import org.apache.lenya.ac.User;
@@ -55,11 +59,16 @@
             }
 
             mailer.setSubject(translatedMessage.getSubject());
-            mailer.setBody(translatedMessage.getBody(), "text/plain");
-            mailer.setCharset("UTF-8");
+            mailer.setBody(translatedMessage.getBody(), "text/plain; charset=UTF-8");
             mailer.send();
-
-        } catch (Exception e) {
+        
+        } catch (AddressException e) {
+            getLogger().error("Sending mail failed (address error): ", e);
+            throw new NotificationException(e);
+        } catch (MessagingException e) {
+            getLogger().error("Sending mail failed (mail error): ", e);
+            throw new NotificationException(e);
+        } catch (ServiceException e) {
             throw new NotificationException(e);
         } finally {
             if (mailer != null) {

Added: lenya/trunk/src/modules/notification/java/test/org/apache/lenya/inbox/InboxTest.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/notification/java/test/org/apache/lenya/inbox/InboxTest.java?view=auto&rev=488305
==============================================================================
--- lenya/trunk/src/modules/notification/java/test/org/apache/lenya/inbox/InboxTest.java (added)
+++ lenya/trunk/src/modules/notification/java/test/org/apache/lenya/inbox/InboxTest.java Mon Dec 18 07:43:43 2006
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.lenya.inbox;
+
+import org.apache.lenya.ac.Identifiable;
+import org.apache.lenya.ac.User;
+import org.apache.lenya.inbox.xml.XmlSourceInbox;
+import org.apache.lenya.notification.AbstractNotificationTest;
+import org.apache.lenya.notification.Message;
+
+/**
+ * Inbox test.
+ */
+public class InboxTest extends AbstractNotificationTest {
+    
+    protected static final String SUBJECT = "hello";
+
+    /**
+     * The test.
+     * @throws Exception if an error occurs.
+     */
+    public void testInbox() throws Exception {
+        
+        User lenya = getAccreditableManager().getUserManager().getUser("lenya");
+        Inbox inbox = getInbox(lenya);
+        
+        cleanUp(inbox, SUBJECT);
+        assertFalse(containsMessage(inbox, SUBJECT));
+        
+        Identifiable[] recipients = { lenya };
+
+        Message message = new Message(SUBJECT, new String[0], "body", new String[0], lenya,
+                recipients);
+        InboxMessage inboxMessage = inbox.add(message);
+        
+        assertEquals(inboxMessage.getMessage().getSubject(), SUBJECT);
+        
+        assertFalse(inboxMessage.isMarkedAsRead());
+        inboxMessage.markAsRead(true);
+        assertTrue(inboxMessage.isMarkedAsRead());
+        
+        XmlSourceInbox xmlInbox = new XmlSourceInbox(getManager(), lenya);
+        assertTrue(containsMessage(xmlInbox, SUBJECT));
+        
+        InboxMessage xmlMessage = getMessage(xmlInbox, SUBJECT);
+        assertTrue(xmlMessage.isMarkedAsRead());
+        
+        cleanUp(inbox, SUBJECT);
+        
+    }
+
+}

Added: lenya/trunk/src/modules/notification/java/test/org/apache/lenya/notification/AbstractNotificationTest.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/notification/java/test/org/apache/lenya/notification/AbstractNotificationTest.java?view=auto&rev=488305
==============================================================================
--- lenya/trunk/src/modules/notification/java/test/org/apache/lenya/notification/AbstractNotificationTest.java (added)
+++ lenya/trunk/src/modules/notification/java/test/org/apache/lenya/notification/AbstractNotificationTest.java Mon Dec 18 07:43:43 2006
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.lenya.notification;
+
+import org.apache.lenya.ac.User;
+import org.apache.lenya.ac.impl.AbstractAccessControlTest;
+import org.apache.lenya.inbox.Inbox;
+import org.apache.lenya.inbox.InboxManager;
+import org.apache.lenya.inbox.InboxMessage;
+
+/**
+ * Base class for notification tests.
+ */
+public abstract class AbstractNotificationTest extends AbstractAccessControlTest {
+
+    protected Inbox getInbox(User user) throws Exception {
+        InboxManager inboxManager = null;
+        try {
+            inboxManager = (InboxManager) getManager().lookup(InboxManager.ROLE);
+            return inboxManager.getInbox(user);
+        }
+        finally {
+            if (inboxManager != null) {
+                getManager().release(inboxManager);
+            }
+        }
+    }
+
+    protected boolean containsMessage(Inbox inbox, String subject) {
+        InboxMessage[] messages = inbox.getMessages();
+        if (messages.length == 0) {
+            return false;
+        }
+        return messages[messages.length - 1].getMessage().getSubject().equals(subject);
+    }
+    
+    protected InboxMessage getMessage(Inbox inbox, String subject) {
+        InboxMessage[] messages = inbox.getMessages();
+        for (int i = 0; i < messages.length; i++) {
+            if (messages[i].getMessage().getSubject().equals(subject)) {
+                return messages[i];
+            }
+        }
+        return null;
+    }
+    
+    protected void cleanUp(Inbox inbox, String subject) {
+        InboxMessage[] messages = inbox.getMessages();
+        for (int i = 0; i < messages.length; i++) {
+            if (messages[i].getMessage().getSubject().equals(subject)) {
+                inbox.remove(messages[i]);
+            }
+        }
+    }
+}

Modified: lenya/trunk/src/modules/notification/java/test/org/apache/lenya/notification/NotificationTest.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/notification/java/test/org/apache/lenya/notification/NotificationTest.java?view=diff&rev=488305&r1=488304&r2=488305
==============================================================================
--- lenya/trunk/src/modules/notification/java/test/org/apache/lenya/notification/NotificationTest.java (original)
+++ lenya/trunk/src/modules/notification/java/test/org/apache/lenya/notification/NotificationTest.java Mon Dec 18 07:43:43 2006
@@ -19,17 +19,15 @@
 
 import org.apache.lenya.ac.Identifiable;
 import org.apache.lenya.ac.User;
-import org.apache.lenya.ac.impl.AbstractAccessControlTest;
 import org.apache.lenya.cms.observation.RepositoryEvent;
 import org.apache.lenya.cms.observation.RepositoryEventFactory;
 import org.apache.lenya.cms.repository.Session;
 import org.apache.lenya.inbox.Inbox;
-import org.apache.lenya.inbox.InboxManager;
 
 /**
  * Notification test.
  */
-public class NotificationTest extends AbstractAccessControlTest {
+public class NotificationTest extends AbstractNotificationTest {
 
     protected static final String SUBJECT = "hello";
 
@@ -57,44 +55,15 @@
         session.enqueueEvent(event);
         
         Inbox inbox = getInbox(alice);
-        cleanUp(inbox);
+        cleanUp(inbox, SUBJECT);
         
-        assertFalse(containsMessage(inbox));
+        assertFalse(containsMessage(inbox, SUBJECT));
         session.commit();
         Thread.sleep(100);
-        assertTrue(containsMessage(inbox));
+        assertTrue(containsMessage(inbox, SUBJECT));
         
-        cleanUp(inbox);
+        cleanUp(inbox, SUBJECT);
 
     }
 
-    protected Inbox getInbox(User user) throws Exception {
-        InboxManager inboxManager = null;
-        try {
-            inboxManager = (InboxManager) getManager().lookup(InboxManager.ROLE);
-            return inboxManager.getInbox(user);
-        }
-        finally {
-            if (inboxManager != null) {
-                getManager().release(inboxManager);
-            }
-        }
-    }
-
-    protected boolean containsMessage(Inbox inbox) {
-        Message[] messages = inbox.getMessages();
-        if (messages.length == 0) {
-            return false;
-        }
-        return messages[messages.length - 1].getSubject().equals(SUBJECT);
-    }
-    
-    protected void cleanUp(Inbox inbox) {
-        Message[] messages = inbox.getMessages();
-        for (int i = 0; i < messages.length; i++) {
-            if (messages[i].getSubject().equals(SUBJECT)) {
-                inbox.remove(messages[i]);
-            }
-        }
-    }
 }

Modified: lenya/trunk/src/modules/notification/resources/i18n/cmsui.xml
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/notification/resources/i18n/cmsui.xml?view=diff&rev=488305&r1=488304&r2=488305
==============================================================================
--- lenya/trunk/src/modules/notification/resources/i18n/cmsui.xml (original)
+++ lenya/trunk/src/modules/notification/resources/i18n/cmsui.xml Mon Dec 18 07:43:43 2006
@@ -29,5 +29,8 @@
   <message key="Messages">Messages</message>
   <message key="Send">Send</message>
   <message key="selected-message">Selected&#160;message</message>
+  <message key="unread-messages">{0} new messages</message>
+  <message key="unread-message">1 new message</message>
+  <message key="Read">Read</message>
   
 </catalogue>

Modified: lenya/trunk/src/modules/notification/resources/i18n/cmsui_de.xml
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/notification/resources/i18n/cmsui_de.xml?view=diff&rev=488305&r1=488304&r2=488305
==============================================================================
--- lenya/trunk/src/modules/notification/resources/i18n/cmsui_de.xml (original)
+++ lenya/trunk/src/modules/notification/resources/i18n/cmsui_de.xml Mon Dec 18 07:43:43 2006
@@ -29,5 +29,8 @@
   <message key="Messages">Nachrichten</message>
   <message key="Send">Senden</message>
   <message key="selected-message">Ausgewählte&#160;Nachricht</message>
+  <message key="unread-messages">{0} neue Nachrichten</message>
+  <message key="unread-message">1 neue Nachricht</message>
+  <message key="Read">Gelesen</message>
   
 </catalogue>

Modified: lenya/trunk/src/modules/notification/usecases/currentMessage.jx
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/notification/usecases/currentMessage.jx?view=diff&rev=488305&r1=488304&r2=488305
==============================================================================
--- lenya/trunk/src/modules/notification/usecases/currentMessage.jx (original)
+++ lenya/trunk/src/modules/notification/usecases/currentMessage.jx Mon Dec 18 07:43:43 2006
@@ -24,8 +24,8 @@
   xmlns:i18n="http://apache.org/cocoon/i18n/2.1"    
   >
   
-  <jx:if test="${usecase.getName().getClass().isInstance(messageIndex)}">
-    <jx:set var="message" value="${java.util.Arrays.asList(inbox.getMessages()).get(java.lang.Integer.valueOf(messageIndex).intValue())}"/>
+  <jx:if test="${usecase.getName().getClass().isInstance(messageId)}">
+    <jx:set var="message" value="${inbox.getMessage(messageId)}"/>
     
     <div class="lenya-box" style="width: 100%">
       <div class="lenya-box-title"><i18n:text>selected-message</i18n:text></div>
@@ -34,16 +34,16 @@
           <tr>
             <td class="lenya-entry-caption"><i18n:text>From</i18n:text>:</td>
             <td style="white-space: nowrap">
-              <jx:out value="${message.getSender().getName()}"/>
-              (<a href="?lenya.usecase=admin.user&amp;userId=${message.getSender().getId()}"><jx:out value="${message.getSender().getId()}"/></a>)
+              <jx:out value="${message.getMessage().getSender().getName()}"/>
+              (<a href="?lenya.usecase=admin.user&amp;userId=${message.getMessage().getSender().getId()}"><jx:out value="${message.getMessage().getSender().getId()}"/></a>)
             </td>
           </tr>
           <tr>
             <td class="lenya-entry-caption"><i18n:text>Subject</i18n:text>:</td>
             <td>
               <i18n:translate>
-                <i18n:text><jx:out value="${message.getSubject()}"/></i18n:text>
-                <jx:forEach var="param" items="${message.getSubjectParameters()}">
+                <i18n:text><jx:out value="${message.getMessage().getSubject()}"/></i18n:text>
+                <jx:forEach var="param" items="${message.getMessage().getSubjectParameters()}">
                   <i18n:param><jx:out value="${param}"/></i18n:param>
                 </jx:forEach>
               </i18n:translate>
@@ -53,8 +53,8 @@
             <td class="lenya-entry-caption" valign="top"><i18n:text>Message</i18n:text>:</td>
             <td>
               <i18n:translate>
-                <i18n:text><jx:out value="${message.getBody()}"/></i18n:text>
-                <jx:forEach var="param" items="${message.getBodyParameters()}">
+                <i18n:text><jx:out value="${message.getMessage().getBody()}"/></i18n:text>
+                <jx:forEach var="param" items="${message.getMessage().getBodyParameters()}">
                   <i18n:param><jx:out value="${param}"/></i18n:param>
                 </jx:forEach>
               </i18n:translate>

Modified: lenya/trunk/src/modules/notification/usecases/inbox.jx
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/notification/usecases/inbox.jx?view=diff&rev=488305&r1=488304&r2=488305
==============================================================================
--- lenya/trunk/src/modules/notification/usecases/inbox.jx (original)
+++ lenya/trunk/src/modules/notification/usecases/inbox.jx Mon Dec 18 07:43:43 2006
@@ -47,7 +47,7 @@
       </p>
       
       <jx:set var="inbox" value="${usecase.getParameter('inbox')}"/>
-      <jx:set var="messageIndex" value="${request.getParameter('messageIndex')}"/>
+      <jx:set var="messageId" value="${request.getParameter('messageId')}"/>
       
       <table>
         <tr>

Modified: lenya/trunk/src/modules/notification/usecases/messageList.jx
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/notification/usecases/messageList.jx?view=diff&rev=488305&r1=488304&r2=488305
==============================================================================
--- lenya/trunk/src/modules/notification/usecases/messageList.jx (original)
+++ lenya/trunk/src/modules/notification/usecases/messageList.jx Mon Dec 18 07:43:43 2006
@@ -29,12 +29,12 @@
       <th style="text-align: left; padding-right: 20px;"><i18n:text>Subject</i18n:text></th>
       <th style="text-align: left; padding-right: 20px;"><i18n:text>Sender</i18n:text></th>
       <th style="text-align: left; padding-right: 20px;"><i18n:text>Date</i18n:text></th>
+      <th style="text-align: left; padding-right: 20px;"><i18n:text>Read</i18n:text></th>
     </tr>
-    <jx:set var="index" value="0"/>
     <jx:forEach var="message" items="${inbox.getMessages()}">
       
       <jx:set var="class" value="normal"/>
-      <jx:if test="${index.toString().equals(messageIndex)}">
+      <jx:if test="${messageId.equals(message.getId())}">
         <jx:set var="class" value="highlight"/>
       </jx:if>
       
@@ -43,24 +43,26 @@
         <input type="hidden" name="lenya.continuation" value="${continuation.id}"/>
         <tr class="${class}">
           <td>
-            <a href="?lenya.usecase=notification.inbox&amp;messageIndex=${index}">
+            <a href="?lenya.usecase=notification.inbox&amp;messageId=${message.getId()}&amp;lenya.continuation=${continuation.id}&amp;submit=Submit">
               <i18n:translate>
-                <i18n:text><jx:out value="${message.getSubject()}"/></i18n:text>
-                <jx:forEach var="param" items="${message.getSubjectParameters()}">
+                <i18n:text><jx:out value="${message.getMessage().getSubject()}"/></i18n:text>
+                <jx:forEach var="param" items="${message.getMessage().getSubjectParameters()}">
                   <i18n:param><jx:out value="${param}"/></i18n:param>
                 </jx:forEach>
               </i18n:translate>
             </a>
           </td>
           <td>
-            <a href="?lenya.usecase=admin.user&amp;userId=${message.getSender().getId()}"><jx:out value="${message.getSender().getId()}"/></a>
+            <a href="?lenya.usecase=admin.user&amp;userId=${message.getMessage().getSender().getId()}"><jx:out value="${message.getMessage().getSender().getId()}"/></a>
           </td>
           <td>
-            <jx:formatDate pattern="yyyy-MM-dd HH:mm:ss" value="${message.getTime()}"/>
+            <jx:formatDate pattern="yyyy-MM-dd HH:mm:ss" value="${message.getMessage().getTime()}"/>
+          </td>
+          <td style="text-align: center;">
+            <jx:if test="${message.isMarkedAsRead()}">&#10004;</jx:if>
           </td>
         </tr>
       </form>
-      <jx:set var="index" value="${index + 1}"/>
     </jx:forEach>
   </table>
   

Modified: lenya/trunk/src/pubs/default/modules/defaultusecases/java/src/org/apache/lenya/defaultpub/cms/usecases/Publish.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/pubs/default/modules/defaultusecases/java/src/org/apache/lenya/defaultpub/cms/usecases/Publish.java?view=diff&rev=488305&r1=488304&r2=488305
==============================================================================
--- lenya/trunk/src/pubs/default/modules/defaultusecases/java/src/org/apache/lenya/defaultpub/cms/usecases/Publish.java (original)
+++ lenya/trunk/src/pubs/default/modules/defaultusecases/java/src/org/apache/lenya/defaultpub/cms/usecases/Publish.java Mon Dec 18 07:43:43 2006
@@ -291,13 +291,13 @@
 
         Workflowable workflowable = WorkflowUtil.getWorkflowable(this.manager, getSession(),
                 getLogger(), authoringDocument);
-        Version version = workflowable.getLatestVersion();
+        Version versions[] = workflowable.getVersions();
+        Version version = versions[versions.length-2];
 
         // we assume that the document has been submitted, otherwise we do nothing
         if (version.getEvent().equals("submit")) {
             
             String userId = version.getUserId();
-
             User user = PolicyUtil.getUser(this.manager, authoringDocument
                     .getCanonicalWebappURL(), userId, getLogger());
             
@@ -322,7 +322,7 @@
             
             NotificationEventDescriptor descriptor = new NotificationEventDescriptor(message);
             RepositoryEvent event = RepositoryEventFactory
-                    .createEvent(this.manager, authoringDocument, getLogger(), descriptor);
+                    .createEvent(this.manager, getSession(), getLogger(), descriptor);
             getSession().enqueueEvent(event);
         }
     }

Modified: lenya/trunk/src/webapp/global-sitemap.xmap
URL: http://svn.apache.org/viewvc/lenya/trunk/src/webapp/global-sitemap.xmap?view=diff&rev=488305&r1=488304&r2=488305
==============================================================================
--- lenya/trunk/src/webapp/global-sitemap.xmap (original)
+++ lenya/trunk/src/webapp/global-sitemap.xmap Mon Dec 18 07:43:43 2006
@@ -165,6 +165,7 @@
               <map:parameter name="workflowstate" value="{workflow:state}"/>
               <map:parameter name="islive" value="{workflow:variable.is_live}"/>
               <map:parameter name="usecase" value="{request-param:lenya.usecase}"/>
+              <map:parameter name="newMessages" value="{inbox:newMessageCount}"/>
             </map:transform>
           </map:when>
           <map:otherwise>
@@ -179,6 +180,7 @@
               <map:parameter name="workflowstate" value="{workflow:state}"/>
               <map:parameter name="islive" value="{workflow:variable.is_live}"/>
               <map:parameter name="usecase" value="{request-param:lenya.usecase}"/>
+              <map:parameter name="newMessages" value="{inbox:newMessageCount}"/>
             </map:transform>
           </map:otherwise>
         </map:select>

Modified: lenya/trunk/src/webapp/lenya/xslt/menu/menu2xhtml.xsl
URL: http://svn.apache.org/viewvc/lenya/trunk/src/webapp/lenya/xslt/menu/menu2xhtml.xsl?view=diff&rev=488305&r1=488304&r2=488305
==============================================================================
--- lenya/trunk/src/webapp/lenya/xslt/menu/menu2xhtml.xsl (original)
+++ lenya/trunk/src/webapp/lenya/xslt/menu/menu2xhtml.xsl Mon Dec 18 07:43:43 2006
@@ -36,7 +36,8 @@
 <xsl:param name="workflowstate"/>
 <xsl:param name="islive"/>
 <xsl:param name="usecase"/>
-
+<xsl:param name="newMessages"/>
+  
 <xsl:variable name="currentTab">
   <xsl:choose>
     <xsl:when test="starts-with($usecase, 'admin.')">admin</xsl:when>
@@ -109,6 +110,23 @@
           <xsl:call-template name="workflow"/>
         </xsl:if>
         <li id="info-user"><i18n:text>User</i18n:text>: <span id="logged-user"><xsl:value-of select="$userid"/></span></li>
+        <xsl:if test="$newMessages != '0'">
+          <li id="info-messages">
+            <a href="?lenya.usecase=notification.inbox">
+              <xsl:choose>
+                <xsl:when test="$newMessages = '1'">
+                  <i18n:text>unread-message</i18n:text>
+                </xsl:when>
+                <xsl:otherwise>
+                  <i18n:translate>
+                    <i18n:text>unread-messages</i18n:text>
+                    <i18n:param><xsl:value-of select="$newMessages"/></i18n:param>
+                  </i18n:translate>
+                </xsl:otherwise>
+              </xsl:choose>
+            </a>
+          </li>
+        </xsl:if>
         <li id="info-time"><i18n:text>Server Time</i18n:text>: <span id="server-time"><xsl:value-of select="$servertime"/></span></li>
       </ul>
     </div>



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org