问题描述
在我的工作流程模型中,我与cm:person类型有关联,在共享配置中,我使用Authority.ftl模板显示它,如何限制可用用户从一组成员中进行选择?
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 ?
推荐答案
为实现此目的,我需要做一些更改:
There s a few changes that I needed to do in order to achieve this:
-
您应该使用新的控制参数在共享模块配置文件中将参数传递给您的Authority.ftl:
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>
在户外\网络扩展\网站-脚本\露天\ \components\form\controlsityauthority.ftl,将此参数传递给js选择器:
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"
});
- 在户外扩展中\ \templates\webscripts\org\alfresco\repository\forms\pickerchildren.get.js读取并使用该参数仅在给定的组中进行查询:
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
});
}
}
}
这篇关于alfresco:将authority.ftl限制为一组用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!