|
@@ 384-389 (lines=6) @@
|
| 381 |
|
$itemName = $path; |
| 382 |
|
|
| 383 |
|
// verify that the file exists before we try to share it |
| 384 |
|
if (!$path) { |
| 385 |
|
$message = 'Sharing %s failed, because the file does not exist'; |
| 386 |
|
$message_t = $l->t('Sharing %s failed, because the file does not exist', array($itemSourceName)); |
| 387 |
|
\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName), \OCP\Util::DEBUG); |
| 388 |
|
throw new \Exception($message_t); |
| 389 |
|
} |
| 390 |
|
// verify that the user has share permission |
| 391 |
|
if (!\OC\Files\Filesystem::isSharable($path) || \OCP\Util::isSharingDisabledForUser()) { |
| 392 |
|
$message = 'You are not allowed to share %s'; |
|
@@ 436-441 (lines=6) @@
|
| 433 |
|
|
| 434 |
|
// Verify share type and sharing conditions are met |
| 435 |
|
if ($shareType === self::SHARE_TYPE_USER) { |
| 436 |
|
if ($shareWith == $uidOwner) { |
| 437 |
|
$message = 'Sharing %s failed, because you can not share with yourself'; |
| 438 |
|
$message_t = $l->t('Sharing %s failed, because you can not share with yourself', [$itemName]); |
| 439 |
|
\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName), \OCP\Util::DEBUG); |
| 440 |
|
throw new \Exception($message_t); |
| 441 |
|
} |
| 442 |
|
if (!\OC::$server->getUserManager()->userExists($shareWith)) { |
| 443 |
|
$message = 'Sharing %s failed, because the user %s does not exist'; |
| 444 |
|
$message_t = $l->t('Sharing %s failed, because the user %s does not exist', array($itemSourceName, $shareWith)); |
|
@@ 661-667 (lines=7) @@
|
| 658 |
|
} |
| 659 |
|
|
| 660 |
|
return $send; |
| 661 |
|
} else { |
| 662 |
|
// Future share types need to include their own conditions |
| 663 |
|
$message = 'Share type %s is not valid for %s'; |
| 664 |
|
$message_t = $l->t('Share type %s is not valid for %s', array($shareType, $itemSource)); |
| 665 |
|
\OCP\Util::writeLog('OCP\Share', sprintf($message, $shareType, $itemSource), \OCP\Util::DEBUG); |
| 666 |
|
throw new \Exception($message_t); |
| 667 |
|
} |
| 668 |
|
|
| 669 |
|
// Put the item into the database |
| 670 |
|
$result = self::put($itemType, $itemSource, $shareType, $shareWith, $uidOwner, $permissions, null, null, $itemSourceName, $expirationDate); |
|
@@ 776-781 (lines=6) @@
|
| 773 |
|
} |
| 774 |
|
} |
| 775 |
|
|
| 776 |
|
if ($date < $today) { |
| 777 |
|
$message = 'Cannot set expiration date. Expiration date is in the past'; |
| 778 |
|
$message_t = $l->t('Cannot set expiration date. Expiration date is in the past'); |
| 779 |
|
\OCP\Util::writeLog('OCP\Share', $message, \OCP\Util::WARN); |
| 780 |
|
throw new \Exception($message_t); |
| 781 |
|
} |
| 782 |
|
|
| 783 |
|
return $date; |
| 784 |
|
} |
|
@@ 884-889 (lines=6) @@
|
| 881 |
|
throw new \Exception($message_t); |
| 882 |
|
} |
| 883 |
|
return self::$backends[$itemType]; |
| 884 |
|
} else { |
| 885 |
|
$message = 'Sharing backend %s not found'; |
| 886 |
|
$message_t = $l->t('Sharing backend %s not found', array($class)); |
| 887 |
|
\OCP\Util::writeLog('OCP\Share', sprintf($message, $class), \OCP\Util::ERROR); |
| 888 |
|
throw new \Exception($message_t); |
| 889 |
|
} |
| 890 |
|
} |
| 891 |
|
$message = 'Sharing backend for %s not found'; |
| 892 |
|
$message_t = $l->t('Sharing backend for %s not found', array($itemType)); |
|
@@ 1737-1743 (lines=7) @@
|
| 1734 |
|
$result['fileSource'] = ($backend instanceof \OCP\Share_Backend_File_Dependent) ? $itemSource : null; |
| 1735 |
|
} |
| 1736 |
|
} |
| 1737 |
|
} else { |
| 1738 |
|
$message = 'Sharing %s failed, because resharing is not allowed'; |
| 1739 |
|
$message_t = $l->t('Sharing %s failed, because resharing is not allowed', array($itemSourceName)); |
| 1740 |
|
|
| 1741 |
|
\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName), \OCP\Util::DEBUG); |
| 1742 |
|
throw new \Exception($message_t); |
| 1743 |
|
} |
| 1744 |
|
} else { |
| 1745 |
|
$result['parent'] = null; |
| 1746 |
|
$result['suggestedItemTarget'] = null; |
|
@@ 1765-1771 (lines=7) @@
|
| 1762 |
|
$meta = \OC\Files\Filesystem::getFileInfo($result['filePath']); |
| 1763 |
|
$result['fileSource'] = $meta['fileid']; |
| 1764 |
|
} |
| 1765 |
|
if ($result['fileSource'] == -1) { |
| 1766 |
|
$message = 'Sharing %s failed, because the file could not be found in the file cache'; |
| 1767 |
|
$message_t = $l->t('Sharing %s failed, because the file could not be found in the file cache', array($itemSource)); |
| 1768 |
|
|
| 1769 |
|
\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSource), \OCP\Util::DEBUG); |
| 1770 |
|
throw new \Exception($message_t); |
| 1771 |
|
} |
| 1772 |
|
} else { |
| 1773 |
|
$result['filePath'] = null; |
| 1774 |
|
$result['fileSource'] = null; |