Esempio n. 1
0
 /**
  * Returns the list of people whom this address book is shared with.
  *
  * Every element in this array should have the following properties:
  *   * href - Often a mailto: address
  *   * commonName - Optional, for example a first + last name
  *   * status - See the Sabre\CalDAV\SharingPlugin::STATUS_ constants.
  *   * readOnly - boolean
  *   * summary - Optional, a description for the share
  *
  * @return array
  */
 public function getShares($addressBookUri)
 {
     $query = $this->db->getQueryBuilder();
     $result = $query->select(['principaluri', 'access'])->from('dav_shares')->where($query->expr()->eq('uri', $query->createNamedParameter($addressBookUri)))->andWhere($query->expr()->eq('type', $query->createNamedParameter('addressbook')))->execute();
     $shares = [];
     while ($row = $result->fetch()) {
         $p = $this->principalBackend->getPrincipalByPath($row['principaluri']);
         $shares[] = ['href' => "principal:{$p['uri']}", 'commonName' => isset($p['{DAV:}displayname']) ? $p['{DAV:}displayname'] : '', 'status' => 1, 'readOnly' => $row['access'] === 1];
     }
     return $shares;
 }
Esempio n. 2
0
 /**
  * Returns the list of people whom this address book is shared with.
  *
  * Every element in this array should have the following properties:
  *   * href - Often a mailto: address
  *   * commonName - Optional, for example a first + last name
  *   * status - See the Sabre\CalDAV\SharingPlugin::STATUS_ constants.
  *   * readOnly - boolean
  *   * summary - Optional, a description for the share
  *
  * @return array
  */
 public function getShares($addressBookId)
 {
     $query = $this->db->getQueryBuilder();
     $result = $query->select(['principaluri', 'access'])->from('dav_shares')->where($query->expr()->eq('resourceid', $query->createNamedParameter($addressBookId)))->andWhere($query->expr()->eq('type', $query->createNamedParameter('addressbook')))->execute();
     $shares = [];
     while ($row = $result->fetch()) {
         $p = $this->principalBackend->getPrincipalByPath($row['principaluri']);
         $shares[] = ['href' => "principal:{$p['uri']}", 'commonName' => isset($p['{DAV:}displayname']) ? $p['{DAV:}displayname'] : '', 'status' => 1, 'readOnly' => $row['access'] === self::ACCESS_READ, '{' . \OCA\DAV\CardDAV\Sharing\Plugin::NS_OWNCLOUD . '}principal' => $p['uri']];
     }
     return $shares;
 }
Esempio n. 3
0
 /**
  * Returns the list of people whom this resource is shared with.
  *
  * Every element in this array should have the following properties:
  *   * href - Often a mailto: address
  *   * commonName - Optional, for example a first + last name
  *   * status - See the Sabre\CalDAV\SharingPlugin::STATUS_ constants.
  *   * readOnly - boolean
  *   * summary - Optional, a description for the share
  *
  * @param int $resourceId
  * @return array
  */
 public function getShares($resourceId)
 {
     $query = $this->db->getQueryBuilder();
     $result = $query->select(['principaluri', 'access'])->from('dav_shares')->where($query->expr()->eq('resourceid', $query->createNamedParameter($resourceId)))->andWhere($query->expr()->eq('type', $query->createNamedParameter($this->resourceType)))->execute();
     $shares = [];
     while ($row = $result->fetch()) {
         $p = $this->principalBackend->getPrincipalByPath($row['principaluri']);
         $shares[] = ['href' => "principal:{$row['principaluri']}", 'commonName' => isset($p['{DAV:}displayname']) ? $p['{DAV:}displayname'] : '', 'status' => 1, 'readOnly' => $row['access'] == self::ACCESS_READ, '{http://owncloud.org/ns}principal' => $row['principaluri'], '{http://owncloud.org/ns}group-share' => is_null($p)];
     }
     return $shares;
 }
Esempio n. 4
0
 public function testGetPrincipalsByPathEmpty()
 {
     $this->userManager->expects($this->once())->method('get')->with('foo')->will($this->returnValue(null));
     $response = $this->connector->getPrincipalByPath('principals/users/foo');
     $this->assertSame(null, $response);
 }