Skip to content

Commit 7a6c62e

Browse files
committed
added status logging; closes #260
1 parent e5307b0 commit 7a6c62e

File tree

5 files changed

+117
-36
lines changed

5 files changed

+117
-36
lines changed

okapi/core/Okapi.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,6 +1070,9 @@ public static function logtypename2id($name)
10701070
if ($name == 'Comment') return 3;
10711071
if ($name == 'Attended') return 7;
10721072
if ($name == 'Will attend') return 8;
1073+
if ($name == 'Archived') return 9;
1074+
if ($name == 'Available') return 10;
1075+
if ($name == 'Temporarily unavailable') return 11;
10731076
if (($name == 'Needs maintenance') && (Settings::get('OC_BRANCH') == 'oc.pl')) return 5;
10741077
throw new \Exception("logtype2id called with invalid log type argument: $name");
10751078
}
483 Bytes
Binary file not shown.

okapi/locale/de_DE/LC_MESSAGES/okapi_messages.po

Lines changed: 37 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ msgid ""
22
msgstr ""
33
"Project-Id-Version: OKAPI\n"
44
"Report-Msgid-Bugs-To: \n"
5-
"POT-Creation-Date: 2018-09-20 15:51+0200\n"
6-
"PO-Revision-Date: 2018-09-25 14:41+0200\n"
7-
"Last-Translator: Harrie Klomp <harrie@harrieklomp.be>\n"
5+
"POT-Creation-Date: 2018-10-31 13:46+0100\n"
6+
"PO-Revision-Date: 2018-10-31 13:53+0100\n"
7+
"Last-Translator: following <following@online.de>\n"
88
"Language-Team: following <following@online.de>\n"
99
"Language: de\n"
1010
"MIME-Version: 1.0\n"
@@ -14,41 +14,41 @@ msgstr ""
1414
"X-Poedit-Basepath: ../../..\n"
1515
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
1616
"X-Poedit-SourceCharset: UTF-8\n"
17-
"X-Generator: Poedit 2.0.6\n"
17+
"X-Generator: Poedit 1.8.7\n"
1818
"X-Poedit-SearchPath-0: .\n"
1919
"X-Poedit-SearchPathExcluded-0: .git\n"
2020

21-
#: services/caches/edit/WebService.php:65
21+
#: services/caches/edit/WebService.php:82
2222
#, php-format
2323
msgid "The password must not be longer than %d characters."
2424
msgstr "Das Passwort darf nicht länger als %d Zeichen sein."
2525

26-
#: services/caches/edit/WebService.php:78
26+
#: services/caches/edit/WebService.php:95
2727
#, php-format
2828
msgid "%s does not allow log passwords for traditional caches."
2929
msgstr "Tradis können bei %s keine Passwörter haben."
3030

31-
#: services/caches/formatters/gpx/WebService.php:427
31+
#: services/caches/formatters/gpx/WebService.php:404
3232
msgid ""
3333
"<b>Geocache coordinates have been changed.</b> They have been replaced with "
3434
"your own custom coordinates which you have provided for this geocache."
3535
msgstr ""
3636
"<b>Die Koordinaten des Geocaches wurden geändert.</b> Sie wurden durch deine "
3737
"eigenen Koordinaten aus der persönlichen Notiz für diesen Cache ersetzt."
3838

39-
#: services/caches/formatters/gpx/WebService.php:433
39+
#: services/caches/formatters/gpx/WebService.php:410
4040
msgid ""
4141
"<b>Geocache coordinates have been changed.</b> Currently they point to one "
4242
"of the alternate waypoints originally described as:"
4343
msgstr ""
4444
"<b>Die Koordinaten des Geocaches wurden geändert.</b> Sie zeigen zurzeit auf "
4545
"einen der zusätzlichen Wegpunkte mit der ursprünglichen Beschreibung:"
4646

47-
#: services/caches/formatters/gpx/WebService.php:446
47+
#: services/caches/formatters/gpx/WebService.php:423
4848
msgid "Original geocache location"
4949
msgstr "Originalposition des Caches"
5050

51-
#: services/caches/formatters/gpx/WebService.php:448
51+
#: services/caches/formatters/gpx/WebService.php:425
5252
#, php-format
5353
msgid "Original (owner-supplied) location of the %s geocache"
5454
msgstr "Originale, vom Besitzer angegebene Position des Geocaches %s"
@@ -212,23 +212,23 @@ msgstr "Das Bild wurde erfolgreich gespeichert."
212212
msgid "Image properties have been successfully updated."
213213
msgstr "Die Bildeigenschaften wurden geändert."
214214

