2012-11-12 46 views
2

我使用Liferay的6.1,我想改變個別組織權限以這樣的方式,這些組織可以通過用戶X勞力士誰不屬於該組織的OrgA管理如何爲不屬於此組織的用戶授予組織管理權限?

特別是:

  • 我想打的OrgA查看和更新​​通過勞力士Control Panel->Users and Organizations形式
  • 用戶X可以添加新的單位和用戶
  • UserX屬於RoleX但是不是OrgA(所以我認爲組織範圍角色不會有幫助)。

我想這樣做以編程方式


我到目前爲止已經試過

  • 創建勞力士並賦予它以下權限:

    • 訪問控制面板 - >用戶和組織(portlet 125)
    • OrgA,範圍4(個體):

      ActionKeys.VIEW,ActionKeys.UPDATE,ActionKeys.ASSIGN_USER_ROLES, ActionKeys.DELETE,ActionKeys.MANAGE_USERS

    • OrgA時的基團,其中範圍4:

      ActionKeys.ASSIGN_MEMBERS, ActionKeys.ASSIGN_USER_ROLES, 
      ActionKeys.CONFIGURE_PORTLETS, ActionKeys.DELETE, 
      ActionKeys.MANAGE_ANNOUNCEMENTS, ActionKeys.MANAGE_LAYOUTS, 
      ActionKeys.UPDATE, ActionKeys.VIEW, ActionKeys.VIEW_MEMBERS 
      

具有RoleX的用戶可以訪問控制面板中的Users and Organizations表單,但他們只能看到他們自己的組織AND NOT OrgA。

我該如何授權查看和管理OrgA?

感謝

回答

2

最後,我能夠完成,修改爲Resource Permissions勞力士修改初始化users_admin portlet的JSP文件中,都使用掛鉤插件。

主要問題是Liferay沒有使用ResourcePermissions來啓用用戶所屬組織以外的組織管理。

尤其是在portal-trunk/portal-web/docroot/html/portlet/users_admin/init.jsp有幾行代碼使之不僅爲公司管理員角色

else if (permissionChecker.isCompanyAdmin()) { 
    filterManageableGroups = false; 
    filterManageableOrganizations = false; 
    filterManageableUserGroups = false; 
} 

所以我加了以下幾行init.jsp(你可以使用初始化-EXT。 JSP在掛機)來啓用它也爲勞力士

if (MyUtils.isRoleX()) { 
    filterManageableGroups = false; 
    filterManageableOrganizations = false; 
    filterManageableUserGroups = false; 
} 

這樣的數據庫查詢不會過濾機構,用戶和組。

第二步是定義添加,更新,管理等權限。用戶和組織以及訪問控制面板中的portlet。

這是非常簡單的使用啓動動作鉤和ResourcePermisssionLocalService API:

private static final String[] ORGANIZATION_ENTRY_ACTION_IDS = new String[] { 
      ActionKeys.VIEW, ActionKeys.UPDATE, ActionKeys.ASSIGN_USER_ROLES, 
      ActionKeys.DELETE, ActionKeys.MANAGE_USERS }; 

    private static final String[] ORGANIZATION_CUSTOM_FIELDS_ENTRY_ACTION_IDS = new String[] { 
      ActionKeys.VIEW, ActionKeys.UPDATE }; 

    public static final String[] ORGANIZATION_MODEL_ACTION_IDS = new String[] { 
      ActionKeys.ASSIGN_MEMBERS, ActionKeys.ASSIGN_USER_ROLES, 
      ActionKeys.DELETE, ActionKeys.MANAGE_ANNOUNCEMENTS, 
      ActionKeys.UPDATE, ActionKeys.VIEW, ActionKeys.MANAGE_USERS, 
      ActionKeys.MANAGE_SUBORGANIZATIONS }; 

    public static final String[] ORGANIZATION_GROUP_ENTRY_ACTION_IDS = new String[] { 
      ActionKeys.ASSIGN_MEMBERS, ActionKeys.ASSIGN_USER_ROLES, 
      ActionKeys.UPDATE, ActionKeys.VIEW, ActionKeys.VIEW_MEMBERS }; 

    private static final String[] PORTAL_ACTION_IDS = new String[] { 
      ActionKeys.ADD_USER, ActionKeys.ADD_ORGANIZATION, 
      ActionKeys.VIEW_CONTROL_PANEL }; 

    private static final String[] USERS_ORG_ADMIN_ACTION_IDS = new String[] { ActionKeys.ACCESS_IN_CONTROL_PANEL }; 

... omissis ...

 ResourcePermissionLocalServiceUtil.setResourcePermissions(companyId, 
       Organization.class.getName(), 
       ResourceConstants.SCOPE_GROUP_TEMPLATE, "0", CiUtils 
         .getRoleX().getPrimaryKey(), 
       ORGANIZATION_MODEL_ACTION_IDS); 

     // ORGANIZATION MODEL COMPANY PERMISSIONS 
     ResourcePermissionLocalServiceUtil.setResourcePermissions(companyId, 
       Organization.class.getName(), ResourceConstants.SCOPE_COMPANY, 
       Long.toString(companyId), 
       CiUtils.getRoleX().getPrimaryKey(), 
       ORGANIZATION_MODEL_ACTION_IDS); 

     // PORTAL (portlet 90) PERMISSIONS 
     ResourcePermissionLocalServiceUtil.setResourcePermissions(companyId, 
       "90", ResourceConstants.SCOPE_COMPANY, 
       Long.toString(companyId), 
       CiUtils.getRoleX().getPrimaryKey(), 
       PORTAL_ACTION_IDS); 

     // USER_ORG_ADMINS PORTLET (125) PERMISSIONS 
     ResourcePermissionLocalServiceUtil.setResourcePermissions(companyId, 
       "125", ResourceConstants.SCOPE_COMPANY, 
       Long.toString(companyId), 
       CiUtils.getRoleX().getPrimaryKey(), 
       USERS_ORG_ADMIN_ACTION_IDS); 

和每個組織:

ResourcePermissionLocalServiceUtil.setResourcePermissions(organization.getCompanyId(), 
          Organization.class.getName(), ResourceConstants.SCOPE_INDIVIDUAL, Long     .toString(organization.getPrimaryKey()), 
           MyUtils.getRoleX().getPrimaryKey(), 
           ORGANIZATION_ENTRY_ACTION_IDS); 
     long groupId = organization.getGroupId(); 

     ResourcePermissionLocalServiceUtil.setResourcePermissions(
        organization.getCompanyId(),Group.class.getName(), ResourceConstants.SCOPE_INDIVIDUAL,Long.toString(groupId), 
        MyUtils.getRoleX().getPrimaryKey(), 
        ORGANIZATION_GROUP_ENTRY_ACTION_IDS); 

希望這可以幫助別人。