Skip to content

Commit 7348ce9

Browse files
committed
added 'location' field for log entries; closes #304
1 parent 8e5d611 commit 7348ce9

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

okapi/services/logs/entries/WebService.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public static function options()
2121
private static $valid_field_names = array(
2222
'uuid', 'cache_code', 'date', 'user', 'type', 'was_recommended', 'comment',
2323
'images', 'internal_id', 'oc_team_entry', 'needs_maintenance2',
24-
'listing_is_outdated',
24+
'listing_is_outdated', 'location',
2525
);
2626

2727
public static function call(OkapiRequest $request)
@@ -53,13 +53,17 @@ public static function call(OkapiRequest $request)
5353
$ratingdate_condition = 'and cr.rating_date=cl.date';
5454
$needs_maintenance_SQL = 'cl.needs_maintenance';
5555
$listing_is_outdated_SQL = 'cl.listing_outdated';
56+
$join_SQL = '';
57+
$latlong_SQL = ', null as latitude, null as longitude';
5658
}
5759
else
5860
{
5961
$teamentry_field = '(cl.type=12)';
6062
$ratingdate_condition = '';
6163
$needs_maintenance_SQL = 'IF(cl.type=5, 2, IF(cl.type=6, 1, 0))';
6264
$listing_is_outdated_SQL = '0';
65+
$join_SQL = 'left join cache_moved cm on cm.log_id=cl.id';
66+
$latlong_SQL = ', cm.latitude, cm.longitude';
6367
}
6468
$rs = Db::query("
6569
select
@@ -70,6 +74,7 @@ public static function call(OkapiRequest $request)
7074
unix_timestamp(cl.date) as date, cl.text,
7175
u.uuid as user_uuid, u.username, u.user_id,
7276
if(cr.user_id is null, 0, 1) as was_recommended
77+
".$latlong_SQL."
7378
from
7479
(cache_logs cl,
7580
user u,
@@ -82,6 +87,7 @@ public static function call(OkapiRequest $request)
8287
".Okapi::logtypename2id("Found it").",
8388
".Okapi::logtypename2id("Attended")."
8489
)
90+
".$join_SQL."
8591
where
8692
cl.uuid in ('".implode("','", array_map('\okapi\Db::escape_string', $log_uuids))."')
8793
and ".((Settings::get('OC_BRANCH') == 'oc.pl') ? "cl.deleted = 0" : "true")."
@@ -109,6 +115,7 @@ public static function call(OkapiRequest $request)
109115
'listing_is_outdated' => $flag_options[$row['listing_is_outdated']],
110116
'oc_team_entry' => $row['oc_team_entry'] ? true : false,
111117
'comment' => Okapi::fix_oc_html($row['text'], Okapi::OBJECT_TYPE_CACHE_LOG),
118+
'location' => $row['latitude'] === null ? null : round($row['latitude'], 6)."|".round($row['longitude'], 6),
112119
'images' => array(),
113120
'internal_id' => $row['id'],
114121
);

okapi/services/logs/entry/docs.xml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,19 @@
155155
<p>Please note that OCPL-based installations will always return <b>null</b> here.</p>
156156
</li>
157157
<li><b>comment</b> - <a href='%OKAPI:docurl:html%'>HTML string</a>, text entered
158-
with the log entry,</li>
158+
with the log entry,
159+
</li>
160+
<li>
161+
<p><b>location</b> - the location of the geocache that was provided
162+
by the logger, in "lat|lon" format (<i>lat</i> and <i>lon</i> are
163+
in full degrees with a dot as a decimal point); <b>null</b>
164+
if no location was provided. For "Moved" logs this is the location
165+
where the cache has been moved to, for all other types of log the
166+
location where the cache has been found.</p>
167+
<p>Note that currently no OC site allows to log a location for other
168+
types than "Moved", so <em>currently</em> it is always <b>null</b>
169+
for other logs than "Moved".</p>
170+
</li>
159171
<li>
160172
<p><b>images</b> - list of dictionaries, each dictionary represents one
161173
image saved along with the log; each dictionary has the following

0 commit comments

Comments
 (0)