@@ -380,7 +380,7 @@ public function prepare_common_search_params()
380
380
throw new InvalidParam ('found_status ' , "' $ tmp' " );
381
381
if ($ tmp != 'either ' )
382
382
{
383
- $ found_cache_ids = self ::get_found_cache_ids ($ this ->request ->token ->user_id );
383
+ $ found_cache_ids = self ::get_found_cache_ids (array ( $ this ->request ->token ->user_id ) );
384
384
$ operator = ($ tmp == 'found_only ' ) ? "in " : "not in " ;
385
385
$ where_conds [] = "caches.cache_id $ operator (' " .implode ("',' " , array_map ('mysql_real_escape_string ' , $ found_cache_ids ))."') " ;
386
386
}
@@ -393,12 +393,13 @@ public function prepare_common_search_params()
393
393
if ($ tmp = $ this ->request ->get_parameter ('found_by ' ))
394
394
{
395
395
try {
396
- $ user = OkapiServiceRunner::call ("services/users/user " , new OkapiInternalRequest (
397
- $ this ->request ->consumer , null , array ('user_uuid ' => $ tmp , 'fields ' => 'internal_id ' )));
396
+ $ users = OkapiServiceRunner::call ("services/users/users " , new OkapiInternalRequest (
397
+ $ this ->request ->consumer , null , array ('user_uuids ' => $ tmp , 'fields ' => 'internal_id ' )));
398
398
} catch (InvalidParam $ e ) { # invalid uuid
399
399
throw new InvalidParam ('found_by ' , $ e ->whats_wrong_about_it );
400
400
}
401
- $ found_cache_ids = self ::get_found_cache_ids ($ user ['internal_id ' ]);
401
+ $ internal_user_ids = array_map (create_function ('$internalid ' , 'return $internalid["internal_id"]; ' ), $ users );
402
+ $ found_cache_ids = self ::get_found_cache_ids ($ internal_user_ids );
402
403
$ where_conds [] = "caches.cache_id in (' " .implode ("',' " , array_map ('mysql_real_escape_string ' , $ found_cache_ids ))."') " ;
403
404
}
404
405
@@ -409,12 +410,13 @@ public function prepare_common_search_params()
409
410
if ($ tmp = $ this ->request ->get_parameter ('not_found_by ' ))
410
411
{
411
412
try {
412
- $ user = OkapiServiceRunner::call ("services/users/user " , new OkapiInternalRequest (
413
- $ this ->request ->consumer , null , array ('user_uuid ' => $ tmp , 'fields ' => 'internal_id ' )));
413
+ $ users = OkapiServiceRunner::call ("services/users/users " , new OkapiInternalRequest (
414
+ $ this ->request ->consumer , null , array ('user_uuids ' => $ tmp , 'fields ' => 'internal_id ' )));
414
415
} catch (InvalidParam $ e ) { # invalid uuid
415
416
throw new InvalidParam ('not_found_by ' , $ e ->whats_wrong_about_it );
416
417
}
417
- $ found_cache_ids = self ::get_found_cache_ids ($ user ['internal_id ' ]);
418
+ $ internal_user_ids = array_map (create_function ('$internalid ' , 'return $internalid["internal_id"]; ' ), $ users );
419
+ $ found_cache_ids = self ::get_found_cache_ids ($ internal_user_ids );
418
420
$ where_conds [] = "caches.cache_id not in (' " .implode ("',' " , array_map ('mysql_real_escape_string ' , $ found_cache_ids ))."') " ;
419
421
}
420
422
@@ -846,13 +848,13 @@ public function get_latitude_expr()
846
848
* Get the list of cache IDs which were found by given user.
847
849
* Parameter needs to be *internal* user id, not uuid.
848
850
*/
849
- private static function get_found_cache_ids ($ internal_user_id )
851
+ private static function get_found_cache_ids ($ internal_user_ids )
850
852
{
851
853
return Db::select_column ("
852
854
select cache_id
853
855
from cache_logs
854
856
where
855
- user_id = ' " .mysql_real_escape_string ( $ internal_user_id ) ."'
857
+ user_id in ( ' " .implode ( " ',' " , array_map ( ' mysql_real_escape_string ' , $ internal_user_ids )) ."')
856
858
and type in (
857
859
' " .mysql_real_escape_string (Okapi::logtypename2id ("Found it " ))."',
858
860
' " .mysql_real_escape_string (Okapi::logtypename2id ("Attended " ))."'
0 commit comments