露天:将 authority.ftl 限制为一组用户 [英] alfresco: limiting authority.ftl to a group of users

查看:33
本文介绍了露天:将 authority.ftl 限制为一组用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的工作流模型中,我与 cm:person 类型有关联,在共享配置中我使用 authority.ftl 模板来显示它,如何限制可用用户从一组成员中选择?

解决方案

为了实现这一点,我需要做一些更改:

  • 您应该使用新的控制参数将参数传递给您的共享模块配置文件中的 authority.ftl:

     <表格><表格><外观><field id="my:personproperty"><控制模板=/org/alfresco/components/form/controls/authority.ftl"><control-param name="filterString">mygroupname</control-param></控制>

  • 在 alfrescoweb-extensionsite-webscriptsorgalfrescocomponentsformcontrolsauthority.ftl 中,将此参数传递给 js 选择器:

<块引用>

 picker.setOptions({itemType: "${field.endpointType}",<#if field.control.params.filterString??>filterString: "${field.control.params.filterString}",</#if>multipleSelectMode: ${field.endpointMany?string},itemFamily: "权限"});

  • 在 alfrescoextension emplateswebscriptsorgalfresco epositoryformspickerchildren.get.js 中读取并使用参数仅在给定的组中进行查询:
<块引用>

 argsFilterString = args['filterString']...if (argsSelectableType == "cm:person"){findUsers(argsSearchTerm, argsFilterString, maxResults, results);}...函数 findUsers(searchTerm, filterString, maxResults, results){var paging = utils.createPaging(maxResults, -1);var searchResults = groups.searchUsers(searchTerm, paging, "lastName");var groupmembers = null;如果(过滤器字符串!= null){var group = groups.getGroup(filterString);var groupmembers = group.getAllUsers();}//为每个结果创建person对象对于每个(搜索结果中的 var 用户){如果 (logger.isLoggingEnabled())logger.log("找到用户 = " + user.userName);变量添加=真;if (groupmembers != null ){var ismember = false;对于每个(组成员中的 var p){if (""+p.userName == ""+user.userName){//需要加 +"" 因为它们是 java 字符串!ismember = true;}}如果 (!ismember){logger.log(user.userName+" 不是组的成员 "+filterString);添加=假;}}如果(添加){//添加到结果中结果.push({项目:createPersonResult(user.person),可选:真});}}}

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:

  • 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 alfrescoweb-extensionsite-webscriptsorgalfrescocomponentsformcontrolsauthority.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 alfrescoextension emplateswebscriptsorgalfresco epositoryformspickerchildren.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 
      });
  }
 }
 }

这篇关于露天:将 authority.ftl 限制为一组用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