215-
#: services/logs/submit/WebService.php:74
215+
#: services/logs/submit/WebService.php:75
216216
msgid ""
217217
"You are trying to publish a log entry with a date in future. Cache log "
218218
"entries are allowed to be published in the past, but NOT in the future."
219219
msgstr ""
220220
"Das Datum deines Logeintrags liegt in der Zukunft. Cache-Logs können nur für "
221221
"die Vergangenheit oder für heute eingetragen werden."
222222

223-
#: services/logs/submit/WebService.php:110
223+
#: services/logs/submit/WebService.php:111
224224
#, php-format
225225
msgid ""
226226
"However, your cache rating was ignored, because %s does not have a rating "
227227
"system."
228228
msgstr ""
229229
"Deine Cachewertung wurde jedoch ignoriert, weil %s kein Bewertungssystem hat."
230230

231-
#: services/logs/submit/WebService.php:135
231+
#: services/logs/submit/WebService.php:136
232232
#, php-format
233233
msgid ""
234234
"However, your cache recommendation was ignored, because %s does not allow "
@@ -237,7 +237,7 @@ msgstr ""
237237
"Deine Empfehlung wurde jedoch ignoriert, weil auf %s keine Event-Caches "
238238
"empfohlen werden können."
239239

240-
#: services/logs/submit/WebService.php:184
240+
#: services/logs/submit/WebService.php:185
241241
#, php-format
242242
msgid ""
243243
"However, your \"does not need maintenance\" flag was ignored, because %s "
@@ -246,91 +246,99 @@ msgstr ""
246246
"Deine Angabe \"benötigt Wartung\" wurde jedoch ignoriert, weil es diese "
247247
"Funktion bei %s nicht gibt. "
248248

249-
#: services/logs/submit/WebService.php:214
249+
#: services/logs/submit/WebService.php:215
250250
msgid ""
251251
"This cache is an Event cache. You cannot \"Find\" it (but you can attend it, "
252252
"or comment on it)!"
253253
msgstr ""
254254
"Dies ist ein Event-Cache. Du kannst ihn nicht \"finden\" (aber du kannst am "
255255
"Event teilnehmen oder einen Hinweis loggen)."
256256

257-
#: services/logs/submit/WebService.php:220
258-
#, fuzzy
257+
#: services/logs/submit/WebService.php:221
259258
msgid ""
260259
"You cannot attend an event before it takes place. Please check the log type "
261260
"and date."
262261
msgstr ""
263262
"Du kannst ein Event nicht besuchen, bevor es stattfindet. Bitte überprüfe "
264263
"den Logtyp und das Logdatum."
265264

266-
#: services/logs/submit/WebService.php:229
265+
#: services/logs/submit/WebService.php:230
267266
msgid ""
268267
"This cache is NOT an Event cache. You cannot \"Attend\" it (but you can find "
269268
"it, or comment on it)!"
270269
msgstr ""
271270
"Dies ist KEIN Event-Cache. Du kannst an ihm nicht \"teilnehmen\" (aber du "
272271
"kannst ihn finden oder kommentieren)."
273272

274-
#: services/logs/submit/WebService.php:239
273+
#: services/logs/submit/WebService.php:237
275274
msgid "Your have to supply some text for your comment."
276275
msgstr "Du musst einen Text für dein Hinweislog eingeben!"
277276

278277
#: services/logs/submit/WebService.php:255
278+
#, php-format
279+
msgid "%s does not allow to unarchive geocaches."
280+
msgstr "%s erlaubt keine Reaktivierung archivierter Caches."
281+
282+
#: services/logs/submit/WebService.php:267
283+
msgid "The geocache must be maintained before it is enabled."
284+
msgstr "Der Geocache muss gewartet werden, bevor er aktiviert wird."
285+
286+
#: services/logs/submit/WebService.php:286
279287
msgid "This cache requires a password. You didn't provide one!"
280288
msgstr ""
281289
"Dieser Cache kann nur mit Kennwort geloggt werden, aber du hast keines "
282290
"angegeben."
283291

284-
#: services/logs/submit/WebService.php:259
292+
#: services/logs/submit/WebService.php:290
285293
msgid "Invalid password!"
286294
msgstr "Ungültiges Kennwort!"
287295

