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
fixes determining whether former user is a share owner
Signed-off-by: Arthur Schiwon <[email protected]>
  • Loading branch information
blizzz committed Oct 28, 2020
commit a5dbf387069f79413ff96435cd088bffd4b69d46
15 changes: 4 additions & 11 deletions apps/user_ldap/lib/User/OfflineUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,29 +242,22 @@ protected function fetchDetails() {
*/
protected function determineShares() {
$query = $this->db->prepare('
SELECT COUNT(`uid_owner`)
SELECT `uid_owner`
FROM `*PREFIX*share`
WHERE `uid_owner` = ?
', 1);
$query->execute(array($this->ocName));
$sResult = $query->fetchColumn(0);
if((int)$sResult === 1) {
if ($query->rowCount() > 0) {
$this->hasActiveShares = true;
return;
}

$query = $this->db->prepare('
SELECT COUNT(`owner`)
SELECT `owner`
FROM `*PREFIX*share_external`
WHERE `owner` = ?
', 1);
$query->execute(array($this->ocName));
$sResult = $query->fetchColumn(0);
if((int)$sResult === 1) {
$this->hasActiveShares = true;
return;
}

$this->hasActiveShares = false;
$this->hasActiveShares = $query->rowCount() > 0;
}
}
8 changes: 5 additions & 3 deletions apps/user_ldap/tests/User/OfflineUserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,12 @@ public function shareOwnerProvider(): array {
public function testHasActiveShares(int $internalOwnerships, int $externalOwnerships, bool $expected) {
$queryMock = $this->createMock(Statement::class);
$queryMock->expects($this->atLeastOnce())
->method('fetchColumn')
->method('execute');
$queryMock->expects($this->atLeastOnce())
->method('rowCount')
->willReturnOnConsecutiveCalls(
(string)$internalOwnerships,
(string)$externalOwnerships
$internalOwnerships > 0 ? 1 : 0,
$externalOwnerships > 0 ? 1 : 0
);

$this->dbc->expects($this->atLeastOnce())
Expand Down