diff --git a/lib/Db/AclMapper.php b/lib/Db/AclMapper.php index d34738d82..327d8aa34 100644 --- a/lib/Db/AclMapper.php +++ b/lib/Db/AclMapper.php @@ -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(); } }