77namespace OC ;
88
99use NCU \Config \Exceptions \TypeConflictException ;
10- use NCU \Config \IUserPreferences ;
10+ use NCU \Config \IUserConfig ;
1111use NCU \Config \ValueType ;
12- use OC \Config \UserPreferences ;
12+ use OC \Config \UserConfig ;
1313use OCP \Cache \CappedMemoryCache ;
1414use OCP \IConfig ;
1515use OCP \IDBConnection ;
@@ -230,20 +230,20 @@ public function deleteAppValues($appName) {
230230 *
231231 * @throws \OCP\PreConditionNotMetException if a precondition is specified and is not met
232232 * @throws \UnexpectedValueException when trying to store an unexpected value
233- * @deprecated 31.0.0 - use {@see IUserPreferences } directly
234- * @see IUserPreferences ::getValueString
235- * @see IUserPreferences ::getValueInt
236- * @see IUserPreferences ::getValueFloat
237- * @see IUserPreferences ::getValueArray
238- * @see IUserPreferences ::getValueBool
233+ * @deprecated 31.0.0 - use {@see IUserConfig } directly
234+ * @see IUserConfig ::getValueString
235+ * @see IUserConfig ::getValueInt
236+ * @see IUserConfig ::getValueFloat
237+ * @see IUserConfig ::getValueArray
238+ * @see IUserConfig ::getValueBool
239239 */
240240 public function setUserValue ($ userId , $ appName , $ key , $ value , $ preCondition = null ) {
241241 if (!is_int ($ value ) && !is_float ($ value ) && !is_string ($ value )) {
242242 throw new \UnexpectedValueException ('Only integers, floats and strings are allowed as value ' );
243243 }
244244
245- /** @var UserPreferences $userPreferences */
246- $ userPreferences = \OCP \Server::get (IUserPreferences ::class);
245+ /** @var UserConfig $userPreferences */
246+ $ userPreferences = \OCP \Server::get (IUserConfig ::class);
247247 if ($ preCondition !== null ) {
248248 try {
249249 if ($ userPreferences ->getValueMixed ($ userId , $ appName , $ key ) !== (string )$ preCondition ) {
@@ -265,19 +265,19 @@ public function setUserValue($userId, $appName, $key, $value, $preCondition = nu
265265 * @param mixed $default the default value to be returned if the value isn't set
266266 *
267267 * @return string
268- * @deprecated 31.0.0 - use {@see IUserPreferences } directly
269- * @see IUserPreferences ::getValueString
270- * @see IUserPreferences ::getValueInt
271- * @see IUserPreferences ::getValueFloat
272- * @see IUserPreferences ::getValueArray
273- * @see IUserPreferences ::getValueBool
268+ * @deprecated 31.0.0 - use {@see IUserConfig } directly
269+ * @see IUserConfig ::getValueString
270+ * @see IUserConfig ::getValueInt
271+ * @see IUserConfig ::getValueFloat
272+ * @see IUserConfig ::getValueArray
273+ * @see IUserConfig ::getValueBool
274274 */
275275 public function getUserValue ($ userId , $ appName , $ key , $ default = '' ) {
276276 if ($ userId === null || $ userId === '' ) {
277277 return $ default ;
278278 }
279- /** @var UserPreferences $userPreferences */
280- $ userPreferences = \OCP \Server::get (IUserPreferences ::class);
279+ /** @var UserConfig $userPreferences */
280+ $ userPreferences = \OCP \Server::get (IUserConfig ::class);
281281 // because $default can be null ...
282282 if (!$ userPreferences ->hasKey ($ userId , $ appName , $ key )) {
283283 return $ default ;
@@ -290,11 +290,12 @@ public function getUserValue($userId, $appName, $key, $default = '') {
290290 *
291291 * @param string $userId the userId of the user that we want to store the value under
292292 * @param string $appName the appName that we stored the value under
293+ *
293294 * @return string[]
294- * @deprecated 31.0.0 - use {@see IUserPreferences ::getKeys} directly
295+ * @deprecated 31.0.0 - use {@see IUserConfig ::getKeys} directly
295296 */
296297 public function getUserKeys ($ userId , $ appName ) {
297- return \OCP \Server::get (IUserPreferences ::class)->getKeys ($ userId , $ appName );
298+ return \OCP \Server::get (IUserConfig ::class)->getKeys ($ userId , $ appName );
298299 }
299300
300301 /**
@@ -303,52 +304,56 @@ public function getUserKeys($userId, $appName) {
303304 * @param string $userId the userId of the user that we want to store the value under
304305 * @param string $appName the appName that we stored the value under
305306 * @param string $key the key under which the value is being stored
306- * @deprecated 31.0.0 - use {@see IUserPreferences::deletePreference} directly
307+ *
308+ * @deprecated 31.0.0 - use {@see IUserConfig::deleteUserConfig} directly
307309 */
308310 public function deleteUserValue ($ userId , $ appName , $ key ) {
309- \OCP \Server::get (IUserPreferences ::class)->deletePreference ($ userId , $ appName , $ key );
311+ \OCP \Server::get (IUserConfig ::class)->deleteUserConfig ($ userId , $ appName , $ key );
310312 }
311313
312314 /**
313315 * Delete all user values
314316 *
315317 * @param string $userId the userId of the user that we want to remove all values from
316- * @deprecated 31.0.0 - use {@see IUserPreferences::deleteAllPreferences} directly
318+ *
319+ * @deprecated 31.0.0 - use {@see IUserConfig::deleteAllUserConfig} directly
317320 */
318321 public function deleteAllUserValues ($ userId ) {
319322 if ($ userId === null ) {
320323 return ;
321324 }
322- \OCP \Server::get (IUserPreferences ::class)->deleteAllPreferences ($ userId );
325+ \OCP \Server::get (IUserConfig ::class)->deleteAllUserConfig ($ userId );
323326 }
324327
325328 /**
326329 * Delete all user related values of one app
327330 *
328331 * @param string $appName the appName of the app that we want to remove all values from
329- * @deprecated 31.0.0 - use {@see IUserPreferences::deleteApp} directly
332+ *
333+ * @deprecated 31.0.0 - use {@see IUserConfig::deleteApp} directly
330334 */
331335 public function deleteAppFromAllUsers ($ appName ) {
332- \OCP \Server::get (IUserPreferences ::class)->deleteApp ($ appName );
336+ \OCP \Server::get (IUserConfig ::class)->deleteApp ($ appName );
333337 }
334338
335339 /**
336340 * Returns all user configs sorted by app of one user
337341 *
338342 * @param ?string $userId the user ID to get the app configs from
343+ *
339344 * @psalm-return array<string, array<string, string>>
340345 * @return array[] - 2 dimensional array with the following structure:
341346 * [ $appId =>
342347 * [ $key => $value ]
343348 * ]
344- * @deprecated 31.0.0 - use {@see IUserPreferences ::getAllValues} directly
349+ * @deprecated 31.0.0 - use {@see IUserConfig ::getAllValues} directly
345350 */
346351 public function getAllUserValues (?string $ userId ): array {
347352 if ($ userId === null || $ userId === '' ) {
348353 return [];
349354 }
350355
351- $ values = \OCP \Server::get (IUserPreferences ::class)->getAllValues ($ userId );
356+ $ values = \OCP \Server::get (IUserConfig ::class)->getAllValues ($ userId );
352357 $ result = [];
353358 foreach ($ values as $ app => $ list ) {
354359 foreach ($ list as $ key => $ value ) {
@@ -364,11 +369,12 @@ public function getAllUserValues(?string $userId): array {
364369 * @param string $appName app to get the value for
365370 * @param string $key the key to get the value for
366371 * @param array $userIds the user IDs to fetch the values for
372+ *
367373 * @return array Mapped values: userId => value
368- * @deprecated 31.0.0 - use {@see IUserPreferences ::getValuesByUsers} directly
374+ * @deprecated 31.0.0 - use {@see IUserConfig ::getValuesByUsers} directly
369375 */
370376 public function getUserValueForUsers ($ appName , $ key , $ userIds ) {
371- return \OCP \Server::get (IUserPreferences ::class)->getValuesByUsers ($ appName , $ key , ValueType::MIXED , $ userIds );
377+ return \OCP \Server::get (IUserConfig ::class)->getValuesByUsers ($ appName , $ key , ValueType::MIXED , $ userIds );
372378 }
373379
374380 /**
@@ -377,11 +383,14 @@ public function getUserValueForUsers($appName, $key, $userIds) {
377383 * @param string $appName the app to get the user for
378384 * @param string $key the key to get the user for
379385 * @param string $value the value to get the user for
380- * @return array<string> of user IDs
381- * @deprecated 31.0.0 - use {@see IUserPreferences::searchUsersByValueString} directly
386+ *
387+ * @return list<string> of user IDs
388+ * @deprecated 31.0.0 - use {@see IUserConfig::searchUsersByValueString} directly
382389 */
383390 public function getUsersForUserValue ($ appName , $ key , $ value ) {
384- return iterator_to_array (\OCP \Server::get (IUserPreferences::class)->searchUsersByValueString ($ appName , $ key , $ value ));
391+ /** @var list<string> $result */
392+ $ result = iterator_to_array (\OCP \Server::get (IUserConfig::class)->searchUsersByValueString ($ appName , $ key , $ value ));
393+ return $ result ;
385394 }
386395
387396 /**
@@ -390,15 +399,18 @@ public function getUsersForUserValue($appName, $key, $value) {
390399 * @param string $appName the app to get the user for
391400 * @param string $key the key to get the user for
392401 * @param string $value the value to get the user for
393- * @return array<string> of user IDs
394- * @deprecated 31.0.0 - use {@see IUserPreferences::searchUsersByValueString} directly
402+ *
403+ * @return list<string> of user IDs
404+ * @deprecated 31.0.0 - use {@see IUserConfig::searchUsersByValueString} directly
395405 */
396406 public function getUsersForUserValueCaseInsensitive ($ appName , $ key , $ value ) {
397407 if ($ appName === 'settings ' && $ key === 'email ' ) {
398408 return $ this ->getUsersForUserValue ($ appName , $ key , strtolower ($ value ));
399409 }
400410
401- return iterator_to_array (\OCP \Server::get (IUserPreferences::class)->searchUsersByValueString ($ appName , $ key , $ value , true ));
411+ /** @var list<string> $result */
412+ $ result = iterator_to_array (\OCP \Server::get (IUserConfig::class)->searchUsersByValueString ($ appName , $ key , $ value , true ));
413+ return $ result ;
402414 }
403415
404416 public function getSystemConfig () {
0 commit comments