| @@ 1077-1092 (lines=16) @@ | ||
| 1074 | * @param string $uri |
|
| 1075 | * @return int |
|
| 1076 | */ |
|
| 1077 | protected function getCardId($addressBookId, $uri) { |
|
| 1078 | $query = $this->db->getQueryBuilder(); |
|
| 1079 | $query->select('id')->from($this->dbCardsTable) |
|
| 1080 | ->where($query->expr()->eq('uri', $query->createNamedParameter($uri))) |
|
| 1081 | ->andWhere($query->expr()->eq('addressbookid', $query->createNamedParameter($addressBookId))); |
|
| 1082 | ||
| 1083 | $result = $query->execute(); |
|
| 1084 | $cardIds = $result->fetch(); |
|
| 1085 | $result->closeCursor(); |
|
| 1086 | ||
| 1087 | if (!isset($cardIds['id'])) { |
|
| 1088 | throw new \InvalidArgumentException('Card does not exists: ' . $uri); |
|
| 1089 | } |
|
| 1090 | ||
| 1091 | return (int)$cardIds['id']; |
|
| 1092 | } |
|
| 1093 | ||
| 1094 | /** |
|
| 1095 | * For shared address books the sharee is set in the ACL of the address book |
|
| @@ 193-209 (lines=17) @@ | ||
| 190 | * @return string |
|
| 191 | * @throws \Exception |
|
| 192 | */ |
|
| 193 | public function getToken($url) { |
|
| 194 | $hash = $this->hash($url); |
|
| 195 | $query = $this->connection->getQueryBuilder(); |
|
| 196 | $query->select('token')->from($this->dbTable) |
|
| 197 | ->where($query->expr()->eq('url_hash', $query->createParameter('url_hash'))) |
|
| 198 | ->setParameter('url_hash', $hash); |
|
| 199 | ||
| 200 | $statement = $query->execute(); |
|
| 201 | $result = $statement->fetch(); |
|
| 202 | $statement->closeCursor(); |
|
| 203 | ||
| 204 | if (!isset($result['token'])) { |
|
| 205 | throw new \Exception('No token found for: ' . $url); |
|
| 206 | } |
|
| 207 | ||
| 208 | return $result['token']; |
|
| 209 | } |
|
| 210 | ||
| 211 | /** |
|
| 212 | * add shared Secret to database |
|
| @@ 2110-2125 (lines=16) @@ | ||
| 2107 | * @param string $uri |
|
| 2108 | * @return int |
|
| 2109 | */ |
|
| 2110 | protected function getCalendarObjectId($calendarId, $uri) { |
|
| 2111 | $query = $this->db->getQueryBuilder(); |
|
| 2112 | $query->select('id')->from('calendarobjects') |
|
| 2113 | ->where($query->expr()->eq('uri', $query->createNamedParameter($uri))) |
|
| 2114 | ->andWhere($query->expr()->eq('calendarid', $query->createNamedParameter($calendarId))); |
|
| 2115 | ||
| 2116 | $result = $query->execute(); |
|
| 2117 | $objectIds = $result->fetch(); |
|
| 2118 | $result->closeCursor(); |
|
| 2119 | ||
| 2120 | if (!isset($objectIds['id'])) { |
|
| 2121 | throw new \InvalidArgumentException('Calendarobject does not exists: ' . $uri); |
|
| 2122 | } |
|
| 2123 | ||
| 2124 | return (int)$objectIds['id']; |
|
| 2125 | } |
|
| 2126 | ||
| 2127 | private function convertPrincipal($principalUri, $toV2) { |
|
| 2128 | if ($this->principalBackend->getPrincipalPrefix() === 'principals') { |
|