|
|
|
|
@@ -94,7 +94,7 @@ class BoardMapper extends DeckMapper implements IPermissionMapper {
|
|
|
|
|
return $board;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function findAllForUser(string $userId, int $since = -1, $includeArchived = true, ?int $before = null): array {
|
|
|
|
|
public function findAllForUser(string $userId, ?int $since = null, bool $includeArchived = true, ?int $before = null): array {
|
|
|
|
|
$useCache = ($since === -1 && $includeArchived === true && $before === null);
|
|
|
|
|
if (!isset($this->userBoardCache[$userId]) || !$useCache) {
|
|
|
|
|
$groups = $this->groupManager->getUserGroupIds(
|
|
|
|
|
@@ -120,24 +120,33 @@ class BoardMapper extends DeckMapper implements IPermissionMapper {
|
|
|
|
|
* @param null $offset
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
public function findAllByUser($userId, $limit = null, $offset = null, $since = -1, $includeArchived = true, ?int $before = null) {
|
|
|
|
|
public function findAllByUser(string $userId, ?int $limit = null, ?int $offset = null, ?int $since = null,
|
|
|
|
|
bool $includeArchived = true, ?int $before = null) {
|
|
|
|
|
// FIXME: One moving to QBMapper we should allow filtering the boards probably by method chaining for additional where clauses
|
|
|
|
|
$sql = 'SELECT id, title, owner, color, archived, deleted_at, 0 as shared, last_modified FROM `*PREFIX*deck_boards` WHERE owner = ? AND last_modified > ?';
|
|
|
|
|
$params = [$userId, $since];
|
|
|
|
|
$sql = 'SELECT id, title, owner, color, archived, deleted_at, 0 as shared, last_modified FROM `*PREFIX*deck_boards` WHERE owner = ?';
|
|
|
|
|
$params = [$userId];
|
|
|
|
|
if (!$includeArchived) {
|
|
|
|
|
$sql .= ' AND NOT archived AND deleted_at = 0';
|
|
|
|
|
}
|
|
|
|
|
if ($since !== null) {
|
|
|
|
|
$sql .= ' AND last_modified > ?';
|
|
|
|
|
$params[] = $since;
|
|
|
|
|
}
|
|
|
|
|
if ($before !== null) {
|
|
|
|
|
$sql .= ' AND last_modified < ?';
|
|
|
|
|
$params[] = $before;
|
|
|
|
|
}
|
|
|
|
|
$sql .= ' UNION ' .
|
|
|
|
|
'SELECT boards.id, title, owner, color, archived, deleted_at, 1 as shared, last_modified FROM `*PREFIX*deck_boards` as boards ' .
|
|
|
|
|
'JOIN `*PREFIX*deck_board_acl` as acl ON boards.id=acl.board_id WHERE acl.participant=? AND acl.type=? AND boards.owner != ? AND last_modified > ?';
|
|
|
|
|
array_push($params, $userId, Acl::PERMISSION_TYPE_USER, $userId, $since);
|
|
|
|
|
'JOIN `*PREFIX*deck_board_acl` as acl ON boards.id=acl.board_id WHERE acl.participant=? AND acl.type=? AND boards.owner != ?';
|
|
|
|
|
array_push($params, $userId, Acl::PERMISSION_TYPE_USER, $userId);
|
|
|
|
|
if (!$includeArchived) {
|
|
|
|
|
$sql .= ' AND NOT archived AND deleted_at = 0';
|
|
|
|
|
}
|
|
|
|
|
if ($since !== null) {
|
|
|
|
|
$sql .= ' AND last_modified > ?';
|
|
|
|
|
$params[] = $since;
|
|
|
|
|
}
|
|
|
|
|
if ($before !== null) {
|
|
|
|
|
$sql .= ' AND last_modified < ?';
|
|
|
|
|
$params[] = $before;
|
|
|
|
|
@@ -165,7 +174,8 @@ class BoardMapper extends DeckMapper implements IPermissionMapper {
|
|
|
|
|
* @param null $offset
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
public function findAllByGroups($userId, $groups, $limit = null, $offset = null, $since = -1, $includeArchived = true, ?int $before = null) {
|
|
|
|
|
public function findAllByGroups(string $userId, array $groups, ?int $limit = null, ?int $offset = null, ?int $since = null,
|
|
|
|
|
bool $includeArchived = true, ?int $before = null) {
|
|
|
|
|
if (count($groups) <= 0) {
|
|
|
|
|
return [];
|
|
|
|
|
}
|
|
|
|
|
@@ -183,6 +193,10 @@ class BoardMapper extends DeckMapper implements IPermissionMapper {
|
|
|
|
|
if (!$includeArchived) {
|
|
|
|
|
$sql .= ' AND NOT archived AND deleted_at = 0';
|
|
|
|
|
}
|
|
|
|
|
if ($since !== null) {
|
|
|
|
|
$sql .= ' AND last_modified > ?';
|
|
|
|
|
$params[] = $since;
|
|
|
|
|
}
|
|
|
|
|
if ($before !== null) {
|
|
|
|
|
$sql .= ' AND last_modified < ?';
|
|
|
|
|
$params[] = $before;
|
|
|
|
|
@@ -196,7 +210,8 @@ class BoardMapper extends DeckMapper implements IPermissionMapper {
|
|
|
|
|
return $entries;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function findAllByCircles($userId, $limit = null, $offset = null, $since = -1, $includeArchived = true, ?int $before = null) {
|
|
|
|
|
public function findAllByCircles(string $userId, ?int $limit = null, ?int $offset = null, ?int $since = null,
|
|
|
|
|
bool $includeArchived = true, ?int $before = null) {
|
|
|
|
|
if (!$this->circlesEnabled) {
|
|
|
|
|
return [];
|
|
|
|
|
}
|
|
|
|
|
@@ -221,6 +236,10 @@ class BoardMapper extends DeckMapper implements IPermissionMapper {
|
|
|
|
|
if (!$includeArchived) {
|
|
|
|
|
$sql .= ' AND NOT archived AND deleted_at = 0';
|
|
|
|
|
}
|
|
|
|
|
if ($since !== null) {
|
|
|
|
|
$sql .= ' AND last_modified > ?';
|
|
|
|
|
$params[] = $since;
|
|
|
|
|
}
|
|
|
|
|
if ($before !== null) {
|
|
|
|
|
$sql .= ' AND last_modified < ?';
|
|
|
|
|
$params[] = $before;
|
|
|
|
|
|