1
0
mirror of https://github.com/owncloudarchive/contacts.git synced 2025-01-30 19:52:17 +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(); $lastmodified = new DateTime();
} }
$permissions = OCP\Share::PERMISSION_CREATE | OCP\Share::PERMISSION_READ $permissions = OCP\PERMISSION_ALL;
| OCP\Share::PERMISSION_UPDATE | OCP\Share::PERMISSION_DELETE
| OCP\Share::PERMISSION_SHARE;
$addressbook = OC_Contacts_Addressbook::find($card['addressbookid']); $addressbook = OC_Contacts_Addressbook::find($card['addressbookid']);
if ($addressbook['userid'] != OCP\User::getUser()) { if ($addressbook['userid'] != OCP\User::getUser()) {
$sharedAddressbook = OCP\Share::getItemSharedWithBySource('addressbook', $card['addressbookid']); $sharedAddressbook = OCP\Share::getItemSharedWithBySource('addressbook', $card['addressbookid']);

View File

@ -62,9 +62,7 @@ class OC_Contacts_Addressbook {
$addressbooks = array(); $addressbooks = array();
while( $row = $result->fetchRow()) { while( $row = $result->fetchRow()) {
$row['permissions'] = OCP\Share::PERMISSION_CREATE $row['permissions'] = OCP\PERMISSION_ALL;
| OCP\Share::PERMISSION_READ | OCP\Share::PERMISSION_UPDATE
| OCP\Share::PERMISSION_DELETE | OCP\Share::PERMISSION_SHARE;
$addressbooks[] = $row; $addressbooks[] = $row;
} }
$addressbooks = array_merge($addressbooks, OCP\Share::getItemsSharedWith('addressbook', OC_Share_Backend_Addressbook::FORMAT_ADDRESSBOOKS)); $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(); $row = $result->fetchRow();
if($row['userid'] != OCP\USER::getUser() && !OC_Group::inGroup(OCP\User::getUser(), 'admin')) { if($row['userid'] != OCP\USER::getUser() && !OC_Group::inGroup(OCP\User::getUser(), 'admin')) {
$sharedAddressbook = OCP\Share::getItemSharedWithBySource('addressbook', $id); $sharedAddressbook = OCP\Share::getItemSharedWithBySource('addressbook', $id);
if (!$sharedAddressbook || !($sharedAddressbook['permissions'] & OCP\Share::PERMISSION_READ)) { if (!$sharedAddressbook || !($sharedAddressbook['permissions'] & OCP\PERMISSION_READ)) {
throw new Exception( throw new Exception(
OC_Contacts_App::$l10n->t( OC_Contacts_App::$l10n->t(
'You do not have the permissions to read this addressbook.' 'You do not have the permissions to read this addressbook.'
@ -141,9 +139,7 @@ class OC_Contacts_Addressbook {
} }
$row['permissions'] = $sharedAddressbook['permissions']; $row['permissions'] = $sharedAddressbook['permissions'];
} else { } else {
$row['permissions'] = OCP\Share::PERMISSION_CREATE $row['permissions'] = OCP\PERMISSION_ALL;
| OCP\Share::PERMISSION_READ | OCP\Share::PERMISSION_UPDATE
| OCP\Share::PERMISSION_DELETE | OCP\Share::PERMISSION_SHARE;
} }
return $row; return $row;
} }
@ -233,7 +229,7 @@ class OC_Contacts_Addressbook {
$addressbook = self::find($id); $addressbook = self::find($id);
if ($addressbook['userid'] != OCP\User::getUser() && !OC_Group::inGroup(OCP\User::getUser(), 'admin')) { if ($addressbook['userid'] != OCP\User::getUser() && !OC_Group::inGroup(OCP\User::getUser(), 'admin')) {
$sharedAddressbook = OCP\Share::getItemSharedWithBySource('addressbook', $id); $sharedAddressbook = OCP\Share::getItemSharedWithBySource('addressbook', $id);
if (!$sharedAddressbook || !($sharedAddressbook['permissions'] & OCP\Share::PERMISSION_UPDATE)) { if (!$sharedAddressbook || !($sharedAddressbook['permissions'] & OCP\PERMISSION_UPDATE)) {
throw new Exception( throw new Exception(
OC_Contacts_App::$l10n->t( OC_Contacts_App::$l10n->t(
'You do not have the permissions to update this addressbook.' 'You do not have the permissions to update this addressbook.'
@ -309,7 +305,7 @@ class OC_Contacts_Addressbook {
$addressbook = self::find($id); $addressbook = self::find($id);
if ($addressbook['userid'] != OCP\User::getUser() && !OC_Group::inGroup(OCP\User::getUser(), 'admin')) { if ($addressbook['userid'] != OCP\User::getUser() && !OC_Group::inGroup(OCP\User::getUser(), 'admin')) {
$sharedAddressbook = OCP\Share::getItemSharedWithBySource('addressbook', $id); $sharedAddressbook = OCP\Share::getItemSharedWithBySource('addressbook', $id);
if (!$sharedAddressbook || !($sharedAddressbook['permissions'] & OCP\Share::PERMISSION_DELETE)) { if (!$sharedAddressbook || !($sharedAddressbook['permissions'] & OCP\PERMISSION_DELETE)) {
throw new Exception( throw new Exception(
OC_Contacts_App::$l10n->t( OC_Contacts_App::$l10n->t(
'You do not have the permissions to delete this addressbook.' '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()) { if($uid != OCP\USER::getUser()) {
$sharedAddressbook = OCP\Share::getItemSharedWithBySource('addressbook', $this->addressBookInfo['id']); $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(); $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(); $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()) { if($uid != OCP\USER::getUser()) {
$sharedAddressbook = OCP\Share::getItemSharedWithBySource('addressbook', $this->addressBookInfo['id']); $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(); $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(); $writeprincipal = 'principals/' . OCP\USER::getUser();
} }
} }

View File

@ -295,7 +295,7 @@ class OC_Contacts_VCard {
$addressbook = OC_Contacts_Addressbook::find($aid); $addressbook = OC_Contacts_Addressbook::find($aid);
if ($addressbook['userid'] != OCP\User::getUser()) { if ($addressbook['userid'] != OCP\User::getUser()) {
$sharedAddressbook = OCP\Share::getItemSharedWithBySource('addressbook', $aid); $sharedAddressbook = OCP\Share::getItemSharedWithBySource('addressbook', $aid);
if (!$sharedAddressbook || !($sharedAddressbook['permissions'] & OCP\Share::PERMISSION_CREATE)) { if (!$sharedAddressbook || !($sharedAddressbook['permissions'] & OCP\PERMISSION_CREATE)) {
throw new Exception( throw new Exception(
OC_Contacts_App::$l10n->t( OC_Contacts_App::$l10n->t(
'You do not have the permissions to add contacts to this addressbook.' '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']); $addressbook = OC_Contacts_Addressbook::find($oldcard['addressbookid']);
if ($addressbook['userid'] != OCP\User::getUser()) { if ($addressbook['userid'] != OCP\User::getUser()) {
$sharedContact = OCP\Share::getItemSharedWithBySource('contact', $object[0], OCP\Share::FORMAT_NONE, null, true); $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; return false;
} }
} }
@ -424,7 +424,7 @@ class OC_Contacts_VCard {
$contact_permissions = $sharedEvent['permissions']; $contact_permissions = $sharedEvent['permissions'];
} }
$permissions = max($addressbook_permissions, $contact_permissions); $permissions = max($addressbook_permissions, $contact_permissions);
if (!($permissions & OCP\Share::PERMISSION_UPDATE)) { if (!($permissions & OCP\PERMISSION_UPDATE)) {
throw new Exception( throw new Exception(
OC_Contacts_App::$l10n->t( OC_Contacts_App::$l10n->t(
'You do not have the permissions to edit this contact.' 'You do not have the permissions to edit this contact.'
@ -526,7 +526,7 @@ class OC_Contacts_VCard {
$contact_permissions = $sharedEvent['permissions']; $contact_permissions = $sharedEvent['permissions'];
} }
$permissions = max($addressbook_permissions, $contact_permissions); $permissions = max($addressbook_permissions, $contact_permissions);
if (!($permissions & OCP\Share::PERMISSION_DELETE)) { if (!($permissions & OCP\PERMISSION_DELETE)) {
throw new Exception( throw new Exception(
OC_Contacts_App::$l10n->t( OC_Contacts_App::$l10n->t(
'You do not have the permissions to delete this contact.' 'You do not have the permissions to delete this contact.'
@ -572,7 +572,7 @@ class OC_Contacts_VCard {
return false; return false;
} }
$sharedContact = OCP\Share::getItemSharedWithBySource('contact', $id, OCP\Share::FORMAT_NONE, null, true); $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; return false;
} }
} }
@ -733,7 +733,7 @@ class OC_Contacts_VCard {
$addressbook = OC_Contacts_Addressbook::find($aid); $addressbook = OC_Contacts_Addressbook::find($aid);
if ($addressbook['userid'] != OCP\User::getUser()) { if ($addressbook['userid'] != OCP\User::getUser()) {
$sharedAddressbook = OCP\Share::getItemSharedWithBySource('addressbook', $aid); $sharedAddressbook = OCP\Share::getItemSharedWithBySource('addressbook', $aid);
if (!$sharedAddressbook || !($sharedAddressbook['permissions'] & OCP\Share::PERMISSION_CREATE)) { if (!$sharedAddressbook || !($sharedAddressbook['permissions'] & OCP\PERMISSION_CREATE)) {
return false; return false;
} }
} }
@ -746,7 +746,7 @@ class OC_Contacts_VCard {
$oldAddressbook = OC_Contacts_Addressbook::find($card['addressbookid']); $oldAddressbook = OC_Contacts_Addressbook::find($card['addressbookid']);
if ($oldAddressbook['userid'] != OCP\User::getUser()) { if ($oldAddressbook['userid'] != OCP\User::getUser()) {
$sharedContact = OCP\Share::getItemSharedWithBySource('contact', $cardId, OCP\Share::FORMAT_NONE, null, true); $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]); unset($id[$index]);
} }
} }
@ -776,7 +776,7 @@ class OC_Contacts_VCard {
$oldAddressbook = OC_Contacts_Addressbook::find($card['addressbookid']); $oldAddressbook = OC_Contacts_Addressbook::find($card['addressbookid']);
if ($oldAddressbook['userid'] != OCP\User::getUser()) { if ($oldAddressbook['userid'] != OCP\User::getUser()) {
$sharedContact = OCP\Share::getItemSharedWithBySource('contact', $id, OCP\Share::FORMAT_NONE, null, true); $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; return false;
} }
} }

View File

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