Welcome to mirror list, hosted at ThFree Co, Russian Federation.

serversharing.php « command « lib « build - github.com/nextcloud/jsxc.nextcloud.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: eb6189b4c406196917840eb2545bf1827659ccd2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
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);
		}
	}
}