diff --git a/management/univention-management-console-module-udm/umc/js/udm/TileView.js b/management/univention-management-console-module-udm/umc/js/udm/TileView.js
index 1cb55b8970..909e3d2227 100644
--- a/management/univention-management-console-module-udm/umc/js/udm/TileView.js
+++ b/management/univention-management-console-module-udm/umc/js/udm/TileView.js
@@ -26,7 +26,7 @@
* /usr/share/common-licenses/AGPL-3; if not, see
* .
*/
-/*global define, window*/
+/*global define*/
define([
"dojo/_base/declare",
@@ -42,34 +42,13 @@ define([
necessaryUdmValues: ["displayName", "mailPrimaryAddress", "firstname", "lastname"],
- _queryTimer: null,
-
- _queryCache: null,
-
_userImageNodes: {},
grid: null,
setPicture: function(item) {
- if (this._queryTimer) {
- this.grid.moduleStore.get(item.$dn$);
- } else {
- this._queryCache = this.grid.moduleStore.transaction();
- this._queryTimer = window.setTimeout(lang.hitch(this, "_setPictures"), 100);
- this.grid.moduleStore.get(item.$dn$);
- }
- },
-
- _setPictures: function() {
- this._queryTimer = null;
- this._queryCache.commit().then(lang.hitch(this, function(data) {
- array.forEach(data, function(item){
- if (item.jpegPhoto) {
- //put(this._userImageNodes[item.$dn$], "+img.umcGridTileIcon[src=data:image/jpeg;base64," + item.jpegPhoto + "]");
- put(this._userImageNodes[item.$dn$], "+div.umcGridTileIcon[style=background-image: url(data:image/jpeg;base64," + item.jpegPhoto + ")]");
- }
- }, this);
- }));
+ var url = lang.replace('/univention/command/udm/properties/users/user/jpegPhoto.jpg?dn={0}', [encodeURIComponent(item.$dn$)]);
+ put(this._userImageNodes[item.$dn$], {style: lang.replace('background-image: url("{0}")', [url])});
},
_getInitials: function(item) {
diff --git a/management/univention-management-console-module-udm/umc/python/udm/__init__.py b/management/univention-management-console-module-udm/umc/python/udm/__init__.py
index 87bd11ab55..647c933128 100644
--- a/management/univention-management-console-module-udm/umc/python/udm/__init__.py
+++ b/management/univention-management-console-module-udm/umc/python/udm/__init__.py
@@ -544,6 +544,31 @@ class Instance(Base, ProgressMixin):
MODULE.process('The LDAP object for the LDAP DN %s could not be found' % ldap_dn)
return result
+ @allow_get_request
+ @sanitize(dn=DNSanitizer(required=True))
+ def jpeg_photo(self, request):
+ thread = notifier.threads.Simple('GetJpeg', notifier.Callback(self._get_jpeg_photo, request), notifier.Callback(self.thread_finished_callback, request))
+ thread.run()
+
+ def _get_jpeg_photo(self, request):
+ dn = request.options['dn']
+ module = get_module('users/user', dn)
+ if module is None:
+ self.finished(request.id, '', mimetype='image/jpeg')
+ return
+ obj = module.get(dn)
+ if obj is None:
+ self.finished(request.id, '', mimetype='image/jpeg')
+ return
+ data = obj.info.get('jpegPhoto', '').decode('base64') # TODO: scale down to 50x50px
+ headers = {
+ # 'Last-Modified': obj.info['modifyTimestamp'] # TODO: enable for users/user
+ # 'ETag': '' : TODO generate
+ 'Cache-Control': 'max-age=2592000',
+ #'Expires': '',
+ }
+ self.finished(request.id, data, mimetype='image/jpeg', headers=headers)
+
@sanitize(
objectPropertyValue=PropertySearchSanitizer(
add_asterisks=ADD_ASTERISKS,
diff --git a/management/univention-management-console-module-udm/umc/udm.xml b/management/univention-management-console-module-udm/umc/udm.xml
index 4556fbc299..7a2bb45d5e 100644
--- a/management/univention-management-console-module-udm/umc/udm.xml
+++ b/management/univention-management-console-module-udm/umc/udm.xml
@@ -317,5 +317,6 @@
+