|
@@ 704-709 (lines=6) @@
|
| 701 |
|
$itemName = $path; |
| 702 |
|
|
| 703 |
|
// verify that the file exists before we try to share it |
| 704 |
|
if (!$path) { |
| 705 |
|
$message = 'Sharing %s failed, because the file does not exist'; |
| 706 |
|
$message_t = $l->t('Sharing %s failed, because the file does not exist', array($itemSourceName)); |
| 707 |
|
\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName), \OCP\Util::DEBUG); |
| 708 |
|
throw new \Exception($message_t); |
| 709 |
|
} |
| 710 |
|
// verify that the user has share permission |
| 711 |
|
if (!\OC\Files\Filesystem::isSharable($path) || \OCP\Util::isSharingDisabledForUser()) { |
| 712 |
|
$message = 'You are not allowed to share %s'; |
|
@@ 756-761 (lines=6) @@
|
| 753 |
|
|
| 754 |
|
// Verify share type and sharing conditions are met |
| 755 |
|
if ($shareType === self::SHARE_TYPE_USER) { |
| 756 |
|
if ($shareWith == $uidOwner) { |
| 757 |
|
$message = 'Sharing %s failed, because you can not share with yourself'; |
| 758 |
|
$message_t = $l->t('Sharing %s failed, because you can not share with yourself', [$itemName]); |
| 759 |
|
\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName), \OCP\Util::DEBUG); |
| 760 |
|
throw new \Exception($message_t); |
| 761 |
|
} |
| 762 |
|
if (!\OC_User::userExists($shareWith)) { |
| 763 |
|
$message = 'Sharing %s failed, because the user %s does not exist'; |
| 764 |
|
$message_t = $l->t('Sharing %s failed, because the user %s does not exist', array($itemSourceName, $shareWith)); |
|
@@ 982-988 (lines=7) @@
|
| 979 |
|
} |
| 980 |
|
|
| 981 |
|
return $send; |
| 982 |
|
} else { |
| 983 |
|
// Future share types need to include their own conditions |
| 984 |
|
$message = 'Share type %s is not valid for %s'; |
| 985 |
|
$message_t = $l->t('Share type %s is not valid for %s', array($shareType, $itemSource)); |
| 986 |
|
\OCP\Util::writeLog('OCP\Share', sprintf($message, $shareType, $itemSource), \OCP\Util::DEBUG); |
| 987 |
|
throw new \Exception($message_t); |
| 988 |
|
} |
| 989 |
|
|
| 990 |
|
// Put the item into the database |
| 991 |
|
$result = self::put($itemType, $itemSource, $shareType, $shareWith, $uidOwner, $permissions, null, null, $itemSourceName, $expirationDate); |
|
@@ 1402-1407 (lines=6) @@
|
| 1399 |
|
} |
| 1400 |
|
} |
| 1401 |
|
|
| 1402 |
|
if ($date < $today) { |
| 1403 |
|
$message = 'Cannot set expiration date. Expiration date is in the past'; |
| 1404 |
|
$message_t = $l->t('Cannot set expiration date. Expiration date is in the past'); |
| 1405 |
|
\OCP\Util::writeLog('OCP\Share', $message, \OCP\Util::WARN); |
| 1406 |
|
throw new \Exception($message_t); |
| 1407 |
|
} |
| 1408 |
|
|
| 1409 |
|
return $date; |
| 1410 |
|
} |
|
@@ 1628-1633 (lines=6) @@
|
| 1625 |
|
throw new \Exception($message_t); |
| 1626 |
|
} |
| 1627 |
|
return self::$backends[$itemType]; |
| 1628 |
|
} else { |
| 1629 |
|
$message = 'Sharing backend %s not found'; |
| 1630 |
|
$message_t = $l->t('Sharing backend %s not found', array($class)); |
| 1631 |
|
\OCP\Util::writeLog('OCP\Share', sprintf($message, $class), \OCP\Util::ERROR); |
| 1632 |
|
throw new \Exception($message_t); |
| 1633 |
|
} |
| 1634 |
|
} |
| 1635 |
|
$message = 'Sharing backend for %s not found'; |
| 1636 |
|
$message_t = $l->t('Sharing backend for %s not found', array($itemType)); |
|
@@ 2481-2487 (lines=7) @@
|
| 2478 |
|
$result['fileSource'] = ($backend instanceof \OCP\Share_Backend_File_Dependent) ? $itemSource : null; |
| 2479 |
|
} |
| 2480 |
|
} |
| 2481 |
|
} else { |
| 2482 |
|
$message = 'Sharing %s failed, because resharing is not allowed'; |
| 2483 |
|
$message_t = $l->t('Sharing %s failed, because resharing is not allowed', array($itemSourceName)); |
| 2484 |
|
|
| 2485 |
|
\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName), \OCP\Util::DEBUG); |
| 2486 |
|
throw new \Exception($message_t); |
| 2487 |
|
} |
| 2488 |
|
} else { |
| 2489 |
|
$result['parent'] = null; |
| 2490 |
|
$result['suggestedItemTarget'] = null; |
|
@@ 2509-2515 (lines=7) @@
|
| 2506 |
|
$meta = \OC\Files\Filesystem::getFileInfo($result['filePath']); |
| 2507 |
|
$result['fileSource'] = $meta['fileid']; |
| 2508 |
|
} |
| 2509 |
|
if ($result['fileSource'] == -1) { |
| 2510 |
|
$message = 'Sharing %s failed, because the file could not be found in the file cache'; |
| 2511 |
|
$message_t = $l->t('Sharing %s failed, because the file could not be found in the file cache', array($itemSource)); |
| 2512 |
|
|
| 2513 |
|
\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSource), \OCP\Util::DEBUG); |
| 2514 |
|
throw new \Exception($message_t); |
| 2515 |
|
} |
| 2516 |
|
} else { |
| 2517 |
|
$result['filePath'] = null; |
| 2518 |
|
$result['fileSource'] = null; |