In my workflow model I have an association to cm:person type, in share configuration I'm using the authority.ftl template to display it, how can I limit the available users to select from down to the members of one group ?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
There s a few changes that I needed to do in order to achieve this:
You should pass a parameter to your authority.ftl in your share modules config file using a new control param:
<config evaluator="node-type" condition="my:customtype"> <forms> <form> <appearance> <field id="my:personproperty"> <control template="/org/alfresco/components/form/controls/authority.ftl"> <control-param name="filterString">mygroupname</control-param> </control>
In alfresco\web-extension\site-webscripts\org\alfresco\components\form\controls\authority.ftl, pass this param to the js picker:
picker.setOptions( { itemType: "${field.endpointType}", <#if field.control.params.filterString??> filterString: "${field.control.params.filterString}", </#if> multipleSelectMode: ${field.endpointMany?string}, itemFamily: "authority" });
- In alfresco\extension\templates\webscripts\org\alfresco\repository\forms\pickerchildren.get.js read and use the parameter to query in only the given group:
argsFilterString = args['filterString'] ... if (argsSelectableType == "cm:person") { findUsers(argsSearchTerm, argsFilterString, maxResults, results); } ... function findUsers(searchTerm, filterString, maxResults, results){ var paging = utils.createPaging(maxResults, -1); var searchResults = groups.searchUsers(searchTerm, paging, "lastName"); var groupmembers = null; if (filterString != null){ var group = groups.getGroup(filterString); var groupmembers = group.getAllUsers(); } // create person object for each result for each(var user in searchResults) { if (logger.isLoggingEnabled()) logger.log("found user = " + user.userName); var add=true; if (groupmembers != null ){ var ismember = false; for each (var p in groupmembers){ if (""+p.userName == ""+user.userName){//need to add +"" cause they are java strings! ismember = true; } } if (!ismember){ logger.log(user.userName+" is no member of group "+filterString); add=false; } } if(add){ // add to results results.push( { item: createPersonResult(user.person), selectable: true }); } } }
回答2:
You can create a new control based on that authority.ftl and authority-finder.js, in which you modify the webscript call to a limited number of users to be returned !
Note : If the webscript doesnot support maxItems parameter (or any other parameter to limit the number of results returned), you can always create your brand new webscript that supports that feature and then point your new control at it.