|
@@ 386-391 (lines=6) @@
|
| 383 |
|
$itemName = $path; |
| 384 |
|
|
| 385 |
|
// verify that the file exists before we try to share it |
| 386 |
|
if (!$path) { |
| 387 |
|
$message = 'Sharing %s failed, because the file does not exist'; |
| 388 |
|
$message_t = $l->t('Sharing %s failed, because the file does not exist', array($itemSourceName)); |
| 389 |
|
\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName), \OCP\Util::DEBUG); |
| 390 |
|
throw new \Exception($message_t); |
| 391 |
|
} |
| 392 |
|
// verify that the user has share permission |
| 393 |
|
if (!\OC\Files\Filesystem::isSharable($path) || \OCP\Util::isSharingDisabledForUser()) { |
| 394 |
|
$message = 'You are not allowed to share %s'; |
|
@@ 438-443 (lines=6) @@
|
| 435 |
|
|
| 436 |
|
// Verify share type and sharing conditions are met |
| 437 |
|
if ($shareType === self::SHARE_TYPE_USER) { |
| 438 |
|
if ($shareWith == $uidOwner) { |
| 439 |
|
$message = 'Sharing %s failed, because you can not share with yourself'; |
| 440 |
|
$message_t = $l->t('Sharing %s failed, because you can not share with yourself', [$itemName]); |
| 441 |
|
\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName), \OCP\Util::DEBUG); |
| 442 |
|
throw new \Exception($message_t); |
| 443 |
|
} |
| 444 |
|
if (!\OC_User::userExists($shareWith)) { |
| 445 |
|
$message = 'Sharing %s failed, because the user %s does not exist'; |
| 446 |
|
$message_t = $l->t('Sharing %s failed, because the user %s does not exist', array($itemSourceName, $shareWith)); |
|
@@ 663-669 (lines=7) @@
|
| 660 |
|
} |
| 661 |
|
|
| 662 |
|
return $send; |
| 663 |
|
} else { |
| 664 |
|
// Future share types need to include their own conditions |
| 665 |
|
$message = 'Share type %s is not valid for %s'; |
| 666 |
|
$message_t = $l->t('Share type %s is not valid for %s', array($shareType, $itemSource)); |
| 667 |
|
\OCP\Util::writeLog('OCP\Share', sprintf($message, $shareType, $itemSource), \OCP\Util::DEBUG); |
| 668 |
|
throw new \Exception($message_t); |
| 669 |
|
} |
| 670 |
|
|
| 671 |
|
// Put the item into the database |
| 672 |
|
$result = self::put($itemType, $itemSource, $shareType, $shareWith, $uidOwner, $permissions, null, null, $itemSourceName, $expirationDate); |
|
@@ 778-783 (lines=6) @@
|
| 775 |
|
} |
| 776 |
|
} |
| 777 |
|
|
| 778 |
|
if ($date < $today) { |
| 779 |
|
$message = 'Cannot set expiration date. Expiration date is in the past'; |
| 780 |
|
$message_t = $l->t('Cannot set expiration date. Expiration date is in the past'); |
| 781 |
|
\OCP\Util::writeLog('OCP\Share', $message, \OCP\Util::WARN); |
| 782 |
|
throw new \Exception($message_t); |
| 783 |
|
} |
| 784 |
|
|
| 785 |
|
return $date; |
| 786 |
|
} |
|
@@ 961-966 (lines=6) @@
|
| 958 |
|
throw new \Exception($message_t); |
| 959 |
|
} |
| 960 |
|
return self::$backends[$itemType]; |
| 961 |
|
} else { |
| 962 |
|
$message = 'Sharing backend %s not found'; |
| 963 |
|
$message_t = $l->t('Sharing backend %s not found', array($class)); |
| 964 |
|
\OCP\Util::writeLog('OCP\Share', sprintf($message, $class), \OCP\Util::ERROR); |
| 965 |
|
throw new \Exception($message_t); |
| 966 |
|
} |
| 967 |
|
} |
| 968 |
|
$message = 'Sharing backend for %s not found'; |
| 969 |
|
$message_t = $l->t('Sharing backend for %s not found', array($itemType)); |
|
@@ 1814-1820 (lines=7) @@
|
| 1811 |
|
$result['fileSource'] = ($backend instanceof \OCP\Share_Backend_File_Dependent) ? $itemSource : null; |
| 1812 |
|
} |
| 1813 |
|
} |
| 1814 |
|
} else { |
| 1815 |
|
$message = 'Sharing %s failed, because resharing is not allowed'; |
| 1816 |
|
$message_t = $l->t('Sharing %s failed, because resharing is not allowed', array($itemSourceName)); |
| 1817 |
|
|
| 1818 |
|
\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName), \OCP\Util::DEBUG); |
| 1819 |
|
throw new \Exception($message_t); |
| 1820 |
|
} |
| 1821 |
|
} else { |
| 1822 |
|
$result['parent'] = null; |
| 1823 |
|
$result['suggestedItemTarget'] = null; |
|
@@ 1842-1848 (lines=7) @@
|
| 1839 |
|
$meta = \OC\Files\Filesystem::getFileInfo($result['filePath']); |
| 1840 |
|
$result['fileSource'] = $meta['fileid']; |
| 1841 |
|
} |
| 1842 |
|
if ($result['fileSource'] == -1) { |
| 1843 |
|
$message = 'Sharing %s failed, because the file could not be found in the file cache'; |
| 1844 |
|
$message_t = $l->t('Sharing %s failed, because the file could not be found in the file cache', array($itemSource)); |
| 1845 |
|
|
| 1846 |
|
\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSource), \OCP\Util::DEBUG); |
| 1847 |
|
throw new \Exception($message_t); |
| 1848 |
|
} |
| 1849 |
|
} else { |
| 1850 |
|
$result['filePath'] = null; |
| 1851 |
|
$result['fileSource'] = null; |