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

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@owncloud.com>2016-05-12 10:59:29 +0300
committerJoas Schilling <nickvergessen@owncloud.com>2016-05-25 17:04:56 +0300
commit4ac283ecd364829d7d4c8a631182770c49dfbd6f (patch)
tree9cc10854101862a9d6d056cc0f7b001b12414d4d /apps/user_ldap/lib/Command/SetConfig.php
parent9d61acb27d11c5a892670ed9e803d3723635fa55 (diff)
Move Command namespace to PSR-4
Diffstat (limited to 'apps/user_ldap/lib/Command/SetConfig.php')
-rw-r--r--apps/user_ldap/lib/Command/SetConfig.php84
1 files changed, 84 insertions, 0 deletions
diff --git a/apps/user_ldap/lib/Command/SetConfig.php b/apps/user_ldap/lib/Command/SetConfig.php
new file mode 100644
index 00000000000..7e2e2f19f66
--- /dev/null
+++ b/apps/user_ldap/lib/Command/SetConfig.php
@@ -0,0 +1,84 @@
+<?php
+/**
+ * @author Arthur Schiwon <blizzz@owncloud.com>
+ * @author Morris Jobke <hey@morrisjobke.de>
+ * @author Thomas Müller <thomas.mueller@tmit.eu>
+ *
+ * @copyright Copyright (c) 2016, ownCloud, Inc.
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * 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, version 3,
+ * along with this program. If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+namespace OCA\User_LDAP\Command;
+
+use Symfony\Component\Console\Command\Command;
+use Symfony\Component\Console\Input\InputArgument;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Output\OutputInterface;
+use \OCA\user_ldap\lib\Helper;
+use \OCA\user_ldap\lib\Configuration;
+
+class SetConfig extends Command {
+
+ protected function configure() {
+ $this
+ ->setName('ldap:set-config')
+ ->setDescription('modifies an LDAP configuration')
+ ->addArgument(
+ 'configID',
+ InputArgument::REQUIRED,
+ 'the configuration ID'
+ )
+ ->addArgument(
+ 'configKey',
+ InputArgument::REQUIRED,
+ 'the configuration key'
+ )
+ ->addArgument(
+ 'configValue',
+ InputArgument::REQUIRED,
+ 'the new configuration value'
+ )
+ ;
+ }
+
+ protected function execute(InputInterface $input, OutputInterface $output) {
+ $helper = new Helper();
+ $availableConfigs = $helper->getServerConfigurationPrefixes();
+ $configID = $input->getArgument('configID');
+ if(!in_array($configID, $availableConfigs)) {
+ $output->writeln("Invalid configID");
+ return;
+ }
+
+ $this->setValue(
+ $configID,
+ $input->getArgument('configKey'),
+ $input->getArgument('configValue')
+ );
+ }
+
+ /**
+ * save the configuration value as provided
+ * @param string $configID
+ * @param string $configKey
+ * @param string $configValue
+ */
+ protected function setValue($configID, $key, $value) {
+ $configHolder = new Configuration($configID);
+ $configHolder->$key = $value;
+ $configHolder->saveConfiguration();
+ }
+}