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 @@ ...@@ -251,6 +251,9 @@
## Added key: 'httpbind.settings.script.label_enable_info' ## Added key: 'httpbind.settings.script.label_enable_info'
## Added key: 'httpbind.settings.script.label_disable' ## Added key: 'httpbind.settings.script.label_disable'
## Added key: 'httpbind.settings.script.label_disable_info' ## Added key: 'httpbind.settings.script.label_disable_info'
##
## 3.4.3
## Added key: 'setup.ldap.user.vcard.avatardb'
# Openfire # Openfire
...@@ -1632,6 +1635,7 @@ setup.ldap.user.vcard.business=Business ...@@ -1632,6 +1635,7 @@ setup.ldap.user.vcard.business=Business
setup.ldap.user.vcard.title=Job Title setup.ldap.user.vcard.title=Job Title
setup.ldap.user.vcard.department=Department setup.ldap.user.vcard.department=Department
setup.ldap.user.vcard.personal=Personal 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.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. 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 { ...@@ -57,6 +57,7 @@ public class LdapUserProfile {
private String businessMobile = ""; private String businessMobile = "";
private String businessFax = ""; private String businessFax = "";
private String businessPager = ""; private String businessPager = "";
private Boolean avatarStoredInDB = false;
public String getName() { public String getName() {
return name; return name;
...@@ -266,6 +267,19 @@ public class LdapUserProfile { ...@@ -266,6 +267,19 @@ public class LdapUserProfile {
this.businessPager = businessPager; 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. * Sets default mapping values when using an Active Directory server.
*/ */
...@@ -296,6 +310,7 @@ public class LdapUserProfile { ...@@ -296,6 +310,7 @@ public class LdapUserProfile {
businessMobile = "{mobile}"; businessMobile = "{mobile}";
businessFax = "{facsimileTelephoneNumber}"; businessFax = "{facsimileTelephoneNumber}";
businessPager = "{pager}"; businessPager = "{pager}";
avatarStoredInDB = false;
} }
/** /**
...@@ -328,10 +343,11 @@ public class LdapUserProfile { ...@@ -328,10 +343,11 @@ public class LdapUserProfile {
businessMobile = "{mobile}"; businessMobile = "{mobile}";
businessFax = ""; businessFax = "";
businessPager = "{pager}"; businessPager = "{pager}";
avatarStoredInDB = false;
} }
/** /**
* Saves current configuration as XML properties. * Saves current configuration as XML/DB properties.
*/ */
public void saveProperties() { public void saveProperties() {
Element vCard = DocumentHelper.createElement(QName.get("vCard", "vcard-temp")); Element vCard = DocumentHelper.createElement(QName.get("vCard", "vcard-temp"));
...@@ -489,11 +505,14 @@ public class LdapUserProfile { ...@@ -489,11 +505,14 @@ public class LdapUserProfile {
// Save duplicated fields in LdapManager (should be removed in the future) // Save duplicated fields in LdapManager (should be removed in the future)
LdapManager.getInstance().setNameField(name.replaceAll("(\\{)([\\d\\D&&[^}]]+)(})", "$2")); LdapManager.getInstance().setNameField(name.replaceAll("(\\{)([\\d\\D&&[^}]]+)(})", "$2"));
LdapManager.getInstance().setEmailField(email.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 * Returns true if the vCard mappings where successfully loaded from the XML/DB
* property. * properties.
* *
* @return true if mappings where loaded from saved property. * @return true if mappings where loaded from saved property.
*/ */
...@@ -614,6 +633,7 @@ public class LdapUserProfile { ...@@ -614,6 +633,7 @@ public class LdapUserProfile {
businessDepartment = element.elementTextTrim("ORGUNIT"); businessDepartment = element.elementTextTrim("ORGUNIT");
} }
} }
avatarStoredInDB = JiveGlobals.getBooleanProperty("ldap.avatarDBStorage", false);
} }
catch (DocumentException e) { catch (DocumentException e) {
Log.error("Error loading vcard mappings from property", e); Log.error("Error loading vcard mappings from property", e);
......
...@@ -82,6 +82,18 @@ ...@@ -82,6 +82,18 @@
searchFilter = ParamUtils.getParameter(request, "searchFilter"); searchFilter = ParamUtils.getParameter(request, "searchFilter");
// Set the properties to the vCard bean with the user input // Set the properties to the vCard bean with the user input
BeanUtils.setProperties(vcardBean, request); 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. // Save settings and redirect.
if (errors.isEmpty()) { if (errors.isEmpty()) {
...@@ -143,7 +155,7 @@ ...@@ -143,7 +155,7 @@
sb.append("&userIndex=").append(request.getParameter("userIndex")); 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"> <script type="text/javascript">
function loadMsg() { function loadMsg() {
var lb = new lightbox(document.getElementById('lbmessage')); var lb = new lightbox(document.getElementById('lbmessage'));
...@@ -155,7 +167,7 @@ ...@@ -155,7 +167,7 @@
<% } %> <% } %>
<% if (initialSetup) { %> <% 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 --> <!-- BEGIN jive-contentBox_stepbar -->
...@@ -193,7 +205,7 @@ ...@@ -193,7 +205,7 @@
</tr> </tr>
<tr> <tr>
<td align="right"><fmt:message key="setup.ldap.user.username_field" />:</td> <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> </tr>
</table> </table>
...@@ -209,11 +221,11 @@ ...@@ -209,11 +221,11 @@
<table border="0" cellpadding="0" cellspacing="2"> <table border="0" cellpadding="0" cellspacing="2">
<tr> <tr>
<td align="right"><fmt:message key="setup.ldap.user.search_fields" />:</td> <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>
<tr> <tr>
<td align="right"><fmt:message key="setup.ldap.user.user_filter" />:</td> <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> </tr>
</table> </table>
</div> </div>
...@@ -239,7 +251,8 @@ ...@@ -239,7 +251,8 @@
<!-- BEGIN jive-contentBox_greybox --> <!-- BEGIN jive-contentBox_greybox -->
<div class="jive-contentBox_greybox"> <div class="jive-contentBox_greybox">
<strong><fmt:message key="setup.ldap.user.vcard.mapping" /></strong> <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 --> <!-- BEGIN vcard table -->
<table border="0" cellpadding="0" cellspacing="1" class="jive-vcardTable" id="jivevCardTable"> <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