diff options
author | John Molakvoæ <skjnldsv@users.noreply.github.com> | 2019-10-05 18:34:14 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-05 18:34:14 +0200 |
commit | 62399c76e81755e385f4c6858c5ee578d19b7e54 (patch) | |
tree | 450dacec7013d4a65cb9d18b1e0ab1a084e96ae7 /core | |
parent | 637c50e647d4d47d79248497d80ad63a20c09fd6 (diff) | |
parent | b9f963225ff646eabd9c6cd1bb6799eba99d3c79 (diff) | |
download | nextcloud-server-62399c76e81755e385f4c6858c5ee578d19b7e54.tar.gz nextcloud-server-62399c76e81755e385f4c6858c5ee578d19b7e54.zip |
Allow group displaynames in the database backend (#17221)
Allow group displaynames in the database backend
Diffstat (limited to 'core')
-rw-r--r-- | core/Command/Group/Add.php | 14 | ||||
-rw-r--r-- | core/Migrations/Version18000Date20190920085628.php | 75 |
2 files changed, 88 insertions, 1 deletions
diff --git a/core/Command/Group/Add.php b/core/Command/Group/Add.php index 61253cf163d..f2ee6195a44 100644 --- a/core/Command/Group/Add.php +++ b/core/Command/Group/Add.php @@ -28,6 +28,7 @@ use OC\Core\Command\Base; use OCP\IGroupManager; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; class Add extends Base { @@ -49,7 +50,13 @@ class Add extends Base { ->addArgument( 'groupid', InputArgument::REQUIRED, - 'Group name' + 'Group id' + ) + ->addOption( + 'display-name', + null, + InputOption::VALUE_REQUIRED, + 'Group name used in the web UI (can contain any characters)' ); } @@ -62,6 +69,11 @@ class Add extends Base { } else { $group = $this->groupManager->createGroup($gid); $output->writeln('Created group "' . $group->getGID() . '"'); + + $displayName = trim((string) $input->getOption('display-name')); + if ($displayName !== '') { + $group->setDisplayName($displayName); + } } } } diff --git a/core/Migrations/Version18000Date20190920085628.php b/core/Migrations/Version18000Date20190920085628.php new file mode 100644 index 00000000000..e84c698bb7b --- /dev/null +++ b/core/Migrations/Version18000Date20190920085628.php @@ -0,0 +1,75 @@ +<?php +declare(strict_types=1); +/** + * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> + * + * @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 + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OC\Core\Migrations; + +use Closure; +use Doctrine\DBAL\Types\Type; +use OCP\DB\ISchemaWrapper; +use OCP\IDBConnection; +use OCP\Migration\SimpleMigrationStep; +use OCP\Migration\IOutput; + +class Version18000Date20190920085628 extends SimpleMigrationStep { + + /** @var IDBConnection */ + protected $connection; + + public function __construct(IDBConnection $connection) { + $this->connection = $connection; + } + + /** + * @param IOutput $output + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` + * @param array $options + * @return null|ISchemaWrapper + */ + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { + /** @var ISchemaWrapper $schema */ + $schema = $schemaClosure(); + + if ($schema->hasTable('groups')) { + $table = $schema->getTable('groups'); + + $table->addColumn('displayname', Type::STRING, [ + 'notnull' => true, + 'length' => 255, + 'default' => '', + ]); + } + + return $schema; + } + + /** + * @param IOutput $output + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` + * @param array $options + */ + public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) { + $query = $this->connection->getQueryBuilder(); + $query->update('groups') + ->set('displayname', 'gid'); + $query->execute(); + } +} |