|
12 | 12 | use src\Models\GeoCache\MobileCacheMove;
|
13 | 13 | use src\Models\OcConfig\OcConfig;
|
14 | 14 | use src\Utils\I18n\I18n;
|
| 15 | +use src\Models\GeoCache\GeoCacheLogCommons; |
| 16 | +use src\Models\GeoCache\GeoCache; |
15 | 17 | +
|
16 | 18 | //prepare the templates and include all neccessary
|
17 | 19 | require_once(__DIR__.'/lib/common.inc.php');
|
|
44 | 46 | if ($log_record) {
|
45 | 47 |
|
46 | 48 | require(__DIR__.'/src/Views/editlog.inc.php');
|
47 |
| - require_once(__DIR__.'/lib/caches.inc.php'); |
48 | 49 | require(__DIR__.'/src/Views/rating.inc.php');
|
49 | 50 |
|
50 | 51 | if ($log_record['node'] != OcConfig::getSiteNodeId()) {
|
|
432 | 433 |
|
433 | 434 | //build logtypeoptions
|
434 | 435 | $logtypeoptions = '';
|
435 |
| - foreach (get_log_types_from_database() AS $type) { |
436 |
| - // skip if permission=O ???? and not owner or COG |
437 |
| - if ($type['permission'] == 'B' && $log_record['user_id'] != $cache_user_id && !($usr['admin'])) |
| 436 | + foreach (GeoCacheLogCommons::logTypesArray() as $type) { |
| 437 | + |
| 438 | + // skip types allowed only for cacheOwner (9,10,11) |
| 439 | + $allowedOnlyForOwner = [GeoCacheLogCommons::LOGTYPE_READYTOSEARCH, |
| 440 | + GeoCacheLogCommons::LOGTYPE_ARCHIVED, |
| 441 | + GeoCacheLogCommons::LOGTYPE_TEMPORARYUNAVAILABLE]; |
| 442 | + if (in_array($type,$allowedOnlyForOwner) && |
| 443 | + $log_record['user_id'] != $cache_user_id && !($usr['admin'])) { |
438 | 444 | continue;
|
| 445 | + } |
| 446 | + |
439 | 447 | // Only COG can write or edit COG comment
|
440 |
| - if ($type['id'] == 12 && !($usr['admin'])) { |
| 448 | + if ($type == GeoCacheLogCommons::LOGTYPE_ADMINNOTE && !($usr['admin'])) { |
441 | 449 | continue;
|
442 | 450 | }
|
443 |
| - if ($log_record['logtype'] != $type['id'] && $log_record['cachestatus'] != 1) |
444 |
| - continue; |
445 |
| - if ($log_record['logtype'] != $type['id'] && $log_record['cachestatus'] == 1 && $log_record['user_id'] == $cache_user_id && $type['id'] != 3 && $type['id'] != 6) |
| 451 | + |
| 452 | + // skip current type of log |
| 453 | + if ($log_record['logtype'] != $type && $log_record['cachestatus'] != GeoCacheCommons::STATUS_READY) { |
446 | 454 | continue;
|
| 455 | + } |
| 456 | + |
| 457 | + if ($log_record['logtype'] != $type && // not same as current type |
| 458 | + $log_record['cachestatus'] == GeoCacheCommons::STATUS_READY && // not ready-to-search |
| 459 | + $log_record['user_id'] == $cache_user_id && // is owner |
| 460 | + $type != GeoCacheLogCommons::LOGTYPE_COMMENT && |
| 461 | + $type != GeoCacheLogCommons::LOGTYPE_MADEMAINTENANCE) { |
| 462 | + |
| 463 | + continue; |
| 464 | + } |
| 465 | + |
447 | 466 | if ($already_found_in_other_comment) {
|
448 |
| - if ($type['id'] == 1 || $type['id'] == 2 || $type['id'] == 7 || $type['id'] == 8 || $type['id'] == 9 || $type['id'] == 10 || $type['id'] == 11) { |
| 467 | + if ($type == GeoCacheLogCommons::LOGTYPE_FOUNDIT || |
| 468 | + $type == GeoCacheLogCommons::LOGTYPE_DIDNOTFIND || |
| 469 | + $type == GeoCacheLogCommons::LOGTYPE_ATTENDED || |
| 470 | + $type == GeoCacheLogCommons::LOGTYPE_WILLATTENDED || |
| 471 | + $type == GeoCacheLogCommons::LOGTYPE_ARCHIVED || |
| 472 | + $type == GeoCacheLogCommons::LOGTYPE_READYTOSEARCH || |
| 473 | + $type == GeoCacheLogCommons::LOGTYPE_TEMPORARYUNAVAILABLE) { |
449 | 474 | continue;
|
450 | 475 | }
|
451 | 476 | }
|
452 |
| - if ($cache_type == 6 || $cache_type == 8) { |
453 |
| - // Event cache |
454 |
| - if ($cache_type == 6) { |
455 |
| - if ($type['id'] == 1 || $type['id'] == 2 || $type['id'] == 4 || $type['id'] == 5 || $type['id'] == 9 || $type['id'] == 10 || $type['id'] == 11) { |
456 |
| - continue; |
457 |
| - } |
| 477 | + |
| 478 | + if ($cache_type == GeoCache::TYPE_EVENT) { |
| 479 | + if ($type == GeoCacheLogCommons::LOGTYPE_FOUNDIT || |
| 480 | + $type == GeoCacheLogCommons::LOGTYPE_DIDNOTFIND || |
| 481 | + $type == GeoCacheLogCommons::LOGTYPE_MOVED || |
| 482 | + $type == GeoCacheLogCommons::LOGTYPE_NEEDMAINTENANCE || |
| 483 | + $type == GeoCacheLogCommons::LOGTYPE_ARCHIVED || |
| 484 | + $type == GeoCacheLogCommons::LOGTYPE_READYTOSEARCH || |
| 485 | + $type == GeoCacheLogCommons::LOGTYPE_TEMPORARYUNAVAILABLE) { |
| 486 | + continue; |
458 | 487 | }
|
459 |
| - // Mobile cache |
460 |
| - if ($cache_type == 8) { |
461 |
| - if ($type['id'] == 7 || $type['id'] == 8 || $type['id'] == 9) { |
462 |
| - continue; |
463 |
| - } |
| 488 | + } else if ($cache_type == GeoCache::TYPE_MOVING) { |
| 489 | + if ($type == GeoCacheLogCommons::LOGTYPE_ATTENDED || |
| 490 | + $type == GeoCacheLogCommons::LOGTYPE_WILLATTENDED || |
| 491 | + $type == GeoCacheLogCommons::LOGTYPE_ARCHIVED) { |
| 492 | + continue; |
464 | 493 | }
|
465 | 494 | } else {
|
466 |
| - if ($log_record['user_id'] == $cache_user_id && ($type['id'] == 1 || $type['id'] == 2 || $type['id'] == 4 || $type['id'] == 5 || $type['id'] == 7 || $type['id'] == 8)) { |
| 495 | + |
| 496 | + if ($log_record['user_id'] == $cache_user_id && // is owner |
| 497 | + ($type == GeoCacheLogCommons::LOGTYPE_FOUNDIT || |
| 498 | + $type == GeoCacheLogCommons::LOGTYPE_DIDNOTFIND || |
| 499 | + $type == GeoCacheLogCommons::LOGTYPE_MOVED || |
| 500 | + $type == GeoCacheLogCommons::LOGTYPE_NEEDMAINTENANCE || |
| 501 | + $type == GeoCacheLogCommons::LOGTYPE_ATTENDED || |
| 502 | + $type == GeoCacheLogCommons::LOGTYPE_WILLATTENDED)) { |
467 | 503 | continue;
|
468 | 504 | }
|
469 |
| - if ($log_record['user_id'] != $cache_user_id && ($type['id'] == 4 || $type['id'] == 7 || $type['id'] == 8 || $type['id'] == 9 || $type['id'] == 10 || $type['id'] == 11)) { |
| 505 | + |
| 506 | + if ($log_record['user_id'] != $cache_user_id && |
| 507 | + ($type == GeoCacheLogCommons::LOGTYPE_MOVED || |
| 508 | + $type == GeoCacheLogCommons::LOGTYPE_ATTENDED || |
| 509 | + $type == GeoCacheLogCommons::LOGTYPE_WILLATTENDED || |
| 510 | + $type == GeoCacheLogCommons::LOGTYPE_ARCHIVED || |
| 511 | + $type == GeoCacheLogCommons::LOGTYPE_READYTOSEARCH || |
| 512 | + $type == GeoCacheLogCommons::LOGTYPE_TEMPORARYUNAVAILABLE)) { |
470 | 513 | continue;
|
471 | 514 | }
|
472 | 515 | }
|
473 | 516 |
|
474 |
| - $lang_db = I18n::getLangForDbTranslations('log_types'); |
475 |
| - |
476 |
| - if ($type['id'] == $log_type) { |
477 |
| - $logtypeoptions .= '<option value="' . $type['id'] . '" selected="selected">' . htmlspecialchars($type[$lang_db], ENT_COMPAT, 'UTF-8') . '</option>' . "\n"; |
| 517 | + if ($type == $log_type) { |
| 518 | + $logtypeoptions .= '<option value="' . $type . '" selected="selected">' . |
| 519 | + htmlspecialchars(tr(GeoCacheLogCommons::typeTranslationKey($type)), ENT_COMPAT, 'UTF-8') . '</option>' . "\n"; |
478 | 520 | } else {
|
479 |
| - $logtypeoptions .= '<option value="' . $type['id'] . '">' . htmlspecialchars($type[$lang_db], ENT_COMPAT, 'UTF-8') . '</option>' . "\n"; |
| 521 | + $logtypeoptions .= '<option value="' . $type . '">' . |
| 522 | + htmlspecialchars(tr(GeoCacheLogCommons::typeTranslationKey($type)), ENT_COMPAT, 'UTF-8') . '</option>' . "\n"; |
480 | 523 | }
|
481 | 524 | }
|
482 | 525 |
|
|
0 commit comments