PageRenderTime 42ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/portal-web/docroot/html/portlet/portlet_configuration/edit_permissions_algorithm_1_to_4_users.jsp

https://github.com/viktorkovacs/liferay-portal-trunk
JavaServer Pages | 198 lines | 138 code | 45 blank | 15 comment | 10 complexity | 197c9f1efc3675cc7595f53fdc0e817d MD5 | raw file
  1. <%--
  2. /**
  3. * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
  4. *
  5. * This library is free software; you can redistribute it and/or modify it under
  6. * the terms of the GNU Lesser General Public License as published by the Free
  7. * Software Foundation; either version 2.1 of the License, or (at your option)
  8. * any later version.
  9. *
  10. * This library is distributed in the hope that it will be useful, but WITHOUT
  11. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  12. * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
  13. * details.
  14. */
  15. --%>
  16. <%@ include file="/html/portlet/portlet_configuration/init.jsp" %>
  17. <%
  18. String tabs3 = (String)request.getAttribute("edit_permissions_algorithm_1_to_4.jsp-tabs3");
  19. portletResource = (String)request.getAttribute("edit_permissions_algorithm_1_to_4.jsp-portletResource");
  20. String modelResource = (String)request.getAttribute("edit_permissions_algorithm_1_to_4.jsp-modelResource");
  21. Group group = (Group)request.getAttribute("edit_permissions_algorithm_1_to_4.jsp-group");
  22. long groupId = (Long)request.getAttribute("edit_permissions_algorithm_1_to_4.jsp-groupId");
  23. Resource resource = (Resource)request.getAttribute("edit_permissions_algorithm_1_to_4.jsp-resource");
  24. PortletURL portletURL = (PortletURL)request.getAttribute("edit_permissions_algorithm_1_to_4.jsp-portletURL");
  25. String userIds = ParamUtil.getString(request, "userIds");
  26. long[] userIdsArray = StringUtil.split(userIds, 0L);
  27. int userIdsPos = ParamUtil.getInteger(request, "userIdsPos");
  28. %>
  29. <aui:input name="userIds" type="hidden" value="<%= userIds %>" />
  30. <aui:input name="userIdsPos" type="hidden" value="<%= userIdsPos %>" />
  31. <aui:input name="userIdsPosValue" type="hidden" />
  32. <aui:input name="userIdActionIds" type="hidden" />
  33. <c:choose>
  34. <c:when test="<%= userIdsArray.length == 0 %>">
  35. <liferay-ui:tabs
  36. names="current,available"
  37. param="tabs3"
  38. url="<%= portletURL.toString() %>"
  39. />
  40. <liferay-ui:search-container
  41. rowChecker="<%= new RowChecker(renderResponse) %>"
  42. searchContainer="<%= new UserSearch(renderRequest, portletURL) %>"
  43. >
  44. <liferay-ui:search-form
  45. page="/html/portlet/enterprise_admin/user_search.jsp"
  46. />
  47. <%
  48. UserSearchTerms searchTerms = (UserSearchTerms)searchContainer.getSearchTerms();
  49. LinkedHashMap userParams = new LinkedHashMap();
  50. if (tabs3.equals("current")) {
  51. userParams.put("permission", new Long(resource.getResourceId()));
  52. }
  53. else if (tabs3.equals("available")) {
  54. if (group.isCommunity()) {
  55. userParams.put("usersGroups", new Long(groupId));
  56. }
  57. else if (group.isOrganization()) {
  58. userParams.put("usersOrgs", new Long(group.getOrganizationId()));
  59. }
  60. }
  61. %>
  62. <liferay-ui:search-container-results>
  63. <%@ include file="/html/portlet/enterprise_admin/user_search_results.jspf" %>
  64. </liferay-ui:search-container-results>
  65. <liferay-ui:search-container-row
  66. className="com.liferay.portal.model.User"
  67. escapedModel="<%= true %>"
  68. keyProperty="userId"
  69. modelVar="user2"
  70. >
  71. <liferay-ui:search-container-column-text
  72. name="name"
  73. property="fullName"
  74. />
  75. <liferay-ui:search-container-column-text
  76. name="screen-name"
  77. orderable="<%= true %>"
  78. property="screenName"
  79. />
  80. <liferay-ui:search-container-column-text
  81. buffer="buffer"
  82. name="permissions"
  83. >
  84. <%
  85. List permissions = PermissionLocalServiceUtil.getUserPermissions(user2.getUserId(), resource.getResourceId());
  86. List actions = ResourceActionsUtil.getActions(permissions);
  87. List actionsNames = ResourceActionsUtil.getActionsNames(pageContext, actions);
  88. buffer.append(StringUtil.merge(actionsNames, ", "));
  89. %>
  90. </liferay-ui:search-container-column-text>
  91. </liferay-ui:search-container-row>
  92. <div class="separator"><!-- --></div>
  93. <aui:button onClick='<%= renderResponse.getNamespace() + "updateUserPermissions();" %>' value="update-permissions" />
  94. <br /><br />
  95. <liferay-ui:search-iterator />
  96. </liferay-ui:search-container>
  97. </c:when>
  98. <c:otherwise>
  99. <%
  100. User user2 = UserLocalServiceUtil.getUserById(userIdsArray[userIdsPos]);
  101. %>
  102. <liferay-ui:header
  103. title="<%= user2.getFullName() %>"
  104. />
  105. <%
  106. List permissions = PermissionLocalServiceUtil.getUserPermissions(user2.getUserId(), resource.getResourceId());
  107. List actions1 = ResourceActionsUtil.getResourceActions(portletResource, modelResource);
  108. List actions2 = ResourceActionsUtil.getActions(permissions);
  109. String leftTitle = "what-he-can-do";
  110. String rightTitle = "what-he-cant-do";
  111. if (user2.isFemale()) {
  112. leftTitle = "what-she-can-do";
  113. rightTitle = "what-she-cant-do";
  114. }
  115. // Left list
  116. List leftList = new ArrayList();
  117. for (int i = 0; i < actions2.size(); i++) {
  118. String actionId = (String)actions2.get(i);
  119. leftList.add(new KeyValuePair(actionId, ResourceActionsUtil.getAction(pageContext, actionId)));
  120. }
  121. leftList = ListUtil.sort(leftList, new KeyValuePairComparator(false, true));
  122. // Right list
  123. List rightList = new ArrayList();
  124. for (int i = 0; i < actions1.size(); i++) {
  125. String actionId = (String)actions1.get(i);
  126. if (!actions2.contains(actionId)) {
  127. rightList.add(new KeyValuePair(actionId, ResourceActionsUtil.getAction(pageContext, actionId)));
  128. }
  129. }
  130. rightList = ListUtil.sort(rightList, new KeyValuePairComparator(false, true));
  131. %>
  132. <div class="assign-permissions">
  133. <liferay-ui:input-move-boxes
  134. leftTitle="<%= leftTitle %>"
  135. rightTitle="<%= rightTitle %>"
  136. leftBoxName="current_actions"
  137. rightBoxName="available_actions"
  138. leftList="<%= leftList %>"
  139. rightList="<%= rightList %>"
  140. />
  141. <aui:button-row>
  142. <%
  143. String taglibPreviousOnClick = renderResponse.getNamespace() + "saveUserPermissions(" + (userIdsPos - 1) + ", '" + userIdsArray[userIdsPos] + "');";
  144. String taglibNextOnClick = renderResponse.getNamespace() + "saveUserPermissions(" + (userIdsPos + 1) + ", '" + userIdsArray[userIdsPos] + "');";
  145. String taglibFinishedOnClick = renderResponse.getNamespace() + "saveUserPermissions(-1, '"+ userIdsArray[userIdsPos] + "');";
  146. %>
  147. <aui:button cssClass="previous" disabled="<%= userIdsPos <= 0 %>" onClick='<%= taglibPreviousOnClick %>' value="previous" />
  148. <aui:button cssClass="next" disabled="<%= userIdsPos + 1 >= userIdsArray.length %>" onClick='<%= taglibNextOnClick %>' value="next" />
  149. <aui:button cssClass="finished" onClick="<%= taglibFinishedOnClick %>" value="finished" />
  150. </aui:button-row>
  151. </div>
  152. </c:otherwise>
  153. </c:choose>