From 814819092e16aed5fd5270e5577c0d8f94f293dc Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Sun, 11 Nov 2012 19:43:44 +0100 Subject: [PATCH] Use CRUDS consts as defined in https://github.com/owncloud/core/pull/356 --- ajax/contact/details.php | 4 +--- lib/addressbook.php | 14 +++++--------- lib/sabre/addressbook.php | 4 ++-- lib/sabre/card.php | 4 ++-- lib/vcard.php | 16 ++++++++-------- templates/settings.php | 8 ++++---- 6 files changed, 22 insertions(+), 28 deletions(-) diff --git a/ajax/contact/details.php b/ajax/contact/details.php index 10041b95..893aab75 100644 --- a/ajax/contact/details.php +++ b/ajax/contact/details.php @@ -55,9 +55,7 @@ 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; +$permissions = OCP\PERMISSION_ALL; $addressbook = OC_Contacts_Addressbook::find($card['addressbookid']); if ($addressbook['userid'] != OCP\User::getUser()) { $sharedAddressbook = OCP\Share::getItemSharedWithBySource('addressbook', $card['addressbookid']); diff --git a/lib/addressbook.php b/lib/addressbook.php index f57e6300..8a3b7d65 100644 --- a/lib/addressbook.php +++ b/lib/addressbook.php @@ -62,9 +62,7 @@ class OC_Contacts_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; } $addressbooks = array_merge($addressbooks, OCP\Share::getItemsSharedWith('addressbook', OC_Share_Backend_Addressbook::FORMAT_ADDRESSBOOKS)); @@ -132,7 +130,7 @@ class OC_Contacts_Addressbook { $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( OC_Contacts_App::$l10n->t( 'You do not have the permissions to read this addressbook.' @@ -141,9 +139,7 @@ class OC_Contacts_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; } @@ -233,7 +229,7 @@ class OC_Contacts_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( OC_Contacts_App::$l10n->t( 'You do not have the permissions to update this addressbook.' @@ -309,7 +305,7 @@ class OC_Contacts_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_DELETE)) { + if (!$sharedAddressbook || !($sharedAddressbook['permissions'] & OCP\PERMISSION_DELETE)) { throw new Exception( OC_Contacts_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 e9eb7747..71316a0b 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 f4414a25..2e1711f4 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 ed644973..b0ad72e1 100644 --- a/lib/vcard.php +++ b/lib/vcard.php @@ -295,7 +295,7 @@ class OC_Contacts_VCard { $addressbook = OC_Contacts_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( OC_Contacts_App::$l10n->t( 'You do not have the permissions to add contacts to this addressbook.' @@ -372,7 +372,7 @@ class OC_Contacts_VCard { $addressbook = OC_Contacts_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; } } @@ -424,7 +424,7 @@ class OC_Contacts_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( OC_Contacts_App::$l10n->t( 'You do not have the permissions to edit this contact.' @@ -526,7 +526,7 @@ class OC_Contacts_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( OC_Contacts_App::$l10n->t( 'You do not have the permissions to delete this contact.' @@ -572,7 +572,7 @@ class OC_Contacts_VCard { 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; } } @@ -733,7 +733,7 @@ class OC_Contacts_VCard { $addressbook = OC_Contacts_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; } } @@ -746,7 +746,7 @@ class OC_Contacts_VCard { $oldAddressbook = OC_Contacts_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]); } } @@ -776,7 +776,7 @@ class OC_Contacts_VCard { $oldAddressbook = OC_Contacts_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 3e65e07b..a4910277 100644 --- a/templates/settings.php +++ b/templates/settings.php @@ -15,7 +15,7 @@ data-owner="" > - + /> @@ -28,7 +28,7 @@ - + - + "> - + ">