예제 #1
0
 /**
  * Returns a list of ACE's for this node.
  *
  * Each ACE has the following properties:
  *   * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
  *     currently the only supported privileges
  *   * 'principal', a url to the principal who owns the node
  *   * 'protected' (optional), indicating that this ACE is not allowed to
  *      be updated.
  *
  * @return array
  */
 public function getACL()
 {
     $readprincipal = $this->getOwner();
     $writeprincipal = $this->getOwner();
     $createprincipal = $this->getOwner();
     $deleteprincipal = $this->getOwner();
     $uid = AddrBook::extractUserID($this->getOwner());
     //\OCP\Config::setUserValue($uid, 'contactsplus', 'syncaddrbook', $this->addressBookInfo['uri']);
     $readWriteACL = array(array('privilege' => '{DAV:}read', 'principal' => 'principals/' . \OCP\User::getUser(), 'protected' => true), array('privilege' => '{DAV:}write', 'principal' => 'principals/' . \OCP\User::getUser(), 'protected' => true));
     if ($uid !== \OCP\USER::getUser()) {
         $sharedAddressbook = \OCP\Share::getItemSharedWithBySource(ContactsApp::SHAREADDRESSBOOK, ContactsApp::SHAREADDRESSBOOKPREFIX . $this->addressBookInfo['id']);
         if ($sharedAddressbook) {
             if ($sharedAddressbook['permissions'] & \OCP\PERMISSION_CREATE && $sharedAddressbook['permissions'] & \OCP\PERMISSION_UPDATE && $sharedAddressbook['permissions'] & \OCP\PERMISSION_DELETE) {
                 return $readWriteACL;
             }
             if ($sharedAddressbook['permissions'] & \OCP\PERMISSION_CREATE) {
                 $createprincipal = 'principals/' . \OCP\USER::getUser();
             }
             if ($sharedAddressbook['permissions'] & \OCP\PERMISSION_READ) {
                 $readprincipal = 'principals/' . \OCP\USER::getUser();
             }
             if ($sharedAddressbook['permissions'] & \OCP\PERMISSION_UPDATE) {
                 $writeprincipal = 'principals/' . \OCP\USER::getUser();
             }
             if ($sharedAddressbook['permissions'] & \OCP\PERMISSION_DELETE) {
                 $deleteprincipal = 'principals/' . \OCP\USER::getUser();
             }
         }
     } else {
         return parent::getACL();
     }
     return array(array('privilege' => '{DAV:}read', 'principal' => $readprincipal, 'protected' => true), array('privilege' => '{DAV:}write-content', 'principal' => $writeprincipal, 'protected' => true), array('privilege' => '{DAV:}bind', 'principal' => $createprincipal, 'protected' => true), array('privilege' => '{DAV:}unbind', 'principal' => $deleteprincipal, 'protected' => true));
 }
예제 #2
0
파일: addressbook.php 프로젝트: evanjt/core
 function getChildACL()
 {
     $acl = parent::getChildACL();
     if ($this->getOwner() === 'principals/system/system') {
         $acl[] = ['privilege' => '{DAV:}read', 'principal' => '{DAV:}authenticated', 'protected' => true];
     }
     return $acl;
 }
예제 #3
0
 function getChildACL()
 {
     $acl = parent::getChildACL();
     if ($this->getOwner() === 'principals/system/system') {
         $acl[] = ['privilege' => '{DAV:}read', 'principal' => '{DAV:}authenticated', 'protected' => true];
     }
     /** @var CardDavBackend $carddavBackend */
     $carddavBackend = $this->carddavBackend;
     return $carddavBackend->applyShareAcl($this->getBookId(), $acl);
 }
예제 #4
0
 /**
  * @param int $iUserId
  * @param \Sabre\CardDAV\AddressBook $oAddressBook
  * @param string $sId
  * @return bool | \Sabre\DAV\Card
  */
 protected function geItem($iUserId, $oAddressBook, $sId)
 {
     $bResult = false;
     $sName = null;
     if ($oAddressBook) {
         $sName = $oAddressBook->getName();
         if (isset($this->aContactItemsCache[$sName][$sId])) {
             $bResult = $this->aContactItemsCache[$sName][$sId];
         } else {
             if ($oAddressBook->childExists($sId)) {
                 $bResult = $oAddressBook->getChild($sId);
             }
         }
     }
     return $bResult;
 }
