aboutsummaryrefslogtreecommitdiffstats
path: root/apps/user_ldap/lib
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2020-11-06 11:28:53 +0100
committerJoas Schilling <coding@schilljs.com>2020-11-06 11:28:53 +0100
commitc5b6e4bc095725223346da9f77180da4f6adb7b9 (patch)
tree3dfd45ec582dfa647f4a78432c9c65ef280f155b /apps/user_ldap/lib
parent5fba0e562f1e9e7e53b28ce5e2a31346c70a7810 (diff)
downloadnextcloud-server-c5b6e4bc095725223346da9f77180da4f6adb7b9.tar.gz
nextcloud-server-c5b6e4bc095725223346da9f77180da4f6adb7b9.zip
Use query builder to interact with member management
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps/user_ldap/lib')
-rw-r--r--apps/user_ldap/lib/Jobs/UpdateGroups.php28
1 files changed, 16 insertions, 12 deletions
diff --git a/apps/user_ldap/lib/Jobs/UpdateGroups.php b/apps/user_ldap/lib/Jobs/UpdateGroups.php
index 0ecd43480c4..67c0c7c7439 100644
--- a/apps/user_ldap/lib/Jobs/UpdateGroups.php
+++ b/apps/user_ldap/lib/Jobs/UpdateGroups.php
@@ -201,17 +201,20 @@ class UpdateGroups extends TimedJob {
*/
private function handleCreatedGroups($createdGroups) {
\OCP\Util::writeLog('user_ldap', 'bgJ "updateGroups" – dealing with created Groups.', ILogger::DEBUG);
- $query = \OC_DB::prepare('
- INSERT
- INTO `*PREFIX*ldap_group_members` (`owncloudname`, `owncloudusers`)
- VALUES (?, ?)
- ');
+
+ $query = $this->dbc->getQueryBuilder();
+ $query->insert('ldap_group_members')
+ ->set('owncloudname', $query->createParameter('owncloudname'))
+ ->set('owncloudusers', $query->createParameter('owncloudusers'));
foreach ($createdGroups as $createdGroup) {
\OCP\Util::writeLog('user_ldap',
'bgJ "updateGroups" – new group "' . $createdGroup . '" found.',
ILogger::INFO);
$users = serialize($this->groupBackend->usersInGroup($createdGroup));
- $query->execute([$createdGroup, $users]);
+
+ $query->setParameter('owncloudname', $createdGroup)
+ ->setParameter('owncloudusers', $users);
+ $query->execute();
}
\OCP\Util::writeLog('user_ldap',
'bgJ "updateGroups" – FINISHED dealing with created Groups.',
@@ -223,16 +226,17 @@ class UpdateGroups extends TimedJob {
*/
private function handleRemovedGroups($removedGroups) {
\OCP\Util::writeLog('user_ldap', 'bgJ "updateGroups" – dealing with removed groups.', ILogger::DEBUG);
- $query = \OC_DB::prepare('
- DELETE
- FROM `*PREFIX*ldap_group_members`
- WHERE `owncloudname` = ?
- ');
+
+ $query = $this->dbc->getQueryBuilder();
+ $query->delete('ldap_group_members')
+ ->where($query->expr()->eq('owncloudname', $query->createParameter('owncloudname')));
+
foreach ($removedGroups as $removedGroup) {
\OCP\Util::writeLog('user_ldap',
'bgJ "updateGroups" – group "' . $removedGroup . '" was removed.',
ILogger::INFO);
- $query->execute([$removedGroup]);
+ $query->setParameter('owncloudname', $removedGroup);
+ $query->execute();
}
\OCP\Util::writeLog('user_ldap',
'bgJ "updateGroups" – FINISHED dealing with removed groups.',