mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
User Profile additions (for collaboration UI) - various new fields in User Profile screen including use of ajax file picker for Avatar image selection
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@7480 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1286,6 +1286,11 @@ home_space_location=Home Space Location
|
||||
home_space_name=Home Space Name
|
||||
presence_provider=Presence Provider
|
||||
presence_username=Presence Username
|
||||
user_organization=Organization
|
||||
user_jobtitle=Job Title
|
||||
user_location=Location
|
||||
user_description=Biography
|
||||
user_avatar=Photo
|
||||
|
||||
# Trashcan messages
|
||||
title_deleted_items=Deleted Items
|
||||
@@ -1435,6 +1440,7 @@ interface_language=Interface Language
|
||||
content_language_filter=Content Language Filter
|
||||
content_all_languages=All Languages
|
||||
user_management=Management
|
||||
select_avatar_prompt=Click here to select an Avatar image
|
||||
|
||||
# Delete Space Dialog messages
|
||||
select_delete_operation=What do you want to delete?
|
||||
|
@@ -26,11 +26,14 @@ package org.alfresco.web.bean.users;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.bean.dialog.BaseDialogBean;
|
||||
@@ -46,6 +49,7 @@ public class EditUserDetailsDialog extends BaseDialogBean
|
||||
{
|
||||
private Node person;
|
||||
protected UsersBeanProperties properties;
|
||||
private NodeRef photoRef;
|
||||
|
||||
/**
|
||||
* @param properties the properties to set
|
||||
@@ -68,14 +72,42 @@ public class EditUserDetailsDialog extends BaseDialogBean
|
||||
try
|
||||
{
|
||||
Map<QName, Serializable> props = this.nodeService.getProperties(getPerson().getNodeRef());
|
||||
props.put(ContentModel.PROP_FIRSTNAME, getFirstName());
|
||||
props.put(ContentModel.PROP_LASTNAME, getLastName());
|
||||
props.put(ContentModel.PROP_EMAIL, getEmail());
|
||||
//props.put(ContentModel.PROP_FIRSTNAME, getFirstName());
|
||||
//props.put(ContentModel.PROP_LASTNAME, getLastName());
|
||||
//props.put(ContentModel.PROP_EMAIL, getEmail());
|
||||
for (String key : getPerson().getProperties().keySet())
|
||||
{
|
||||
props.put(QName.createQName(key), (Serializable)getPerson().getProperties().get(key));
|
||||
}
|
||||
|
||||
// persist changes
|
||||
this.nodeService.setProperties(getPerson().getNodeRef(), props);
|
||||
// crop person description to 1024 chars as HTML TextArea has no limiter
|
||||
String personDesc = (String)props.get(ContentModel.PROP_PERSONDESC);
|
||||
if (personDesc != null && personDesc.length() > 1024)
|
||||
{
|
||||
personDesc = personDesc.substring(0, 1024);
|
||||
props.put(ContentModel.PROP_PERSONDESC, personDesc);
|
||||
}
|
||||
|
||||
// if the above call was successful, then reset Person Node in the session
|
||||
// persist all property changes
|
||||
NodeRef personRef = getPerson().getNodeRef();
|
||||
this.nodeService.setProperties(personRef, props);
|
||||
|
||||
// setup user avatar association
|
||||
if (this.photoRef != null)
|
||||
{
|
||||
List<AssociationRef> refs = this.nodeService.getTargetAssocs(personRef, ContentModel.ASSOC_AVATAR);
|
||||
// remove old association if it exists
|
||||
if (refs.size() == 1)
|
||||
{
|
||||
NodeRef existingRef = refs.get(0).getTargetRef();
|
||||
this.nodeService.removeAssociation(
|
||||
personRef, existingRef, ContentModel.ASSOC_AVATAR);
|
||||
}
|
||||
// setup new association
|
||||
this.nodeService.createAssociation(personRef, this.photoRef, ContentModel.ASSOC_AVATAR);
|
||||
}
|
||||
|
||||
// if the above calls were successful, then reset Person Node in the session
|
||||
Application.getCurrentUser(context).reset();
|
||||
}
|
||||
catch (Throwable err)
|
||||
@@ -121,4 +153,26 @@ public class EditUserDetailsDialog extends BaseDialogBean
|
||||
person.getProperties().put(ContentModel.PROP_LASTNAME.toString(), lastName);
|
||||
}
|
||||
|
||||
public Map<String, Object> getPersonProperties()
|
||||
{
|
||||
return person.getProperties();
|
||||
}
|
||||
|
||||
public NodeRef getPersonPhotoRef()
|
||||
{
|
||||
if (this.photoRef == null)
|
||||
{
|
||||
List<AssociationRef> refs = this.nodeService.getTargetAssocs(person.getNodeRef(), ContentModel.ASSOC_AVATAR);
|
||||
if (refs.size() == 1)
|
||||
{
|
||||
this.photoRef = refs.get(0).getTargetRef();
|
||||
}
|
||||
}
|
||||
return this.photoRef;
|
||||
}
|
||||
|
||||
public void setPersonPhotoRef(NodeRef ref)
|
||||
{
|
||||
this.photoRef = ref;
|
||||
}
|
||||
}
|
||||
|
@@ -24,13 +24,19 @@
|
||||
*/
|
||||
package org.alfresco.web.bean.users;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.search.SearchService;
|
||||
import org.alfresco.service.cmr.security.AuthenticationService;
|
||||
import org.alfresco.service.cmr.security.PersonService;
|
||||
import org.alfresco.service.cmr.usage.ContentUsageService;
|
||||
import org.alfresco.web.app.servlet.DownloadContentServlet;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
import org.alfresco.web.ui.common.Utils;
|
||||
import org.alfresco.web.ui.common.component.data.UIRichList;
|
||||
|
||||
public class UsersBeanProperties
|
||||
@@ -257,4 +263,26 @@ public class UsersBeanProperties
|
||||
{
|
||||
return this.contentUsageService.getEnabled();
|
||||
}
|
||||
|
||||
public String getPersonDescription()
|
||||
{
|
||||
String desc = (String)this.person.getProperties().get(ContentModel.PROP_PERSONDESC);
|
||||
return desc != null ? Utils.stripUnsafeHTMLTags(desc).replace("\r\n", "<p>") : null;
|
||||
}
|
||||
|
||||
public String getAvatarUrl()
|
||||
{
|
||||
String avatarUrl = null;
|
||||
|
||||
List<AssociationRef> refs = this.nodeService.getTargetAssocs(this.person.getNodeRef(), ContentModel.ASSOC_AVATAR);
|
||||
// remove old association if it exists
|
||||
if (refs.size() == 1)
|
||||
{
|
||||
NodeRef photoRef = refs.get(0).getTargetRef();
|
||||
String name = (String)this.nodeService.getProperty(photoRef, ContentModel.PROP_NAME);
|
||||
avatarUrl = DownloadContentServlet.generateBrowserURL(photoRef, name);
|
||||
}
|
||||
|
||||
return avatarUrl;
|
||||
}
|
||||
}
|
||||
|
@@ -355,7 +355,15 @@ public abstract class BaseAjaxItemPicker extends UIInput
|
||||
ValueBinding vb = getValueBinding("initialSelection");
|
||||
if (vb != null)
|
||||
{
|
||||
this.initialSelectionId = (String)vb.getValue(getFacesContext());
|
||||
Object objSelection = vb.getValue(getFacesContext());
|
||||
if (objSelection instanceof NodeRef)
|
||||
{
|
||||
this.initialSelectionId = ((NodeRef)objSelection).toString();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.initialSelectionId = (String)objSelection;
|
||||
}
|
||||
}
|
||||
|
||||
return this.initialSelectionId;
|
||||
|
@@ -489,6 +489,18 @@ a.topToolbarLinkHighlight, a.topToolbarLinkHighlight:link, a.topToolbarLinkHighl
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.userPropertyLabel
|
||||
{
|
||||
vertical-align: top;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.userPropertyValue
|
||||
{
|
||||
vertical-align: top;
|
||||
padding-right: 16px;
|
||||
}
|
||||
|
||||
.summaryPopupPanel
|
||||
{
|
||||
background-image: url(../images/parts/popup_bg.gif);
|
||||
|
@@ -60,7 +60,7 @@ function updateButtonState()
|
||||
<h:outputText value=" #{msg.person_properties}" escape="false" />
|
||||
</h:panelGrid>
|
||||
|
||||
<h:panelGrid columns="3" cellpadding="2" cellspacing="2" width="100%">
|
||||
<h:panelGrid columns="3" cellpadding="2" cellspacing="2" width="100%" columnClasses=",alignTop,">
|
||||
<h:graphicImage value="/images/icons/required_field.gif" alt="#{msg.required_field}" />
|
||||
<h:outputText value="#{msg.first_name}:"/>
|
||||
<h:inputText id="first-name" value="#{DialogManager.bean.firstName}" size="35" maxlength="1024" onkeyup="updateButtonState();" onchange="updateButtonState();" />
|
||||
@@ -72,6 +72,31 @@ function updateButtonState()
|
||||
<h:graphicImage value="/images/icons/required_field.gif" alt="#{msg.required_field}" />
|
||||
<h:outputText value="#{msg.email}"/>
|
||||
<h:inputText id="email" value="#{DialogManager.bean.email}" size="35" maxlength="1024" onkeyup="updateButtonState();" onchange="updateButtonState();" />
|
||||
|
||||
<f:verbatim/>
|
||||
<h:outputText value="#{msg.user_organization}:"/>
|
||||
<h:inputText id="organsiation" value="#{DialogManager.bean.personProperties.organization}" size="35" maxlength="1024" />
|
||||
|
||||
<f:verbatim/>
|
||||
<h:outputText value="#{msg.user_jobtitle}:"/>
|
||||
<h:inputText id="jobtitle" value="#{DialogManager.bean.personProperties.jobtitle}" size="35" maxlength="1024" />
|
||||
|
||||
<f:verbatim/>
|
||||
<h:outputText value="#{msg.user_location}:"/>
|
||||
<h:inputText id="location" value="#{DialogManager.bean.personProperties.location}" size="35" maxlength="1024" />
|
||||
|
||||
<f:verbatim/>
|
||||
<h:outputText value="#{msg.user_description}:"/>
|
||||
<h:inputTextarea id="biography" value="#{DialogManager.bean.personProperties.persondescription}" rows="6" cols="60" />
|
||||
|
||||
<f:verbatim/>
|
||||
<h:outputText value="#{msg.user_avatar}:"/>
|
||||
<r:ajaxFileSelector id="avatar"
|
||||
value="#{DialogManager.bean.personPhotoRef}"
|
||||
label="#{msg.select_avatar_prompt}"
|
||||
initialSelection="#{DialogManager.bean.personProperties.homeFolder}"
|
||||
styleClass="selector" />
|
||||
|
||||
</h:panelGrid>
|
||||
|
||||
<f:verbatim>
|
||||
|
@@ -41,20 +41,52 @@
|
||||
facetsId="dialog:dialog-body:mydetails-panel-facets" border="white" bgcolor="white"
|
||||
titleBorder="lbgrey" expandedTitleBorder="dotted"
|
||||
titleBgcolor="white">
|
||||
<h:panelGrid columns="2" cellpadding="2" cellspacing="2">
|
||||
<h:outputText value="#{msg.first_name}:" styleClass="propertiesLabel" />
|
||||
<h:outputText value="#{UsersBeanProperties.person.properties.firstName}" />
|
||||
<h:panelGrid columns="2" columnClasses="alignTop,alignTop">
|
||||
<h:panelGrid columns="2" cellpadding="2" cellspacing="2" columnClasses="userPropertyLabel,userPropertyValue">
|
||||
<h:outputText value="#{msg.first_name}:" styleClass="propertiesLabel" />
|
||||
<h:outputText value="#{UsersBeanProperties.person.properties.firstName}" />
|
||||
|
||||
<h:outputText value="#{msg.last_name}:" styleClass="propertiesLabel" />
|
||||
<h:outputText value="#{UsersBeanProperties.person.properties.lastName}" />
|
||||
|
||||
<h:outputText value="#{msg.email}:" styleClass="propertiesLabel" />
|
||||
<h:outputText value="#{UsersBeanProperties.person.properties.email}" />
|
||||
|
||||
<h:outputText value="#{msg.user_description}:" styleClass="propertiesLabel" />
|
||||
<h:panelGroup rendered="#{!empty UsersBeanProperties.personDescription}">
|
||||
<f:verbatim><div style="border: 1px solid #cccccc;padding:4px"></f:verbatim>
|
||||
<h:outputText value="#{UsersBeanProperties.personDescription}" escape="false" />
|
||||
<f:verbatim></div></f:verbatim>
|
||||
</h:panelGroup>
|
||||
</h:panelGrid>
|
||||
|
||||
<h:outputText value="#{msg.last_name}:" styleClass="propertiesLabel" />
|
||||
<h:outputText value="#{UsersBeanProperties.person.properties.lastName}" />
|
||||
|
||||
<h:outputText value="#{msg.email}:" styleClass="propertiesLabel" />
|
||||
<h:outputText value="#{UsersBeanProperties.person.properties.email}" />
|
||||
<h:panelGrid columns="2" cellpadding="2" cellspacing="2" columnClasses="userPropertyLabel,userPropertyValue">
|
||||
<h:outputText value="#{msg.user_organization}:" styleClass="propertiesLabel" />
|
||||
<h:outputText value="#{UsersBeanProperties.person.properties.organization}" />
|
||||
|
||||
<h:outputText value="#{msg.user_jobtitle}:" styleClass="propertiesLabel" />
|
||||
<h:outputText value="#{UsersBeanProperties.person.properties.jobtitle}" />
|
||||
|
||||
<h:outputText value="#{msg.user_location}:" styleClass="propertiesLabel" />
|
||||
<h:outputText value="#{UsersBeanProperties.person.properties.location}" />
|
||||
|
||||
<h:outputText value="#{msg.user_avatar}:" styleClass="propertiesLabel" />
|
||||
<h:panelGroup>
|
||||
<h:panelGroup rendered="#{UsersBeanProperties.avatarUrl == null}">
|
||||
<f:verbatim><div style="border: 2px solid #cccccc;width:120px;height:120px"></f:verbatim>
|
||||
</h:panelGroup>
|
||||
<h:panelGroup rendered="#{UsersBeanProperties.avatarUrl != null}">
|
||||
<f:verbatim><div style="border: 2px solid #cccccc;width:120px;height:auto"></f:verbatim>
|
||||
</h:panelGroup>
|
||||
<h:graphicImage url="#{UsersBeanProperties.avatarUrl}" width="120" rendered="#{UsersBeanProperties.avatarUrl != null}" />
|
||||
<f:verbatim></div></f:verbatim>
|
||||
</h:panelGroup>
|
||||
</h:panelGrid>
|
||||
</h:panelGrid>
|
||||
|
||||
<%-- context for current user is setup on entry to user console --%>
|
||||
<a:actionLink id="change-password" value="#{msg.change_password}"
|
||||
action="dialog:changeMyPassword"
|
||||
action="dialog:changeMyPassword" style="padding-top:6px"
|
||||
image="/images/icons/change_password.gif"
|
||||
rendered="#{NavigationBean.isGuest == false}" />
|
||||
</a:panel>
|
||||
|
Reference in New Issue
Block a user