| @@ 42-60 (lines=19) @@ | ||
| 39 | * @return Direct |
|
| 40 | * @throws DoesNotExistException |
|
| 41 | */ |
|
| 42 | public function getByToken(string $token): Direct { |
|
| 43 | $qb = $this->db->getQueryBuilder(); |
|
| 44 | ||
| 45 | $qb->select('*') |
|
| 46 | ->from('directlink') |
|
| 47 | ->where( |
|
| 48 | $qb->expr()->eq('token', $qb->createNamedParameter($token)) |
|
| 49 | ); |
|
| 50 | ||
| 51 | $cursor = $qb->execute(); |
|
| 52 | $data = $cursor->fetch(); |
|
| 53 | $cursor->closeCursor(); |
|
| 54 | ||
| 55 | if ($data === false) { |
|
| 56 | throw new DoesNotExistException('Direct link with token does not exist'); |
|
| 57 | } |
|
| 58 | ||
| 59 | return Direct::fromRow($data); |
|
| 60 | } |
|
| 61 | ||
| 62 | public function deleteExpired(int $expiration) { |
|
| 63 | $qb = $this->db->getQueryBuilder(); |
|
| @@ 825-842 (lines=18) @@ | ||
| 822 | * @return array |
|
| 823 | * @throws ShareNotFound |
|
| 824 | */ |
|
| 825 | private function getRawShare($id) { |
|
| 826 | ||
| 827 | // Now fetch the inserted share and create a complete share object |
|
| 828 | $qb = $this->dbConnection->getQueryBuilder(); |
|
| 829 | $qb->select('*') |
|
| 830 | ->from('share') |
|
| 831 | ->where($qb->expr()->eq('id', $qb->createNamedParameter($id))); |
|
| 832 | ||
| 833 | $cursor = $qb->execute(); |
|
| 834 | $data = $cursor->fetch(); |
|
| 835 | $cursor->closeCursor(); |
|
| 836 | ||
| 837 | if ($data === false) { |
|
| 838 | throw new ShareNotFound; |
|
| 839 | } |
|
| 840 | ||
| 841 | return $data; |
|
| 842 | } |
|
| 843 | ||
| 844 | /** |
|
| 845 | * Create a share object from an database row |
|
| @@ 43-56 (lines=14) @@ | ||
| 40 | * @return AccessToken |
|
| 41 | * @throws AccessTokenNotFoundException |
|
| 42 | */ |
|
| 43 | public function getByCode($code) { |
|
| 44 | $qb = $this->db->getQueryBuilder(); |
|
| 45 | $qb |
|
| 46 | ->select('*') |
|
| 47 | ->from($this->tableName) |
|
| 48 | ->where($qb->expr()->eq('hashed_code', $qb->createNamedParameter(hash('sha512', $code)))); |
|
| 49 | $result = $qb->execute(); |
|
| 50 | $row = $result->fetch(); |
|
| 51 | $result->closeCursor(); |
|
| 52 | if($row === false) { |
|
| 53 | throw new AccessTokenNotFoundException(); |
|
| 54 | } |
|
| 55 | return AccessToken::fromRow($row); |
|
| 56 | } |
|
| 57 | ||
| 58 | /** |
|
| 59 | * delete all access token from a given client |
|
| @@ 43-56 (lines=14) @@ | ||
| 40 | * @return Client |
|
| 41 | * @throws ClientNotFoundException |
|
| 42 | */ |
|
| 43 | public function getByIdentifier($clientIdentifier) { |
|
| 44 | $qb = $this->db->getQueryBuilder(); |
|
| 45 | $qb |
|
| 46 | ->select('*') |
|
| 47 | ->from($this->tableName) |
|
| 48 | ->where($qb->expr()->eq('client_identifier', $qb->createNamedParameter($clientIdentifier))); |
|
| 49 | $result = $qb->execute(); |
|
| 50 | $row = $result->fetch(); |
|
| 51 | $result->closeCursor(); |
|
| 52 | if($row === false) { |
|
| 53 | throw new ClientNotFoundException(); |
|
| 54 | } |
|
| 55 | return Client::fromRow($row); |
|
| 56 | } |
|
| 57 | ||
| 58 | /** |
|
| 59 | * @param string $uid internal uid of the client |
|
| @@ 63-76 (lines=14) @@ | ||
| 60 | * @return Client |
|
| 61 | * @throws ClientNotFoundException |
|
| 62 | */ |
|
| 63 | public function getByUid($uid) { |
|
| 64 | $qb = $this->db->getQueryBuilder(); |
|
| 65 | $qb |
|
| 66 | ->select('*') |
|
| 67 | ->from($this->tableName) |
|
| 68 | ->where($qb->expr()->eq('id', $qb->createNamedParameter($uid, IQueryBuilder::PARAM_INT))); |
|
| 69 | $result = $qb->execute(); |
|
| 70 | $row = $result->fetch(); |
|
| 71 | $result->closeCursor(); |
|
| 72 | if($row === false) { |
|
| 73 | throw new ClientNotFoundException(); |
|
| 74 | } |
|
| 75 | return Client::fromRow($row); |
|
| 76 | } |
|
| 77 | ||
| 78 | /** |
|
| 79 | * @return Client[] |
|
| @@ 1001-1018 (lines=18) @@ | ||
| 998 | * @return array |
|
| 999 | * @throws ShareNotFound |
|
| 1000 | */ |
|
| 1001 | protected function getRawShare($id) { |
|
| 1002 | ||
| 1003 | // Now fetch the inserted share and create a complete share object |
|
| 1004 | $qb = $this->dbConnection->getQueryBuilder(); |
|
| 1005 | $qb->select('*') |
|
| 1006 | ->from('share') |
|
| 1007 | ->where($qb->expr()->eq('id', $qb->createNamedParameter($id))); |
|
| 1008 | ||
| 1009 | $cursor = $qb->execute(); |
|
| 1010 | $data = $cursor->fetch(); |
|
| 1011 | $cursor->closeCursor(); |
|
| 1012 | ||
| 1013 | if ($data === false) { |
|
| 1014 | throw new ShareNotFound; |
|
| 1015 | } |
|
| 1016 | ||
| 1017 | return $data; |
|
| 1018 | } |
|
| 1019 | ||
| 1020 | public function getSharesInFolder($userId, Folder $node, $reshares) { |
|
| 1021 | $qb = $this->dbConnection->getQueryBuilder(); |
|