1
0
mirror of https://github.com/owncloudarchive/contacts.git synced 2025-01-18 07:52:21 +01:00
This commit is contained in:
Thomas Tanghus 2012-11-11 19:43:44 +01:00
parent 4aff80e8c2
commit 814819092e
6 changed files with 22 additions and 28 deletions

View File

@ -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']);

View File

@ -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.'

View File

@ -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();
}
}

View File

@ -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();
}
}

View File

@ -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;
}
}

View File

@ -15,7 +15,7 @@
data-owner="<?php echo $addressbook['userid'] ?>"
>
<td class="active">
<?php if($addressbook['permissions'] & OCP\Share::PERMISSION_UPDATE) { ?>
<?php if($addressbook['permissions'] & OCP\PERMISSION_UPDATE) { ?>
<input type="checkbox" <?php echo (($addressbook['active']) == '1' ? ' checked="checked"' : ''); ?> />
<?php } ?>
</td>
@ -28,7 +28,7 @@
<a class="svg action cloud" title="<?php echo $l->t('Show read-only VCF link'); ?>"></a>
</td>
<td class="action">
<?php if($addressbook['permissions'] & OCP\Share::PERMISSION_SHARE) { ?>
<?php if($addressbook['permissions'] & OCP\PERMISSION_SHARE) { ?>
<a class="svg action share" data-item-type="addressbook"
data-item="<?php echo $addressbook['id'] ?>"
data-possible-permissions="<?php echo $addressbook['permissions'] ?>"
@ -40,12 +40,12 @@
href="<?php echo OCP\Util::linkToAbsolute('contacts', 'export.php'); ?>?bookid=<?php echo $addressbook['id'] ?>"></a>
</td>
<td class="action">
<?php if($addressbook['permissions'] & OCP\Share::PERMISSION_UPDATE) { ?>
<?php if($addressbook['permissions'] & OCP\PERMISSION_UPDATE) { ?>
<a class="svg action edit" title="<?php echo $l->t("Edit"); ?>"></a>
<?php } ?>
</td>
<td class="action">
<?php if($addressbook['permissions'] & OCP\Share::PERMISSION_DELETE) { ?>
<?php if($addressbook['permissions'] & OCP\PERMISSION_DELETE) { ?>
<a class="svg action delete" title="<?php echo $l->t("Delete"); ?>"></a>
<?php } ?>
</td>