288-
#: services/logs/submit/WebService.php:396
296+
#: services/logs/submit/WebService.php:427
289297
msgid "You have already submitted a log entry with exactly the same contents."
290298
msgstr ""
291299
"Du hast bereits einen Logeintrag mit genau dem gleichen Inhalt gemacht."
292300

293-
#: services/logs/submit/WebService.php:430
301+
#: services/logs/submit/WebService.php:461
294302
msgid ""
295303
"You have already submitted a \"Found it\" log entry once. Now you may submit "
296304
"\"Comments\" only!"
297305
msgstr ""
298306
"Du hast diesen Cache bereits als \"gefunden\" geloggt. Ein zweites Fundlog "
299307
"ist nicht möglich, aber du kannst stattdessen einen Hinweis loggen."
300308

301-
#: services/logs/submit/WebService.php:432
309+
#: services/logs/submit/WebService.php:463
302310
msgid ""
303311
"You have already submitted an \"Attended\" log entry once. Now you may "
304312
"submit \"Comments\" only!"
305313
msgstr ""
306314
"Du hast dieses Event bereits als \"teilgenommen\" geloggt. Eine zweite "
307315
"Teilnahme ist nicht möglich, aber du kannst stattdessen einen Hinweis loggen."
308316

309-
#: services/logs/submit/WebService.php:442
317+
#: services/logs/submit/WebService.php:473
310318
msgid "You are the owner of this cache. You may submit \"Comments\" only!"
311319
msgstr ""
312320
"Als Besitzer des Caches kannst du nur Hinweise loggen, keine Funde oder "
313321
"Nichtfunde."
314322

315-
#: services/logs/submit/WebService.php:464
323+
#: services/logs/submit/WebService.php:495
316324
msgid "You have already rated this cache once. Your rating cannot be changed."
317325
msgstr ""
318326
"Du hast diesen Cache bereits bewertet. Deine Bewertung ist nicht änderbar."
319327

320-
#: services/logs/submit/WebService.php:485
328+
#: services/logs/submit/WebService.php:516
321329
msgid "You have already recommended this cache once."
322330
msgstr "Du hast diesen Cache bereits empfohlen."
323331

324-
#: services/logs/submit/WebService.php:501
332+
#: services/logs/submit/WebService.php:532
325333
msgid "You don't have any recommendations to give. Find more caches first!"
326334
msgstr ""
327335
"Du musst mehr Caches finden, um eine weitere Bewertung abgeben zu können."
328336

329-
#: services/logs/submit/WebService.php:552
337+
#: services/logs/submit/WebService.php:595
330338
msgid "Event caches cannot \"need maintenance\"."
331339
msgstr "Event-Caches können keine \"Wartung benötigen\"."
332340

333-
#: services/logs/submit/WebService.php:710
341+
#: services/logs/submit/WebService.php:753
334342
msgid "Your cache log entry was posted successfully."
335343
msgstr "Dein Log wurde veröffentlicht."
336344

okapi/services/logs/submit/WebService.php

Lines changed: 70 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ private static function _call(OkapiRequest $request)
4747
$logtype = $request->get_parameter('logtype');
4848
if (!$logtype) throw new ParamMissing('logtype');
4949
if (!in_array($logtype, array(
50-
'Found it', "Didn't find it", 'Comment', 'Will attend', 'Attended'
50+
'Found it', "Didn't find it", 'Comment', 'Will attend', 'Attended',
51+
'Available', 'Temporarily unavailable', 'Archived'
5152
))) {
5253
throw new InvalidParam('logtype', "'$logtype' in not a valid logtype code.");
5354
}
@@ -209,7 +210,7 @@ private static function _call(OkapiRequest $request)
209210

