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:
@@ -69,28 +69,14 @@ class AclMapper extends DeckMapper implements IPermissionMapper {
|
|||||||
'newOwner' => $newOwnerId,
|
'newOwner' => $newOwnerId,
|
||||||
'type' => Acl::PERMISSION_TYPE_USER
|
'type' => Acl::PERMISSION_TYPE_USER
|
||||||
];
|
];
|
||||||
//We want preserve permissions from both users
|
|
||||||
$sql = "UPDATE `{$this->tableName}` AS `source`
|
// Drop existing ACL rules for the new owner
|
||||||
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
|
|
||||||
$sql = "DELETE FROM `{$this->tableName}`
|
$sql = "DELETE FROM `{$this->tableName}`
|
||||||
WHERE `participant` = :newOwner
|
WHERE `participant` = :newOwner
|
||||||
AND `type` = :type
|
AND `type` = :type
|
||||||
AND EXISTS (SELECT `id` FROM (SELECT `id` FROM `{$this->tableName}`
|
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 = $this->execute($sql, $params);
|
||||||
$stmt->closeCursor();
|
$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();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user