From 653628c8fb69dc3f9d26751520f91e43a18f17ae Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 20 Sep 2019 11:33:02 +0200 Subject: Allow to set the group display name in the database backend Signed-off-by: Joas Schilling --- lib/private/Group/Database.php | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'lib/private/Group/Database.php') diff --git a/lib/private/Group/Database.php b/lib/private/Group/Database.php index 5e39398c60d..4aab8b8eaec 100644 --- a/lib/private/Group/Database.php +++ b/lib/private/Group/Database.php @@ -52,6 +52,7 @@ use OCP\Group\Backend\IDeleteGroupBackend; use OCP\Group\Backend\IGetDisplayNameBackend; use OCP\Group\Backend\IGroupDetailsBackend; use OCP\Group\Backend\IRemoveFromGroupBackend; +use OCP\Group\Backend\ISetDisplayNameBackend; use OCP\IDBConnection; /** @@ -65,7 +66,8 @@ class Database extends ABackend IDeleteGroupBackend, IGetDisplayNameBackend, IGroupDetailsBackend, - IRemoveFromGroupBackend { + IRemoveFromGroupBackend, + ISetDisplayNameBackend { /** @var string[] */ private $groupCache = []; @@ -450,4 +452,24 @@ class Database extends ABackend return []; } + /** + * @param string $gid + * @param string $displayName + * @return bool + * @since 18.0.0 + */ + public function setDisplayName(string $gid, string $displayName): bool { + if (!$this->groupExists($gid)) { + return false; + } + + $query = $this->dbConn->getQueryBuilder(); + $query->update('groups') + ->set('displayname', $query->createNamedParameter($displayName)) + ->where($query->expr()->eq('gid', $query->createNamedParameter($gid))); + $query->execute(); + + return true; + } + } -- cgit v1.2.3