Here is a script in a madeup language. It checks the permissions on the actual document triggered and sends an email alert to all people who can read the file except to the person who triggered the alert (he already knows…) :
user = getcurrentuser(); document = getcurrentdocument(); perms = getpermissions(document);
for each(perms as perm) { if (perm["username"] != user.getname()) { mail = newmail(); mail.subject = "new document "" + document.getname() + "" changed"; mail.to = getPersonFromName(perm["username"]).getemail(); mail.from = "admin@mysite.com"; mail.body = "blah blah " + document.geturl() + "blabla. Bye."; mail.send(); } }
1) Is thi possible using the javascript API? Could you give me a hint on how to implement the "perms = getpermissions" and "for each (perms as perm)" please? I dont know how to parse tokenised string in javascript :s
2) Are discussions nodes taken care of, this way? Is there any way i can detect that the current node is a discussion and mention it in the email?
The issue here is that the getPermissions() method only retrieves the permissions explicity applied to a node. It does not return and calculate the permissions as inherited from any parent nodes and which therefore also apply. However using the node.parent API and the JavaScript Permissions API method inheritsPermissions() you can work out all permissions applied to a node including the inheritance chain. In addition, Groups of users are returned in the getPermissions() data, but again you can use the People API to calculate which users are in the Groups and in turn get those users emails addresses. You may want to do some background reading on the way Alfresco permissions work on our wiki first!
BTW if i cant get this to work, is there any way i can ask a company/someone to do it instead? I sold an Alfresco install for a test to a company, but they want some customization. We dont have budget right now to buy a full licence, but we do for some development.