aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Share20
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/Share20')
-rw-r--r--lib/private/Share20/DefaultShareProvider.php43
-rw-r--r--lib/private/Share20/Exception/BackendError.php1
-rw-r--r--lib/private/Share20/Exception/InvalidShare.php1
-rw-r--r--lib/private/Share20/Exception/ProviderException.php1
-rw-r--r--lib/private/Share20/LegacyHooks.php1
-rw-r--r--lib/private/Share20/Manager.php26
-rw-r--r--lib/private/Share20/ProviderFactory.php2
-rw-r--r--lib/private/Share20/Share.php7
8 files changed, 31 insertions, 51 deletions
diff --git a/lib/private/Share20/DefaultShareProvider.php b/lib/private/Share20/DefaultShareProvider.php
index ad002a1fc96..41a727593b3 100644
--- a/lib/private/Share20/DefaultShareProvider.php
+++ b/lib/private/Share20/DefaultShareProvider.php
@@ -249,7 +249,6 @@ class DefaultShareProvider implements IShareProvider {
* @throws \OCP\Files\NotFoundException
*/
public function update(\OCP\Share\IShare $share) {
-
$originalShare = $this->getShareById($share->getId());
if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) {
@@ -306,7 +305,6 @@ class DefaultShareProvider implements IShareProvider {
->andWhere($qb->expr()->neq('permissions', $qb->createNamedParameter(0)))
->set('permissions', $qb->createNamedParameter($share->getPermissions()))
->execute();
-
} elseif ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK) {
$qb = $this->dbConn->getQueryBuilder();
$qb->update('share')
@@ -380,7 +378,6 @@ class DefaultShareProvider implements IShareProvider {
} else {
$id = $data['id'];
}
-
} elseif ($share->getShareType() === IShare::TYPE_USER) {
if ($share->getSharedWith() !== $recipient) {
throw new ProviderException('Recipient does not match');
@@ -431,7 +428,7 @@ class DefaultShareProvider implements IShareProvider {
->orderBy('id');
$cursor = $qb->execute();
- while($data = $cursor->fetch()) {
+ while ($data = $cursor->fetch()) {
$children[] = $this->createShare($data);
}
$cursor->closeCursor();
@@ -471,7 +468,6 @@ class DefaultShareProvider implements IShareProvider {
*/
public function deleteFromSelf(IShare $share, $recipient) {
if ($share->getShareType() === IShare::TYPE_GROUP) {
-
$group = $this->groupManager->get($share->getSharedWith());
$user = $this->userManager->get($recipient);
@@ -518,9 +514,7 @@ class DefaultShareProvider implements IShareProvider {
->where($qb->expr()->eq('id', $qb->createNamedParameter($id)))
->execute();
}
-
} elseif ($share->getShareType() === IShare::TYPE_USER) {
-
if ($share->getSharedWith() !== $recipient) {
throw new ProviderException('Recipient does not match');
}
@@ -600,7 +594,6 @@ class DefaultShareProvider implements IShareProvider {
->set('file_target', $qb->createNamedParameter($share->getTarget()))
->where($qb->expr()->eq('id', $qb->createNamedParameter($share->getId())))
->execute();
-
} elseif ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) {
// Check if there is a usergroup share
@@ -737,7 +730,7 @@ class DefaultShareProvider implements IShareProvider {
$cursor = $qb->execute();
$shares = [];
- while($data = $cursor->fetch()) {
+ while ($data = $cursor->fetch()) {
$shares[] = $this->createShare($data);
}
$cursor->closeCursor();
@@ -816,7 +809,7 @@ class DefaultShareProvider implements IShareProvider {
->execute();
$shares = [];
- while($data = $cursor->fetch()) {
+ while ($data = $cursor->fetch()) {
$shares[] = $this->createShare($data);
}
$cursor->closeCursor();
@@ -887,13 +880,12 @@ class DefaultShareProvider implements IShareProvider {
$cursor = $qb->execute();
- while($data = $cursor->fetch()) {
+ while ($data = $cursor->fetch()) {
if ($this->isAccessibleResult($data)) {
$shares[] = $this->createShare($data);
}
}
$cursor->closeCursor();
-
} elseif ($shareType === \OCP\Share::SHARE_TYPE_GROUP) {
$user = $this->userManager->get($userId);
$allGroups = $this->groupManager->getUserGroups($user);
@@ -902,7 +894,7 @@ class DefaultShareProvider implements IShareProvider {
$shares2 = [];
$start = 0;
- while(true) {
+ while (true) {
$groups = array_slice($allGroups, $start, 100);
$start += 100;
@@ -933,8 +925,12 @@ class DefaultShareProvider implements IShareProvider {
}
- $groups = array_filter($groups, function ($group) { return $group instanceof IGroup; });
- $groups = array_map(function (IGroup $group) { return $group->getGID(); }, $groups);
+ $groups = array_filter($groups, function ($group) {
+ return $group instanceof IGroup;
+ });
+ $groups = array_map(function (IGroup $group) {
+ return $group->getGID();
+ }, $groups);
$qb->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_GROUP)))
->andWhere($qb->expr()->in('share_with', $qb->createNamedParameter(
@@ -947,7 +943,7 @@ class DefaultShareProvider implements IShareProvider {
));
$cursor = $qb->execute();
- while($data = $cursor->fetch()) {
+ while ($data = $cursor->fetch()) {
if ($offset > 0) {
$offset--;
continue;
@@ -1077,7 +1073,7 @@ class DefaultShareProvider implements IShareProvider {
$result = [];
$start = 0;
- while(true) {
+ while (true) {
/** @var Share[] $shareSlice */
$shareSlice = array_slice($shares, $start, 100);
$start += 100;
@@ -1109,7 +1105,7 @@ class DefaultShareProvider implements IShareProvider {
$stmt = $query->execute();
- while($data = $stmt->fetch()) {
+ while ($data = $stmt->fetch()) {
$shareMap[$data['parent']]->setPermissions((int)$data['permissions']);
$shareMap[$data['parent']]->setStatus((int)$data['accepted']);
$shareMap[$data['parent']]->setTarget($data['file_target']);
@@ -1212,7 +1208,7 @@ class DefaultShareProvider implements IShareProvider {
$cursor = $qb->execute();
$ids = [];
- while($row = $cursor->fetch()) {
+ while ($row = $cursor->fetch()) {
$ids[] = (int)$row['id'];
}
$cursor->closeCursor();
@@ -1255,7 +1251,7 @@ class DefaultShareProvider implements IShareProvider {
$cursor = $qb->execute();
$ids = [];
- while($row = $cursor->fetch()) {
+ while ($row = $cursor->fetch()) {
$ids[] = (int)$row['id'];
}
$cursor->closeCursor();
@@ -1310,7 +1306,7 @@ class DefaultShareProvider implements IShareProvider {
$users = [];
$link = false;
- while($row = $cursor->fetch()) {
+ while ($row = $cursor->fetch()) {
$type = (int)$row['share_type'];
if ($type === \OCP\Share::SHARE_TYPE_USER) {
$uid = $row['share_with'];
@@ -1411,7 +1407,6 @@ class DefaultShareProvider implements IShareProvider {
* @throws \OCP\Files\NotFoundException
*/
private function sendNote(array $recipients, IShare $share) {
-
$toList = [];
foreach ($recipients as $recipient) {
@@ -1423,7 +1418,6 @@ class DefaultShareProvider implements IShareProvider {
}
if (!empty($toList)) {
-
$filename = $share->getNode()->getName();
$initiator = $share->getSharedBy();
$note = $share->getNote();
@@ -1475,7 +1469,6 @@ class DefaultShareProvider implements IShareProvider {
$message->useTemplate($emailTemplate);
$this->mailer->send($message);
}
-
}
public function getAllShares(): iterable {
@@ -1492,7 +1485,7 @@ class DefaultShareProvider implements IShareProvider {
);
$cursor = $qb->execute();
- while($data = $cursor->fetch()) {
+ while ($data = $cursor->fetch()) {
try {
$share = $this->createShare($data);
} catch (InvalidShare $e) {
diff --git a/lib/private/Share20/Exception/BackendError.php b/lib/private/Share20/Exception/BackendError.php
index b36cc1a9111..5ba17b7a458 100644
--- a/lib/private/Share20/Exception/BackendError.php
+++ b/lib/private/Share20/Exception/BackendError.php
@@ -23,5 +23,4 @@
namespace OC\Share20\Exception;
class BackendError extends \Exception {
-
}
diff --git a/lib/private/Share20/Exception/InvalidShare.php b/lib/private/Share20/Exception/InvalidShare.php
index 908049ae75a..1216bfa9aea 100644
--- a/lib/private/Share20/Exception/InvalidShare.php
+++ b/lib/private/Share20/Exception/InvalidShare.php
@@ -23,5 +23,4 @@
namespace OC\Share20\Exception;
class InvalidShare extends \Exception {
-
}
diff --git a/lib/private/Share20/Exception/ProviderException.php b/lib/private/Share20/Exception/ProviderException.php
index 7d3f79f7120..f60f5a8f385 100644
--- a/lib/private/Share20/Exception/ProviderException.php
+++ b/lib/private/Share20/Exception/ProviderException.php
@@ -23,5 +23,4 @@
namespace OC\Share20\Exception;
class ProviderException extends \Exception {
-
}
diff --git a/lib/private/Share20/LegacyHooks.php b/lib/private/Share20/LegacyHooks.php
index f292499584e..1e2391f0bd0 100644
--- a/lib/private/Share20/LegacyHooks.php
+++ b/lib/private/Share20/LegacyHooks.php
@@ -173,6 +173,5 @@ class LegacyHooks {
];
\OC_Hook::emit(Share::class, 'post_shared', $postHookData);
-
}
}
diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php
index 7ec678b07fb..b9a97e4225f 100644
--- a/lib/private/Share20/Manager.php
+++ b/lib/private/Share20/Manager.php
@@ -234,7 +234,7 @@ class Manager implements IManager {
if ($share->getSharedWith() === null) {
throw new \InvalidArgumentException('SharedWith should not be empty');
}
- } elseif ($share->getShareType() === \OCP\Share::SHARE_TYPE_REMOTE_GROUP) {
+ } elseif ($share->getShareType() === \OCP\Share::SHARE_TYPE_REMOTE_GROUP) {
if ($share->getSharedWith() === null) {
throw new \InvalidArgumentException('SharedWith should not be empty');
}
@@ -442,7 +442,6 @@ class Manager implements IManager {
* @throws \Exception
*/
protected function validateExpirationDate(\OCP\Share\IShare $share) {
-
$expirationDate = $share->getExpirationDate();
if ($expirationDate !== null) {
@@ -532,7 +531,7 @@ class Manager implements IManager {
*/
$provider = $this->factory->getProviderForType(\OCP\Share::SHARE_TYPE_USER);
$existingShares = $provider->getSharesByPath($share->getNode());
- foreach($existingShares as $existingShare) {
+ foreach ($existingShares as $existingShare) {
// Ignore if it is the same share
try {
if ($existingShare->getFullId() === $share->getFullId()) {
@@ -589,7 +588,7 @@ class Manager implements IManager {
*/
$provider = $this->factory->getProviderForType(\OCP\Share::SHARE_TYPE_GROUP);
$existingShares = $provider->getSharesByPath($share->getNode());
- foreach($existingShares as $existingShare) {
+ foreach ($existingShares as $existingShare) {
try {
if ($existingShare->getFullId() === $share->getFullId()) {
continue;
@@ -658,7 +657,7 @@ class Manager implements IManager {
// Make sure that we do not share a path that contains a shared mountpoint
if ($path instanceof \OCP\Files\Folder) {
$mounts = $this->mountManager->findIn($path->getPath());
- foreach($mounts as $mount) {
+ foreach ($mounts as $mount) {
if ($mount->getStorage()->instanceOfStorage('\OCA\Files_Sharing\ISharedStorage')) {
throw new \InvalidArgumentException('Path contains files shared with you');
}
@@ -706,7 +705,7 @@ class Manager implements IManager {
$storage = $share->getNode()->getStorage();
if ($storage->instanceOfStorage('OCA\Files_Sharing\External\Storage')) {
$parent = $share->getNode()->getParent();
- while($parent->getStorage()->instanceOfStorage('OCA\Files_Sharing\External\Storage')) {
+ while ($parent->getStorage()->instanceOfStorage('OCA\Files_Sharing\External\Storage')) {
$parent = $parent->getParent();
}
$share->setShareOwner($parent->getOwner()->getUID());
@@ -720,13 +719,11 @@ class Manager implements IManager {
//Verify the expiration date
$share = $this->validateExpirationDateInternal($share);
-
} elseif ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) {
$this->groupCreateChecks($share);
//Verify the expiration date
$share = $this->validateExpirationDateInternal($share);
-
} elseif ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK) {
$this->linkCreateChecks($share);
$this->setLinkParent($share);
@@ -797,7 +794,7 @@ class Manager implements IManager {
if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) {
$mailSend = $share->getMailSend();
- if($mailSend === true) {
+ if ($mailSend === true) {
$user = $this->userManager->get($share->getSharedWith());
if ($user !== null) {
$emailAddress = $user->getEMailAddress();
@@ -888,7 +885,7 @@ class Manager implements IManager {
// The "Reply-To" is set to the sharer if an mail address is configured
// also the default footer contains a "Do not reply" which needs to be adjusted.
$initiatorEmail = $initiatorUser->getEMailAddress();
- if($initiatorEmail !== null) {
+ if ($initiatorEmail !== null) {
$message->setReplyTo([$initiatorEmail => $initiatorDisplayName]);
$emailTemplate->addFooter($instanceName . ($this->defaults->getSlogan() !== '' ? ' - ' . $this->defaults->getSlogan() : ''));
} else {
@@ -898,7 +895,7 @@ class Manager implements IManager {
$message->useTemplate($emailTemplate);
try {
$failedRecipients = $this->mailer->send($message);
- if(!empty($failedRecipients)) {
+ if (!empty($failedRecipients)) {
$this->logger->error('Share notification mail could not be sent to: ' . implode(', ', $failedRecipients));
return;
}
@@ -1117,7 +1114,6 @@ class Manager implements IManager {
* @throws \InvalidArgumentException
*/
public function deleteShare(\OCP\Share\IShare $share) {
-
try {
$share->getFullId();
} catch (\UnexpectedValueException $e) {
@@ -1238,10 +1234,9 @@ class Manager implements IManager {
$shares2 = [];
- while(true) {
+ while (true) {
$added = 0;
foreach ($shares as $share) {
-
try {
$this->checkExpireDate($share);
} catch (ShareNotFound $e) {
@@ -1381,7 +1376,7 @@ class Manager implements IManager {
}
$share = null;
try {
- if($this->shareApiAllowLinks()) {
+ if ($this->shareApiAllowLinks()) {
$provider = $this->factory->getProviderForType(\OCP\Share::SHARE_TYPE_LINK);
$share = $provider->getShareByToken($token);
}
@@ -1450,7 +1445,6 @@ class Manager implements IManager {
$this->deleteShare($share);
throw new ShareNotFound($this->l->t('The requested share does not exist anymore'));
}
-
}
/**
diff --git a/lib/private/Share20/ProviderFactory.php b/lib/private/Share20/ProviderFactory.php
index cf23779a8b9..6186d1c37cf 100644
--- a/lib/private/Share20/ProviderFactory.php
+++ b/lib/private/Share20/ProviderFactory.php
@@ -197,7 +197,6 @@ class ProviderFactory implements IProviderFactory {
* @suppress PhanUndeclaredClassMethod
*/
protected function getShareByCircleProvider() {
-
if ($this->circlesAreNotAvailable) {
return null;
}
@@ -210,7 +209,6 @@ class ProviderFactory implements IProviderFactory {
}
if ($this->shareByCircleProvider === null) {
-
$this->shareByCircleProvider = new \OCA\Circles\ShareByCircleProvider(
$this->serverContainer->getDatabaseConnection(),
$this->serverContainer->getSecureRandom(),
diff --git a/lib/private/Share20/Share.php b/lib/private/Share20/Share.php
index b05b72e7ada..fb4fc4c4078 100644
--- a/lib/private/Share20/Share.php
+++ b/lib/private/Share20/Share.php
@@ -112,7 +112,7 @@ class Share implements \OCP\Share\IShare {
$id = (string)$id;
}
- if(!is_string($id)) {
+ if (!is_string($id)) {
throw new \InvalidArgumentException('String expected.');
}
@@ -145,7 +145,7 @@ class Share implements \OCP\Share\IShare {
* @inheritdoc
*/
public function setProviderId($id) {
- if(!is_string($id)) {
+ if (!is_string($id)) {
throw new \InvalidArgumentException('String expected.');
}
@@ -172,14 +172,13 @@ class Share implements \OCP\Share\IShare {
*/
public function getNode() {
if ($this->node === null) {
-
if ($this->shareOwner === null || $this->fileId === null) {
throw new NotFoundException();
}
// for federated shares the owner can be a remote user, in this
// case we use the initiator
- if($this->userManager->userExists($this->shareOwner)) {
+ if ($this->userManager->userExists($this->shareOwner)) {
$userFolder = $this->rootFolder->getUserFolder($this->shareOwner);
} else {
$userFolder = $this->rootFolder->getUserFolder($this->sharedBy);