@@ -34,7 +34,7 @@ public static function options()
34
34
'is_ignored ' , 'willattends ' , 'country ' , 'state ' , 'preview_image ' ,
35
35
'trip_time ' , 'trip_distance ' , 'attribution_note ' ,'gc_code ' , 'hint2 ' , 'hints2 ' ,
36
36
'protection_areas ' , 'short_description ' , 'short_descriptions ' , 'needs_maintenance ' ,
37
- 'watchers ' );
37
+ 'watchers ' , ' is_rated ' , ' is_recommended ' );
38
38
39
39
public static function call (OkapiRequest $ request )
40
40
{
@@ -273,6 +273,8 @@ public static function call(OkapiRequest $request)
273
273
case 'is_not_found ' : /* handled separately */ break ;
274
274
case 'is_watched ' : /* handled separately */ break ;
275
275
case 'is_ignored ' : /* handled separately */ break ;
276
+ case 'is_rated ' : /* handled separately */ break ;
277
+ case 'is_recommended ' : /* handled separately */ break ;
276
278
case 'founds ' : $ entry ['founds ' ] = $ row ['founds ' ] + 0 ; break ;
277
279
case 'notfounds ' :
278
280
if ($ row ['type ' ] != 6 ) { # non-event
@@ -501,6 +503,53 @@ public static function call(OkapiRequest $request)
501
503
$ result_ref ['is_ignored ' ] = isset ($ tmp2 [$ cache_code ]);
502
504
}
503
505
506
+ # is_rated
507
+
508
+ if (in_array ('is_rated ' , $ fields ))
509
+ {
510
+ if ($ request ->token == null )
511
+ throw new BadRequest ("Level 3 Authentication is required to access 'is_rated' field. " );
512
+ $ tmp2 = array ();
513
+ if (Settings::get ('OC_BRANCH ' ) == 'oc.pl ' )
514
+ {
515
+ $ tmp = Db::select_column ("
516
+ select c.wp_oc
517
+ from
518
+ caches c,
519
+ scores s
520
+ where
521
+ c.cache_id = s.cache_id
522
+ and s.user_id = ' " .Db::escape_string ($ request ->token ->user_id )."'
523
+ " );
524
+ foreach ($ tmp as $ cache_code )
525
+ $ tmp2 [$ cache_code ] = true ;
526
+ }
527
+ foreach ($ results as $ cache_code => &$ result_ref )
528
+ $ result_ref ['is_rated ' ] = isset ($ tmp2 [$ cache_code ]);
529
+ }
530
+
531
+ # is_recommended
532
+
533
+ if (in_array ('is_recommended ' , $ fields ))
534
+ {
535
+ if ($ user_id == null )
536
+ throw new BadRequest ("Either 'user_uuid' parameter OR Level 3 Authentication is required to access 'is_recommended' field. " );
537
+ $ tmp = Db::select_column ("
538
+ select c.wp_oc
539
+ from
540
+ caches c,
541
+ cache_rating cr
542
+ where
543
+ c.cache_id = cr.cache_id
544
+ and cr.user_id = ' " .Db::escape_string ($ user_id )."'
545
+ " );
546
+ $ tmp2 = array ();
547
+ foreach ($ tmp as $ cache_code )
548
+ $ tmp2 [$ cache_code ] = true ;
549
+ foreach ($ results as $ cache_code => &$ result_ref )
550
+ $ result_ref ['is_recommended ' ] = isset ($ tmp2 [$ cache_code ]);
551
+ }
552
+
504
553
# Descriptions and hints.
505
554
506
555
if (in_array ('description ' , $ fields ) || in_array ('descriptions ' , $ fields )
0 commit comments