…
<action type="simple-link" id="onActionMailUtilisateurs" permission="edit" href="{mailUtilisateursUrl}" label="actions.document.mail-utilisateurs" />
…
et…
mailUtilisateursUrl: fnPageURL("mail-utilisateurs?nodeRef=" + nodeRef + "&proxyAlfresco=" + Alfresco.constants.PROXY_URI + "&contentUrl=" + contentUrl),
…
<?xml version='1.0' encoding='UTF-8'?>
<page>
<title>Mail utilisateurs avec lien documents</title>
<title-id>page.mailUtilisateurs.title</title-id>
<description>Mail Utilisateurs</description>
<description-id>page.mailUtilisateurs.description</description-id>
<template-instance>mail-utilisateurs</template-instance>
<authentication>user</authentication>
</page>
<?xml version='1.0' encoding='UTF-8'?>
<template-instance>
<template-type>org/alfresco/mail-utilisateurs</template-type>
<properties>
<pageFamily>documentlibrary</pageFamily>
<container>documentLibrary</container>
</properties>
<components>
<component>
<region-id>mail-utilisateurs</region-id>
<url>/components/mail-utilisateurs/mail-utilisateurs</url>
<properties>
<itemId>{nodeRef}</itemId>
<contentId>{contentUrl}</contentId>
<proxyId>{proxyAlfresco}</proxyId>
</properties>
</component>
</components>
</template-instance>
//var nodeRef = args["noderef"];
//var document = search.findNode(nodeRef);
var persons = [];
var perms = document.getPermissions();
for(var i=0 ; i<perms.length ; i++) {
var perm = perms[i].split(";");
if(perm[0] == "ALLOWED" && perm[1].lastIndexOf("GROUP_") != -1) {
var group = people.getGroup(perm[1]);
if(group) {
var persons = people.getMembers(group);
for each (person in persons){
if(person.properties.userName != "admin" && person.properties.userName != "guest") {
var email = person.properties.email;
if(email)
sendMail(email);
}
}
}
}
}
function sendMail(email) {
// Envoi mail
var mail = actions.create("mail");
mail.parameters.to = email;
mail.parameters.subject = "Nouveau Document";
mail.parameters.from = "Info@Alfresco";
mail.parameters.template = companyhome.childByNamePath("Data Dictionary/Email Templates/Notify Email Templates/notify_user_email.ftl");
mail.parameters.text = "Inutile grace au Template ";
mail.execute(document);
}
<webscript>
<shortname>Mon webscript</shortname>
<description>Mon webscript qui envoie des mails</description>
<url>/sendMail</url>
<format default="json">argument</format>
<authentication>user</authentication>
</webscript>
try {
model.users = [];
model.failures = [];
var nodeRef = args["noderef"];
var document = search.findNode(nodeRef);
var perms = document.getPermissions();
for (var i=0 ; i<perms.length ; i++) {
var perm = perms[i].split(";");
if (perm[0] == "ALLOWED" && perm[1].lastIndexOf("GROUP_") != -1) {
var group = people.getGroup(perm[1]);
if (group) {
var persons = people.getMembers(group);
for each (p in persons) {
if (p.properties.userName != "admin" && p.properties.userName != "guest") {
var email = p.properties.email;
if (email) {
sendMail(p, document);
}
}
}
}
}
}
}
catch (e) {}
function sendMail(p, doc) {
try {
// Envoi mail
var mail = actions.create("mail");
mail.parameters.to = p.properties.email;
mail.parameters.subject = "Nouveau Document";
mail.parameters.from = "Info@Alfresco";
mail.parameters.template = companyhome.childByNamePath("Data Dictionary/Email Templates/Notify Email Templates/notify_user_email.ftl");
mail.parameters.text = "Inutile grace au Template ";
mail.execute(doc);
model.users.push(p.properties.userName);
}
catch(e) {
model.failures.push(p.properties.userName);
}
}
mon-webscript.get.json.ftl<@compress single_line=true>
<#escape x as jsonUtils.encodeJSONString(x)>
{
"document": "${document.name}",
"users": [
<#list users as userName>
"${userName}"
<#if userName_has_next>,</#if>
</#list>
],
"failures": [
<#list failures as authority>
"${authority}"
<#if authority_has_next>,</#if>
</#list>
]
}
</#escape>
</@>
var nodeRef = page.url.args.nodeRef;
var result = remote.call("/sendMail?nodeRef=" + stringUtils.urlEncode(nodeRef));
if (result.status == 200) {
var json = eval('(' + result + ')');
model.success = json.users;
model.failures = json.failures;
}
<webscript>
<shortname>Mail utilisateurs avec lien document</shortname>
<description>Mon webscript qui envoie des mails</description>
<url>/sendMailUtilisateurs?nodeRef={nodeRef?}</url>
<format default="json">argument</format>
<authentication>user</authentication>
</webscript>
…
var email = person.properties.email;
// Insertion dans la table users (suppression des doublons)
if(email) {
var exist = 0;
for(var seq=0 ; seq<users.length ; seq++) {
if (users[seq] == email) {
exist = 1;
}
}
if (exist == 0){
users[users.length] = email;
}
…
Content from pre 2016 and from language groups that have been closed.
Content is read-only.
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.