From 26ae5e6dfbdd482e6fbfe1cd6a1161ff39f984cc Mon Sep 17 00:00:00 2001 From: Adam Serbinski Date: Fri, 27 May 2022 10:40:54 -0400 Subject: ShareByMailProvider: getAccessList: return full list of recipients Previously was returning only boolean true if the Node was shared by email, or false if not. Now provides an array containing the list of email share recipients. Signed-off-by: Adam Serbinski --- apps/sharebymail/lib/ShareByMailProvider.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'apps') diff --git a/apps/sharebymail/lib/ShareByMailProvider.php b/apps/sharebymail/lib/ShareByMailProvider.php index 5a840b895ff..8c5962e22fc 100644 --- a/apps/sharebymail/lib/ShareByMailProvider.php +++ b/apps/sharebymail/lib/ShareByMailProvider.php @@ -1098,18 +1098,26 @@ class ShareByMailProvider implements IShareProvider { } $qb = $this->dbConnection->getQueryBuilder(); - $qb->select('share_with') + $qb->select('share_with', 'file_source') ->from('share') ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_EMAIL))) ->andWhere($qb->expr()->in('file_source', $qb->createNamedParameter($ids, IQueryBuilder::PARAM_INT_ARRAY))) ->andWhere($qb->expr()->orX( $qb->expr()->eq('item_type', $qb->createNamedParameter('file')), $qb->expr()->eq('item_type', $qb->createNamedParameter('folder')) - )) - ->setMaxResults(1); + )); $cursor = $qb->executeQuery(); - $mail = $cursor->fetch() !== false; + $mail = array(); + while ($row = $cursor->fetch()) { + if ($currentAccess === false) { + $mail[] = $row['share_with']; + } else { + $mail[$row['share_with']] = [ + 'node_id' => $row['file_source'] + ]; + } + } $cursor->closeCursor(); return ['public' => $mail]; -- cgit v1.2.3 From 9c528d412c677b686d0776a43ec9567d6639a083 Mon Sep 17 00:00:00 2001 From: Adam Serbinski Date: Fri, 27 May 2022 11:29:15 -0400 Subject: ShareByMailProvider: getAccessList: add token to returned array This allows the share URI to be regenerated. Signed-off-by: Adam Serbinski --- apps/sharebymail/lib/ShareByMailProvider.php | 5 +++-- lib/private/Share20/Manager.php | 4 ++-- lib/public/Share/IManager.php | 8 ++++---- 3 files changed, 9 insertions(+), 8 deletions(-) (limited to 'apps') diff --git a/apps/sharebymail/lib/ShareByMailProvider.php b/apps/sharebymail/lib/ShareByMailProvider.php index 8c5962e22fc..a8c1174e289 100644 --- a/apps/sharebymail/lib/ShareByMailProvider.php +++ b/apps/sharebymail/lib/ShareByMailProvider.php @@ -1098,7 +1098,7 @@ class ShareByMailProvider implements IShareProvider { } $qb = $this->dbConnection->getQueryBuilder(); - $qb->select('share_with', 'file_source') + $qb->select('share_with', 'file_source', 'token') ->from('share') ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_EMAIL))) ->andWhere($qb->expr()->in('file_source', $qb->createNamedParameter($ids, IQueryBuilder::PARAM_INT_ARRAY))) @@ -1114,7 +1114,8 @@ class ShareByMailProvider implements IShareProvider { $mail[] = $row['share_with']; } else { $mail[$row['share_with']] = [ - 'node_id' => $row['file_source'] + 'node_id' => $row['file_source'], + 'token' => $row['token'] ]; } } diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php index 279750afaa6..bafea10b125 100644 --- a/lib/private/Share20/Manager.php +++ b/lib/private/Share20/Manager.php @@ -1690,8 +1690,8 @@ class Manager implements IManager { * ], * public => bool * mail => [ - * 'email1@maildomain1' => ['node_id' => 42], - * 'email2@maildomain2' => ['node_id' => 23], + * 'email1@maildomain1' => ['node_id' => 42, 'token' => 'aBcDeFg'], + * 'email2@maildomain2' => ['node_id' => 23, 'token' => 'hIjKlMn'], * ] * ] * diff --git a/lib/public/Share/IManager.php b/lib/public/Share/IManager.php index 18c429e1cec..1c75b306fe2 100644 --- a/lib/public/Share/IManager.php +++ b/lib/public/Share/IManager.php @@ -256,7 +256,7 @@ interface IManager { * |-folder2 (32) * |-fileA (42) * - * fileA is shared with user1 and user1@server1 email1@maildomain1 + * fileA is shared with user1 and user1@server1 and email1@maildomain1 * folder2 is shared with group2 (user4 is a member of group2) * folder1 is shared with user2 (renamed to "folder (1)") and user2@server2 * and email2@maildomain2 @@ -274,9 +274,9 @@ interface IManager { * ], * public => bool * mail => [ - * 'email1@maildomain1' => ['node_id' => 42], - * 'email2@maildomain2' => ['node_id' => 23], - * ] + * 'email1@maildomain1' => ['node_id' => 42, 'token' => 'aBcDeFg'], + * 'email2@maildomain2' => ['node_id' => 23, 'token' => 'hIjKlMn'], + * ] * * The access list to '/folder1/folder2/fileA' **without** $currentAccess is: * [ -- cgit v1.2.3 From 34ca6bd46ad926e23280d46f1591c60119724875 Mon Sep 17 00:00:00 2001 From: Adam Serbinski Date: Fri, 27 May 2022 11:42:26 -0400 Subject: ShareByMailProvider: getAccessList: recommended style changes Signed-off-by: Adam Serbinski --- apps/sharebymail/lib/ShareByMailProvider.php | 2 +- lib/private/Share20/Manager.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'apps') diff --git a/apps/sharebymail/lib/ShareByMailProvider.php b/apps/sharebymail/lib/ShareByMailProvider.php index a8c1174e289..3704de4309f 100644 --- a/apps/sharebymail/lib/ShareByMailProvider.php +++ b/apps/sharebymail/lib/ShareByMailProvider.php @@ -1108,7 +1108,7 @@ class ShareByMailProvider implements IShareProvider { )); $cursor = $qb->executeQuery(); - $mail = array(); + $mail = []; while ($row = $cursor->fetch()) { if ($currentAccess === false) { $mail[] = $row['share_with']; diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php index bafea10b125..2bef6ba3ce7 100644 --- a/lib/private/Share20/Manager.php +++ b/lib/private/Share20/Manager.php @@ -1690,9 +1690,9 @@ class Manager implements IManager { * ], * public => bool * mail => [ - * 'email1@maildomain1' => ['node_id' => 42, 'token' => 'aBcDeFg'], - * 'email2@maildomain2' => ['node_id' => 23, 'token' => 'hIjKlMn'], - * ] + * 'email1@maildomain1' => ['node_id' => 42, 'token' => 'aBcDeFg'], + * 'email2@maildomain2' => ['node_id' => 23, 'token' => 'hIjKlMn'], + * ] * ] * * The access list to '/folder1/folder2/fileA' **without** $currentAccess is: -- cgit v1.2.3 From 01e32340af1d01ace001e2f3c39f16d9f6cccd6d Mon Sep 17 00:00:00 2001 From: Adam Serbinski Date: Thu, 26 Jan 2023 10:19:54 -0500 Subject: ShareByMailProvider: getAccessList: set both array keys 'public' and 'mail' To preserve prior behaviour where 'public' was set 'true' if there are any mail recipients. The 'mail' key will be an array of email recipients. Signed-off-by: Adam Serbinski --- apps/sharebymail/lib/ShareByMailProvider.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'apps') diff --git a/apps/sharebymail/lib/ShareByMailProvider.php b/apps/sharebymail/lib/ShareByMailProvider.php index 3704de4309f..e7f1db25a9b 100644 --- a/apps/sharebymail/lib/ShareByMailProvider.php +++ b/apps/sharebymail/lib/ShareByMailProvider.php @@ -1108,6 +1108,7 @@ class ShareByMailProvider implements IShareProvider { )); $cursor = $qb->executeQuery(); + $public = $cursor->rowCount() > 0; $mail = []; while ($row = $cursor->fetch()) { if ($currentAccess === false) { @@ -1121,7 +1122,7 @@ class ShareByMailProvider implements IShareProvider { } $cursor->closeCursor(); - return ['public' => $mail]; + return ['public' => $public, 'mail' => $mail]; } public function getAllShares(): iterable { -- cgit v1.2.3 From f45eb75e3de1d82695f38f49f28e69278b7f9dbb Mon Sep 17 00:00:00 2001 From: Adam Serbinski Date: Thu, 21 Mar 2024 15:26:30 -0400 Subject: ShareByMailProvider: getAccessList: set correct value for 'public' PDOStatement::rowCount behavior is undefined for SELECT statements for some database types, therefore manually set the value for 'public' based on actual results fetched. Signed-off-by: Adam Serbinski --- apps/sharebymail/lib/ShareByMailProvider.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'apps') diff --git a/apps/sharebymail/lib/ShareByMailProvider.php b/apps/sharebymail/lib/ShareByMailProvider.php index e7f1db25a9b..f1bb3fe94ca 100644 --- a/apps/sharebymail/lib/ShareByMailProvider.php +++ b/apps/sharebymail/lib/ShareByMailProvider.php @@ -1108,9 +1108,10 @@ class ShareByMailProvider implements IShareProvider { )); $cursor = $qb->executeQuery(); - $public = $cursor->rowCount() > 0; + $public = false; $mail = []; while ($row = $cursor->fetch()) { + $public = true; if ($currentAccess === false) { $mail[] = $row['share_with']; } else { -- cgit v1.2.3