From 26bed15085a02b3af1ea0abd1d4b789831e47c13 Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Tue, 15 Apr 2014 14:06:44 +0200 Subject: [PATCH] UI permission fixes noticed when merging #457 --- js/addressbooks.js | 8 +++++++- js/contacts.js | 19 +++++++++++-------- templates/contacts.php | 2 +- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/js/addressbooks.js b/js/addressbooks.js index f3840227..71342c7f 100644 --- a/js/addressbooks.js +++ b/js/addressbooks.js @@ -29,6 +29,12 @@ OC.Contacts = OC.Contacts || {}; if(!this.hasPermission(OC.PERMISSION_UPDATE)) { this.$li.find('a.action.edit').hide(); } + if(!this.hasPermission(OC.PERMISSION_SHARE)) { + this.$li.find('a.action.share').hide(); + } + if(['local', 'ldap'].indexOf(this.getBackend() === -1)) { + this.$li.find('a.action.carddav').hide(); + } this.$li.find('input:checkbox').prop('checked', this.book.active).on('change', function() { console.log('activate', self.getId()); var checkbox = $(this).get(0); @@ -53,7 +59,7 @@ OC.Contacts = OC.Contacts || {}; console.log('delete', self.getId()); self.destroy(); }); - this.$li.find('a.action.globe').on('click keypress', function() { + this.$li.find('a.action.carddav').on('click keypress', function() { var uri = (self.book.owner === oc_current_user ) ? self.book.uri : self.book.uri + '_shared_by_' + self.book.owner; var link = OC.linkToRemote('carddav')+'/addressbooks/'+encodeURIComponent(oc_current_user)+'/'+encodeURIComponent(uri); var $dropdown = $('
  • ') diff --git a/js/contacts.js b/js/contacts.js index 8306745b..044c9e7d 100644 --- a/js/contacts.js +++ b/js/contacts.js @@ -1488,15 +1488,18 @@ OC.Contacts = OC.Contacts || {}; } } }); - if(this.metadata.owner !== OC.currentUser - && !(this.hasPermission(OC.PERMISSION_UPDATE) - || this.hasPermission(OC.PERMISSION_DELETE))) { - this.setEnabled(false); - this.showActions(['close', 'export']); - } else { - this.setEnabled(true); - this.showActions(['close', 'add', 'export', 'delete']); + var actions = ['close', 'export']; + if(this.hasPermission(OC.PERMISSION_DELETE)) { + actions.push('delete'); } + if(this.hasPermission(OC.PERMISSION_UPDATE)) { + actions.push('add'); + this.setEnabled(true); + } else { + this.setEnabled(false); + } + this.showActions(actions); + return this.$fullelem; }; diff --git a/templates/contacts.php b/templates/contacts.php index 74f63911..c06e6440 100644 --- a/templates/contacts.php +++ b/templates/contacts.php @@ -501,7 +501,7 @@ use OCA\Contacts\ImportManager; - +