Just cleanup old ACL rules, there are none for the board owner so nothing to cleanup or persist there

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl
2020-11-10 12:54:17 +01:00
parent 7c68414435
commit c0886cfc7a

View File

@@ -69,28 +69,14 @@ class AclMapper extends DeckMapper implements IPermissionMapper {
'newOwner' => $newOwnerId,
'type' => Acl::PERMISSION_TYPE_USER
];
//We want preserve permissions from both users
$sql = "UPDATE `{$this->tableName}` AS `source`
LEFT JOIN `{$this->tableName}` AS `target`
ON `target`.`participant` = :newOwner AND `target`.`type` = :type
SET `source`.`permission_edit` =(`source`.`permission_edit` || `target`.`permission_edit`),
`source`.`permission_share` =(`source`.`permission_share` || `target`.`permission_share`),
`source`.`permission_manage` =(`source`.`permission_manage` || `target`.`permission_manage`)
WHERE `source`.`participant` = :owner AND `source`.`type` = :type";
$stmt = $this->execute($sql, $params);
$stmt->closeCursor();
//We can't transfer acl if target already in acl
// Drop existing ACL rules for the new owner
$sql = "DELETE FROM `{$this->tableName}`
WHERE `participant` = :newOwner
AND `type` = :type
AND EXISTS (SELECT `id` FROM (SELECT `id` FROM `{$this->tableName}`
WHERE `participant` = :owner AND `type` = :type) as tmp)";
WHERE `participant` = :newOwner AND `type` = :type) as tmp)";
$stmt = $this->execute($sql, $params);
$stmt->closeCursor();
//Now we can transfer without errors
$sqlUpdate = "UPDATE `{$this->tableName}`
SET `participant` = :newOwner WHERE `participant` = :owner AND `type` = :type";
$stmt = $this->execute($sqlUpdate, $params);
$stmt->closeCursor();
}
}