예제 #5
0
 function testGetChanges()
 {
     if (!SABRE_HASSQLITE) {
         $this->markTestSkipped('Sqlite is required for this test to run');
     }
     $ab = new AddressBook(TestUtil::getBackend(), ['id' => 1, '{DAV:}sync-token' => 2]);
     $this->assertEquals(['syncToken' => 2, 'modified' => [], 'deleted' => [], 'added' => ['UUID-2345']], $ab->getChanges(1, 1));
 }
예제 #6
0
 function propPatch(PropPatch $propPatch)
 {
     if (isset($this->addressBookInfo['{http://owncloud.org/ns}owner-principal'])) {
         throw new Forbidden();
     }
     parent::propPatch($propPatch);
 }
예제 #7
0
 public function __construct(CardDavBackend $carddavBackend, array $addressBookInfo)
 {
     parent::__construct($carddavBackend, $addressBookInfo);
 }
예제 #8
0
 /**
  * Returns a list of ACE's for this node.
  *
  * Each ACE has the following properties:
  *   * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
  *     currently the only supported privileges
  *   * 'principal', a url to the principal who owns the node
  *   * 'protected' (optional), indicating that this ACE is not allowed to
  *      be updated.
  *
  * @return array
  */
 public function getACL()
 {
     $readprincipal = $this->getOwner();
     $writeprincipal = $this->getOwner();
     $createprincipal = $this->getOwner();
     $deleteprincipal = $this->getOwner();
     $uid = $this->carddavBackend->userIDByPrincipal($this->getOwner());
     $readWriteACL = array(array('privilege' => '{DAV:}read', 'principal' => 'principals/' . \OCP\User::getUser(), 'protected' => true), array('privilege' => '{DAV:}write', 'principal' => 'principals/' . \OCP\User::getUser(), 'protected' => true));
     if ($uid !== \OCP\User::getUser()) {
         list(, $id) = explode('::', $this->addressBookInfo['id']);
         $sharedAddressbook = \OCP\Share::getItemSharedWithBySource('addressbook', $id);
         if ($sharedAddressbook) {
             if ($sharedAddressbook['permissions'] & \OCP\PERMISSION_CREATE && $sharedAddressbook['permissions'] & \OCP\PERMISSION_UPDATE && $sharedAddressbook['permissions'] & \OCP\PERMISSION_DELETE) {
                 return $readWriteACL;
             }
             if ($sharedAddressbook['permissions'] & \OCP\PERMISSION_CREATE) {
                 $createprincipal = 'principals/' . \OCP\User::getUser();
             }
             if ($sharedAddressbook['permissions'] & \OCP\PERMISSION_READ) {
                 $readprincipal = 'principals/' . \OCP\User::getUser();
             }
             if ($sharedAddressbook['permissions'] & \OCP\PERMISSION_UPDATE) {
                 $writeprincipal = 'principals/' . \OCP\User::getUser();
             }
             if ($sharedAddressbook['permissions'] & \OCP\PERMISSION_DELETE) {
                 $deleteprincipal = 'principals/' . \OCP\User::getUser();
             }
         }
     } else {
         return parent::getACL();
     }
     return array(array('privilege' => '{DAV:}read', 'principal' => $readprincipal, 'protected' => true), array('privilege' => '{DAV:}write-content', 'principal' => $writeprincipal, 'protected' => true), array('privilege' => '{DAV:}bind', 'principal' => $createprincipal, 'protected' => true), array('privilege' => '{DAV:}unbind', 'principal' => $deleteprincipal, 'protected' => true));
 }
예제 #9
0
 function testGetSyncToken2()
 {
     $this->driver = 'sqlite';
     $this->dropTables(['addressbooks', 'cards', 'addressbookchanges']);
     $this->createSchema('addressbooks');
     $backend = new Backend\PDO($this->getPDO());
     $ab = new AddressBook($backend, ['id' => 1, '{http://sabredav.org/ns}sync-token' => 2]);
     $this->assertEquals(2, $ab->getSyncToken());
 }
예제 #10
0
 function delete()
 {
     if (isset($this->addressBookInfo['{http://owncloud.org/ns}owner-principal'])) {
         $principal = 'principal:' . parent::getOwner();
         $shares = $this->getShares();
         $shares = array_filter($shares, function ($share) use($principal) {
             return $share['href'] === $principal;
         });
         if (empty($shares)) {
             throw new Forbidden();
         }
         /** @var CardDavBackend $cardDavBackend */
         $cardDavBackend = $this->carddavBackend;
         $cardDavBackend->updateShares($this, [], ['href' => $principal]);
         return;
     }
     parent::delete();
 }