Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
delete shares to an user
Signed-off-by: Lukas Reschke <[email protected]>
  • Loading branch information
tcitworld authored and LukasReschke committed Sep 27, 2016
commit 5215833fe4b661c46dfed88eb29754011dbb899f
10 changes: 10 additions & 0 deletions apps/dav/lib/CalDAV/CalDavBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,16 @@ function deleteCalendar($calendarId) {
$this->sharingBackend->deleteAllShares($calendarId);
}

/**
* Delete all of an user's shares
*
* @param string $principaluri
* @return void
*/
function deleteAllSharesForUser($principaluri) {
$this->sharingBackend->deleteAllSharesByUser($principaluri);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For or By? This looks like a trap for the future 🙈

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, thanks.

}

/**
* Returns all calendar objects within a calendar.
*
Expand Down
8 changes: 8 additions & 0 deletions apps/dav/lib/DAV/Sharing/Backend.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,14 @@ public function deleteAllShares($resourceId) {
->execute();
}

public function deleteAllSharesByUser($principaluri) {
$query = $this->db->getQueryBuilder();
$query->delete('dav_shares')
->where($query->expr()->eq('principaluri', $query->createNamedParameter($principaluri)))
->andWhere($query->expr()->eq('type', $query->createNamedParameter($this->resourceType)))
->execute();
}

/**
* @param IShareable $shareable
* @param string $element
Expand Down
1 change: 1 addition & 0 deletions apps/dav/lib/HookManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public function postDeleteUser($params) {
foreach ($calendarsToDelete as $calendar) {
$this->calDav->deleteCalendar($calendar['id']);
}
$this->calDav->deleteAllSharesForUser('principals/users/' . $uid);

$addressBooksToDelete = $this->cardDav->getAddressBooksForUser('principals/users/' . $uid);
foreach ($addressBooksToDelete as $addressBook) {
Expand Down
1 change: 1 addition & 0 deletions apps/dav/tests/unit/DAV/HookManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ public function testDeleteCalendar() {
['id' => 'personal']
]);
$cal->expects($this->once())->method('deleteCalendar');
$cal->expects($this->once())->method('deleteAllSharesForUser');

/** @var CardDavBackend | \PHPUnit_Framework_MockObject_MockObject $card */
$card = $this->getMockBuilder(CardDavBackend::class)
Expand Down