diff options
author | sualko <klaus@jsxc.org> | 2018-12-05 12:24:52 +0300 |
---|---|---|
committer | sualko <klaus@jsxc.org> | 2018-12-05 12:35:54 +0300 |
commit | f54bdcec78841770ec391e3b33f33e762169ad94 (patch) | |
tree | d32bf1630bbf3e58b5ba9ab1c0184a4e14601054 /build/lib/command/serversharing.php | |
parent | d71398a68326b27eeebc96b004fb227440be826c (diff) |
build v3.4.3v3.4.3
Diffstat (limited to 'build/lib/command/serversharing.php')
-rw-r--r-- | build/lib/command/serversharing.php | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/build/lib/command/serversharing.php b/build/lib/command/serversharing.php new file mode 100644 index 0000000..eb6189b --- /dev/null +++ b/build/lib/command/serversharing.php @@ -0,0 +1,76 @@ +<?php + +namespace OCA\OJSXC\Command; + +use OCA\OJSXC\AppInfo\Application; +use OCP\IConfig; +use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; + +class serversharing extends Command +{ + + /** + * @var IConfig + */ + private $config; + + public function __construct( + IConfig $config + ) { + parent::__construct(); + $this->config = $config; + } + + protected function configure() + { + $this->setName('ojsxc:server_sharing'); + $this->setDescription('Use the Server Sharing settings https://github.com/jsxc/jsxc/wiki/Restrict-chatting-(Nextcloud-internal)'); + $this->addOption('enable'); + $this->addOption('disable'); + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + if (\OCP\Util::getVersion()[0] < 13) { + $output->write('This feature is only supported in Nextcloud 13 or later.', true); + return; + } + + if (Application::getServerType() !== 'internal') { + $output->write('This feature is only supported using the internal backend.', true); + return; + } + + $enable = $input->getOption('enable'); + $disable = $input->getOption('disable'); + + if (!$enable && !$disable) { + if ($this->config->getAppValue('ojsxc', 'use_server_sharing_settings', 'no') === 'yes') { + $state = 'enabled'; + } else { + $state = 'disabled'; + } + $output->write('This feature is currently ' . $state, true); + return; + } + + if ($enable === $disable) { + // if both enable and disable passed or none option + $output->write('Please provide only --enable or --disable', true); + return; + } + + + if ($enable) { + $this->config->setAppValue('ojsxc', 'use_server_sharing_settings', 'yes'); + $output->write('Successfully enabled.', true); + } + + if ($disable) { + $this->config->setAppValue('ojsxc', 'use_server_sharing_settings', 'no'); + $output->write('Successfully disabled.', true); + } + } +} |