2016-11-16 12:46:32 +03:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @copyright 2016, Roeland Jago Douma <roeland@famdouma.nl>
|
|
|
|
*
|
2020-09-07 15:37:44 +03:00
|
|
|
* @author Jan C. Borchardt <hey@jancborchardt.net>
|
2019-12-03 21:57:53 +03:00
|
|
|
* @author Julius Härtl <jus@bitgrid.net>
|
2016-11-16 12:46:32 +03:00
|
|
|
* @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
|
2018-06-27 20:59:17 +03:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2016-11-16 12:46:32 +03:00
|
|
|
*
|
|
|
|
*/
|
2019-11-22 22:52:10 +03:00
|
|
|
|
2020-01-30 15:30:45 +03:00
|
|
|
namespace OCA\Settings\Settings\Personal;
|
2016-11-16 12:46:32 +03:00
|
|
|
|
2020-08-06 23:55:30 +03:00
|
|
|
use OCA\Viewer\Event\LoadViewer;
|
2016-11-16 12:46:32 +03:00
|
|
|
use OCP\AppFramework\Http\TemplateResponse;
|
2020-08-06 23:55:30 +03:00
|
|
|
use OCP\AppFramework\Services\IInitialState;
|
|
|
|
use OCP\EventDispatcher\IEventDispatcher;
|
|
|
|
use OCP\Files\IRootFolder;
|
|
|
|
use OCP\IURLGenerator;
|
|
|
|
use OCP\IUserSession;
|
2016-11-16 12:46:32 +03:00
|
|
|
use OCP\Settings\ISettings;
|
2020-03-06 15:08:23 +03:00
|
|
|
use OCP\Support\Subscription\IRegistry;
|
2020-08-06 23:55:30 +03:00
|
|
|
use OCP\Util;
|
2016-11-16 12:46:32 +03:00
|
|
|
|
|
|
|
class ServerDevNotice implements ISettings {
|
2020-03-06 15:08:23 +03:00
|
|
|
|
|
|
|
/** @var IRegistry */
|
|
|
|
private $registry;
|
|
|
|
|
2020-08-06 23:55:30 +03:00
|
|
|
/** @var IEventDispatcher */
|
|
|
|
private $eventDispatcher;
|
|
|
|
|
|
|
|
/** @var IRootFolder */
|
|
|
|
private $rootFolder;
|
|
|
|
|
|
|
|
/** @var IUserSession */
|
|
|
|
private $userSession;
|
|
|
|
|
|
|
|
/** @var IInitialState */
|
|
|
|
private $initialState;
|
|
|
|
|
|
|
|
/** @var IURLGenerator */
|
|
|
|
private $urlGenerator;
|
|
|
|
|
|
|
|
public function __construct(IRegistry $registry,
|
|
|
|
IEventDispatcher $eventDispatcher,
|
|
|
|
IRootFolder $rootFolder,
|
|
|
|
IUserSession $userSession,
|
|
|
|
IInitialState $initialState,
|
|
|
|
IURLGenerator $urlGenerator) {
|
2020-03-06 15:08:23 +03:00
|
|
|
$this->registry = $registry;
|
2020-08-06 23:55:30 +03:00
|
|
|
$this->eventDispatcher = $eventDispatcher;
|
|
|
|
$this->rootFolder = $rootFolder;
|
|
|
|
$this->userSession = $userSession;
|
|
|
|
$this->initialState = $initialState;
|
|
|
|
$this->urlGenerator = $urlGenerator;
|
2020-03-06 15:08:23 +03:00
|
|
|
}
|
|
|
|
|
2016-11-16 12:46:32 +03:00
|
|
|
/**
|
|
|
|
* @return TemplateResponse
|
|
|
|
*/
|
|
|
|
public function getForm() {
|
2020-08-06 23:55:30 +03:00
|
|
|
$userFolder = $this->rootFolder->getUserFolder($this->userSession->getUser()->getUID());
|
|
|
|
|
|
|
|
$hasInitialState = false;
|
|
|
|
|
2020-09-07 19:02:57 +03:00
|
|
|
// viewer is default enabled and this makes a zero-cost assertion for Psalm
|
|
|
|
assert(class_exists(LoadViewer::class));
|
|
|
|
|
2020-08-06 23:55:30 +03:00
|
|
|
// If the Reasons to use Nextcloud.pdf file is here, let's init Viewer
|
|
|
|
if ($userFolder->nodeExists('Reasons to use Nextcloud.pdf')) {
|
|
|
|
$this->eventDispatcher->dispatch(LoadViewer::class, new LoadViewer());
|
|
|
|
$hasInitialState = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Always load the script
|
|
|
|
Util::addScript('settings', 'vue-settings-nextcloud-pdf');
|
|
|
|
$this->initialState->provideInitialState('has-reasons-use-nextcloud-pdf', $hasInitialState);
|
|
|
|
|
|
|
|
return new TemplateResponse('settings', 'settings/personal/development.notice', [
|
|
|
|
'reasons-use-nextcloud-pdf-link' => $this->urlGenerator->linkToRoute('settings.Reasons.getPdf')
|
|
|
|
]);
|
2016-11-16 12:46:32 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string the section ID, e.g. 'sharing'
|
|
|
|
*/
|
|
|
|
public function getSection() {
|
2020-03-06 15:08:23 +03:00
|
|
|
if ($this->registry->delegateHasValidSubscription()) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2018-06-27 20:59:17 +03:00
|
|
|
return 'personal-info';
|
2016-11-16 12:46:32 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return int whether the form should be rather on the top or bottom of
|
|
|
|
* the admin section. The forms are arranged in ascending order of the
|
|
|
|
* priority values. It is required to return a value between 0 and 100.
|
|
|
|
*
|
|
|
|
* E.g.: 70
|
|
|
|
*/
|
|
|
|
public function getPriority() {
|
|
|
|
return 1000;
|
|
|
|
}
|
|
|
|
}
|