Allow transfer of single boards

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl
2022-03-14 09:47:46 +01:00
parent b774090032
commit a45e46f80a
8 changed files with 114 additions and 39 deletions

View File

@@ -63,7 +63,7 @@ class AclMapper extends DeckMapper implements IPermissionMapper {
* @param $newOwnerId
* @return void
*/
public function transferOwnership($boardId, $ownerId, $newOwnerId) {
public function transferOwnership($boardId, $newOwnerId) {
$params = [
'newOwner' => $newOwnerId,
'type' => Acl::PERMISSION_TYPE_USER,

View File

@@ -153,7 +153,7 @@ class AssignmentMapper extends QBMapper implements IPermissionMapper {
* @param $newOwnerId
* @return void
*/
public function transferOwnership(string $ownerId, string $newOwnerId) {
public function transferOwnership(string $ownerId, string $newOwnerId, int $boardId = null) {
$params = [
'owner' => $ownerId,
'newOwner' => $newOwnerId,
@@ -164,7 +164,7 @@ class AssignmentMapper extends QBMapper implements IPermissionMapper {
(SELECT id FROM `*PREFIX*{$this->tableName}` WHERE `participant` = :owner)";
$stmt = $this->db->executeQuery($sql, $params);
$stmt->closeCursor();
$sql = "UPDATE `*PREFIX*{$this->tableName}` SET `participant` = :newOwner WHERE `participant` = :owner AND `type`= :type";
$stmt = $this->db->executeQuery($sql, $params);
$stmt->closeCursor();

View File

@@ -477,25 +477,23 @@ class BoardMapper extends QBMapper implements IPermissionMapper {
}
/**
* @param $ownerId
* @param $newOwnerId
* @return void
* @throws \OCP\DB\Exception
*/
public function transferOwnership($ownerId, $newOwnerId) {
$params = [
'owner' => $ownerId,
'newOwner' => $newOwnerId
];
$sql = "UPDATE `*PREFIX*{$this->tableName}` SET `owner` = :newOwner WHERE `owner` = :owner";
$stmt = $this->db->executeQuery($sql, $params);
$stmt->closeCursor();
public function transferOwnership(string $ownerId, string $newOwnerId, $boardId = null): void {
$qb = $this->db->getQueryBuilder();
$qb->update('deck_boards')
->set('owner', $qb->createNamedParameter($newOwnerId, IQueryBuilder::PARAM_STR))
->where($qb->expr()->eq('owner', $qb->createNamedParameter($ownerId, IQueryBuilder::PARAM_STR)));
if ($boardId !== null) {
$qb->andWhere($qb->expr()->eq('id', $qb->createNamedParameter($boardId, IQueryBuilder::PARAM_INT)));
}
$qb->executeStatement();
}
/**
* Reset cache for a given board or a given user
*/
public function flushCache(?int $boardId = null, ?string $userId = null)
{
public function flushCache(?int $boardId = null, ?string $userId = null) {
if ($boardId) {
unset($this->boardCache[$boardId]);
} else {

View File

@@ -587,12 +587,7 @@ class CardMapper extends QBMapper implements IPermissionMapper {
});
}
/**
* @param $ownerId
* @param $newOwnerId
* @return void
*/
public function transferOwnership($ownerId, $newOwnerId) {
public function transferOwnership(string $ownerId, string $newOwnerId, int $boardId = null): void {
$params = [
'owner' => $ownerId,
'newOwner' => $newOwnerId