Browse Source
Allow users to specify to accept (internal) shares by default
Allow users to specify to accept (internal) shares by default
Fixes #18255 A new user setting allows a user to always accept (internal) shares. For example if they don't like accepting shares manually ;) Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>pull/18385/head
No known key found for this signature in database
GPG Key ID: F941078878347C0C
24 changed files with 410 additions and 55 deletions
-
4apps/files_sharing/appinfo/info.xml
-
6apps/files_sharing/appinfo/routes.php
-
3apps/files_sharing/composer/composer/autoload_classmap.php
-
3apps/files_sharing/composer/composer/autoload_static.php
-
4apps/files_sharing/js/dist/additionalScripts.js
-
2apps/files_sharing/js/dist/additionalScripts.js.map
-
2apps/files_sharing/js/dist/collaboration.js
-
2apps/files_sharing/js/dist/collaboration.js.map
-
2apps/files_sharing/js/dist/files_sharing.js
-
2apps/files_sharing/js/dist/files_sharing.js.map
-
88apps/files_sharing/js/dist/files_sharing_tab.js
-
2apps/files_sharing/js/dist/files_sharing_tab.js.map
-
2apps/files_sharing/js/dist/main.js
-
2apps/files_sharing/js/dist/main.js.map
-
36apps/files_sharing/js/dist/personal-settings.js
-
1apps/files_sharing/js/dist/personal-settings.js.map
-
2apps/files_sharing/lib/AppInfo/Application.php
-
54apps/files_sharing/lib/Controller/SettingsController.php
-
59apps/files_sharing/lib/Listener/UserShareAcceptanceListener.php
-
62apps/files_sharing/lib/Settings/Personal.php
-
59apps/files_sharing/src/components/PersonalSettings.vue
-
38apps/files_sharing/src/personal-settings.js
-
29apps/files_sharing/templates/Settings/personal.php
-
1apps/files_sharing/webpack.js
4
apps/files_sharing/js/dist/additionalScripts.js
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
2
apps/files_sharing/js/dist/additionalScripts.js.map
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -1,2 +1,2 @@ |
|||
!function(e){var n={};function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:r})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,n){if(1&n&&(e=t(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(t.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var o in e)t.d(r,o,function(n){return e[n]}.bind(null,o));return r},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.p="/js/",t(t.s=110)}({110:function(e,n,r){r.p=OC.linkTo("files_sharing","js/dist/"),r.nc=btoa(OC.requestToken),window.OCP.Collaboration.registerType("file",{action:function(){return new Promise((function(e,n){OC.dialogs.filepicker(t("files_sharing","Link to a file"),(function(t){OC.Files.getClient().getFileInfo(t).then((function(n,t){e(t.id)})).fail((function(){n(new Error("Cannot get fileinfo"))}))}),!1,null,!1,OC.dialogs.FILEPICKER_TYPE_CHOOSE,"",{allowDirectoryChooser:!0})}))},typeString:t("files_sharing","Link to a file"),typeIconClass:"icon-files-dark"})}}); |
|||
!function(e){var n={};function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:r})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,n){if(1&n&&(e=t(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(t.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var o in e)t.d(r,o,function(n){return e[n]}.bind(null,o));return r},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.p="/js/",t(t.s=220)}({220:function(e,n,r){r.p=OC.linkTo("files_sharing","js/dist/"),r.nc=btoa(OC.requestToken),window.OCP.Collaboration.registerType("file",{action:function(){return new Promise((function(e,n){OC.dialogs.filepicker(t("files_sharing","Link to a file"),(function(t){OC.Files.getClient().getFileInfo(t).then((function(n,t){e(t.id)})).fail((function(){n(new Error("Cannot get fileinfo"))}))}),!1,null,!1,OC.dialogs.FILEPICKER_TYPE_CHOOSE,"",{allowDirectoryChooser:!0})}))},typeString:t("files_sharing","Link to a file"),typeIconClass:"icon-files-dark"})}}); |
|||
//# sourceMappingURL=collaboration.js.map
|
2
apps/files_sharing/js/dist/collaboration.js.map
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
2
apps/files_sharing/js/dist/files_sharing.js
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
2
apps/files_sharing/js/dist/files_sharing.js.map
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
88
apps/files_sharing/js/dist/files_sharing_tab.js
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
2
apps/files_sharing/js/dist/files_sharing_tab.js.map
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
2
apps/files_sharing/js/dist/main.js.map
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
36
apps/files_sharing/js/dist/personal-settings.js
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
1
apps/files_sharing/js/dist/personal-settings.js.map
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1,54 @@ |
|||
<?php |
|||
declare(strict_types=1); |
|||
/** |
|||
* @copyright Copyright (c) 2019, Roeland Jago Douma <roeland@famdouma.nl> |
|||
* |
|||
* @author Roeland Jago Douma <roeland@famdouma.nl> |
|||
* |
|||
* @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/>. |
|||
* |
|||
*/ |
|||
|
|||
namespace OCA\Files_Sharing\Controller; |
|||
|
|||
use OCA\Files_Sharing\AppInfo\Application; |
|||
use OCP\AppFramework\Controller; |
|||
use OCP\AppFramework\Http\JSONResponse; |
|||
use OCP\IConfig; |
|||
use OCP\IRequest; |
|||
|
|||
class SettingsController extends Controller { |
|||
|
|||
/** @var IConfig */ |
|||
private $config; |
|||
/** @var string */ |
|||
private $userId; |
|||
|
|||
public function __construct(IRequest $request, IConfig $config, string $userId) { |
|||
parent::__construct(Application::APP_ID, $request); |
|||
|
|||
$this->config = $config; |
|||
$this->userId = $userId; |
|||
} |
|||
|
|||
/** |
|||
* @NoAdminRequired |
|||
*/ |
|||
public function setDefaultAccept(bool $accept): JSONResponse { |
|||
$this->config->setUserValue($this->userId, Application::APP_ID, 'default_accept', $accept ? 'yes' : 'no'); |
|||
return new JSONResponse(); |
|||
} |
|||
} |
@ -0,0 +1,59 @@ |
|||
<?php |
|||
declare(strict_types=1); |
|||
/** |
|||
* @copyright Copyright (c) 2019, Roeland Jago Douma <roeland@famdouma.nl> |
|||
* |
|||
* @author Roeland Jago Douma <roeland@famdouma.nl> |
|||
* |
|||
* @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/>. |
|||
* |
|||
*/ |
|||
|
|||
namespace OCA\Files_Sharing\Listener; |
|||
|
|||
use OCP\EventDispatcher\Event; |
|||
use OCP\EventDispatcher\IEventListener; |
|||
use OCP\IConfig; |
|||
use OCP\Share\Events\SharedEvent; |
|||
use OCP\Share\IManager; |
|||
|
|||
class UserShareAcceptanceListener implements IEventListener { |
|||
|
|||
/** @var IConfig */ |
|||
private $config; |
|||
/** @var IManager */ |
|||
private $shareManager; |
|||
/** @var string */ |
|||
private $userId; |
|||
|
|||
public function __construct(IConfig $config, IManager $shareManager, string $userId) { |
|||
$this->config = $config; |
|||
$this->shareManager = $shareManager; |
|||
$this->userId = $userId; |
|||
} |
|||
|
|||
public function handle(Event $event): void { |
|||
if (!($event instanceof SharedEvent)) { |
|||
return; |
|||
} |
|||
|
|||
if ($this->config->getUserValue($this->userId, 'files_sharing','default_accept','no') === 'yes') { |
|||
$share = $event->getShare(); |
|||
$this->shareManager->acceptShare($share, $this->userId); |
|||
} |
|||
} |
|||
|
|||
} |
@ -0,0 +1,62 @@ |
|||
<?php |
|||
declare(strict_types=1); |
|||
/** |
|||
* @copyright Copyright (c) 2019, Roeland Jago Douma <roeland@famdouma.nl> |
|||
* |
|||
* @author Roeland Jago Douma <roeland@famdouma.nl> |
|||
* |
|||
* @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/>. |
|||
* |
|||
*/ |
|||
|
|||
namespace OCA\Files_Sharing\Settings; |
|||
|
|||
use OCA\Files_Sharing\AppInfo\Application; |
|||
use OCP\AppFramework\Http\TemplateResponse; |
|||
use OCP\IConfig; |
|||
use OCP\IInitialStateService; |
|||
use OCP\Settings\ISettings; |
|||
|
|||
class Personal implements ISettings { |
|||
|
|||
/** @var IConfig */ |
|||
private $config; |
|||
/** @var IInitialStateService */ |
|||
private $initialState; |
|||
/** @var string */ |
|||
private $userId; |
|||
|
|||
public function __construct(IConfig $config, IInitialStateService $initialState, string $userId) { |
|||
$this->config = $config; |
|||
$this->initialState = $initialState; |
|||
$this->userId = $userId; |
|||
} |
|||
|
|||
public function getForm(): TemplateResponse { |
|||
$value = $this->config->getUserValue($this->userId, Application::APP_ID, 'default_accept', 'no') === 'yes'; |
|||
$this->initialState->provideInitialState(Application::APP_ID, 'accept_default', $value); |
|||
return new TemplateResponse('files_sharing', 'Settings/personal'); |
|||
} |
|||
|
|||
public function getSection(): string { |
|||
return 'sharing'; |
|||
} |
|||
|
|||
public function getPriority(): int { |
|||
return 90; |
|||
} |
|||
|
|||
} |
@ -0,0 +1,59 @@ |
|||
<!-- |
|||
- @copyright 2019 Roeland Jago Douma <roeland@famdouma.nl> |
|||
- |
|||
- @author 2019 Roeland Jago Douma <roeland@famdouma.nl> |
|||
- |
|||
- @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/>. |
|||
--> |
|||
|
|||
<template> |
|||
<div id="files-sharing-personal-settings" class="section"> |
|||
<h2>{{ t('files', 'Sharing') }}</h2> |
|||
<input id="files-sharing-personal-settings-accept" |
|||
v-model="accepting" |
|||
type="checkbox" |
|||
@change="toggleEnabled"> |
|||
<label for="files-sharing-personal-settings-accept">{{ t('files_sharing', 'Accept user and group shares by default') }}</label> |
|||
</div> |
|||
</template> |
|||
|
|||
<script> |
|||
import axios from '@nextcloud/axios' |
|||
import { loadState } from '@nextcloud/initial-state' |
|||
import { generateUrl } from '@nextcloud/router' |
|||
|
|||
export default { |
|||
name: 'PersonalSettings', |
|||
data() { |
|||
return { |
|||
accepting: true |
|||
} |
|||
}, |
|||
mounted() { |
|||
this.accepting = loadState('files_sharing', 'accept_default') |
|||
}, |
|||
methods: { |
|||
toggleEnabled() { |
|||
axios.put( |
|||
generateUrl('/apps/files_sharing/settings/defaultAccept'), |
|||
{ |
|||
accept: this.accepting |
|||
} |
|||
) |
|||
} |
|||
} |
|||
} |
|||
</script> |
@ -0,0 +1,38 @@ |
|||
// global t
|
|||
|
|||
/* |
|||
* @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at> |
|||
* |
|||
* @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at> |
|||
* |
|||
* @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/>.
|
|||
*/ |
|||
|
|||
import Vue from 'vue' |
|||
import { getRequestToken } from '@nextcloud/auth' |
|||
import { generateFilePath } from '@nextcloud/router' |
|||
|
|||
import PersonalSettings from './components/PersonalSettings' |
|||
|
|||
// eslint-disable-next-line camelcase
|
|||
__webpack_nonce__ = btoa(getRequestToken()) |
|||
// eslint-disable-next-line camelcase
|
|||
__webpack_public_path__ = generateFilePath('files', '', 'js/') |
|||
|
|||
Vue.prototype.t = t |
|||
|
|||
const View = Vue.extend(PersonalSettings) |
|||
new View().$mount('#files-personal-settings') |
@ -0,0 +1,29 @@ |
|||
<?php |
|||
declare(strict_types=1); |
|||
/** |
|||
* @copyright Copyright (c) 2019, Roeland Jago Douma <roeland@famdouma.nl> |
|||
* |
|||
* @author Roeland Jago Douma <roeland@famdouma.nl> |
|||
* |
|||
* @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/>. |
|||
* |
|||
*/ |
|||
|
|||
script(\OCA\Files_Sharing\AppInfo\Application::APP_ID, 'dist/personal-settings'); |
|||
|
|||
?>
|
|||
<div id="files-sharing-personal-settings" class="section"> |
|||
</div> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue