Do not allow to have an empty display name

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2019-09-27 14:28:54 +02:00
parent 704c7b6672
commit b9f963225f
No known key found for this signature in database
GPG Key ID: 7076EA9751AACDDA
2 changed files with 9 additions and 2 deletions

View File

@ -70,8 +70,9 @@ class Add extends Base {
$group = $this->groupManager->createGroup($gid);
$output->writeln('Created group "' . $group->getGID() . '"');
if ($input->hasOption('display-name')) {
$group->setDisplayName($input->getOption('display-name'));
$displayName = trim((string) $input->getOption('display-name'));
if ($displayName !== '') {
$group->setDisplayName($displayName);
}
}
}

View File

@ -109,6 +109,7 @@ class Database extends ABackend
$builder = $this->dbConn->getQueryBuilder();
$result = $builder->insert('groups')
->setValue('gid', $builder->createNamedParameter($gid))
->setValue('displayname', $builder->createNamedParameter($gid))
->execute();
} catch(UniqueConstraintViolationException $e) {
$result = 0;
@ -451,6 +452,11 @@ class Database extends ABackend
$this->fixDI();
$displayName = trim($displayName);
if ($displayName === '') {
$displayName = $gid;
}
$query = $this->dbConn->getQueryBuilder();
$query->update('groups')
->set('displayname', $query->createNamedParameter($displayName))