Skip to content

Commit 304dcec

Browse files
committed
removing depreciated caches.inc.php from the code
1 parent a47e569 commit 304dcec

20 files changed

+255
-230
lines changed

cacheratings.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
//prepare the templates and include all necessary
66
require_once(__DIR__.'/lib/common.inc.php');
7-
require_once(__DIR__.'/lib/caches.inc.php');
87
require_once(__DIR__.'/src/Views/lib/icons.inc.php');
98

109
global $usr;

editcache.php

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use src\Utils\Gis\Countries;
1515
use src\Utils\Uri\SimpleRouter;
1616
use src\Controllers\PictureController;
17+
use src\Models\GeoCache\GeoCacheCommons;
1718

1819
require_once(__DIR__.'/lib/common.inc.php');
1920

@@ -84,7 +85,6 @@ function build_drop_seq($item_row, $selected_seq, $max_drop, $thisid, $drop_type
8485
if ($cache_record = $dbc->dbResultFetch($s)) {
8586

8687
if ($cache_record['user_id'] == $usr['userid'] || $usr['admin']) {
87-
require_once(__DIR__.'/lib/caches.inc.php');
8888

8989
// from deleted editcache.inc.php:
9090
$submit = 'Zapisz';
@@ -739,23 +739,30 @@ function build_drop_seq($item_row, $selected_seq, $max_drop, $thisid, $drop_type
739739

740740
//build typeoptions
741741
$types = '';
742-
foreach (get_cache_types_from_database() as $type) {
742+
foreach (GeoCacheCommons::CacheTypesArray() as $type) {
743743

744744
// blockforbidden cache types
745-
if (($type['id'] != $cache_type) && in_array($type['id'], OcConfig::getNoNewCacheOfTypesArray()) && !$usr['admin']) {
745+
if (($type != $cache_type) && in_array($type, OcConfig::getNoNewCacheOfTypesArray()) && !$usr['admin']) {
746746
continue;
747747
}
748-
if (isset($config['cacheLimitByTypePerUser'][$cache_type]) && $cacheLimitByTypePerUser[$cache_type] >= $config['cacheLimitByTypePerUser'][$cache_type] && !$usr['admin']) {
748+
if (isset($config['cacheLimitByTypePerUser'][$cache_type]) &&
749+
$cacheLimitByTypePerUser[$cache_type] >= $config['cacheLimitByTypePerUser'][$cache_type] &&
750+
!$usr['admin']) {
749751
continue;
750752
}
751-
if (isset($cacheLimitByTypePerUser[$type['id']]) && isset($config['cacheLimitByTypePerUser'][$type['id']]) && $cacheLimitByTypePerUser[$type['id']] >= $config['cacheLimitByTypePerUser'][$type['id']] && !$usr['admin']) {
753+
if (isset($cacheLimitByTypePerUser[$type]) &&
754+
isset($config['cacheLimitByTypePerUser'][$type]) &&
755+
$cacheLimitByTypePerUser[$type] >= $config['cacheLimitByTypePerUser'][$type] &&
756+
!$usr['admin']) {
752757
continue;
753758
}
754759

755-
if ($type['id'] == $cache_type) {
756-
$types .= '<option value="' . $type['id'] . '" selected="selected">' . htmlspecialchars($type[I18n::getCurrentLang()], ENT_COMPAT, 'UTF-8') . '</option>';
760+
if ($type == $cache_type) {
761+
$types .= '<option value="' . $type . '" selected="selected">' .
762+
htmlspecialchars( tr(GeoCacheCommons::CacheTypeTranslationKey($type)), ENT_COMPAT, 'UTF-8') . '</option>';
757763
} else {
758-
$types .= '<option value="' . $type['id'] . '">' . htmlspecialchars($type[I18n::getCurrentLang()], ENT_COMPAT, 'UTF-8') . '</option>';
764+
$types .= '<option value="' . $type . '">' .
765+
htmlspecialchars( tr( GeoCacheCommons::CacheTypeTranslationKey($type)), ENT_COMPAT, 'UTF-8') . '</option>';
759766
}
760767
}
761768
tpl_set_var('typeoptions', $types);

editlog.php

Lines changed: 70 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
use src\Models\GeoCache\MobileCacheMove;
1313
use src\Models\OcConfig\OcConfig;
1414
use src\Utils\I18n\I18n;
15+
use src\Models\GeoCache\GeoCacheLogCommons;
16+
use src\Models\GeoCache\GeoCache;
1517
+
1618
//prepare the templates and include all neccessary
1719
require_once(__DIR__.'/lib/common.inc.php');
@@ -44,7 +46,6 @@
4446
if ($log_record) {
4547

4648
require(__DIR__.'/src/Views/editlog.inc.php');
47-
require_once(__DIR__.'/lib/caches.inc.php');
4849
require(__DIR__.'/src/Views/rating.inc.php');
4950

5051
if ($log_record['node'] != OcConfig::getSiteNodeId()) {
@@ -432,51 +433,93 @@
432433

433434
//build logtypeoptions
434435
$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'])) {
438444
continue;
445+
}
446+
439447
// Only COG can write or edit COG comment
440-
if ($type['id'] == 12 && !($usr['admin'])) {
448+
if ($type == GeoCacheLogCommons::LOGTYPE_ADMINNOTE && !($usr['admin'])) {
441449
continue;
442450
}
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) {
446454
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+
447466
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) {
449474
continue;
450475
}
451476
}
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;
458487
}
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;
464493
}
465494
} 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)) {
467503
continue;
468504
}
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)) {
470513
continue;
471514
}
472515
}
473516

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";
478520
} 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";
480523
}
481524
}
482525

