|
@@ 306-309 (lines=4) @@
|
| 303 |
|
|
| 304 |
|
if ($shareType === \OCP\Share::SHARE_TYPE_USER) { |
| 305 |
|
// Valid user is required to share |
| 306 |
|
if ($shareWith === null || !$this->userManager->userExists($shareWith)) { |
| 307 |
|
$share->getNode()->unlock(ILockingProvider::LOCK_SHARED); |
| 308 |
|
return new \OC_OCS_Result(null, 404, $this->l->t('Please specify a valid user')); |
| 309 |
|
} |
| 310 |
|
$share->setSharedWith($shareWith); |
| 311 |
|
$share->setPermissions($permissions); |
| 312 |
|
} else if ($shareType === \OCP\Share::SHARE_TYPE_GROUP) { |
|
@@ 313-316 (lines=4) @@
|
| 310 |
|
$share->setSharedWith($shareWith); |
| 311 |
|
$share->setPermissions($permissions); |
| 312 |
|
} else if ($shareType === \OCP\Share::SHARE_TYPE_GROUP) { |
| 313 |
|
if (!$this->shareManager->allowGroupSharing()) { |
| 314 |
|
$share->getNode()->unlock(ILockingProvider::LOCK_SHARED); |
| 315 |
|
return new \OC_OCS_Result(null, 404, $this->l->t('Group sharing is disabled by the administrator')); |
| 316 |
|
} |
| 317 |
|
|
| 318 |
|
// Valid group is required to share |
| 319 |
|
if ($shareWith === null || !$this->groupManager->groupExists($shareWith)) { |
|
@@ 319-322 (lines=4) @@
|
| 316 |
|
} |
| 317 |
|
|
| 318 |
|
// Valid group is required to share |
| 319 |
|
if ($shareWith === null || !$this->groupManager->groupExists($shareWith)) { |
| 320 |
|
$share->getNode()->unlock(ILockingProvider::LOCK_SHARED); |
| 321 |
|
return new \OC_OCS_Result(null, 404, $this->l->t('Please specify a valid group')); |
| 322 |
|
} |
| 323 |
|
$share->setSharedWith($shareWith); |
| 324 |
|
$share->setPermissions($permissions); |
| 325 |
|
} else if ($shareType === \OCP\Share::SHARE_TYPE_LINK) { |
|
@@ 327-330 (lines=4) @@
|
| 324 |
|
$share->setPermissions($permissions); |
| 325 |
|
} else if ($shareType === \OCP\Share::SHARE_TYPE_LINK) { |
| 326 |
|
//Can we even share links? |
| 327 |
|
if (!$this->shareManager->shareApiAllowLinks()) { |
| 328 |
|
$share->getNode()->unlock(ILockingProvider::LOCK_SHARED); |
| 329 |
|
return new \OC_OCS_Result(null, 404, $this->l->t('Public link sharing is disabled by the administrator')); |
| 330 |
|
} |
| 331 |
|
|
| 332 |
|
/* |
| 333 |
|
* For now we only allow 1 link share. |
|
@@ 345-348 (lines=4) @@
|
| 342 |
|
$publicUpload = $this->request->getParam('publicUpload', null); |
| 343 |
|
if ($publicUpload === 'true') { |
| 344 |
|
// Check if public upload is allowed |
| 345 |
|
if (!$this->shareManager->shareApiLinkAllowPublicUpload()) { |
| 346 |
|
$share->getNode()->unlock(ILockingProvider::LOCK_SHARED); |
| 347 |
|
return new \OC_OCS_Result(null, 403, $this->l->t('Public upload disabled by the administrator')); |
| 348 |
|
} |
| 349 |
|
|
| 350 |
|
// Public upload can only be set for folders |
| 351 |
|
if ($path instanceof \OCP\Files\File) { |
|
@@ 351-354 (lines=4) @@
|
| 348 |
|
} |
| 349 |
|
|
| 350 |
|
// Public upload can only be set for folders |
| 351 |
|
if ($path instanceof \OCP\Files\File) { |
| 352 |
|
$share->getNode()->unlock(ILockingProvider::LOCK_SHARED); |
| 353 |
|
return new \OC_OCS_Result(null, 404, $this->l->t('Public upload is only possible for publicly shared folders')); |
| 354 |
|
} |
| 355 |
|
|
| 356 |
|
$share->setPermissions( |
| 357 |
|
\OCP\Constants::PERMISSION_READ | |
|
@@ 394-397 (lines=4) @@
|
| 391 |
|
|
| 392 |
|
$share->setSharedWith($shareWith); |
| 393 |
|
$share->setPermissions($permissions); |
| 394 |
|
} else { |
| 395 |
|
$share->getNode()->unlock(ILockingProvider::LOCK_SHARED); |
| 396 |
|
return new \OC_OCS_Result(null, 400, $this->l->t('Unknown share type')); |
| 397 |
|
} |
| 398 |
|
|
| 399 |
|
$share->setShareType($shareType); |
| 400 |
|
$share->setSharedBy($this->currentUser->getUID()); |
|
@@ 624-627 (lines=4) @@
|
| 621 |
|
// correct |
| 622 |
|
$newPermissions === (\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_DELETE) |
| 623 |
|
) { |
| 624 |
|
if (!$this->shareManager->shareApiLinkAllowPublicUpload()) { |
| 625 |
|
$share->getNode()->unlock(ILockingProvider::LOCK_SHARED); |
| 626 |
|
return new \OC_OCS_Result(null, 403, $this->l->t('Public upload disabled by the administrator')); |
| 627 |
|
} |
| 628 |
|
|
| 629 |
|
if (!($share->getNode() instanceof \OCP\Files\Folder)) { |
| 630 |
|
$share->getNode()->unlock(ILockingProvider::LOCK_SHARED); |
|
@@ 629-632 (lines=4) @@
|
| 626 |
|
return new \OC_OCS_Result(null, 403, $this->l->t('Public upload disabled by the administrator')); |
| 627 |
|
} |
| 628 |
|
|
| 629 |
|
if (!($share->getNode() instanceof \OCP\Files\Folder)) { |
| 630 |
|
$share->getNode()->unlock(ILockingProvider::LOCK_SHARED); |
| 631 |
|
return new \OC_OCS_Result(null, 400, $this->l->t('Public upload is only possible for publicly shared folders')); |
| 632 |
|
} |
| 633 |
|
|
| 634 |
|
// normalize to correct public upload permissions |
| 635 |
|
$newPermissions = \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_DELETE; |
|
@@ 682-685 (lines=4) @@
|
| 679 |
|
$maxPermissions |= $incomingShare->getPermissions(); |
| 680 |
|
} |
| 681 |
|
|
| 682 |
|
if ($share->getPermissions() & ~$maxPermissions) { |
| 683 |
|
$share->getNode()->unlock(ILockingProvider::LOCK_SHARED); |
| 684 |
|
return new \OC_OCS_Result(null, 404, $this->l->t('Cannot increase permissions')); |
| 685 |
|
} |
| 686 |
|
} |
| 687 |
|
} |
| 688 |
|
|
|
@@ 227-230 (lines=4) @@
|
| 224 |
|
return new \OC_OCS_Result(null, 404, 'could not delete share'); |
| 225 |
|
} |
| 226 |
|
|
| 227 |
|
if (!$this->canAccessShare($share, false)) { |
| 228 |
|
$share->getNode()->unlock(ILockingProvider::LOCK_SHARED); |
| 229 |
|
return new \OC_OCS_Result(null, 404, $this->l->t('Could not delete share')); |
| 230 |
|
} |
| 231 |
|
|
| 232 |
|
$this->shareManager->deleteShare($share); |
| 233 |
|
|
|
@@ 576-579 (lines=4) @@
|
| 573 |
|
|
| 574 |
|
$share->getNode()->lock(\OCP\Lock\ILockingProvider::LOCK_SHARED); |
| 575 |
|
|
| 576 |
|
if (!$this->canAccessShare($share, false)) { |
| 577 |
|
$share->getNode()->unlock(ILockingProvider::LOCK_SHARED); |
| 578 |
|
return new \OC_OCS_Result(null, 404, $this->l->t('Wrong share ID, share doesn\'t exist')); |
| 579 |
|
} |
| 580 |
|
|
| 581 |
|
$permissions = $this->request->getParam('permissions', null); |
| 582 |
|
$password = $this->request->getParam('password', null); |