... next time, before asking too quickly I will take more time to read/understand the doc :-/ Note: for accounts without email: $userDoc.getValue('email') return XWiki.xwikiblog -> $userDoc.getValue('email') $MyUser.getEmail() return XWiki.xwikiblog -> I will probably publish a simplest formulaire which propose a list of groups... when I have more time. Here correct code (to adapt with previous code for groups): {{velocity}} #set ($sql = ", BaseObject as obj where obj.name=doc.fullName and obj.className='XWiki.XWikiUsers'") #set ($allUsers = $xwiki.searchDocuments($sql)) #foreach ($user in $allUsers) #set ($userDoc = $xwiki.getDocument($user)) #if ($email != 'mailto:') ## $user -> $email $user -> $userDoc.getValue('email') #end #end ---- #set ($sql = ", BaseObject as obj where obj.name=doc.fullName and obj.className='XWiki.XWikiUsers'") #set ($allUsers = $xwiki.searchDocuments($sql)) #foreach ($user in $allUsers) #set ($MyUser = $xwiki.getUser("$user")) #if ($email != 'mailto:') ## $user -> $email $user -> $MyUser.getEmail() #end #end {{/velocity}} Thxs everybodys ________________________________ De : Marius Dumitru Florea <[email protected]> À : Pascal BASTIEN <[email protected]>; XWiki Users <[email protected]> Envoyé le : Jeudi 25 septembre 2014 10h56 Objet : Re: [xwiki-users] Can I send email to a group with xwiki 6? On Thu, Sep 25, 2014 at 11:18 AM, Pascal BASTIEN <[email protected]> wrote:
"it's a kind of magic" for $stringtool :-)
... but I didn't manage to use $user.getProperty('email').value or $user.getValue('email')
I try this: {{velocity}}
#set ($sql = ", BaseObject as obj where obj.name=doc.fullName and obj.className='XWiki.XWikiUsers'") #set ($allUsers = $xwiki.searchDocuments($sql)) #foreach ($user in $allUsers) ##cut ...
#if ($email != 'mailto:') ## $user -> $email
$user -> $user.getProperty('email').value - $user.getValue('email')
You can always do $someVariable.class.name to see the Java class name and then to look for the corresponding javadoc to see the available method. In this case, $user is a plain Java string so it doesn't have the 'getProperty' method. If you don't believe me, look for 'searchDocuments' in http://platform.xwiki.org/xwiki/bin/view/SRD/Navigation?api=xwiki&xpage=embe... You need a Document object. See http://platform.xwiki.org/xwiki/bin/view/SRD/Navigation?api=doc&xpage=embed which has 'getValue'. #set ($userDoc = $xwiki.getDocument($user)) $user.getValue('email')
#end #end
{{/velocity}}
and this:
{{velocity}} #set ($sql = ", BaseObject as obj where obj.name=doc.fullName and obj.className='XWiki.XWikiUsers'") #set ($allUsers = $xwiki.searchDocuments($sql)) #foreach ($user in $allUsers)
#set ($MyUser = $xwiki.getUser("$user"))
getUser return an object of type User, http://maven.xwiki.org/site/docs/xwiki-javadoc-4.1.x/com/xpn/xwiki/api/User.... , which doesn't have any getProperty or getValue method but has getEmail. You really need to check the type of objects you are using.
#if ($email != 'mailto:') ## $user -> $email $user -> $MyUser.getProperty('email').value - $MyUser.getValue('email') #end #end
{{/velocity}}
without success :-(
________________________________ De : "Guillaume "Louis-Marie" Delhumeau" <[email protected]> À : XWiki Users <[email protected]> Envoyé le : Jeudi 25 septembre 2014 9h19 Objet : Re: [xwiki-users] Can I send email to a group with xwiki 6?
2014-09-24 22:27 GMT+02:00 Sergiu Dumitriu <[email protected]>:
On 09/24/2014 10:15 AM, Pascal BASTIEN wrote:
Hello,
(freely inspired/adapted by: http://extensions.xwiki.org/xwiki/bin/view/Extension/Test+Mail (Vincent) and http://xwiki.markmail.org/message/bksyjlpwezx4dgco?q=getAllMembersNamesForGr... (Sergiu)
Some questions: to replace some text in velocity, I used $text.replaceAll(xxx,yyy). Are they a way to use StringUtils tools in velocity?
http://commons.apache.org/proper/commons-lang/javadocs/api-3.1/org/apache/co...
If yes, how?
Yes, $stringtool
I failed to get email adress with $userdoc.display("email","view",$user) function but without "mailto:" prefix ...
http://maven.xwiki.org/site/docs/xwiki-javadoc-4.1.x/com/xpn/xwiki/api/Docum...
Use $user.getProperty('email').value to access the raw value, display methods generate HTML code.
Since 6.2, you can do $user.getValue('email') :)
Are they a tip with wrappingSyntaxId value? or I must use regexp like i did?
If there are too much email I don't know if my macro is safe... (Perhaps there are a way to insert a sleep instruction in velocity?)
Thxs
-- Sergiu Dumitriu http://purl.org/net/sergiu _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
-- Guillaume Delhumeau ([email protected]) Research & Development Engineer at XWiki SAS Committer on the XWiki.org project
_______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users