Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Allow fetching albums without files
Signed-off-by: Simon Spannagel <simonspa@kth.se>
  • Loading branch information
Simon Spannagel committed Jan 24, 2023
commit 7027273bf007b999393d06e5182777ac120ba95e
28 changes: 28 additions & 0 deletions lib/Album/AlbumMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,34 @@ function computeKey($c) {
$this->connection->commit();
}

/**
* @param string $collaboratorId
* @param int $collaboratorType
* @return AlbumInfo[]
*/
public function getSharedAlbumsForCollaborator(string $collaboratorId, int $collaboratorType): array {
$query = $this->connection->getQueryBuilder();
$rows = $query
->select("a.album_id", "name", "user", "location", "created", "last_added_photo")
->from("photos_albums_collabs", "c")
->leftJoin("c", "photos_albums", "a", $query->expr()->eq("a.album_id", "c.album_id"))
->where($query->expr()->eq('collaborator_id', $query->createNamedParameter($collaboratorId)))
->andWhere($query->expr()->eq('collaborator_type', $query->createNamedParameter($collaboratorType, IQueryBuilder::PARAM_INT)))
->executeQuery()
->fetchAll();

return array_map(function (array $row) {
return new AlbumInfo(
(int)$row['album_id'],
$row['user'],
$row['name'].' ('.$row['user'].')',
$row['location'],
(int)$row['created'],
(int)$row['last_added_photo']
);
}, $rows);
}

/**
* @param string $collaboratorId
* @param string $collaboratorsType - The type of the collaborator, either a user or a group.
Expand Down