[MAGNOLIA-1230] Adding the handling of roles and groups in the method "convertEmailList" of class MgnlMailFactory (sending mails to all users of a group or a role) Created: 24/Nov/06  Updated: 23/Jan/13  Resolved: 13/Apr/07

Status: Closed
Project: Magnolia
Component/s: None
Affects Version/s: 3.0 Final
Fix Version/s: 3.0.3, 3.1 M1

Type: Task Priority: Minor
Reporter: Khalil SLIMI Assignee: Philipp Bärfuss
Resolution: Fixed Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Text File MgnlMailFactory.java.patch    
Issue Links:
supersession
is superseded by MAGNOLIA-1948 MgnlMailFactory can't read e-mail add... Closed
Template:
Acceptance criteria:
Empty
Task DoR:
Empty
Date of First Response:

 Comments   
Comment by Khalil SLIMI [ 24/Nov/06 ]

I've created a patch for this issue here it is :

##############################################################################

else if (userName.startsWith(MailConstants.PREFIX_GROUP)) {

userName = StringUtils.removeStart(userName, MailConstants.PREFIX_GROUP);

try {

HierarchyManager hm = ContentRepository.getHierarchyManager(ContentRepository.USERS);

Collection users = hm.getRoot().getChildren(ItemType.USER);

Iterator iter = users.iterator();

while(iter.hasNext()){

Content userNode = ((Content) iter.next());

MgnlUserManager manager = new MgnlUserManager();

MgnlUser user = (MgnlUser) manager.getUser(userNode.getName());

if (user.getGroups().contains(userName))

{ ret.append(getUserMail(user.getName())); }
}
}
catch (Exception e) { log.error("can not get user email info."); }

}
else if (userName.startsWith(MailConstants.PREFIX_ROLE)) {

userName = StringUtils.removeStart(userName, MailConstants.PREFIX_ROLE);

try {

HierarchyManager hm = ContentRepository.getHierarchyManager(ContentRepository.USERS);

Collection users = hm.getRoot().getChildren(ItemType.USER);

Iterator iter = users.iterator();

while(iter.hasNext()){

Content userNode = ((Content) iter.next());

MgnlUserManager manager = new MgnlUserManager();

MgnlUser user = (MgnlUser) manager.getUser(userNode.getName());

if (user.getRoles().contains(userName)){ ret.append(getUserMail(user.getName())); }

}
}
catch (Exception e)

{ log.error("can not get user email info."); }

}

############################################################################

Comment by Capitaine Harold [ 28/Nov/06 ]

I corrected the patch send by Kalil, just to avoids new instances.

***********************

else if (userName.startsWith(MailConstants.PREFIX_GROUP)) {

userName = StringUtils.removeStart(userName, MailConstants.PREFIX_GROUP);

try {

HierarchyManager hm = ContentRepository.getHierarchyManager(ContentRepository.USERS);

Collection users = hm.getRoot().getChildren(ItemType.USER);

Iterator iter = users.iterator();

while(iter.hasNext()){

Content userNode = ((Content) iter.next());

MgnlUserManager manager = Security.getUserManager();

MgnlUser user = (MgnlUser) manager.getUser(userNode.getName());

if (user.getGroups().contains(userName))

{ ret.append(getUserMail(user.getName())); }
}
}
catch (Exception e) { log.error("can not get user email info."); }

}
else if (userName.startsWith(MailConstants.PREFIX_ROLE)) {

userName = StringUtils.removeStart(userName, MailConstants.PREFIX_ROLE);

try {

HierarchyManager hm = ContentRepository.getHierarchyManager(ContentRepository.USERS);

Collection users = hm.getRoot().getChildren(ItemType.USER);

Iterator iter = users.iterator();

while(iter.hasNext()){

Content userNode = ((Content) iter.next());

MgnlUserManager manager = Security.getUserManager();

MgnlUser user = (MgnlUser) manager.getUser(userNode.getName());

if (user.getRoles().contains(userName)){ ret.append(getUserMail(user.getName())); }

}
}
catch (Exception e)

{ log.error("can not get user email info."); }

}

Comment by Magnolia International [ 28/Nov/06 ]

guys, thanks for this, but could you provide "real" patches against svn, and as attachments ? Makes everything easier for everybody...

svn diff > foobar.patch

Comment by Anthony Ogier [ 28/Nov/06 ]

Here is the patch

Comment by Henryk Paluch [ 05/Apr/07 ]

Hello!
This patch is still missing from Magnolia 3.0.2 (both CE and EE) - which makes workflow notifications pretty useless (because it is using group based notification).
Is there yet any reason to not include this into production Magnolia?

Comment by Philipp Bracher [ 13/Apr/07 ]

commited to trunk and branch

Generated at Mon Feb 12 03:24:55 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.