Author: mflorea
Date: 2008-01-14 12:10:10 +0100 (Mon, 14 Jan 2008)
New Revision: 6807

Modified:
   
xwiki-products/curriki/trunk/plugins/spacemanager/src/main/java/org/xwiki/plugin/spacemanager/impl/SpaceManagerImpl.java
Log:
Added api.Context to the velocity context when sending notification e-mails

Modified: 
xwiki-products/curriki/trunk/plugins/spacemanager/src/main/java/org/xwiki/plugin/spacemanager/impl/SpaceManagerImpl.java
===================================================================
--- 
xwiki-products/curriki/trunk/plugins/spacemanager/src/main/java/org/xwiki/plugin/spacemanager/impl/SpaceManagerImpl.java
    2008-01-13 21:59:37 UTC (rev 6806)
+++ 
xwiki-products/curriki/trunk/plugins/spacemanager/src/main/java/org/xwiki/plugin/spacemanager/impl/SpaceManagerImpl.java
    2008-01-14 11:10:10 UTC (rev 6807)
@@ -1172,7 +1172,7 @@
     }
 
     private void sendMail(String action, Space space, XWikiContext context)
-            throws SpaceManagerException
+        throws SpaceManagerException
     {
         if (!mailNotification) {
             return;
@@ -1193,8 +1193,8 @@
 
         if (fromUser == null) {
             throw new 
SpaceManagerException(SpaceManagerException.MODULE_PLUGIN_SPACEMANAGER,
-                    SpaceManagerException.ERROR_SPACE_SENDER_EMAIL_INVALID,
-                    "Sender email is invalid");
+                SpaceManagerException.ERROR_SPACE_SENDER_EMAIL_INVALID,
+                "Sender email is invalid");
         }
 
         boolean toUsersValid = toUsers.length > 0;
@@ -1209,8 +1209,8 @@
 
         if (!toUsersValid) {
             throw new 
SpaceManagerException(SpaceManagerException.MODULE_PLUGIN_SPACEMANAGER,
-                    SpaceManagerException.ERROR_SPACE_TARGET_EMAIL_INVALID,
-                    "Target email is invalid");
+                SpaceManagerException.ERROR_SPACE_TARGET_EMAIL_INVALID,
+                "Target email is invalid");
         }
         String strToUsers = join(toUsers, ",");
 
@@ -1218,26 +1218,27 @@
 
         try {
             String templateDocFullName =
-                    getTemplateMailPageName(space.getSpaceName(), action, 
context);
+                getTemplateMailPageName(space.getSpaceName(), action, context);
             XWikiDocument mailDoc = 
context.getWiki().getDocument(templateDocFullName, context);
             XWikiDocument translatedMailDoc = 
mailDoc.getTranslatedDocument(context);
             mailSender.prepareVelocityContext(fromUser, strToUsers, "", 
vContext, context);
             vContext.put("xwiki", new 
com.xpn.xwiki.api.XWiki(context.getWiki(), context));
+            vContext.put("context", new com.xpn.xwiki.api.Context(context));
             String mailSubject =
-                    
XWikiVelocityRenderer.evaluate(translatedMailDoc.getTitle(), 
templateDocFullName,
-                            vContext);
+                XWikiVelocityRenderer.evaluate(translatedMailDoc.getTitle(), 
templateDocFullName,
+                    vContext);
             String mailContent =
-                    
XWikiVelocityRenderer.evaluate(translatedMailDoc.getContent(),
-                            templateDocFullName, vContext);
+                XWikiVelocityRenderer.evaluate(translatedMailDoc.getContent(),
+                    templateDocFullName, vContext);
 
             Mail mail =
-                    new Mail(fromUser, strToUsers, null, null, mailSubject, 
mailContent, null);
+                new Mail(fromUser, strToUsers, null, null, mailSubject, 
mailContent, null);
             mailSender.sendMail(mail, context);
         } catch (Exception e) {
             throw new 
SpaceManagerException(SpaceManagerException.MODULE_PLUGIN_SPACEMANAGER,
-                    SpaceManagerException.ERROR_SPACE_SENDING_EMAIL_FAILED,
-                    "Sending notification email failed",
-                    e);
+                SpaceManagerException.ERROR_SPACE_SENDING_EMAIL_FAILED,
+                "Sending notification email failed",
+                e);
         }
     }
 

_______________________________________________
notifications mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/notifications

Reply via email to