Commit c32604d0 authored by Daniel Henninger's avatar Daniel Henninger Committed by dhenninger

[JM-460] Added support for avatar to be pulled from/stored in local database...

[JM-460] Added support for avatar to be pulled from/stored in local database instead of LDAP.  LDAP wins if an avatar is already present, however.

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@9671 b35dd754-fafc-0310-a699-88a17e54d16e
parent e23e7c15
......@@ -251,6 +251,9 @@
## Added key: 'httpbind.settings.script.label_enable_info'
## Added key: 'httpbind.settings.script.label_disable'
## Added key: 'httpbind.settings.script.label_disable_info'
##
## 3.4.3
## Added key: 'setup.ldap.user.vcard.avatardb'
# Openfire
......@@ -1632,6 +1635,7 @@ setup.ldap.user.vcard.business=Business
setup.ldap.user.vcard.title=Job Title
setup.ldap.user.vcard.department=Department
setup.ldap.user.vcard.personal=Personal
setup.ldap.user.vcard.avatardb=Store avatar in database if not provided by LDAP
setup.ldap.test.error-loading-sample=An error occured while loading sample from LDAP. Check error.log for more information.
setup.ldap.test.internal-server-error=Test page is not able to find required information in HTTP session.
......
......@@ -57,6 +57,7 @@ public class LdapUserProfile {
private String businessMobile = "";
private String businessFax = "";
private String businessPager = "";
private Boolean avatarStoredInDB = false;
public String getName() {
return name;
......@@ -266,6 +267,19 @@ public class LdapUserProfile {
this.businessPager = businessPager;
}
public Boolean getAvatarStoredInDB() {
return avatarStoredInDB;
}
public void setAvatarStoredInDB(Boolean avatarStoredInDB) {
if (avatarStoredInDB == null) {
this.avatarStoredInDB = false;
}
else {
this.avatarStoredInDB = avatarStoredInDB;
}
}
/**
* Sets default mapping values when using an Active Directory server.
*/
......@@ -296,6 +310,7 @@ public class LdapUserProfile {
businessMobile = "{mobile}";
businessFax = "{facsimileTelephoneNumber}";
businessPager = "{pager}";
avatarStoredInDB = false;
}
/**
......@@ -328,10 +343,11 @@ public class LdapUserProfile {
businessMobile = "{mobile}";
businessFax = "";
businessPager = "{pager}";
avatarStoredInDB = false;
}
/**
* Saves current configuration as XML properties.
* Saves current configuration as XML/DB properties.
*/
public void saveProperties() {
Element vCard = DocumentHelper.createElement(QName.get("vCard", "vcard-temp"));
......@@ -489,11 +505,14 @@ public class LdapUserProfile {
// Save duplicated fields in LdapManager (should be removed in the future)
LdapManager.getInstance().setNameField(name.replaceAll("(\\{)([\\d\\D&&[^}]]+)(})", "$2"));
LdapManager.getInstance().setEmailField(email.replaceAll("(\\{)([\\d\\D&&[^}]]+)(})", "$2"));
// Store the DB storage variable in the actual database.
JiveGlobals.setProperty("ldap.avatarDBStorage", avatarStoredInDB.toString());
}
/**
* Returns true if the vCard mappings where successfully loaded from the XML
* property.
* Returns true if the vCard mappings where successfully loaded from the XML/DB
* properties.
*
* @return true if mappings where loaded from saved property.
*/
......@@ -614,6 +633,7 @@ public class LdapUserProfile {
businessDepartment = element.elementTextTrim("ORGUNIT");
}
}
avatarStoredInDB = JiveGlobals.getBooleanProperty("ldap.avatarDBStorage", false);
}
catch (DocumentException e) {
Log.error("Error loading vcard mappings from property", e);
......
......@@ -82,6 +82,18 @@
searchFilter = ParamUtils.getParameter(request, "searchFilter");
// Set the properties to the vCard bean with the user input
BeanUtils.setProperties(vcardBean, request);
if (request.getParameter("storeAvatarInDB") != null) {
vcardBean.setAvatarStoredInDB(true);
}
else {
vcardBean.setAvatarStoredInDB(false);
}
// Store the vcard db setting for later saving.
Map<String,String> xmppSettings = (Map<String,String>)session.getAttribute("xmppSettings");
if (xmppSettings != null) {
xmppSettings.put("ldap.avatarDBStorage", vcardBean.getAvatarStoredInDB().toString());
session.setAttribute("xmppSettings", xmppSettings);
}
// Save settings and redirect.
if (errors.isEmpty()) {
......@@ -143,7 +155,7 @@
sb.append("&userIndex=").append(request.getParameter("userIndex"));
}
%>
<a href="<%= sb.toString()%>" id="lbmessage" title="<fmt:message key="global.test" />" style="display:none;"></a>
<a href="<%= sb.toString()%>" id="lbmessage" title="<fmt:message key="global.test" />" style="display:none;"/>
<script type="text/javascript">
function loadMsg() {
var lb = new lightbox(document.getElementById('lbmessage'));
......@@ -155,7 +167,7 @@
<% } %>
<% if (initialSetup) { %>
<h1><fmt:message key="setup.ldap.profile" />: <span><fmt:message key="setup.ldap.user_mapping" /></h1>
<h1><fmt:message key="setup.ldap.profile" />: <span><fmt:message key="setup.ldap.user_mapping" /></span></h1>
<% } %>
<!-- BEGIN jive-contentBox_stepbar -->
......@@ -193,7 +205,7 @@
</tr>
<tr>
<td align="right"><fmt:message key="setup.ldap.user.username_field" />:</td>
<td><input type="text" name="usernameField" id="jiveLDAPusername" size="22" maxlength="50" value="<%= usernameField!=null?usernameField:""%>"><span class="jive-setup-helpicon" onmouseover="domTT_activate(this, event, 'content', '<fmt:message key="setup.ldap.user.username_field_description" />', 'styleClass', 'jiveTooltip', 'trail', true, 'delay', 300, 'lifetime', -1);"></span></td>
<td><input type="text" name="usernameField" id="jiveLDAPusername" size="22" maxlength="50" value="<%= usernameField!=null?usernameField:""%>"><span class="jive-setup-helpicon" onmouseover="domTT_activate(this, event, 'content', '<fmt:message key="setup.ldap.user.username_field_description" />', 'styleClass', 'jiveTooltip', 'trail', true, 'delay', 300, 'lifetime', -1);"/></td>
</tr>
</table>
......@@ -209,11 +221,11 @@
<table border="0" cellpadding="0" cellspacing="2">
<tr>
<td align="right"><fmt:message key="setup.ldap.user.search_fields" />:</td>
<td><input type="text" name="searchFields" value="<%= searchFields!=null?searchFields:""%>" id="jiveLDAPsearchfields" size="40" maxlength="250"><span class="jive-setup-helpicon" onmouseover="domTT_activate(this, event, 'content', '<fmt:message key="setup.ldap.user.search_fields_description" />', 'styleClass', 'jiveTooltip', 'trail', true, 'delay', 300, 'lifetime', -1);"></span></td>
<td><input type="text" name="searchFields" value="<%= searchFields!=null?searchFields:""%>" id="jiveLDAPsearchfields" size="40" maxlength="250"><span class="jive-setup-helpicon" onmouseover="domTT_activate(this, event, 'content', '<fmt:message key="setup.ldap.user.search_fields_description" />', 'styleClass', 'jiveTooltip', 'trail', true, 'delay', 300, 'lifetime', -1);"/></td>
</tr>
<tr>
<td align="right"><fmt:message key="setup.ldap.user.user_filter" />:</td>
<td><input type="text" name="searchFilter" value="<%= searchFilter!=null?searchFilter:""%>" id="jiveLDAPsearchfilter" size="40" maxlength="250"><span class="jive-setup-helpicon" onmouseover="domTT_activate(this, event, 'content', '<fmt:message key="setup.ldap.user.user_filter_description" />', 'styleClass', 'jiveTooltip', 'trail', true, 'delay', 300, 'lifetime', -1);"></span></td>
<td><input type="text" name="searchFilter" value="<%= searchFilter!=null?searchFilter:""%>" id="jiveLDAPsearchfilter" size="40" maxlength="250"><span class="jive-setup-helpicon" onmouseover="domTT_activate(this, event, 'content', '<fmt:message key="setup.ldap.user.user_filter_description" />', 'styleClass', 'jiveTooltip', 'trail', true, 'delay', 300, 'lifetime', -1);"/></td>
</tr>
</table>
</div>
......@@ -239,7 +251,8 @@
<!-- BEGIN jive-contentBox_greybox -->
<div class="jive-contentBox_greybox">
<strong><fmt:message key="setup.ldap.user.vcard.mapping" /></strong>
<p><fmt:message key="setup.ldap.user.vcard.description" /></p>
<p><fmt:message key="setup.ldap.user.vcard.description" /><br/>
<input type="checkbox" value="enabled" name="storeAvatarInDB"<%= vcardBean.getAvatarStoredInDB() ? " checked" : ""%>/> <fmt:message key="setup.ldap.user.vcard.avatardb" /></p>
<!-- BEGIN vcard table -->
<table border="0" cellpadding="0" cellspacing="1" class="jive-vcardTable" id="jivevCardTable">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment