added hooks for disabling username editing to non admins and removal of suffix and prefix for user details

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portal/liferay62-plugins/social-dockbar-hook@128750 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2016-05-20 14:25:18 +00:00
parent 84ce2abae2
commit b3bc927321
2 changed files with 220 additions and 0 deletions

View File

@ -0,0 +1,186 @@
<%--
/**
* Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
--%>
<%@ include file="/html/portlet/users_admin/init.jsp" %>
<%
User selUser = (User)request.getAttribute("user.selUser");
Contact selContact = (Contact)request.getAttribute("user.selContact");
Calendar birthday = CalendarFactoryUtil.getCalendar();
birthday.set(Calendar.MONTH, Calendar.JANUARY);
birthday.set(Calendar.DATE, 1);
birthday.set(Calendar.YEAR, 1970);
if (selContact != null) {
birthday.setTime(selContact.getBirthday());
}
%>
<liferay-ui:error-marker key="errorSection" value="details" />
<aui:model-context bean="<%= selUser %>" model="<%= User.class %>" />
<h3><liferay-ui:message key="details" /></h3>
<div class="row-fluid">
<aui:fieldset cssClass="span6">
<liferay-ui:success key="verificationEmailSent" message="your-email-verification-code-has-been-sent-and-the-new-email-address-will-be-applied-to-your-account-once-it-has-been-verified" />
<liferay-ui:error exception="<%= DuplicateUserScreenNameException.class %>" focusField="screenName" message="the-screen-name-you-requested-is-already-taken" />
<liferay-ui:error exception="<%= GroupFriendlyURLException.class %>" focusField="screenName">
<%
GroupFriendlyURLException gfurle = (GroupFriendlyURLException)errorException;
%>
<c:if test="<%= gfurle.getType() == GroupFriendlyURLException.DUPLICATE %>">
<liferay-ui:message key="the-screen-name-you-requested-is-associated-with-an-existing-friendly-url" />
</c:if>
</liferay-ui:error>
<liferay-ui:error exception="<%= ReservedUserScreenNameException.class %>" focusField="screenName" message="the-screen-name-you-requested-is-reserved" />
<liferay-ui:error exception="<%= UserFieldException.class %>">
<%
UserFieldException ufe = (UserFieldException)errorException;
StringBundler sb = new StringBundler();
List<String> fields = ufe.getFields();
for (int i = 0; i < fields.size(); i++) {
String field = fields.get(i);
sb.append(LanguageUtil.get(pageContext, TextFormatter.format(field, TextFormatter.K)));
if ((i + 1) < fields.size()) {
sb.append(StringPool.COMMA_AND_SPACE);
}
}
%>
<liferay-ui:message arguments="<%= sb.toString() %>" key="your-portal-administrator-has-disabled-the-ability-to-modify-the-following-fields" />
</liferay-ui:error>
<liferay-ui:error exception="<%= UserScreenNameException.class %>" focusField="screenName" message="please-enter-a-valid-screen-name" />
<c:if test="<%= !PrefsPropsUtil.getBoolean(company.getCompanyId(), PropsKeys.USERS_SCREEN_NAME_ALWAYS_AUTOGENERATE) || (selUser != null) %>">
<c:choose>
<c:when test='<%= PrefsPropsUtil.getBoolean(company.getCompanyId(), PropsKeys.USERS_SCREEN_NAME_ALWAYS_AUTOGENERATE) || !UsersAdminUtil.hasUpdateFieldPermission(permissionChecker, user, selUser, "screenName") %>'>
<aui:input disabled="<%= true %>" name="screenName" />
</c:when>
<c:otherwise>
<% boolean isAdministrator = RoleLocalServiceUtil.hasUserRole(user.getUserId(), user.getCompanyId(), RoleConstants.ADMINISTRATOR, true); %>
<aui:input disabled="<%= ! isAdministrator %>" name="screenName" />
</c:otherwise>
</c:choose>
</c:if>
<liferay-ui:error exception="<%= DuplicateUserEmailAddressException.class %>" focusField="emailAddress" message="the-email-address-you-requested-is-already-taken" />
<liferay-ui:error exception="<%= ReservedUserEmailAddressException.class %>" focusField="emailAddress" message="the-email-address-you-requested-is-reserved" />
<liferay-ui:error exception="<%= UserEmailAddressException.class %>" focusField="emailAddress" message="please-enter-a-valid-email-address" />
<c:choose>
<c:when test='<%= !UsersAdminUtil.hasUpdateFieldPermission(permissionChecker, user, selUser, "emailAddress") %>'>
<aui:input disabled="<%= true %>" name="emailAddress" />
</c:when>
<c:otherwise>
<%
User displayEmailAddressUser = null;
if (selUser != null) {
displayEmailAddressUser = (User)selUser.clone();
displayEmailAddressUser.setEmailAddress(displayEmailAddressUser.getDisplayEmailAddress());
}
%>
<aui:input bean="<%= displayEmailAddressUser %>" model="<%= User.class %>" name="emailAddress">
<c:if test="<%= PrefsPropsUtil.getBoolean(company.getCompanyId(), PropsKeys.USERS_EMAIL_ADDRESS_REQUIRED) %>">
<aui:validator name="required" />
</c:if>
</aui:input>
</c:otherwise>
</c:choose>
<%@ include file="/html/portlet/users_admin/user/details_user_name.jspf" %>
</aui:fieldset>
<aui:fieldset cssClass="span5">
<div>
<c:if test="<%= selUser != null %>">
<c:choose>
<c:when test='<%= UsersAdminUtil.hasUpdateFieldPermission(permissionChecker, user, selUser, "portrait") %>'>
<portlet:renderURL var="editUserPortraitURL" windowState="<%= LiferayWindowState.POP_UP.toString() %>">
<portlet:param name="struts_action" value="/users_admin/edit_user_portrait" />
<portlet:param name="redirect" value="<%= currentURL %>" />
<portlet:param name="p_u_i_d" value="<%= String.valueOf(selUser.getUserId()) %>" />
<portlet:param name="portrait_id" value="<%= String.valueOf(selUser.getPortraitId()) %>" />
</portlet:renderURL>
<liferay-ui:logo-selector
currentLogoURL="<%= selUser.getPortraitURL(themeDisplay) %>"
defaultLogoURL="<%= UserConstants.getPortraitURL(themeDisplay.getPathImage(), selUser.isMale(), 0) %>"
editLogoURL="<%= editUserPortraitURL %>"
imageId="<%= selUser.getPortraitId() %>"
logoDisplaySelector=".user-logo"
/>
</c:when>
<c:otherwise>
<img alt="<liferay-ui:message key="portrait" />" src="<%= selUser.getPortraitURL(themeDisplay) %>" />
</c:otherwise>
</c:choose>
</c:if>
</div>
<c:if test="<%= selUser != null %>">
<liferay-ui:error exception="<%= DuplicateUserIdException.class %>" message="the-user-id-you-requested-is-already-taken" />
<liferay-ui:error exception="<%= ReservedUserIdException.class %>" message="the-user-id-you-requested-is-reserved" />
<liferay-ui:error exception="<%= UserIdException.class %>" message="please-enter-a-valid-user-id" />
<aui:input name="userId" type="resource" value="<%= String.valueOf(selUser.getUserId()) %>" />
</c:if>
<c:choose>
<c:when test="<%= PrefsPropsUtil.getBoolean(company.getCompanyId(), PropsKeys.FIELD_ENABLE_COM_LIFERAY_PORTAL_MODEL_CONTACT_BIRTHDAY) %>">
<liferay-ui:error exception="<%= ContactBirthdayException.class %>" message="please-enter-a-valid-date" />
<aui:input bean="<%= selContact %>" cssClass="modify-link" disabled='<%= !UsersAdminUtil.hasUpdateFieldPermission(permissionChecker, user, selUser, "birthday") %>' model="<%= Contact.class %>" name="birthday" value="<%= birthday %>" />
</c:when>
<c:otherwise>
<aui:input name="birthdayMonth" type="hidden" value="<%= Calendar.JANUARY %>" />
<aui:input name="birthdayDay" type="hidden" value="1" />
<aui:input name="birthdayYear" type="hidden" value="1970" />
</c:otherwise>
</c:choose>
<c:if test="<%= PrefsPropsUtil.getBoolean(company.getCompanyId(), PropsKeys.FIELD_ENABLE_COM_LIFERAY_PORTAL_MODEL_CONTACT_MALE) %>">
<aui:select bean="<%= selContact %>" disabled='<%= !UsersAdminUtil.hasUpdateFieldPermission(permissionChecker, user, selUser, "gender") %>' label="gender" model="<%= Contact.class %>" name="male">
<aui:option label="male" value="true" />
<aui:option label="female" value="false" />
</aui:select>
</c:if>
<aui:input disabled='<%= !UsersAdminUtil.hasUpdateFieldPermission(permissionChecker, user, selUser, "jobTitle") %>' name="jobTitle" />
</aui:fieldset>
</div>

View File

@ -0,0 +1,34 @@
<%--
/**
* Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
--%>
<%-- <aui:select bean="<%= selContact %>" disabled='<%= !UsersAdminUtil.hasUpdateFieldPermission(permissionChecker, user, selUser, "prefix") %>' label="title[person]" listType="<%= ListTypeConstants.CONTACT_PREFIX %>" listTypeFieldName="prefixId" model="<%= Contact.class %>" name="prefixId" showEmptyOption="<%= true %>" /> --%>
<liferay-ui:error exception="<%= ContactFirstNameException.class %>" message="please-enter-a-valid-first-name" />
<liferay-ui:error exception="<%= ContactFullNameException.class %>" message="please-enter-a-valid-first-middle-and-last-name" />
<aui:input disabled='<%= !UsersAdminUtil.hasUpdateFieldPermission(permissionChecker, user, selUser, "firstName") %>' name="firstName" />
<aui:input disabled='<%= !UsersAdminUtil.hasUpdateFieldPermission(permissionChecker, user, selUser, "middleName") %>' name="middleName" />
<liferay-ui:error exception="<%= ContactLastNameException.class %>" message="please-enter-a-valid-last-name" />
<aui:input disabled='<%= !UsersAdminUtil.hasUpdateFieldPermission(permissionChecker, user, selUser, "lastName") %>' name="lastName">
<c:if test="<%= PrefsPropsUtil.getBoolean(company.getCompanyId(), PropsKeys.USERS_LAST_NAME_REQUIRED, PropsValues.USERS_LAST_NAME_REQUIRED) %>">
<aui:validator name="required" />
</c:if>
</aui:input>
<%-- <aui:select bean="<%= selContact %>" disabled='<%= !UsersAdminUtil.hasUpdateFieldPermission(permissionChecker, user, selUser, "suffix") %>' label="suffix" listType="<%= ListTypeConstants.CONTACT_SUFFIX %>" listTypeFieldName="suffixId" model="<%= Contact.class %>" name="suffixId" showEmptyOption="<%= true %>" /> --%>