Fixes #3454 - No indication in ticket sidebar when a subscribed user no longer has access to a ticket.
This commit is contained in:
parent
89c3a5e9c9
commit
beee44522b
4 changed files with 41 additions and 19 deletions
|
@ -43,6 +43,7 @@ class App.WidgetMention extends App.Controller
|
||||||
|
|
||||||
user = App.User.find(mention.user_id)
|
user = App.User.find(mention.user_id)
|
||||||
continue if !user
|
continue if !user
|
||||||
|
continue if !user.active
|
||||||
|
|
||||||
if mention.user_id is App.Session.get().id
|
if mention.user_id is App.Session.get().id
|
||||||
subscribed = true
|
subscribed = true
|
||||||
|
@ -50,7 +51,13 @@ class App.WidgetMention extends App.Controller
|
||||||
# no break because we need to check if user is subscribed
|
# no break because we need to check if user is subscribed
|
||||||
continue if counter > 10
|
continue if counter > 10
|
||||||
|
|
||||||
mention.avatar = user.avatar('30', '', '')
|
css = ''
|
||||||
|
mention.access = true
|
||||||
|
if !@object.isAccessibleBy(user, 'read')
|
||||||
|
css = 'avatar--inactive'
|
||||||
|
mention.access = false
|
||||||
|
|
||||||
|
mention.avatar = user.avatar('30', '', css)
|
||||||
|
|
||||||
mentions.push(mention)
|
mentions.push(mention)
|
||||||
counter++
|
counter++
|
||||||
|
|
|
@ -324,7 +324,31 @@ class App.Ticket extends App.Model
|
||||||
return @userGroupAccess(permission)
|
return @userGroupAccess(permission)
|
||||||
|
|
||||||
userGroupAccess: (permission) ->
|
userGroupAccess: (permission) ->
|
||||||
user = App.User.current()
|
user = App.User.current()
|
||||||
|
return @isAccessibleByGroup(user, permission)
|
||||||
|
|
||||||
|
userIsCustomer: ->
|
||||||
|
user = App.User.current()
|
||||||
|
return true if user.id is @customer_id
|
||||||
|
false
|
||||||
|
|
||||||
|
userIsOwner: ->
|
||||||
|
user = App.User.current()
|
||||||
|
return @isAccessibleByOwner(user)
|
||||||
|
|
||||||
|
currentView: ->
|
||||||
|
return 'agent' if App.User.current()?.permission('ticket.agent') && @userGroupAccess('read')
|
||||||
|
return 'customer' if App.User.current()?.permission('ticket.customer')
|
||||||
|
return
|
||||||
|
|
||||||
|
isAccessibleByOwner: (user) ->
|
||||||
|
return false if !user
|
||||||
|
return true if user.id is @owner_id
|
||||||
|
false
|
||||||
|
|
||||||
|
isAccessibleByGroup: (user, permission) ->
|
||||||
|
return false if !user
|
||||||
|
|
||||||
group_ids = user.allGroupIds(permission)
|
group_ids = user.allGroupIds(permission)
|
||||||
return false if !@group_id
|
return false if !@group_id
|
||||||
|
|
||||||
|
@ -334,17 +358,8 @@ class App.Ticket extends App.Model
|
||||||
|
|
||||||
return false
|
return false
|
||||||
|
|
||||||
userIsCustomer: ->
|
isAccessibleBy: (user, permission) ->
|
||||||
user = App.User.current()
|
return false if !user
|
||||||
return true if user.id is @customer_id
|
return false if !user.permission('ticket.agent')
|
||||||
false
|
return true if @isAccessibleByOwner(user)
|
||||||
|
return @isAccessibleByGroup(user, permission)
|
||||||
userIsOwner: ->
|
|
||||||
user = App.User.current()
|
|
||||||
return true if user.id is @owner_id
|
|
||||||
false
|
|
||||||
|
|
||||||
currentView: ->
|
|
||||||
return 'agent' if App.User.current()?.permission('ticket.agent') && @userGroupAccess('read')
|
|
||||||
return 'customer' if App.User.current()?.permission('ticket.customer')
|
|
||||||
return
|
|
||||||
|
|
|
@ -269,13 +269,13 @@ class App.User extends App.Model
|
||||||
###
|
###
|
||||||
allGroupIds: (permission = 'full') ->
|
allGroupIds: (permission = 'full') ->
|
||||||
group_ids = []
|
group_ids = []
|
||||||
user_group_ids = App.Session.get('group_ids')
|
user_group_ids = @group_ids
|
||||||
if user_group_ids
|
if user_group_ids
|
||||||
for local_group_id, local_permission of user_group_ids
|
for local_group_id, local_permission of user_group_ids
|
||||||
if _.include(local_permission, permission) || _.include(local_permission, 'full')
|
if _.include(local_permission, permission) || _.include(local_permission, 'full')
|
||||||
group_ids.push local_group_id
|
group_ids.push local_group_id
|
||||||
|
|
||||||
user_role_ids = App.Session.get('role_ids')
|
user_role_ids = @role_ids
|
||||||
if user_role_ids
|
if user_role_ids
|
||||||
for role_id in user_role_ids
|
for role_id in user_role_ids
|
||||||
if App.Role.exists(role_id)
|
if App.Role.exists(role_id)
|
||||||
|
|
|
@ -9,6 +9,6 @@
|
||||||
</form>
|
</form>
|
||||||
<div class="controls-label">
|
<div class="controls-label">
|
||||||
<% for mention in @mentions: %>
|
<% for mention in @mentions: %>
|
||||||
<a href="#user/profile/<%= mention.user_id %>"><%- mention.avatar %></a>
|
<a href="#user/profile/<%= mention.user_id %>"<% if !mention.access: %> title="<%- @T('User has no access and will not recieve notifications.') %>"<% end %>><%- mention.avatar %></a>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue