--- a/management/univention-management-console-module-udm/conffiles/etc/apache2/sites-available/univention-directory-manager.conf +++ a/management/univention-management-console-module-udm/conffiles/etc/apache2/sites-available/univention-directory-manager.conf @@ -3,3 +3,5 @@ Options -Indexes + +RewriteRule /univention/management/command/udm/(users/users)/(.*)/image /univention/management/command/udm/image?flavor=$1&dn=$2 --- a/management/univention-management-console-module-udm/umc/js/udm.js +++ a/management/univention-management-console-module-udm/umc/js/udm.js @@ -741,7 +741,7 @@ define([ var additionalGridViews = {}; if (this.moduleFlavor === 'users/user') { - additionalGridViews = {tile: new TileView()}; + additionalGridViews = {tile: new TileView({moduleFlavor: this.moduleFlavor})}; } // generate the data grid --- a/management/univention-management-console-module-udm/umc/js/udm/TileView.js +++ a/management/univention-management-console-module-udm/umc/js/udm/TileView.js @@ -26,15 +26,16 @@ * /usr/share/common-licenses/AGPL-3; if not, see * . */ -/*global define, window*/ +/*global define*/ define([ "dojo/_base/declare", "dojo/_base/array", "dojo/_base/lang", + "dojo/io-query", "dojo/on", "put-selector/put", -], function(declare, array, lang, on, put) { +], function(declare, array, lang, ioQuery, on, put) { return declare("umc.module.udm.TileView", [], { @@ -43,6 +44,7 @@ define([ necessaryUdmValues: ["displayName", "mailPrimaryAddress", "firstname", "lastname"], _queryTimer: null, + moduleFlavor: null, _queryCache: null, @@ -50,28 +52,6 @@ define([ 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); - })); - }, - _getInitials: function(item) { var initials = ""; // FIXME: item.firstname[0] is not unicode save! @@ -115,10 +95,10 @@ define([ } this._userImageNodes[item.$dn$] = put(div, "div.umcGridTileIcon", this._getInitials(item)); var nameNode = put(div, 'div.umcGridTileName', item.name); - this.setPicture(item); + var idProperty = this.grid.moduleStore.idProperty; + put(put(div, '+div.umcGridTileIcon'), 'img[src=/univention/management/command/udm/' + encodeURIComponent(this.moduleFlavor) + '/' + encodeURIComponent(idProperty) + '/image'); put(div, this._getDescription(item)); var defaultAction = this.grid._getDefaultActionForItem(item); - var idProperty = this.grid.moduleStore.idProperty; on(nameNode, 'click', lang.hitch(this, function() { defaultAction.callback([item[idProperty]], [item]); })); --- a/management/univention-management-console-module-udm/umc/python/udm/__init__.py +++ a/management/univention-management-console-module-udm/umc/python/udm/__init__.py @@ -48,7 +48,7 @@ from univention.lib.i18n import Translation from univention.management.console.config import ucr from univention.management.console.modules import Base, UMC_OptionTypeError, UMC_OptionMissing, UMC_CommandError, UMC_Error -from univention.management.console.modules.decorators import simple_response, sanitize, multi_response, prevent_xsrf_check +from univention.management.console.modules.decorators import simple_response, sanitize, multi_response, prevent_xsrf_check, allow_get_request from univention.management.console.modules.sanitizers import ( Sanitizer, LDAPSearchSanitizer, EmailSanitizer, ChoicesSanitizer, ListSanitizer, StringSanitizer, DictSanitizer, BooleanSanitizer @@ -495,6 +495,23 @@ def _thread(request): thread = notifier.threads.Simple('Get', notifier.Callback(_thread, request), notifier.Callback(self.thread_finished_callback, request)) thread.run() + @allow_get_request + @sanitize(dn=StringSanitizer(required=True)) + def image(self, request): + def _thread(request): + ldap_dn = request.options['dn'] + if request.flavor == 'users/self': + ldap_dn = self._user_dn + module = get_module(request.flavor, ldap_dn) + if module is None: + raise ObjectDoesNotExist(ldap_dn) + obj = module.get(ldap_dn) + if not obj: + raise UMC_Error() + self.finished(request.id, obj.info.get('jpegPhoto'), mimetype='image/jpeg', headers={'Cache-Control': '', 'Expires': 'Tue, 15 Nov 3020 12:45:26 GMT'}) + thread = notifier.threads.Simple('Get', notifier.Callback(_thread, request), notifier.Callback(self.thread_finished_callback, request)) + thread.run() + @sanitize( objectPropertyValue=LDAPSearchSanitizer( add_asterisks=ADD_ASTERISKS, --- a/management/univention-management-console-module-udm/umc/udm.xml +++ a/management/univention-management-console-module-udm/umc/udm.xml @@ -116,6 +116,7 @@ +