editwp.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
use src\Utils\Database\XDb;
44
use src\Utils\I18n\I18n;
5+
use src\Models\GeoCache\WaypointCommons;
56

67
//prepare the templates and include all neccessary
78
require_once(__DIR__.'/lib/common.inc.php');
@@ -67,18 +68,19 @@
6768

6869

6970
$tplname = 'editwp';
70-
require_once(__DIR__.'/lib/caches.inc.php');
7171
require(__DIR__.'/src/Views/newcache.inc.php');
7272

7373
$wp_type = isset($_POST['type']) ? $_POST['type'] : $wp_record['type'];
7474
//build typeoptions
7575
$types = '<option disabled selected="selected">' . tr('choose_waypoint_type') . '</options>';
76-
foreach (get_wp_types_from_database($cache_record['type']) as $type) {
76+
foreach (WaypointCommons::getTypesArray($cache_record['type']) as $type) {
7777

7878
if ($type['id'] == $wp_type) {
79-
$types .= '<option value="' . $type['id'] . '" selected="selected">' . htmlspecialchars($type[I18n::getCurrentLang()], ENT_COMPAT, 'UTF-8') . '</option>';
79+
$types .= '<option value="' . $type . '" selected="selected">' .
80+
htmlspecialchars(tr (WaypointCommons::typeTranslationKey($type)), ENT_COMPAT, 'UTF-8') . '</option>';
8081
} else {
81-
$types .= '<option value="' . $type['id'] . '">' . htmlspecialchars($type[I18n::getCurrentLang()], ENT_COMPAT, 'UTF-8') . '</option>';
82+
$types .= '<option value="' . $type . '">' .
83+
htmlspecialchars(tr (WaypointCommons::typeTranslationKey($type)), ENT_COMPAT, 'UTF-8') . '</option>';
8284
}
8385
}
8486
tpl_set_var('typeoptions', $types);

lib/caches.inc.php

Lines changed: 0 additions & 54 deletions
This file was deleted.

lib/languages/en.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -844,8 +844,6 @@
844844
'new_coords' => 'New coordinates',
845845
'viewlog_aktywnosc' => 'Total user activity (total of caches found, not found and hidden)',
846846
'viewlog_kordy' => 'Cache coordinates after moving',
847-
'log_type_temp_unavailable' => 'Temporarily unavailable',
848-
'log_type_available' => 'Ready to find',
849847
'log_mobile_init' => 'Starting coordinates',
850848
'error_coords_not_ok' => 'Wrong coordinates!',
851849
'error_nofulltext' => 'Invalid entry. Change the name to search.',
@@ -1020,11 +1018,7 @@
10201018
'lxg01' => 'Wrong date. Please enter correct date: DD-MM-YYYY',
10211019
'lxg02' => 'Rate cache, or select you do not want rate this cache.',
10221020
'lxg05' => 'Send log entry',
1023-
'lxg08' => 'Write a note',
1024-
'lxg09' => 'Moved',
1025-
'lxg10' => 'Needs maintenance',
10261021
'lxg11' => 'OC Team Comment',
1027-
'made_service' => 'Maintenance performed',
10281022
'remove_desc_01' => 'Should the description in',
10291023
'remove_desc_02' => 'from the cache',
10301024
'remove_desc_03' => 'be removed?',

lib/search.html.inc.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use src\Utils\Uri\OcCookie;
88
use src\Models\Coordinates\Coordinates;
99
use src\Utils\I18n\I18n;
10+
use src\Models\GeoCache\GeoCacheCommons;
1011

1112
/**
1213
* This script is used (can be loaded) by /search.php
@@ -405,7 +406,7 @@ function fHideColumn($nr, $set)
405406
}
406407
}
407408
;
408-
$tmpline = str_replace('{cachetype}', htmlspecialchars(cache_type_from_id($caches_record['cache_type']), ENT_COMPAT, 'UTF-8'), $tmpline);
409+
$tmpline = str_replace('{cachetype}', tr(GeoCacheCommons::CacheTypeTranslationKey($caches_record['cache_type'])), $tmpline);
409410

410411
// sp2ong short_desc ermitteln TODO: nicht die erste sondern die richtige wählen
411412
$tmpline = str_replace('{wp_oc}', htmlspecialchars($caches_record['wp_oc'], ENT_COMPAT, 'UTF-8'), $tmpline);

0 commit comments

Comments
 (0)