210211
if ($cache['type'] == 'Event')
211212
{
212-
if (!in_array($logtype, array('Will attend', 'Attended', 'Comment'))) {
213+
if (in_array($logtype, array('Found it', "Didn't find it"))) {
213214
throw new CannotPublishException(_(
214215
'This cache is an Event cache. You cannot "Find" it (but '.
215216
'you can attend it, or comment on it)!'
@@ -230,16 +231,46 @@ private static function _call(OkapiRequest $request)
230231
'(but you can find it, or comment on it)!'
231232
));
232233
}
233-
else if (!in_array($logtype, array('Found it', "Didn't find it", 'Comment'))) {
234-
throw new Exception("Unknown log entry - should be documented here.");
235-
}
236234
}
237235
if ($logtype == 'Comment' && strlen(trim($comment)) == 0) {
238236
throw new CannotPublishException(_(
239237
"Your have to supply some text for your comment."
240238
));
241239
}
242240

241+
if (in_array($logtype, array('Available', 'Temporarily unavailable', 'Archived')))
242+
{
243+
if ($user['uuid'] != $cache['owner']['uuid'])
244+
throw new BadRequest("The status of a geocache can only be changed by the owner.");
245+
246+
if (Settings::get('OC_BRANCH') == 'oc.pl')
247+
{
248+
if ($logtype == $cache['status']) {
249+
# OCPL does not allow to confirm an existing geocache status.
250+
# We silently change the log to a comment.
251+
$logtype = 'Comment';
252+
}
253+
elseif ($cache['status'] == 'Archived') {
254+
throw new CannotPublishException(sprintf(_(
255+
"%s does not allow to unarchive geocaches."
256+
), Okapi::get_normalized_site_name()));
257+
}
258+
}
259+
260+
# Geocaches must be in good shape before enabling them. At OCDE,
261+
# enabling implies setting "cache is ok" (does not need maintenance).
262+
263+
if ($logtype == 'Available')
264+
{
265+
if ($needs_maintenance2 == 'true')
266+
throw new CannotPublishException(_(
267+
"The geocache must be maintained before it is enabled."
268+
));
269+
elseif ($needs_maintenance2 == 'null' && Settings::get('OC_BRANCH') == 'oc.de')
270+
$needs_maintenance2 = 'false';
271+
}
272+
}
273+
243274
# Password check.
244275

245276
if (($logtype == 'Found it' || $logtype == 'Attended') && $cache['req_passwd'])
@@ -543,6 +574,18 @@ private static function _call(OkapiRequest $request)
543574
$second_formatted_comment = $formatted_comment;
544575
$formatted_comment = "";
545576
}
577+
elseif (in_array($logtype, array(
578+
'Available', 'Temporarily unavailable', 'Archived')))
579+
{
580+
# For status-changing logs, we'll issue two log entries, but this time
581+
# we put the "Needs maintenance" first with empty comment, then the
582+
# status-changing log with comment text.
583+
584+
$second_logtype = $logtype;
585+
$second_formatted_comment = $formatted_comment;
586+
$logtype = 'Needs maintenance';
587+
$formatted_comment = "";
588+
}
546589
else if ($logtype == 'Will attend' || $logtype == 'Attended')
547590
{
548591
# OC branches which allow maintenance logs, still don't allow them on
@@ -865,6 +908,28 @@ private static function insert_log_row(
865908
);
866909
");
867910

911+
# update geocache status
912+
913+
if (in_array($logtype, array('Available', 'Temporarily unavailable', 'Archived')))
914+
{
915+
if (Settings::get('OC_BRANCH') == 'oc.de') {
916+
Db::execute("
917+
set @STATUS_CHANGE_USER_ID = '".Db::escape_string($user_internal_id)."'"
918+
);
919+
$set_last_modified_SQL = "";
920+
# OCDE will update last_modified via trigger if status changes.
921+
}
922+
else
923+
$set_last_modified_SQL = ", last_modified = NOW()";
924+
925+
$status_id = Okapi::cache_status_name2id($logtype);
926+
DB::execute("
927+
update caches
928+
set status = '".Db::escape_string($status_id)."'".$set_last_modified_SQL."
929+
where cache_id = '".Db::escape_string($cache_internal_id)."'
930+
");
931+
}
932+
868933
return $log_uuid;
869934
}
870935
}

okapi/services/logs/submit/docs.xml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,19 @@
99
<p>Code of the geocache.</p>
1010
</req>
1111
<req name='logtype'>
12-
<p>Type of an entry. This should be one of:</p>
12+
<p>Type of an entry. This may be one of:</p>
1313
<ul>
1414
<li>
1515
<i>Will attend</i>, <i>Attended</i> or <i>Comment</i> for Event caches;
1616
</li>
1717
<li>
1818
<i>Found it</i>, <i>Didn't find it</i> or <i>Comment</i> for all other
19-
cache types.
19+
cache types;
20+
</li>
21+
<li>
22+
<i>Available</i>, <i>Temporarily unavailable</i> or <i>Archived</i> for
23+
any caches owned by your user. This will set the corresponding geocache
24+
status.
2025
</li>
2126
</ul>
2227
</req>

0 commit comments

Comments
 (0)