2019-12-12 15:45:59 -05:00
|
|
|
<?php
|
2019-12-19 07:16:31 -05:00
|
|
|
|
2019-12-12 15:45:59 -05:00
|
|
|
declare(strict_types=1);
|
2019-12-19 07:16:31 -05:00
|
|
|
|
2019-12-12 15:45:59 -05:00
|
|
|
/**
|
2024-06-06 13:48:28 -04:00
|
|
|
* SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
2019-12-12 15:45:59 -05:00
|
|
|
*/
|
|
|
|
|
namespace OCA\Files_Sharing\Settings;
|
|
|
|
|
|
|
|
|
|
use OCA\Files_Sharing\AppInfo\Application;
|
2025-07-16 12:23:12 -04:00
|
|
|
use OCA\Files_Sharing\Helper;
|
2019-12-12 15:45:59 -05:00
|
|
|
use OCP\AppFramework\Http\TemplateResponse;
|
2021-03-02 13:52:39 -05:00
|
|
|
use OCP\AppFramework\Services\IInitialState;
|
2019-12-12 15:45:59 -05:00
|
|
|
use OCP\IConfig;
|
|
|
|
|
use OCP\Settings\ISettings;
|
|
|
|
|
|
|
|
|
|
class Personal implements ISettings {
|
|
|
|
|
|
2024-10-18 06:04:22 -04:00
|
|
|
public function __construct(
|
|
|
|
|
private IConfig $config,
|
|
|
|
|
private IInitialState $initialState,
|
|
|
|
|
private string $userId,
|
|
|
|
|
) {
|
2019-12-12 15:45:59 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getForm(): TemplateResponse {
|
2020-01-16 12:42:58 -05:00
|
|
|
$defaultAcceptSystemConfig = $this->config->getSystemValueBool('sharing.enable_share_accept', false) ? 'no' : 'yes';
|
2025-07-16 12:23:12 -04:00
|
|
|
$defaultShareFolder = $this->config->getSystemValue('share_folder', '/');
|
|
|
|
|
$userShareFolder = Helper::getShareFolder(userId: $this->userId);
|
2020-01-16 12:42:58 -05:00
|
|
|
$acceptDefault = $this->config->getUserValue($this->userId, Application::APP_ID, 'default_accept', $defaultAcceptSystemConfig) === 'yes';
|
|
|
|
|
$enforceAccept = $this->config->getSystemValueBool('sharing.force_share_accept', false);
|
2021-07-25 11:57:11 -04:00
|
|
|
$allowCustomDirectory = $this->config->getSystemValueBool('sharing.allow_custom_share_folder', true);
|
2025-07-16 12:23:12 -04:00
|
|
|
|
2021-03-02 13:52:39 -05:00
|
|
|
$this->initialState->provideInitialState('accept_default', $acceptDefault);
|
|
|
|
|
$this->initialState->provideInitialState('enforce_accept', $enforceAccept);
|
2021-07-25 11:57:11 -04:00
|
|
|
$this->initialState->provideInitialState('allow_custom_share_folder', $allowCustomDirectory);
|
2025-07-16 12:23:12 -04:00
|
|
|
$this->initialState->provideInitialState('default_share_folder', $defaultShareFolder);
|
|
|
|
|
$this->initialState->provideInitialState('share_folder', $userShareFolder);
|
|
|
|
|
|
2019-12-12 15:45:59 -05:00
|
|
|
return new TemplateResponse('files_sharing', 'Settings/personal');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getSection(): string {
|
|
|
|
|
return 'sharing';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getPriority(): int {
|
|
|
|
|
return 90;
|
|
|
|
|
}
|
|
|
|
|
}
|