mirror of
https://github.com/owncloudarchive/contacts.git
synced 2025-01-18 07:52:21 +01:00
Contacts: Don't mix possible permissions with actual permissions.
This commit is contained in:
parent
73055dffd4
commit
49f728a86a
@ -110,7 +110,8 @@ class Addressbook extends AbstractPIMCollection {
|
||||
* @return int
|
||||
*/
|
||||
public function getPermissions() {
|
||||
return min($this->addressBookInfo['permissions'], $this->backend->getAddressBookPermissions());
|
||||
return $this->addressBookInfo['permissions'];
|
||||
//return min($this->addressBookInfo['permissions'], $this->backend->getAddressBookPermissions());
|
||||
}
|
||||
|
||||
function getBackend() {
|
||||
@ -186,6 +187,9 @@ class Addressbook extends AbstractPIMCollection {
|
||||
if(!$this->hasPermission(\OCP\PERMISSION_CREATE)) {
|
||||
throw new \Exception('Access denied');
|
||||
}
|
||||
if(!$this->getBackend()->hasContactMethodFor(\OCP\PERMISSION_CREATE)) {
|
||||
throw new \Exception('Not implemented');
|
||||
}
|
||||
$contact = new Contact($this, $this->backend, $data);
|
||||
if($contact->save() === false) {
|
||||
return false;
|
||||
@ -208,6 +212,9 @@ class Addressbook extends AbstractPIMCollection {
|
||||
if(!$this->hasPermission(\OCP\PERMISSION_DELETE)) {
|
||||
throw new \Exception('Access denied');
|
||||
}
|
||||
if(!$this->getBackend()->hasContactMethodFor(\OCP\PERMISSION_DELETE)) {
|
||||
throw new \Exception('Not implemented');
|
||||
}
|
||||
if($this->backend->deleteContact($this->getId(), $id)) {
|
||||
if(isset($this->objects[$id])) {
|
||||
unset($this->objects[$id]);
|
||||
|
@ -86,6 +86,7 @@ abstract class AbstractBackend {
|
||||
}
|
||||
}
|
||||
|
||||
\OCP\Util::writeLog('contacts', __METHOD__.', permissions' . $permissions, \OCP\Util::DEBUG);
|
||||
return $permissions;
|
||||
}
|
||||
|
||||
@ -104,6 +105,7 @@ abstract class AbstractBackend {
|
||||
}
|
||||
}
|
||||
|
||||
\OCP\Util::writeLog('contacts', __METHOD__.', permissions' . $permissions, \OCP\Util::DEBUG);
|
||||
return $permissions;
|
||||
}
|
||||
|
||||
@ -115,7 +117,7 @@ abstract class AbstractBackend {
|
||||
* Returns the supported actions as int to be
|
||||
* compared with \OCP\PERMISSION_CREATE etc.
|
||||
*/
|
||||
public function hasContactPermission($permission) {
|
||||
public function hasContactMethodFor($permission) {
|
||||
return (bool)($this->getContactPermissions() & $permission);
|
||||
}
|
||||
|
||||
@ -127,7 +129,7 @@ abstract class AbstractBackend {
|
||||
* Returns the supported actions as int to be
|
||||
* compared with \OCP\PERMISSION_CREATE etc.
|
||||
*/
|
||||
public function hasAddressBooksPermission($permission) {
|
||||
public function hasAddressBooksMethodFor($permission) {
|
||||
return (bool)($this->getAddressBooksPermissions() & $permission);
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,7 @@ class Contact extends VObject\VCard implements IPIMObject {
|
||||
case 'displayname':
|
||||
case 'fullname':
|
||||
$this->props['displayname'] = $value;
|
||||
$this->FN = $value;
|
||||
//$this->FN = $value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -247,7 +247,10 @@ class Contact extends VObject\VCard implements IPIMObject {
|
||||
$this->props['displayname'] = (string)$this->FN;
|
||||
}
|
||||
if($this->getId()) {
|
||||
if($this->props['backend']
|
||||
if(!$this->getBackend()->hasContactMethodFor(\OCP\PERMISSION_UPDATE)) {
|
||||
throw new \Exception('Not implemented');
|
||||
}
|
||||
if($this->getBackend()
|
||||
->updateContact(
|
||||
$this->getParent()->getId(),
|
||||
$this->getId(),
|
||||
@ -262,7 +265,10 @@ class Contact extends VObject\VCard implements IPIMObject {
|
||||
}
|
||||
} else {
|
||||
//print(__METHOD__.' ' . print_r($this->getParent(), true));
|
||||
$this->props['id'] = $this->props['backend']->createContact(
|
||||
if(!$this->getBackend()->hasContactMethodFor(\OCP\PERMISSION_CREATE)) {
|
||||
throw new \Exception('Not implemented');
|
||||
}
|
||||
$this->props['id'] = $this->getBackend()->createContact(
|
||||
$this->getParent()->getId(), $this
|
||||
);
|
||||
$this->setSaved(true);
|
||||
|
Loading…
x
Reference in New Issue
Block a user