@@ -21,7 +21,7 @@ public static function options()
21
21
}
22
22
23
23
private static $ valid_field_names = array ('uuid ' , 'username ' , 'profile_url ' , 'internal_id ' , 'is_admin ' ,
24
- 'caches_found ' , 'caches_notfound ' , 'caches_hidden ' , 'rcmds_given ' );
24
+ 'caches_found ' , 'caches_notfound ' , 'caches_hidden ' , 'rcmds_given ' , ' home_location ' );
25
25
26
26
public static function call (OkapiRequest $ request )
27
27
{
@@ -39,7 +39,7 @@ public static function call(OkapiRequest $request)
39
39
if (!in_array ($ field , self ::$ valid_field_names ))
40
40
throw new InvalidParam ('fields ' , "' $ field' is not a valid field code. " );
41
41
$ rs = Db::query ("
42
- select user_id, uuid, username, admin
42
+ select user_id, uuid, username, admin, latitude, longitude
43
43
from user
44
44
where uuid in (' " .implode ("',' " , array_map ('mysql_real_escape_string ' , $ user_uuids ))."')
45
45
" );
@@ -72,6 +72,20 @@ public static function call(OkapiRequest $request)
72
72
case 'caches_notfound ' : /* handled separately */ break ;
73
73
case 'caches_hidden ' : /* handled separately */ break ;
74
74
case 'rcmds_given ' : /* handled separately */ break ;
75
+ case 'home_location ' :
76
+ if (!$ request ->token ) {
77
+ $ entry ['home_location ' ] = null ;
78
+ } elseif ($ request ->token ->user_id != $ row ['user_id ' ]) {
79
+ $ entry ['home_location ' ] = null ;
80
+ } elseif (!$ row ['latitude ' ] && !$ row ['longitude ' ]) {
81
+ # OCPL sets NULL/NULL for unknown location, OCDE sets 0/0.
82
+ # It is safe to return null also for OCPL 0/0, as this value
83
+ # does not make sense.
84
+ $ entry ['home_location ' ] = null ;
85
+ } else {
86
+ $ entry ['home_location ' ] = round ($ row ['latitude ' ], 6 )."| " .round ($ row ['longitude ' ], 6 );
87
+ }
88
+ break ;
75
89
default : throw new Exception ("Missing field case: " .$ field );
76
90
}
77
91
}
0 commit comments