Compare commits

...

1 Commits

Author SHA1 Message Date
Robin Appelman 43b90e2e89
Add method to get all user preferences for an app-key pair
Signed-off-by: Robin Appelman <robin@icewind.nl>
2021-04-23 13:57:03 +02:00
2 changed files with 35 additions and 0 deletions

View File

@ -535,6 +535,30 @@ class AllConfig implements \OCP\IConfig {
return $userIDs;
}
/**
* Returns all user configs set for an appid-key pair
*
* @param string $appId the app ID to get the app configs from
* @param string $key thekey to get the app configs from
* @return array<string, string> - array with the following structure:
* [ $userId => $value ]
*/
public function getUserValuesForKey(string $appId, string $key): array {
// TODO - FIXME
$this->fixDIInit();
$data = [];
$query = $this->connection->getQueryBuilder();
$query->select('userid', 'configvalue')
->from('preferences')
->where($query->expr()->eq('appid', $query->createNamedParameter($appId)))
->andWhere($query->expr()->eq('configkey', $query->createNamedParameter($key)));
$result = $query->execute()->fetchAll();
$userIds = array_column($result, 'userid');
$values = array_column($result, 'configvalue');
return array_combine($userIds, $values);
}
public function getSystemConfig() {
return $this->systemConfig;
}

View File

@ -257,4 +257,15 @@ interface IConfig {
* @since 8.0.0
*/
public function getUsersForUserValue($appName, $key, $value);
/**
* Returns all user configs set for an appid-key pair
*
* @param string $appId the app ID to get the app configs from
* @param string $key thekey to get the app configs from
* @return array<string, string> - array with the following structure:
* [ $userId => $value ]
* @since 22.0.0
*/
public function getUserValuesForKey(string $appId, string $key): array;
}