diff --git a/README.md b/README.md index 95d9e1fd..cd8e688c 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,16 @@ A first run wizard that explains the usage of Nextcloud to new users ![](https://user-images.githubusercontent.com/3404133/51537050-bcc73e00-1e4d-11e9-8de0-29e6951c2b29.png) +## Configuration + +No configuration is needed, but it is possible to prevent the wizard from opening for users by default. +When disabled users can only open it from manually clicking "About" in the user menu. + +This can be done by setting an app setting value: + +``` +occ config:app:set --value false firstrunwizard wizard_enabled +``` ## Development setup diff --git a/lib/Listener/BeforeTemplateRenderedListener.php b/lib/Listener/BeforeTemplateRenderedListener.php index fca019e6..fd23274b 100644 --- a/lib/Listener/BeforeTemplateRenderedListener.php +++ b/lib/Listener/BeforeTemplateRenderedListener.php @@ -29,6 +29,7 @@ use OCA\FirstRunWizard\AppInfo\Application; use OCA\FirstRunWizard\Notification\AppHint; use OCP\AppFramework\Http\Events\BeforeTemplateRenderedEvent; +use OCP\AppFramework\Services\IAppConfig; use OCP\AppFramework\Services\IInitialState; use OCP\BackgroundJob\IJobList; use OCP\Defaults; @@ -43,36 +44,15 @@ * @template-implements IEventListener */ class BeforeTemplateRenderedListener implements IEventListener { - /** - * @var IUserSession - */ - private $userSession; - /** - * @var IConfig - */ - private $config; - /** - * @var AppHint - */ - private $appHint; - /** - * @var IJobList - */ - private $jobList; - - /** @var IInitialState */ - protected $initialState; - - /** @var Defaults */ - protected $theming; public function __construct( - IConfig $config, - IUserSession $userSession, - IJobList $jobList, - AppHint $appHint, - IInitialState $initialState, - Defaults $theming, + private IConfig $config, + private IAppConfig $appConfig, + private IUserSession $userSession, + private IJobList $jobList, + private AppHint $appHint, + private IInitialState $initialState, + private Defaults $theming, ) { $this->userSession = $userSession; $this->config = $config; @@ -92,14 +72,16 @@ public function handle(Event $event): void { return; } - if ($this->config->getUserValue($user->getUID(), Application::APP_ID, 'show', '1') !== '0') { - Util::addScript(Application::APP_ID, Application::APP_ID . '-activate'); + if ($this->appConfig->getAppValueBool('wizard_enabled', true)) { + if ($this->config->getUserValue($user->getUID(), Application::APP_ID, 'show', '1') !== '0') { + Util::addScript(Application::APP_ID, Application::APP_ID . '-activate'); - $this->jobList->add('OCA\FirstRunWizard\Notification\BackgroundJob', ['uid' => $this->userSession->getUser()->getUID()]); - } + $this->jobList->add('OCA\FirstRunWizard\Notification\BackgroundJob', ['uid' => $this->userSession->getUser()->getUID()]); + } - if ($this->config->getSystemValueBool('appstoreenabled', true)) { - $this->appHint->sendAppHintNotifications(); + if ($this->config->getSystemValueBool('appstoreenabled', true)) { + $this->appHint->sendAppHintNotifications(); + } } Util::addScript(Application::APP_ID, Application::APP_ID . '-about');