diff --git a/ajax/contact/details.php b/ajax/contact/details.php index f3090fe0..b2198cdb 100644 --- a/ajax/contact/details.php +++ b/ajax/contact/details.php @@ -55,10 +55,9 @@ if(!$lastmodified) { $lastmodified = new DateTime(); } -$permissions = OCP\Share::PERMISSION_CREATE | OCP\Share::PERMISSION_READ - | OCP\Share::PERMISSION_UPDATE | OCP\Share::PERMISSION_DELETE - | OCP\Share::PERMISSION_SHARE; -$addressbook = OCA\Contacts\Addressbook::find($card['addressbookid']); +$permissions = OCP\PERMISSION_ALL; +$addressbook = OC_Contacts_Addressbook::find($card['addressbookid']); + if ($addressbook['userid'] != OCP\User::getUser()) { $sharedAddressbook = OCP\Share::getItemSharedWithBySource('addressbook', $card['addressbookid']); if($sharedAddressbook) { diff --git a/lib/addressbook.php b/lib/addressbook.php index e4271d9a..8fb28879 100644 --- a/lib/addressbook.php +++ b/lib/addressbook.php @@ -70,9 +70,7 @@ class Addressbook { $addressbooks = array(); while( $row = $result->fetchRow()) { - $row['permissions'] = \OCP\Share::PERMISSION_CREATE - | \OCP\Share::PERMISSION_READ | \OCP\Share::PERMISSION_UPDATE - | \OCP\Share::PERMISSION_DELETE | \OCP\Share::PERMISSION_SHARE; + $row['permissions'] = \OCP\PERMISSION_ALL; $addressbooks[] = $row; } @@ -145,9 +143,10 @@ class Addressbook { return false; } $row = $result->fetchRow(); + if($row['userid'] != \OCP\USER::getUser() && !\OC_Group::inGroup(\OCP\User::getUser(), 'admin')) { $sharedAddressbook = \OCP\Share::getItemSharedWithBySource('addressbook', $id); - if (!$sharedAddressbook || !($sharedAddressbook['permissions'] & \OCP\Share::PERMISSION_READ)) { + if (!$sharedAddressbook || !($sharedAddressbook['permissions'] & \OCP\PERMISSION_READ)) { throw new Exception( App::$l10n->t( 'You do not have the permissions to read this addressbook.' @@ -156,9 +155,7 @@ class Addressbook { } $row['permissions'] = $sharedAddressbook['permissions']; } else { - $row['permissions'] = \OCP\Share::PERMISSION_CREATE - | \OCP\Share::PERMISSION_READ | \OCP\Share::PERMISSION_UPDATE - | \OCP\Share::PERMISSION_DELETE | \OCP\Share::PERMISSION_SHARE; + $row['permissions'] = OCP\PERMISSION_ALL; } return $row; } @@ -261,7 +258,7 @@ class Addressbook { $addressbook = self::find($id); if ($addressbook['userid'] != \OCP\User::getUser() && !\OC_Group::inGroup(OCP\User::getUser(), 'admin')) { $sharedAddressbook = \OCP\Share::getItemSharedWithBySource('addressbook', $id); - if (!$sharedAddressbook || !($sharedAddressbook['permissions'] & \OCP\Share::PERMISSION_UPDATE)) { + if (!$sharedAddressbook || !($sharedAddressbook['permissions'] & \OCP\PERMISSION_UPDATE)) { throw new \Exception( App::$l10n->t( 'You do not have the permissions to update this addressbook.' @@ -348,9 +345,10 @@ class Addressbook { */ public static function delete($id) { $addressbook = self::find($id); + if ($addressbook['userid'] != \OCP\User::getUser() && !\OC_Group::inGroup(OCP\User::getUser(), 'admin')) { $sharedAddressbook = \OCP\Share::getItemSharedWithBySource('addressbook', $id); - if (!$sharedAddressbook || !($sharedAddressbook['permissions'] & \OCP\Share::PERMISSION_DELETE)) { + if (!$sharedAddressbook || !($sharedAddressbook['permissions'] & \OCP\PERMISSION_DELETE)) { throw new Exception( App::$l10n->t( 'You do not have the permissions to delete this addressbook.' diff --git a/lib/sabre/addressbook.php b/lib/sabre/addressbook.php index c1f10d59..a3e92166 100644 --- a/lib/sabre/addressbook.php +++ b/lib/sabre/addressbook.php @@ -72,10 +72,10 @@ class OC_Connector_Sabre_CardDAV_AddressBook extends Sabre_CardDAV_AddressBook { if($uid != OCP\USER::getUser()) { $sharedAddressbook = OCP\Share::getItemSharedWithBySource('addressbook', $this->addressBookInfo['id']); - if ($sharedAddressbook && ($sharedAddressbook['permissions'] & OCP\Share::PERMISSION_READ)) { + if ($sharedAddressbook && ($sharedAddressbook['permissions'] & OCP\PERMISSION_READ)) { $readprincipal = 'principals/' . OCP\USER::getUser(); } - if ($sharedAddressbook && ($sharedAddressbook['permissions'] & OCP\Share::PERMISSION_UPDATE)) { + if ($sharedAddressbook && ($sharedAddressbook['permissions'] & OCP\PERMISSION_UPDATE)) { $writeprincipal = 'principals/' . OCP\USER::getUser(); } } diff --git a/lib/sabre/card.php b/lib/sabre/card.php index ef9a6dbb..1d5f780a 100644 --- a/lib/sabre/card.php +++ b/lib/sabre/card.php @@ -67,10 +67,10 @@ class OC_Connector_Sabre_CardDAV_Card extends Sabre_CardDAV_Card { if($uid != OCP\USER::getUser()) { $sharedAddressbook = OCP\Share::getItemSharedWithBySource('addressbook', $this->addressBookInfo['id']); - if ($sharedAddressbook && ($sharedAddressbook['permissions'] & OCP\Share::PERMISSION_READ)) { + if ($sharedAddressbook && ($sharedAddressbook['permissions'] & OCP\PERMISSION_READ)) { $readprincipal = 'principals/' . OCP\USER::getUser(); } - if ($sharedAddressbook && ($sharedAddressbook['permissions'] & OCP\Share::PERMISSION_UPDATE)) { + if ($sharedAddressbook && ($sharedAddressbook['permissions'] & OCP\PERMISSION_UPDATE)) { $writeprincipal = 'principals/' . OCP\USER::getUser(); } } diff --git a/lib/vcard.php b/lib/vcard.php index bba44246..be34f80c 100644 --- a/lib/vcard.php +++ b/lib/vcard.php @@ -323,7 +323,7 @@ class VCard { $addressbook = Addressbook::find($aid); if ($addressbook['userid'] != \OCP\User::getUser()) { $sharedAddressbook = \OCP\Share::getItemSharedWithBySource('addressbook', $aid); - if (!$sharedAddressbook || !($sharedAddressbook['permissions'] & \OCP\Share::PERMISSION_CREATE)) { + if (!$sharedAddressbook || !($sharedAddressbook['permissions'] & \OCP\PERMISSION_CREATE)) { throw new \Exception( App::$l10n->t( 'You do not have the permissions to add contacts to this addressbook.' @@ -402,10 +402,11 @@ class VCard { if (!$oldcard) { return false; } + $addressbook = Addressbook::find($oldcard['addressbookid']); if ($addressbook['userid'] != \OCP\User::getUser()) { $sharedContact = \OCP\Share::getItemSharedWithBySource('contact', $object[0], \OCP\Share::FORMAT_NONE, null, true); - if (!$sharedContact || !($sharedContact['permissions'] & \OCP\Share::PERMISSION_UPDATE)) { + if (!$sharedContact || !($sharedContact['permissions'] & \OCP\PERMISSION_UPDATE)) { return false; } } @@ -463,7 +464,7 @@ class VCard { $contact_permissions = $sharedEvent['permissions']; } $permissions = max($addressbook_permissions, $contact_permissions); - if (!($permissions & \OCP\Share::PERMISSION_UPDATE)) { + if (!($permissions & \OCP\PERMISSION_UPDATE)) { throw new \Exception( App::$l10n->t( 'You do not have the permissions to edit this contact.' @@ -576,7 +577,8 @@ class VCard { $contact_permissions = $sharedEvent['permissions']; } $permissions = max($addressbook_permissions, $contact_permissions); - if (!($permissions & \OCP\Share::PERMISSION_DELETE)) { + + if (!($permissions & \OCP\PERMISSION_DELETE)) { throw new \Exception( App::$l10n->t( 'You do not have the permissions to delete this contact.' @@ -623,8 +625,9 @@ class VCard { if (!$id) { return false; } + $sharedContact = \OCP\Share::getItemSharedWithBySource('contact', $id, \OCP\Share::FORMAT_NONE, null, true); - if (!$sharedContact || !($sharedContact['permissions'] & \OCP\Share::PERMISSION_DELETE)) { + if (!$sharedContact || !($sharedContact['permissions'] & \OCP\PERMISSION_DELETE)) { return false; } } @@ -812,7 +815,7 @@ class VCard { $addressbook = Addressbook::find($aid); if ($addressbook['userid'] != \OCP\User::getUser()) { $sharedAddressbook = \OCP\Share::getItemSharedWithBySource('addressbook', $aid); - if (!$sharedAddressbook || !($sharedAddressbook['permissions'] & \OCP\Share::PERMISSION_CREATE)) { + if (!$sharedAddressbook || !($sharedAddressbook['permissions'] & \OCP\PERMISSION_CREATE)) { return false; } } @@ -825,7 +828,7 @@ class VCard { $oldAddressbook = Addressbook::find($card['addressbookid']); if ($oldAddressbook['userid'] != \OCP\User::getUser()) { $sharedContact = \OCP\Share::getItemSharedWithBySource('contact', $cardId, \OCP\Share::FORMAT_NONE, null, true); - if (!$sharedContact || !($sharedContact['permissions'] & \OCP\Share::PERMISSION_DELETE)) { + if (!$sharedContact || !($sharedContact['permissions'] & \OCP\PERMISSION_DELETE)) { unset($id[$index]); } } @@ -859,7 +862,7 @@ class VCard { $oldAddressbook = Addressbook::find($card['addressbookid']); if ($oldAddressbook['userid'] != \OCP\User::getUser()) { $sharedContact = \OCP\Share::getItemSharedWithBySource('contact', $id, \OCP\Share::FORMAT_NONE, null, true); - if (!$sharedContact || !($sharedContact['permissions'] & \OCP\Share::PERMISSION_DELETE)) { + if (!$sharedContact || !($sharedContact['permissions'] & \OCP\PERMISSION_DELETE)) { return false; } } diff --git a/templates/settings.php b/templates/settings.php index 331089be..269def02 100644 --- a/templates/settings.php +++ b/templates/settings.php @@ -16,7 +16,7 @@ data-owner="" >