diff --git a/pyweb/mumble/media/js/channelviewerplugins.js b/pyweb/mumble/media/js/channelviewerplugins.js index 6c674bd..74cb04d 100644 --- a/pyweb/mumble/media/js/channelviewerplugins.js +++ b/pyweb/mumble/media/js/channelviewerplugins.js @@ -37,14 +37,30 @@ Ext.ux.MumbleUserEditor = Ext.extend( Ext.Component, { }], }, { title: gettext("Avatar"), - html: '', + scope: this, + listeners: { + afterrender: function( panel ){ + Mumble.hasTexture( this.scope.serverid, this.scope.userdata.userid, function(provider, response){ + if( response.result.has ){ + panel.el.dom.children[0].children[0].innerHTML = String.format( + 'avatar', response.result.url + ); + } + else{ + panel.el.dom.children[0].children[0].innerHTML = + gettext("This user does not have an Avatar."); + } + } ); + } + }, + html: gettext("Loading..."), }, { title: gettext("Infos"), html: "", }, { xtype: "form", border: false, - title: gettext("Kick/Ban"), + title: gettext("Administration"), items: [{ xtype: "checkbox", fieldLabel: gettext("Ban"), @@ -72,6 +88,28 @@ Ext.ux.MumbleUserEditor = Ext.extend( Ext.Component, { this.serverid, this.userdata.session, f.reason, (f.ban || false), parseInt(f.duration) ); } + }, { + text: gettext("Mute"), + enableToggle: true, + scope: this, + ref: '../mutebutton', + pressed: this.userdata.mute, + disabled: this.userdata.deaf, + toggleHandler: function(btn, state){ + Mumble.muteUser(this.serverid, this.userdata.session, state); + } + }, { + text: gettext("Deafen"), + enableToggle: true, + scope: this, + ref: '../deafenbutton', + pressed: this.userdata.deaf, + toggleHandler: function(btn, state){ + Mumble.deafenUser(this.serverid, this.userdata.session, state); + if( state ) + btn.refOwner.mutebutton.toggle(true, true); + btn.refOwner.mutebutton.setDisabled(state); + } }], }], }], diff --git a/pyweb/mumble/mmobjects.py b/pyweb/mumble/mmobjects.py index 53d584f..ca51553 100644 --- a/pyweb/mumble/mmobjects.py +++ b/pyweb/mumble/mmobjects.py @@ -310,8 +310,14 @@ class mmPlayer( object ): else: del pldata["address"] - if self.mumbleuser and self.mumbleuser.hasTexture(): - pldata['x_texture'] = "http://" + Site.objects.get_current().domain + self.mumbleuser.textureUrl + if self.channel.server.hasUserTexture(self.userid): + from views import showTexture + from django.core.urlresolvers import reverse + textureurl = reverse( showTexture, kwargs={ 'server': self.channel.server.id, 'userid': self.userid } ) + pldata['x_texture'] = "http://" + Site.objects.get_current().domain + textureUrl + + if self.mumbleuser and self.mumbleuser.gravatar: + pldata['x_gravatar'] = self.mumbleuser.gravatar return pldata @@ -325,8 +331,14 @@ class mmPlayer( object ): else: me.set( "address", "" ) - if self.mumbleuser and self.mumbleuser.hasTexture(): - me.set( 'x_texture', "http://" + Site.objects.get_current().domain + self.mumbleuser.textureUrl ) + if self.channel.server.hasUserTexture(self.userid): + from views import showTexture + from django.core.urlresolvers import reverse + textureurl = reverse( showTexture, kwargs={ 'server': self.channel.server.id, 'userid': self.userid } ) + me.set( 'x_texture', "http://" + Site.objects.get_current().domain + textureUrl ) + + if self.mumbleuser and self.mumbleuser.gravatar: + me.set( 'x_gravatar', self.mumbleuser.gravatar ) def asMvXml( self, parentnode ): """ Return an XML node for this player suitable for MumbleViewer-ng. """ diff --git a/pyweb/mumble/models.py b/pyweb/mumble/models.py index 6aed3f8..c1d1e74 100644 --- a/pyweb/mumble/models.py +++ b/pyweb/mumble/models.py @@ -567,7 +567,22 @@ class Mumble( models.Model ): return self.ctl.muteUser( self.srvid, sessionid, mute ) def deafenUser( self, sessionid, deafen=True ): - return self.ctl.moveUser( self.srvid, sessionid, deafen ) + return self.ctl.deafenUser( self.srvid, sessionid, deafen ) + + def hasUserTexture( self, userid ): + """ Check if this user has a texture set. """ + try: + self.getUserTexture( userid ) + except ValueError: + return False + else: + return True + + def getUserTexture( self, userid ): + return self.ctl.getTexture( self.srvid, userid ) + + def setUserTexture( self, userid, image ): + return self.ctl.setTexture( self.srvid, userid, image ) def moveChannel( self, channelid, parentid ): return self.ctl.moveChannel( self.srvid, channelid, parentid ) @@ -713,11 +728,11 @@ class MumbleUser( models.Model ): # Texture handlers def getTexture( self ): """ Get the user texture as a PIL Image. """ - return self.server.ctl.getTexture(self.server.srvid, self.mumbleid) + return self.server.getUserTexture( self.mumbleid ) def setTexture( self, image ): """ Install the given image as the user's texture. """ - self.server.ctl.setTexture(self.server.srvid, self.mumbleid, image) + self.server.setTexture( self.mumbleid, image ) def setTextureFromUrl( self, url, transparency=None ): """ Retrieve the image at the given URL and set it as my texture. """ @@ -730,12 +745,7 @@ class MumbleUser( models.Model ): def hasTexture( self ): """ Check if this user has a texture set. """ - try: - self.getTexture() - except ValueError: - return False - else: - return True + return self.server.hasUserTexture( self.mumbleid ) def gravatarUrl( self, size=80 ): """ Get a Gravatar URL for my owner's email adress (if any), or using the User's cert hash. diff --git a/pyweb/mumble/views.py b/pyweb/mumble/views.py index 6c0176b..ad4c762 100644 --- a/pyweb/mumble/views.py +++ b/pyweb/mumble/views.py @@ -204,18 +204,24 @@ def mobile_show( request, server ): 'MumbleAccount':user, }, context_instance = RequestContext(request) ) +@EXT_DIRECT_PROVIDER.register_method( "Mumble" ) +def hasTexture( request, server, userid ): + srv = get_object_or_404( Mumble, id=int(server) ) + if srv.hasUserTexture(int(userid)): + return { + 'has': True, + 'url': reverse( showTexture, kwargs={ 'server': server, 'userid': userid } ) + } + else: + return { 'has': False, 'url': None } def showTexture( request, server, userid ): - """ Pack the given user's texture into an HttpResponse. - - If userid is none, use the currently logged in User. - """ + """ Pack the given user's texture into an HttpResponse. """ srv = get_object_or_404( Mumble, id=int(server) ) - user = get_object_or_404( MumbleUser, server=srv, id=int(userid) ) try: - img = user.getTexture() + img = srv.getUserTexture(int(userid)) except ValueError: raise Http404() else: @@ -280,6 +286,20 @@ def kickUser( request, server, sessionid, reason, ban, duration ): srv.banUser( sessionid, reason, duration ) srv.kickUser( sessionid, reason ) +@EXT_DIRECT_PROVIDER.register_method( "Mumble" ) +def muteUser( request, server, sessionid, mute ): + srv = get_object_or_404( Mumble, id=int(server) ) + if not srv.isUserAdmin( request.user ): + raise Exception( 'Access denied' ) + srv.muteUser(sessionid, mute) + +@EXT_DIRECT_PROVIDER.register_method( "Mumble" ) +def deafenUser( request, server, sessionid, deaf ): + srv = get_object_or_404( Mumble, id=int(server) ) + if not srv.isUserAdmin( request.user ): + raise Exception( 'Access denied' ) + srv.deafenUser(sessionid, deaf) + @EXT_DIRECT_PROVIDER.register_method( "MumbleUserAdmin" ) def users( request, server ): """ Create a list of MumbleUsers for a given server serialized as a JSON object.