Skip to content

Commit

Permalink
add share by mail share provider
Browse files Browse the repository at this point in the history
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
  • Loading branch information
schiessle committed Oct 5, 2016
1 parent 5cf90a3 commit 9701f31
Show file tree
Hide file tree
Showing 8 changed files with 671 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
!/apps/files
!/apps/federation
!/apps/federatedfilesharing
!/apps/sharebymail
!/apps/encryption
!/apps/files_external
!/apps/files_sharing
Expand Down
21 changes: 19 additions & 2 deletions apps/files_sharing/lib/API/Share20OCS.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ protected function formatShare(\OCP\Share\IShare $share) {
$result['share_with'] = $share->getSharedWith();
$result['share_with_displayname'] = $share->getSharedWith();
$result['token'] = $share->getToken();
} else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_EMAIL) {
$result['share_with'] = $share->getSharedWith();
$result['share_with_displayname'] = $share->getSharedWith();
$result['token'] = $share->getToken();
}

$result['mail_send'] = $share->getMailSend() ? 1 : 0;
Expand Down Expand Up @@ -390,6 +394,9 @@ public function createShare(

$share->setSharedWith($shareWith);
$share->setPermissions($permissions);
} else if ($shareType === \OCP\Share::SHARE_TYPE_EMAIL) {
$share->setPermissions(\OCP\Constants::PERMISSION_READ);
$share->setSharedWith($shareWith);
} else {
throw new OCSBadRequestException($this->l->t('Unknown share type'));
}
Expand Down Expand Up @@ -456,6 +463,7 @@ private function getSharesInDir($folder) {
$shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser->getUID(), \OCP\Share::SHARE_TYPE_USER, $node, false, -1, 0));
$shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser->getUID(), \OCP\Share::SHARE_TYPE_GROUP, $node, false, -1, 0));
$shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser->getUID(), \OCP\Share::SHARE_TYPE_LINK, $node, false, -1, 0));
$shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser->getUID(), \OCP\Share::SHARE_TYPE_EMAIL, $node, false, -1, 0));
if ($this->shareManager->outgoingServer2ServerSharesAllowed()) {
$shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser->getUID(), \OCP\Share::SHARE_TYPE_REMOTE, $node, false, -1, 0));
}
Expand Down Expand Up @@ -531,7 +539,8 @@ public function getShares(
$userShares = $this->shareManager->getSharesBy($this->currentUser->getUID(), \OCP\Share::SHARE_TYPE_USER, $path, $reshares, -1, 0);
$groupShares = $this->shareManager->getSharesBy($this->currentUser->getUID(), \OCP\Share::SHARE_TYPE_GROUP, $path, $reshares, -1, 0);
$linkShares = $this->shareManager->getSharesBy($this->currentUser->getUID(), \OCP\Share::SHARE_TYPE_LINK, $path, $reshares, -1, 0);
$shares = array_merge($userShares, $groupShares, $linkShares);
$mailShares = $this->shareManager->getSharesBy($this->currentUser->getUID(), \OCP\Share::SHARE_TYPE_EMAIL, $path, $reshares, -1, 0);
$shares = array_merge($userShares, $groupShares, $linkShares, $mailShares);

if ($this->shareManager->outgoingServer2ServerSharesAllowed()) {
$federatedShares = $this->shareManager->getSharesBy($this->currentUser->getUID(), \OCP\Share::SHARE_TYPE_REMOTE, $path, $reshares, -1, 0);
Expand Down Expand Up @@ -761,7 +770,15 @@ private function getShareById($id) {

// First check if it is an internal share.
try {
$share = $this->shareManager->getShareById('ocinternal:'.$id);
$share = $this->shareManager->getShareById('ocinternal:' . $id);
return $share;
} catch (ShareNotFound $e) {
// Do nothing, just try the other share type
}

try {
$share = $this->shareManager->getShareById('ocMailShare:' . $id);
return $share;
} catch (ShareNotFound $e) {
if (!$this->shareManager->outgoingServer2ServerSharesAllowed()) {
throw new ShareNotFound();
Expand Down
22 changes: 22 additions & 0 deletions apps/sharebymail/appinfo/app.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
/**
* @copyright Copyright (c) 2016 Bjoern Schiessle <bjoern@schiessle.org>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

$app = new \OCP\AppFramework\App('sharebymail');
14 changes: 14 additions & 0 deletions apps/sharebymail/appinfo/info.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0"?>
<info>
<id>sharebymail</id>
<name>Share by mail</name>
<description>Share provider which allows you to share files by mail</description>
<licence>AGPL</licence>
<author>Bjoern Schiessle</author>
<version>1.0.0</version>
<namespace>ShareByMail</namespace>
<category>other</category>
<dependencies>
<owncloud min-version="9.2" max-version="9.2" />
</dependencies>
</info>
Loading

0 comments on commit 9701f31

Please sign in to comment.