PageRenderTime 98ms CodeModel.GetById 29ms RepoModel.GetById 0ms app.codeStats 0ms

/portlets/contacts-portlet/docroot/contacts_center/view.jsp

https://github.com/l15k4/liferay-plugins
JavaServer Pages | 294 lines | 224 code | 57 blank | 13 comment | 9 complexity | 3b562f257f9002b254a65b3ddf1f191a 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="/init.jsp" %>
  17. <%
  18. int socialRelationType = ParamUtil.getInteger(request, "socialRelationType");
  19. String name = ParamUtil.getString(request, "name");
  20. boolean userPublicPage = false;
  21. Group group = themeDisplay.getScopeGroup();
  22. if (group.isUser() && layout.isPublicLayout()) {
  23. userPublicPage = true;
  24. }
  25. LinkedHashMap<String, Object> params = new LinkedHashMap<String, Object>();
  26. if (userPublicPage) {
  27. params.put("socialRelation", new Long[] {group.getClassPK()});
  28. }
  29. else if (socialRelationType != 0) {
  30. params.put("socialRelationType", new Long[] {themeDisplay.getUserId(), new Long(socialRelationType)});
  31. }
  32. List<User> users = UserLocalServiceUtil.search(company.getCompanyId(), name, WorkflowConstants.STATUS_APPROVED, params, 0, maxResultCount, new UserLastNameComparator(true));
  33. int usersCount = UserLocalServiceUtil.searchCount(themeDisplay.getCompanyId(), name, WorkflowConstants.STATUS_APPROVED, params);
  34. PortletURL portletURL = renderResponse.createRenderURL();
  35. portletURL.setWindowState(WindowState.NORMAL);
  36. %>
  37. <c:choose>
  38. <c:when test="<%= userPublicPage && (usersCount <= 0) %>">
  39. <aui:layout cssClass="contacts-center-home">
  40. <h3 class="header-title">
  41. <liferay-ui:message arguments="<%= new Object[] {group.getDescriptiveName(), String.valueOf(usersCount)} %>" key="x-has-no-contacts" />
  42. </h3>
  43. </aui:layout>
  44. </c:when>
  45. <c:otherwise>
  46. <aui:form action="<%= portletURL.toString() %>" method="post" name="fm">
  47. <aui:layout cssClass="contacts-search aui-search-bar">
  48. <aui:input cssClass="search-input" id="name" name="name" size="30" type="text" value="<%= HtmlUtil.escape(name) %>" />
  49. </aui:layout>
  50. <c:if test="<%= !userPublicPage %>">
  51. <aui:layout cssClass="contact-group-filter">
  52. <aui:select inlineField="true" label="" name="socialRelationType">
  53. <aui:option label="all" selected='<%= socialRelationType == 0 %>' value="all" />
  54. <aui:option label="connections" selected='<%= socialRelationType == SocialRelationConstants.TYPE_BI_CONNECTION %>' value="<%= SocialRelationConstants.TYPE_BI_CONNECTION %>" />
  55. <aui:option label="following" selected='<%= socialRelationType == SocialRelationConstants.TYPE_UNI_FOLLOWER %>' value="<%= SocialRelationConstants.TYPE_UNI_FOLLOWER %>" />
  56. </aui:select>
  57. </aui:layout>
  58. </c:if>
  59. <div class="clear"><!-- --></div>
  60. <aui:layout cssClass="contacts-result-container lfr-app-column-view">
  61. <aui:column columnWidth="30" first="<%= true %>">
  62. <aui:layout cssClass="contacts-result">
  63. <%
  64. String lastNameAnchor = StringPool.SPACE;
  65. for (User user2 : users) {
  66. %>
  67. <c:if test="<%= !StringUtil.startsWith(user2.getLastName(), lastNameAnchor) %>">
  68. <%
  69. lastNameAnchor = user2.getLastName().substring(0, 1);
  70. %>
  71. <div class="lastNameAnchor">
  72. <a><%= StringUtil.upperCase(lastNameAnchor) %></a>
  73. </div>
  74. </c:if>
  75. <liferay-portlet:renderURL windowState="<%= LiferayWindowState.EXCLUSIVE.toString() %>" var="viewSummaryURL">
  76. <portlet:param name="jspPage" value="/contacts_center/view_user.jsp" />
  77. <portlet:param name="userId" value="<%= String.valueOf(user2.getUserId()) %>" />
  78. </liferay-portlet:renderURL>
  79. <div class="lfr-contact-grid-item" data-viewSummaryURL="<%= viewSummaryURL %>">
  80. <div class="lfr-contact-thumb">
  81. <img alt="<%= HtmlUtil.escape(user2.getFullName()) %>" src="<%= user2.getPortraitURL(themeDisplay) %>" />
  82. </div>
  83. <div class="lfr-contact-info">
  84. <div class="lfr-contact-name">
  85. <a><%= HtmlUtil.escape(user2.getLastName()) %>, <%= HtmlUtil.escape(user2.getFirstName()) %></a>
  86. </div>
  87. <div class="lfr-contact-extra">
  88. <%= HtmlUtil.escape(user2.getEmailAddress()) %>
  89. </div>
  90. </div>
  91. <div class="clear"><!-- --></div>
  92. </div>
  93. <%
  94. }
  95. %>
  96. <c:if test="<%= usersCount > maxResultCount %>">
  97. <div class="more-results">
  98. <a href="javascript:;" data-end="<%= maxResultCount %>" data-lastNameAnchor="<%= lastNameAnchor %>"><liferay-ui:message key="view-more" /> (<%= usersCount - maxResultCount %>)</a>
  99. </div>
  100. </c:if>
  101. </aui:layout>
  102. </aui:column>
  103. <aui:column columnWidth="70" cssClass="contacts-container">
  104. <c:choose>
  105. <c:when test="<%= userPublicPage %>">
  106. <%
  107. request.setAttribute(WebKeys.CONTACTS_USER, users.get(0));
  108. %>
  109. <liferay-util:include page="/contacts_center/view_user.jsp" servletContext="<%= application %>" />
  110. </c:when>
  111. <c:otherwise>
  112. <aui:layout cssClass="contacts-center-home">
  113. <liferay-ui:header
  114. title="contacts-center"
  115. />
  116. <%
  117. int allUsersCount = UserLocalServiceUtil.getUsersCount();
  118. int connectionUsersCount = UserLocalServiceUtil.getSocialUsersCount(themeDisplay.getUserId(), SocialRelationConstants.TYPE_BI_CONNECTION);
  119. int followingUsersCount = UserLocalServiceUtil.getSocialUsersCount(themeDisplay.getUserId(), SocialRelationConstants.TYPE_UNI_FOLLOWER);
  120. %>
  121. <aui:layout cssClass="contacts-count connections">
  122. <a href="javascript:;"><liferay-ui:message arguments="<%= String.valueOf(connectionUsersCount) %>" key="you-have-x-connections" /></a>
  123. </aui:layout>
  124. <aui:layout cssClass="contacts-count followings">
  125. <a href="javascript:;"><liferay-ui:message arguments="<%= String.valueOf(followingUsersCount) %>" key="you-are-following-x-people" /></a>
  126. </aui:layout>
  127. <aui:layout cssClass="contacts-count all">
  128. <a href="javascript:;"><liferay-ui:message arguments="<%= String.valueOf(allUsersCount) %>" key="view-all-x-users" /></a>
  129. </aui:layout>
  130. <c:if test="<%= (connectionUsersCount <= 0) && (followingUsersCount <= 0) %>">
  131. <aui:layout cssClass="contacts-center-introduction">
  132. <liferay-ui:message key="contacts-center-allows-you-to-search-view-and-establish-social-relations-with-other-users" />
  133. </aui:layout>
  134. </c:if>
  135. </aui:layout>
  136. </c:otherwise>
  137. </c:choose>
  138. </aui:column>
  139. </aui:layout>
  140. </aui:form>
  141. <aui:script use="aui-base,aui-io,datatype-number">
  142. Liferay.Contacts.init(
  143. {
  144. contactsResult: '.contacts-portlet .contacts-result-content',
  145. contactsResultContainer: '.contacts-portlet .contacts-result',
  146. contactsResultURL: '<portlet:resourceURL id="getContacts"><portlet:param name="portletResource" value="<%= portletResource %>" /></portlet:resourceURL>',
  147. contactsSearchInput: '#<portlet:namespace />name'
  148. }
  149. );
  150. var searchInput = A.one('.contacts-portlet #<portlet:namespace />name');
  151. <c:if test="<%= !userPublicPage %>">
  152. var contactFilterContainer = A.one('.contacts-portlet .contact-group-filter');
  153. var contactFilterSelect = contactFilterContainer.one('select[name=<portlet:namespace />socialRelationType]');
  154. contactFilterSelect.on(
  155. 'change',
  156. function(event) {
  157. searchInput.set('value', '');
  158. Liferay.Contacts.updateContacts(searchInput.get('value'), contactFilterSelect.get('value'));
  159. }
  160. );
  161. </c:if>
  162. var contactsResult = A.one('.contacts-portlet .contacts-result');
  163. contactsResult.delegate(
  164. 'click',
  165. function(event) {
  166. var uri = event.currentTarget.getAttribute('data-viewSummaryURL');
  167. var contactSummary = A.one('.contacts-portlet .contacts-result-container .contacts-container-content');
  168. if (!contactSummary.io) {
  169. contactSummary.plug(
  170. A.Plugin.IO,
  171. {
  172. autoLoad: false
  173. }
  174. );
  175. }
  176. contactSummary.io.set('uri', uri);
  177. contactSummary.io.start();
  178. },
  179. '.lfr-contact-grid-item'
  180. );
  181. contactsResult.delegate(
  182. 'click',
  183. function(event) {
  184. var start = A.DataType.Number.parse(event.currentTarget.getAttribute('data-end'));
  185. var end = start + <%= maxResultCount %>;
  186. var lastNameAnchor = event.currentTarget.getAttribute('data-lastNameAnchor');
  187. A.io.request(
  188. '<portlet:resourceURL id="getContacts"><portlet:param name="portletResource" value="<%= portletResource %>" /></portlet:resourceURL>',
  189. {
  190. after: {
  191. success: function(event, id, obj) {
  192. Liferay.Contacts.showMoreResult(this.get('responseData'), lastNameAnchor);
  193. }
  194. },
  195. data: {
  196. end: end,
  197. keywords: searchInput.get('value'),
  198. socialRelationType: contactFilterSelect.get('value') || 'all',
  199. start: start
  200. }
  201. }
  202. );
  203. },
  204. '.more-results a'
  205. );
  206. <c:if test="<%= !userPublicPage %>">
  207. var viewConnections = A.one('.contacts-portlet .contacts-center-home .connections');
  208. viewConnections.on(
  209. 'click',
  210. function(event) {
  211. contactFilterSelect.set('value', '<%= SocialRelationConstants.TYPE_BI_CONNECTION %>');
  212. Liferay.Contacts.updateContacts(searchInput.get('value'), contactFilterSelect.get('value'));
  213. },
  214. 'a'
  215. );
  216. var viewFollowings = A.one('.contacts-portlet .contacts-center-home .followings');
  217. viewFollowings.on(
  218. 'click',
  219. function(event) {
  220. contactFilterSelect.set('value', '<%= SocialRelationConstants.TYPE_UNI_FOLLOWER %>');
  221. Liferay.Contacts.updateContacts(searchInput.get('value'), contactFilterSelect.get('value'));
  222. },
  223. 'a'
  224. );
  225. var viewAll = A.one('.contacts-portlet .contacts-center-home .all');
  226. viewAll.on(
  227. 'click',
  228. function(event) {
  229. contactFilterSelect.set('value', 'all');
  230. Liferay.Contacts.updateContacts(searchInput.get('value'), contactFilterSelect.get('value'));
  231. },
  232. 'a'
  233. );
  234. </c:if>
  235. </aui:script>
  236. </c:otherwise>
  237. </c:choose>