Date: Fri, 27 Sep 2019 22:44:56 +0200
Subject: [PATCH 2/8] #576: fix - waypoint coords are hidden for not logged
users
---
src/Views/viewcache/viewcache.tpl.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Views/viewcache/viewcache.tpl.php b/src/Views/viewcache/viewcache.tpl.php
index 3f9e953f44..ea1c212d65 100644
--- a/src/Views/viewcache/viewcache.tpl.php
+++ b/src/Views/viewcache/viewcache.tpl.php
@@ -632,7 +632,7 @@ function eventAttendancePopup() {
=tr($wp->getTypeTranslationKey())?>
- areCoordsHidden()) { ?>
+ isUserAuthorized && !$wp->areCoordsHidden()) { ?>
=$wp->getCoordinates()->getLatitudeString()?> =$wp->getCoordinates()->getLongitudeString()?>
From 00b3d3c154e89df4e714fb0d0dc60c46e3e88e62 Mon Sep 17 00:00:00 2001
From: kojoty
Date: Sat, 28 Sep 2019 11:30:37 +0200
Subject: [PATCH 3/8] #1514: config files for prima aprilis settings
---
config/primaAprilis.default.php | 28 +++++++
getLogEntries.php | 5 +-
images/oc_logo_1A.png | Bin 4278 -> 0 bytes
lib/settingsDefault.inc.php | 2 -
.../PageLayout/MainLayoutController.php | 7 +-
src/Models/OcConfig/OcConfig.php | 1 +
src/Models/OcConfig/PrimaAprilisTrait.php | 72 ++++++++++++++++++
src/Utils/DateTime/Year.php | 6 ++
viewlogs.php | 7 +-
viewprofile.php | 6 +-
10 files changed, 120 insertions(+), 14 deletions(-)
create mode 100644 config/primaAprilis.default.php
delete mode 100644 images/oc_logo_1A.png
create mode 100644 src/Models/OcConfig/PrimaAprilisTrait.php
diff --git a/config/primaAprilis.default.php b/config/primaAprilis.default.php
new file mode 100644
index 0000000000..45eac6c3ea
--- /dev/null
+++ b/config/primaAprilis.default.php
@@ -0,0 +1,28 @@
+' . rand(1, 9) . ') ';
} else {
$tmplog_username_aktywnosc = ' ( ' . ($record['ukryte'] + $record['znalezione'] + $record['nieznalezione']) . ') ';
diff --git a/images/oc_logo_1A.png b/images/oc_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*T_3b$KQ(a=KB
zvp|0Xaxa~S!mWn-#@2+JHgu;$0X-cXjxPMzv^mEYUuM~{Ls8-ERMdPakuZmrRuB
zojWi5=;KTq$W)xww}2{}+-^fFg
z5%j9LgFHP#ys2(dZ&voQL)W?1B3lwkn*$C>k}cUc`28?zW);=d!ZS>(P1Z!KB|K2uN%z7qbk-3
zd?(0mMOzig3igjc#?pCwQHpJijhW*PJ+k?BpySr2&qw<{`}jYYc%=XJEloC$-aqu&
ziXqaH$qZ%wx`R7xW+|#%D?`2e?~p^
zWDU>1(8k(tvmd|vUgl$*py8oC(6b18bfF3$6}8p@Mc3FA+6>_<)sBOqT_SvK+x8_{
z@vo|CYaLL%cXPT#1xZD$TM;gI-vbnpvudsAV|%2W2lm)dfOI-gZMPcrDpKzg>M>*^
z{_G0c{Kp8sRW;#AW7qtR_*1FCpgmzPmLcc(cLHf
YFG6V(^soK+tN;K207*qoM6N<$f)iOuR{#J2
diff --git a/lib/settingsDefault.inc.php b/lib/settingsDefault.inc.php
index 6d0c9e8f37..3a2c869dd3 100644
--- a/lib/settingsDefault.inc.php
+++ b/lib/settingsDefault.inc.php
@@ -40,8 +40,6 @@
'headerLogo' => 'oc_logo.png',
/** main logo; winter version, displayed during december and january. */
'headerLogoWinter' => 'oc_logo_winter.png',
- /** main logo; prima aprilis version (april fools), displayed only on april 1st. */
- 'headerLogo1stApril' => 'oc_logo_1A.png',
/** qrcode logo: show qrcode image and link the prefered way. */
'qrCodeLogo' => 'qrcode_bg.jpg',
'qrCodeUrl' => 'https://opencaching.pl/viewcache.php?wp=OP3C90',
diff --git a/src/Controllers/PageLayout/MainLayoutController.php b/src/Controllers/PageLayout/MainLayoutController.php
index f6e6d73b64..c5bf5759b8 100644
--- a/src/Controllers/PageLayout/MainLayoutController.php
+++ b/src/Controllers/PageLayout/MainLayoutController.php
@@ -112,7 +112,7 @@ private function initMainLayout()
'/views/common/mainLayout.css'));
}
- if (Year::isPrimaAprilisToday()) {
+ if (Year::isPrimaAprilisToday() && OcConfig::isPADanceEnabled()) {
// add rythm JS
$this->view->addLocalJs(
Uri::getLinkWithModificationTime(
@@ -124,15 +124,14 @@ private function initMainLayout()
$this->view->addLocalJs(Uri::getLinkWithModificationTime(
'/vendor/js-cookie/js-cookie/src/js.cookie.js'));
-
}
- if (Year::isPrimaAprilisToday()) {
+ if (Year::isPrimaAprilisToday() && OcConfig::isPADanceEnabled()) {
$this->view->loadJQuery();
$logo = $config['headerLogo'];
$logoTitle = 'discoCaching';
$logoSubtitle = 'The first discoCaching site!';
- } else if (date('m') == 12 || date('m') == 1) {
+ } else if (Year::isChristmassTime()) {
$logo = $config['headerLogoWinter'];
$logoTitle = tr('oc_on_all_pages_top_' . $config['ocNode']);
$logoSubtitle = tr('oc_subtitle_on_all_pages_' . $config['ocNode']);
diff --git a/src/Models/OcConfig/OcConfig.php b/src/Models/OcConfig/OcConfig.php
index 4efcd3f35d..da461eec01 100644
--- a/src/Models/OcConfig/OcConfig.php
+++ b/src/Models/OcConfig/OcConfig.php
@@ -5,6 +5,7 @@
final class OcConfig extends ConfigReader
{
use EmailConfigTrait, SiteConfigTrait, I18nConfigTrait, PicturesConfigTrait, MapConfigTrait;
+ use PrimaAprilisTrait;
/*
const OCNODE_GERMANY = 1; // Opencaching Germany http://www.opencaching.de OC
diff --git a/src/Models/OcConfig/PrimaAprilisTrait.php b/src/Models/OcConfig/PrimaAprilisTrait.php
new file mode 100644
index 0000000000..b615827f07
--- /dev/null
+++ b/src/Models/OcConfig/PrimaAprilisTrait.php
@@ -0,0 +1,72 @@
+primaAprilisConfig) {
+ $this->primaAprilisConfig = self::getConfig("primaAprilis", "config");
+ }
+ return $this->primaAprilisConfig;
+ }
+
+ /**
+ * Get Var from site.* files
+ *
+ * @param string $varName
+ * @throws \Exception
+ * @return string|array
+ */
+ private static function getPAVar($varName)
+ {
+ $config = self::instance()->getPAConfig();
+ if (!is_array($config)) {
+ throw new \Exception("Invalid $varName setting: see /config/primaAprilis.*");
+ }
+ return $config[$varName];
+ }
+}
diff --git a/src/Utils/DateTime/Year.php b/src/Utils/DateTime/Year.php
index 5896b8e930..5ccdaedfe4 100644
--- a/src/Utils/DateTime/Year.php
+++ b/src/Utils/DateTime/Year.php
@@ -23,4 +23,10 @@ public static function current()
{
return date("Y");
}
+
+ public static function isChristmassTime()
+ {
+ $month = date('m');
+ return ($month == 12 || $month == 1);
+ }
}
diff --git a/viewlogs.php b/viewlogs.php
index cc697e1246..4101333f25 100644
--- a/viewlogs.php
+++ b/viewlogs.php
@@ -10,6 +10,7 @@
use src\Utils\Text\UserInputFilter;
use src\Models\OcConfig\OcConfig;
use src\Models\Coordinates\Coordinates;
+use src\Utils\DateTime\Year;
require_once (__DIR__.'/lib/common.inc.php');
@@ -303,8 +304,8 @@
$dateTimeTmpArray = explode(' ', $record['date']);
$tmplog = mb_ereg_replace('{time}', substr($dateTimeTmpArray[1], 0, -3), $tmplog);
- // display user activity (by Łza 2012)
- if ((date('m') == 4) and ( date('d') == 1)) {
+ // display user activity
+ if (Year::isPrimaAprilisToday() && OcConfig::isPAUserStatsRandEnabled()) {
$tmplog_username_aktywnosc = ' ( ' . rand(1, 9) . ') ';
} else {
$tmplog_username_aktywnosc = ' ( ' . ($record['ukryte'] + $record['znalezione'] + $record['nieznalezione']) . ') ';
@@ -319,7 +320,7 @@
$tmplog = mb_ereg_replace('{username_aktywnosc}', $tmplog_username_aktywnosc, $tmplog);
- // mobile caches by Łza
+ // mobile caches
if (($record['type'] == 4) && ($record['mobile_latitude'] != 0) && ! $disable_spoiler_view) {
$tmplog_kordy_mobilnej = mb_ereg_replace(" ", " ", htmlspecialchars(Coordinates::donNotUse_latToDegreeStr($record['mobile_latitude']), ENT_COMPAT, 'UTF-8')) . ' ' . mb_ereg_replace(" ", " ", htmlspecialchars(Coordinates::donNotUse_lonToDegreeStr($record['mobile_longitude']), ENT_COMPAT, 'UTF-8'));
$tmplog = mb_ereg_replace('{kordy_mobilniaka}', $record['km'] . ' km [ ' . $tmplog_kordy_mobilnej . ']', $tmplog);
diff --git a/viewprofile.php b/viewprofile.php
index f61c929f00..468e2baeab 100644
--- a/viewprofile.php
+++ b/viewprofile.php
@@ -97,7 +97,7 @@
StopWatch::click(__LINE__);
tpl_set_var('username', htmlspecialchars($user->getUserName()));
-if ((date('m') == 4) and ( date('d') == 1)) {
+if (Year::isPrimaAprilisToday() && OcConfig::isPAFakeUserNameEnabled()) {
tpl_set_var('username', tr('primaAprilis1'));
}
tpl_set_var('registered', Formatter::date($user->getDateCreated()));
@@ -211,7 +211,7 @@
$content .= '' . tr('more') . '';
}
-if (Year::isPrimaAprilisToday()) {
+if (Year::isPrimaAprilisToday() && OcConfig::isPAUserStatsRandEnabled()) {
$act = rand(-10, 10);
} else {
$act = $user->getFoundGeocachesCount() + $user->getNotFoundGeocachesCount() + $user->getHiddenGeocachesCount();
@@ -327,7 +327,7 @@
}
- if (Year::isPrimaAprilisToday()) {
+ if (Year::isPrimaAprilisToday() && OcConfig::isPAUserStatsRandEnabled()) {
$found = rand(-10, 10);
$userNotFounds = rand(666, 9999);
}
From 7d6837ef771a6d49f7f1020e85ef9262d846a95b Mon Sep 17 00:00:00 2001
From: kojoty
Date: Sat, 28 Sep 2019 21:56:12 +0200
Subject: [PATCH 4/8] forbiddenCacheTypes moved to /config
---
config/geocache.default.php | 9 +++-
config/geocache.nl.php | 1 +
config/geocache.pl.php | 13 +++++
config/geocache.ro.php | 10 +++-
config/geocache.uk.php | 13 +++++
editcache.php | 4 +-
lib/settingsDefault.inc.php | 10 ----
newcache.php | 6 +--
src/Models/OcConfig/GeocacheConfigTrait.php | 58 +++++++++++++++++++++
src/Models/OcConfig/OcConfig.php | 18 +------
src/Models/OcConfig/PrimaAprilisTrait.php | 2 +-
11 files changed, 109 insertions(+), 35 deletions(-)
create mode 100644 config/geocache.pl.php
create mode 100644 config/geocache.uk.php
create mode 100644 src/Models/OcConfig/GeocacheConfigTrait.php
diff --git a/config/geocache.default.php b/config/geocache.default.php
index c1ff3ce536..f00b3bf909 100644
--- a/config/geocache.default.php
+++ b/config/geocache.default.php
@@ -16,7 +16,7 @@
*
* (All other size-related features will automatically adjust to the sizes
* which are in use for existing caches.)
- *
+ *
* The order does not matter.
*/
$geocache['enabledSizes'] = [
@@ -27,3 +27,10 @@
GeoCacheCommons::SIZE_XLARGE,
GeoCacheCommons::SIZE_NONE,
];
+
+/**
+ * Types of geocache which are forbidden on creation (it is possible thatsuch geocaches are still in DB,
+ * but no NEW caches of this can be created
+ */
+$geocache['noNewCachesOfTypes'] = [];
+
diff --git a/config/geocache.nl.php b/config/geocache.nl.php
index a6c78b1781..fc45dddab1 100644
--- a/config/geocache.nl.php
+++ b/config/geocache.nl.php
@@ -7,3 +7,4 @@
*/
$geocache['enabledSizes'][] = GeoCacheCommons::SIZE_NANO;
+
diff --git a/config/geocache.pl.php b/config/geocache.pl.php
new file mode 100644
index 0000000000..0a067def09
--- /dev/null
+++ b/config/geocache.pl.php
@@ -0,0 +1,13 @@
+= $config['cacheLimitByTypePerUser'][$cache_type] && !$usr['admin']) {
@@ -766,7 +766,7 @@ function build_drop_seq($item_row, $selected_seq, $max_drop, $thisid, $drop_type
// blockforbidden cache sizes
if ($size != $sel_size
- && !in_array($size, OcConfig::instance()->getGeocacheConfig('enabledSizes'))
+ && !in_array($size, OcConfig::getEnabledCacheSizesArray())
) {
continue;
}
diff --git a/lib/settingsDefault.inc.php b/lib/settingsDefault.inc.php
index 3a2c869dd3..377da61af8 100644
--- a/lib/settingsDefault.inc.php
+++ b/lib/settingsDefault.inc.php
@@ -63,16 +63,6 @@
* another site.
*/
'otherSites_minfinds' => 100,
- /**
- * not allowed cache types (user cannot create caches of this types).
- *
- * Cachetypes must be lib/cache.php constant TYPE_*
- */
- 'forbidenCacheTypes' => array(
- cache::TYPE_VIRTUAL,
- cache::TYPE_WEBCAM,
- cache::TYPE_GEOPATHFINAL
- ),
/**
* cache limits for user. If user is allowed to place limited nomber of specified cache type,
* place cachetype and limit here.
diff --git a/newcache.php b/newcache.php
index d67541ac91..04a3b04616 100644
--- a/newcache.php
+++ b/newcache.php
@@ -323,7 +323,7 @@
$types = '';
foreach ($cacheTypes as $typeId => $type) {
/* block creating forbidden cache types */
- if (in_array($typeId, $config['forbidenCacheTypes'])) {
+ if (in_array($typeId, OcConfig::getNoNewCacheOfTypesArray())) {
continue;
}
/* apply cache limit by type per user */
@@ -607,7 +607,7 @@
// cache-type
$type_not_ok = false;
// block forbiden cache types
- if ($sel_type == - 1 || in_array($sel_type, $config['forbidenCacheTypes'])) {
+ if ($sel_type == - 1 || in_array($sel_type, OcConfig::getNoNewCacheOfTypesArray())) {
tpl_set_var('type_message', $type_not_ok_message);
$error = true;
$type_not_ok = true;
@@ -773,7 +773,7 @@ function buildCacheSizeSelector($sel_type, $sel_size)
$sizes = '';
foreach (GeoCacheCommons::CacheSizesArray() as $size) {
- if (!in_array($size, OcConfig::instance()->getGeoCacheConfig('enabledSizes'))) {
+ if (!in_array($size, OcConfig::getEnabledCacheSizesArray())) {
continue;
}
diff --git a/src/Models/OcConfig/GeocacheConfigTrait.php b/src/Models/OcConfig/GeocacheConfigTrait.php
new file mode 100644
index 0000000000..b24ce9084f
--- /dev/null
+++ b/src/Models/OcConfig/GeocacheConfigTrait.php
@@ -0,0 +1,58 @@
+geocacheConfig) {
+ $this->geocacheConfig = self::getConfig("geocache", "geocache");
+ }
+ return $this->geocacheConfig;
+ }
+
+ /**
+ * Get Var from geocache.* files
+ *
+ * @param string $varName
+ * @throws \Exception
+ * @return string|array
+ */
+ private static function getGeocacheConfigVar($varName)
+ {
+ $config = self::instance()->getGeocacheConfig();
+ if (!is_array($config)) {
+ throw new \Exception("Invalid $varName setting: see /config/geocache.*");
+ }
+ return $config[$varName];
+ }
+}
diff --git a/src/Models/OcConfig/OcConfig.php b/src/Models/OcConfig/OcConfig.php
index da461eec01..4c91cb13a7 100644
--- a/src/Models/OcConfig/OcConfig.php
+++ b/src/Models/OcConfig/OcConfig.php
@@ -5,7 +5,7 @@
final class OcConfig extends ConfigReader
{
use EmailConfigTrait, SiteConfigTrait, I18nConfigTrait, PicturesConfigTrait, MapConfigTrait;
- use PrimaAprilisTrait;
+ use PrimaAprilisTrait, GeocacheConfigTrait;
/*
const OCNODE_GERMANY = 1; // Opencaching Germany http://www.opencaching.de OC
@@ -51,9 +51,6 @@ final class OcConfig extends ConfigReader
/** @var array the \src\Utils\Lock objects configuration array */
private $lockConfig;
- /** @var array the watchlist configuration array */
- private $geoCacheConfig;
-
/** @var array the watchlist configuration array */
private $watchlistConfig;
@@ -289,19 +286,6 @@ public function getLockConfig()
return $this->lockConfig;
}
-
- public function getGeoCacheConfig($setting = null)
- {
- if ($this->geoCacheConfig == null) {
- $this->geoCacheConfig = self::getConfig("geocache", "geocache");
- }
- if ($setting !== null) {
- return $this->geoCacheConfig[$setting];
- } else {
- return $this->geoCacheConfig;
- }
- }
-
/**
* Gives watchlist configuration, tries to initialize it if null
*
diff --git a/src/Models/OcConfig/PrimaAprilisTrait.php b/src/Models/OcConfig/PrimaAprilisTrait.php
index b615827f07..e9faa7bafb 100644
--- a/src/Models/OcConfig/PrimaAprilisTrait.php
+++ b/src/Models/OcConfig/PrimaAprilisTrait.php
@@ -55,7 +55,7 @@ protected function getPAConfig()
}
/**
- * Get Var from site.* files
+ * Get Var from geocache.* files
*
* @param string $varName
* @throws \Exception
From 4e23e6f3113eb9a64cf460127dff3c7186223d98 Mon Sep 17 00:00:00 2001
From: kojoty
Date: Sun, 29 Sep 2019 00:31:23 +0200
Subject: [PATCH 5/8] removing depreciated caches.inc.php from the code
---
cacheratings.php | 1 -
editcache.php | 23 +++--
editlog.php | 97 +++++++++++++-----
editwp.php | 10 +-
lib/caches.inc.php | 54 ----------
lib/languages/en.php | 6 --
lib/search.html.inc.php | 3 +-
log.php | 112 ++++++++++++---------
log_cache_multi.php | 1 -
log_cache_multi_panel.php | 30 ++----
my_logs.php | 4 +-
myroutes_search.php | 1 -
newcache.php | 1 -
newcaches.php | 4 +-
newwp.php | 17 ++--
search.php | 1 -
src/Models/GeoCache/GeoCacheLogCommons.php | 2 +-
src/Models/GeoCache/Waypoint.php | 24 +----
src/Models/GeoCache/WaypointCommons.php | 64 ++++++++++++
src/Views/log_cache_multi.tpl.php | 30 ++----
20 files changed, 255 insertions(+), 230 deletions(-)
delete mode 100644 lib/caches.inc.php
create mode 100644 src/Models/GeoCache/WaypointCommons.php
diff --git a/cacheratings.php b/cacheratings.php
index 5b89217548..cfce4cd043 100644
--- a/cacheratings.php
+++ b/cacheratings.php
@@ -4,7 +4,6 @@
//prepare the templates and include all necessary
require_once(__DIR__.'/lib/common.inc.php');
-require_once(__DIR__.'/lib/caches.inc.php');
require_once(__DIR__.'/src/Views/lib/icons.inc.php');
global $usr;
diff --git a/editcache.php b/editcache.php
index 4c0b3b757c..ebd97c90b4 100644
--- a/editcache.php
+++ b/editcache.php
@@ -14,6 +14,7 @@
use src\Utils\Gis\Countries;
use src\Utils\Uri\SimpleRouter;
use src\Controllers\PictureController;
+use src\Models\GeoCache\GeoCacheCommons;
require_once(__DIR__.'/lib/common.inc.php');
@@ -84,7 +85,6 @@ function build_drop_seq($item_row, $selected_seq, $max_drop, $thisid, $drop_type
if ($cache_record = $dbc->dbResultFetch($s)) {
if ($cache_record['user_id'] == $usr['userid'] || $usr['admin']) {
- require_once(__DIR__.'/lib/caches.inc.php');
// from deleted editcache.inc.php:
$submit = 'Zapisz';
@@ -739,23 +739,30 @@ function build_drop_seq($item_row, $selected_seq, $max_drop, $thisid, $drop_type
//build typeoptions
$types = '';
- foreach (get_cache_types_from_database() as $type) {
+ foreach (GeoCacheCommons::CacheTypesArray() as $type) {
// blockforbidden cache types
- if (($type['id'] != $cache_type) && in_array($type['id'], OcConfig::getNoNewCacheOfTypesArray()) && !$usr['admin']) {
+ if (($type != $cache_type) && in_array($type, OcConfig::getNoNewCacheOfTypesArray()) && !$usr['admin']) {
continue;
}
- if (isset($config['cacheLimitByTypePerUser'][$cache_type]) && $cacheLimitByTypePerUser[$cache_type] >= $config['cacheLimitByTypePerUser'][$cache_type] && !$usr['admin']) {
+ if (isset($config['cacheLimitByTypePerUser'][$cache_type]) &&
+ $cacheLimitByTypePerUser[$cache_type] >= $config['cacheLimitByTypePerUser'][$cache_type] &&
+ !$usr['admin']) {
continue;
}
- if (isset($cacheLimitByTypePerUser[$type['id']]) && isset($config['cacheLimitByTypePerUser'][$type['id']]) && $cacheLimitByTypePerUser[$type['id']] >= $config['cacheLimitByTypePerUser'][$type['id']] && !$usr['admin']) {
+ if (isset($cacheLimitByTypePerUser[$type]) &&
+ isset($config['cacheLimitByTypePerUser'][$type]) &&
+ $cacheLimitByTypePerUser[$type] >= $config['cacheLimitByTypePerUser'][$type] &&
+ !$usr['admin']) {
continue;
}
- if ($type['id'] == $cache_type) {
- $types .= '';
+ if ($type == $cache_type) {
+ $types .= '';
} else {
- $types .= '';
+ $types .= '';
}
}
tpl_set_var('typeoptions', $types);
diff --git a/editlog.php b/editlog.php
index 6809a423cf..e074455743 100644
--- a/editlog.php
+++ b/editlog.php
@@ -12,6 +12,8 @@
use src\Models\GeoCache\MobileCacheMove;
use src\Models\OcConfig\OcConfig;
use src\Utils\I18n\I18n;
+use src\Models\GeoCache\GeoCacheLogCommons;
+use src\Models\GeoCache\GeoCache;
+
//prepare the templates and include all neccessary
require_once(__DIR__.'/lib/common.inc.php');
@@ -44,7 +46,6 @@
if ($log_record) {
require(__DIR__.'/src/Views/editlog.inc.php');
- require_once(__DIR__.'/lib/caches.inc.php');
require(__DIR__.'/src/Views/rating.inc.php');
if ($log_record['node'] != OcConfig::getSiteNodeId()) {
@@ -432,51 +433,93 @@
//build logtypeoptions
$logtypeoptions = '';
- foreach (get_log_types_from_database() AS $type) {
- // skip if permission=O ???? and not owner or COG
- if ($type['permission'] == 'B' && $log_record['user_id'] != $cache_user_id && !($usr['admin']))
+ foreach (GeoCacheLogCommons::logTypesArray() as $type) {
+
+ // skip types allowed only for cacheOwner (9,10,11)
+ $allowedOnlyForOwner = [GeoCacheLogCommons::LOGTYPE_READYTOSEARCH,
+ GeoCacheLogCommons::LOGTYPE_ARCHIVED,
+ GeoCacheLogCommons::LOGTYPE_TEMPORARYUNAVAILABLE];
+ if (in_array($type,$allowedOnlyForOwner) &&
+ $log_record['user_id'] != $cache_user_id && !($usr['admin'])) {
continue;
+ }
+
// Only COG can write or edit COG comment
- if ($type['id'] == 12 && !($usr['admin'])) {
+ if ($type == GeoCacheLogCommons::LOGTYPE_ADMINNOTE && !($usr['admin'])) {
continue;
}
- if ($log_record['logtype'] != $type['id'] && $log_record['cachestatus'] != 1)
- continue;
- if ($log_record['logtype'] != $type['id'] && $log_record['cachestatus'] == 1 && $log_record['user_id'] == $cache_user_id && $type['id'] != 3 && $type['id'] != 6)
+
+ // skip current type of log
+ if ($log_record['logtype'] != $type && $log_record['cachestatus'] != GeoCacheCommons::STATUS_READY) {
continue;
+ }
+
+ if ($log_record['logtype'] != $type && // not same as current type
+ $log_record['cachestatus'] == GeoCacheCommons::STATUS_READY && // not ready-to-search
+ $log_record['user_id'] == $cache_user_id && // is owner
+ $type != GeoCacheLogCommons::LOGTYPE_COMMENT &&
+ $type != GeoCacheLogCommons::LOGTYPE_MADEMAINTENANCE) {
+
+ continue;
+ }
+
if ($already_found_in_other_comment) {
- if ($type['id'] == 1 || $type['id'] == 2 || $type['id'] == 7 || $type['id'] == 8 || $type['id'] == 9 || $type['id'] == 10 || $type['id'] == 11) {
+ if ($type == GeoCacheLogCommons::LOGTYPE_FOUNDIT ||
+ $type == GeoCacheLogCommons::LOGTYPE_DIDNOTFIND ||
+ $type == GeoCacheLogCommons::LOGTYPE_ATTENDED ||
+ $type == GeoCacheLogCommons::LOGTYPE_WILLATTENDED ||
+ $type == GeoCacheLogCommons::LOGTYPE_ARCHIVED ||
+ $type == GeoCacheLogCommons::LOGTYPE_READYTOSEARCH ||
+ $type == GeoCacheLogCommons::LOGTYPE_TEMPORARYUNAVAILABLE) {
continue;
}
}
- if ($cache_type == 6 || $cache_type == 8) {
- // Event cache
- if ($cache_type == 6) {
- if ($type['id'] == 1 || $type['id'] == 2 || $type['id'] == 4 || $type['id'] == 5 || $type['id'] == 9 || $type['id'] == 10 || $type['id'] == 11) {
- continue;
- }
+
+ if ($cache_type == GeoCache::TYPE_EVENT) {
+ if ($type == GeoCacheLogCommons::LOGTYPE_FOUNDIT ||
+ $type == GeoCacheLogCommons::LOGTYPE_DIDNOTFIND ||
+ $type == GeoCacheLogCommons::LOGTYPE_MOVED ||
+ $type == GeoCacheLogCommons::LOGTYPE_NEEDMAINTENANCE ||
+ $type == GeoCacheLogCommons::LOGTYPE_ARCHIVED ||
+ $type == GeoCacheLogCommons::LOGTYPE_READYTOSEARCH ||
+ $type == GeoCacheLogCommons::LOGTYPE_TEMPORARYUNAVAILABLE) {
+ continue;
}
- // Mobile cache
- if ($cache_type == 8) {
- if ($type['id'] == 7 || $type['id'] == 8 || $type['id'] == 9) {
- continue;
- }
+ } else if ($cache_type == GeoCache::TYPE_MOVING) {
+ if ($type == GeoCacheLogCommons::LOGTYPE_ATTENDED ||
+ $type == GeoCacheLogCommons::LOGTYPE_WILLATTENDED ||
+ $type == GeoCacheLogCommons::LOGTYPE_ARCHIVED) {
+ continue;
}
} else {
- 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)) {
+
+ if ($log_record['user_id'] == $cache_user_id && // is owner
+ ($type == GeoCacheLogCommons::LOGTYPE_FOUNDIT ||
+ $type == GeoCacheLogCommons::LOGTYPE_DIDNOTFIND ||
+ $type == GeoCacheLogCommons::LOGTYPE_MOVED ||
+ $type == GeoCacheLogCommons::LOGTYPE_NEEDMAINTENANCE ||
+ $type == GeoCacheLogCommons::LOGTYPE_ATTENDED ||
+ $type == GeoCacheLogCommons::LOGTYPE_WILLATTENDED)) {
continue;
}
- 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)) {
+
+ if ($log_record['user_id'] != $cache_user_id &&
+ ($type == GeoCacheLogCommons::LOGTYPE_MOVED ||
+ $type == GeoCacheLogCommons::LOGTYPE_ATTENDED ||
+ $type == GeoCacheLogCommons::LOGTYPE_WILLATTENDED ||
+ $type == GeoCacheLogCommons::LOGTYPE_ARCHIVED ||
+ $type == GeoCacheLogCommons::LOGTYPE_READYTOSEARCH ||
+ $type == GeoCacheLogCommons::LOGTYPE_TEMPORARYUNAVAILABLE)) {
continue;
}
}
- $lang_db = I18n::getLangForDbTranslations('log_types');
-
- if ($type['id'] == $log_type) {
- $logtypeoptions .= '' . "\n";
+ if ($type == $log_type) {
+ $logtypeoptions .= '' . "\n";
} else {
- $logtypeoptions .= '' . "\n";
+ $logtypeoptions .= '' . "\n";
}
}
diff --git a/editwp.php b/editwp.php
index 33dee72250..cf62025057 100644
--- a/editwp.php
+++ b/editwp.php
@@ -2,6 +2,7 @@
use src\Utils\Database\XDb;
use src\Utils\I18n\I18n;
+use src\Models\GeoCache\WaypointCommons;
//prepare the templates and include all neccessary
require_once(__DIR__.'/lib/common.inc.php');
@@ -67,18 +68,19 @@
$tplname = 'editwp';
- require_once(__DIR__.'/lib/caches.inc.php');
require(__DIR__.'/src/Views/newcache.inc.php');
$wp_type = isset($_POST['type']) ? $_POST['type'] : $wp_record['type'];
//build typeoptions
$types = '';
+ $types .= '';
} else {
- $types .= '';
+ $types .= '';
}
}
tpl_set_var('typeoptions', $types);
diff --git a/lib/caches.inc.php b/lib/caches.inc.php
deleted file mode 100644
index 339fbaf7e9..0000000000
--- a/lib/caches.inc.php
+++ /dev/null
@@ -1,54 +0,0 @@
- 'New coordinates',
'viewlog_aktywnosc' => 'Total user activity (total of caches found, not found and hidden)',
'viewlog_kordy' => 'Cache coordinates after moving',
- 'log_type_temp_unavailable' => 'Temporarily unavailable',
- 'log_type_available' => 'Ready to find',
'log_mobile_init' => 'Starting coordinates',
'error_coords_not_ok' => 'Wrong coordinates!',
'error_nofulltext' => 'Invalid entry. Change the name to search.',
@@ -1021,11 +1019,7 @@
'lxg01' => 'Wrong date. Please enter correct date: DD-MM-YYYY',
'lxg02' => 'Rate cache, or select you do not want rate this cache.',
'lxg05' => 'Send log entry',
- 'lxg08' => 'Write a note',
- 'lxg09' => 'Moved',
- 'lxg10' => 'Needs maintenance',
'lxg11' => 'OC Team Comment',
- 'made_service' => 'Maintenance performed',
'remove_desc_01' => 'Should the description in',
'remove_desc_02' => 'from the cache',
'remove_desc_03' => 'be removed?',
diff --git a/lib/search.html.inc.php b/lib/search.html.inc.php
index 48b2560c2b..5c80f7d536 100644
--- a/lib/search.html.inc.php
+++ b/lib/search.html.inc.php
@@ -7,6 +7,7 @@
use src\Utils\Uri\OcCookie;
use src\Models\Coordinates\Coordinates;
use src\Utils\I18n\I18n;
+use src\Models\GeoCache\GeoCacheCommons;
/**
* This script is used (can be loaded) by /search.php
@@ -405,7 +406,7 @@ function fHideColumn($nr, $set)
}
}
;
- $tmpline = str_replace('{cachetype}', htmlspecialchars(cache_type_from_id($caches_record['cache_type']), ENT_COMPAT, 'UTF-8'), $tmpline);
+ $tmpline = str_replace('{cachetype}', tr(GeoCacheCommons::CacheTypeTranslationKey($caches_record['cache_type'])), $tmpline);
// sp2ong short_desc ermitteln TODO: nicht die erste sondern die richtige wählen
$tmpline = str_replace('{wp_oc}', htmlspecialchars($caches_record['wp_oc'], ENT_COMPAT, 'UTF-8'), $tmpline);
diff --git a/log.php b/log.php
index 93404de943..4f720a0c44 100644
--- a/log.php
+++ b/log.php
@@ -37,7 +37,6 @@
$view->loadJquery();
-require_once(__DIR__.'/lib/caches.inc.php');
require(__DIR__.'/src/Views/rating.inc.php');
if(!isset($_REQUEST['cacheid'])){
@@ -661,7 +660,7 @@
tpl_set_var('display', "none");
}
- foreach (get_log_types_from_database() AS $type) {
+ foreach (GeoCacheLogCommons::logTypesArray() AS $type) {
// do not allow 'finding' or 'not finding' own or archived cache
// (events can be logged) $geoCache->getStatus() == 2 || $geoCache->getStatus() == 3
@@ -674,37 +673,44 @@
//3 = Write a note;
if ($user->hasOcTeamRole() && $geoCache->getStatus() == GeoCache::STATUS_WAITAPPROVERS){
- $logtypeoptions .= '' . "\n";
+ $logtypeoptions .= '' . "\n";
} else {
- $logtypeoptions .= '' . "\n";
+ $logtypeoptions .= '' . "\n";
}
//4 = Moved
if ($geoCache->getCacheType() == GeoCache::TYPE_MOVING ||
$geoCache->getCacheType() == GeoCache::TYPE_OWNCACHE ) {
- $logtypeoptions .= '' . "\n";
+ $logtypeoptions .= '' . "\n";
}
//5 = Needs maintenace
if ($user->getUserId() != $geoCache->getOwnerId()) {
- $logtypeoptions .= '' . "\n";
+ $logtypeoptions .= '' . "\n";
}
- $logtypeoptions .= '' . "\n";
+
+ $logtypeoptions .= '' . "\n";
//12 = OC Team Comment
if ($user->hasOcTeamRole()) {
- $logtypeoptions .= '' . "\n";
+ $logtypeoptions .= '' . "\n";
}
// service log by Łza
// if curently logged user is a cache owner and cache status is "avilable"
// then add log type option "temp. unavailable";
//11 = Temporarily unavailable
- if ($user->getUserId() == $geoCache->getOwnerId() &&
- $geoCache->getStatus() == GeoCache::STATUS_READY) {
+ if ($user->getUserId() == $geoCache->getOwnerId() && $geoCache->getStatus() == GeoCache::STATUS_READY) {
- $logtypeoptions .= '' . "\n";
+ $logtypeoptions .= '' . "\n";
}
// if curently logged user is a cache owner and cache status is "temp. unavailable"
@@ -713,28 +719,18 @@
if ( $user->getUserId() == $geoCache->getOwnerId() &&
$geoCache->getStatus() == GeoCache::STATUS_UNAVAILABLE ) {
- $logtypeoptions .= '' . "\n";
+ $logtypeoptions .= '' . "\n";
}
break;
}
-
-
- // skip if permission=O and not owner
- if ($type['permission'] == 'O' &&
- $user->getUserId() != $geoCache->getOwnerId() &&
- $type['permission']){
-
- continue;
- }
-
-
// if virtual, webcam = archived -> allow only comment log type
if (($geoCache->getCacheType() == GeoCache::TYPE_VIRTUAL ||
$geoCache->getCacheType() == GeoCache::TYPE_WEBCAM )
&& $geoCache->getStatus() == GeoCache::STATUS_ARCHIVED) {
- if ($type['id'] != 3) {
+ if ($type != GeoCacheLog::LOGTYPE_COMMENT) {
continue;
}
}
@@ -746,7 +742,7 @@
//so zero time here to allow logging WILLATTENDED or ATTENDED in the day of event
// if user logged event as willattended before or event it's over, do not display logtype 'attended'
- if ($type['id'] == GeoCacheLog::LOGTYPE_WILLATTENDED) {
+ if ($type == GeoCacheLog::LOGTYPE_WILLATTENDED) {
if ($geoCache->hasUserLogByType($user, GeoCacheLog::LOGTYPE_WILLATTENDED) ||
$now > $geoCache->getDatePlaced()) {
continue;
@@ -754,60 +750,86 @@
}
// if user logged event as attended before or event has not happened yet,
//do not display logtype 'attended'
- if ($type['id'] == GeoCacheLog::LOGTYPE_ATTENDED) {
+ if ($type == GeoCacheLog::LOGTYPE_ATTENDED) {
if ($geoCache->hasUserLogByType($user, GeoCacheLog::LOGTYPE_ATTENDED) ||
$now < $geoCache->getDatePlaced()) {
continue;
}
}
if ($user->hasOcTeamRole()) {
- if ($type['id'] == 1 || $type['id'] == 2 || $type['id'] == 4 ||
- $type['id'] == 5 || $type['id'] == 9 || $type['id'] == 10 || $type['id'] == 11) {
+ if ($type == GeoCacheLog::LOGTYPE_FOUNDIT ||
+ $type == GeoCacheLog::LOGTYPE_DIDNOTFIND ||
+ $type == GeoCacheLog::LOGTYPE_MOVED ||
+ $type == GeoCacheLog::LOGTYPE_NEEDMAINTENANCE ||
+ $type == GeoCacheLog::LOGTYPE_ARCHIVED ||
+ $type == GeoCacheLog::LOGTYPE_READYTOSEARCH ||
+ $type == GeoCacheLog::LOGTYPE_TEMPORARYUNAVAILABLE) {
continue;
}
} else {
- if ($type['id'] == 1 || $type['id'] == 2 || $type['id'] == 4 ||
- $type['id'] == 5 || $type['id'] == 9 || $type['id'] == 10 ||
- $type['id'] == 11 || $type['id'] == 12) {
+ if ($type == GeoCacheLog::LOGTYPE_FOUNDIT ||
+ $type == GeoCacheLog::LOGTYPE_DIDNOTFIND ||
+ $type == GeoCacheLog::LOGTYPE_MOVED ||
+ $type == GeoCacheLog::LOGTYPE_NEEDMAINTENANCE ||
+ $type == GeoCacheLog::LOGTYPE_ARCHIVED ||
+ $type == GeoCacheLog::LOGTYPE_READYTOSEARCH ||
+ $type == GeoCacheLog::LOGTYPE_TEMPORARYUNAVAILABLE ||
+ $type == GeoCacheLog::LOGTYPE_ADMINNOTE) {
continue;
}
}
- } else {
+ } else { // NOT-EVENT
if ($geoCache->getCacheType() == GeoCache::TYPE_MOVING) {
if ($user->hasOcTeamRole()) {
// skip will attend/attended if the cache no event
- if ($type['id'] == 7 || $type['id'] == 8 || $type['id'] == 9 || $type['id'] == 10 || $type['id'] == 11) {
+ if ($type == GeoCacheLog::LOGTYPE_ATTENDED ||
+ $type == GeoCacheLog::LOGTYPE_WILLATTENDED ||
+ $type == GeoCacheLog::LOGTYPE_ARCHIVED ||
+ $type == GeoCacheLog::LOGTYPE_READYTOSEARCH ||
+ $type == GeoCacheLog::LOGTYPE_TEMPORARYUNAVAILABLE) {
continue;
}
} else {
- if ($type['id'] == 7 || $type['id'] == 8 || $type['id'] == 9 || $type['id'] == 10 || $type['id'] == 11 || $type['id'] == 12) {
+ if ($type == GeoCacheLog::LOGTYPE_ATTENDED ||
+ $type == GeoCacheLog::LOGTYPE_WILLATTENDED ||
+ $type == GeoCacheLog::LOGTYPE_ARCHIVED ||
+ $type == GeoCacheLog::LOGTYPE_READYTOSEARCH ||
+ $type == GeoCacheLog::LOGTYPE_TEMPORARYUNAVAILABLE ||
+ $type == GeoCacheLog::LOGTYPE_ADMINNOTE) {
continue;
}
}
} else {
// skip will attend/attended/Moved if the cache no event and Mobile
if ($user->hasOcTeamRole()) {
- if ($type['id'] == 4 || $type['id'] == 7 || $type['id'] == 8 || $type['id'] == 9 || $type['id'] == 10 || $type['id'] == 11) {
+ if ($type == GeoCacheLog::LOGTYPE_MOVED ||
+ $type == GeoCacheLog::LOGTYPE_ATTENDED ||
+ $type == GeoCacheLog::LOGTYPE_WILLATTENDED ||
+ $type == GeoCacheLog::LOGTYPE_ARCHIVED ||
+ $type == GeoCacheLog::LOGTYPE_READYTOSEARCH ||
+ $type == GeoCacheLog::LOGTYPE_TEMPORARYUNAVAILABLE) {
continue;
}
} else {
- if ($type['id'] == 4 || $type['id'] == 7 || $type['id'] == 8 || $type['id'] == 9 || $type['id'] == 10 || $type['id'] == 11 || $type['id'] == 12) {
+ if ($type == GeoCacheLog::LOGTYPE_MOVED ||
+ $type == GeoCacheLog::LOGTYPE_ATTENDED ||
+ $type == GeoCacheLog::LOGTYPE_WILLATTENDED ||
+ $type == GeoCacheLog::LOGTYPE_ARCHIVED ||
+ $type == GeoCacheLog::LOGTYPE_READYTOSEARCH ||
+ $type == GeoCacheLog::LOGTYPE_TEMPORARYUNAVAILABLE ||
+ $type == GeoCacheLog::LOGTYPE_ADMINNOTE) {
continue;
}
}
}
}
- if (isset($type[I18n::getCurrentLang()])){
- $lang_db = I18n::getCurrentLang();
- } else {
- $lang_db = "en";
- }
-
- if ($type['id'] == $log_type) {
- $logtypeoptions .= '' . "\n";
+ if ($type == $log_type) {
+ $logtypeoptions .= '' . "\n";
} else {
- $logtypeoptions .= '' . "\n";
+ $logtypeoptions .= '' . "\n";
}
}
diff --git a/log_cache_multi.php b/log_cache_multi.php
index 7b01b7af8c..8bb7489076 100644
--- a/log_cache_multi.php
+++ b/log_cache_multi.php
@@ -97,7 +97,6 @@
if ($usr == false || (!isset($_FILES['userfile']) && !isset($_SESSION['log_cache_multi_data']))) {
tpl_redirect('log_cache_multi_send.php');
} else {
- require_once(__DIR__.'/lib/caches.inc.php');
$tplname = 'log_cache_multi';
$myHtml = "";
diff --git a/log_cache_multi_panel.php b/log_cache_multi_panel.php
index 8133c97c49..e9845e16c5 100644
--- a/log_cache_multi_panel.php
+++ b/log_cache_multi_panel.php
@@ -1,5 +1,7 @@
@@ -99,14 +100,16 @@
}
?>
- | " . $v['kod_str'] . " " . $v['cache_name'] : " "; ?> |
+ " .
+ $v['kod_str'] . " " . $v['cache_name'] : " "; ?> |
", $v['data']) : " ";
echo " ";
- echo isset($v['status']) ? " " : " ";
+ echo isset($v['status']) ? " " : " ";
?> |
", $v['last_date']) . " " . (isset($v['last_status']) ? " " : " ") : " ";
+ echo isset($v['got_last_activity']) ? str_replace(" ", " ", $v['last_date']) . " " . (isset($v['last_status']) ? " " : " ") : " ";
?> |
| |
@@ -124,22 +127,3 @@
}
}
-function get_icon_for_status($status)
-{
- $typyStatusow = get_log_types_from_database();
- foreach ($typyStatusow as $k => $v) {
- if ($v['id'] == $status) {
- return $v['icon_small'];
- }
- }
-}
-
-function get_icon_for_cache_type($type)
-{
- $typySkrzynek = get_cache_types_from_database();
- foreach ($typySkrzynek as $k => $v) {
- if ($v['id'] == $type) {
- return $v['icon_large'];
- }
- }
-}
diff --git a/my_logs.php b/my_logs.php
index 27e198dd87..9555842aab 100644
--- a/my_logs.php
+++ b/my_logs.php
@@ -22,7 +22,7 @@
tpl_set_var('userid', $user_id);
}
- $logTypes = GeoCacheLog::logTypes();
+ $logTypes = GeoCacheLog::logTypesArray();
if (isset($_REQUEST['logtypes'])) {
$logTypes = array_intersect($logTypes, explode(',', $_REQUEST['logtypes']));
}
@@ -61,7 +61,7 @@
$startat = max(0, floor((($start / $LOGS_PER_PAGE) + 1) / $PAGES_LISTED) * $PAGES_LISTED);
$logsPage = 'my_logs.php?userid='.$user_id;
- if (array_diff(GeoCacheLog::logTypes(), $logTypes)) {
+ if (array_diff(GeoCacheLog::logTypesArray(), $logTypes)) {
$logsPage .= '&logtypes='.implode(',',$logTypes);
}
$logsPage .= '&start=';
diff --git a/myroutes_search.php b/myroutes_search.php
index e22a4793c2..8b0244df16 100644
--- a/myroutes_search.php
+++ b/myroutes_search.php
@@ -13,7 +13,6 @@
require_once (__DIR__.'/lib/export.inc.php');
require_once (__DIR__.'/lib/format.gpx.inc.php');
require_once (__DIR__.'/lib/calculation.inc.php');
-require_once (__DIR__.'/lib/caches.inc.php');
require_once (__DIR__.'/src/Views/lib/icons.inc.php');
global $content, $bUseZip, $usr, $config;
diff --git a/newcache.php b/newcache.php
index 04a3b04616..082adaa355 100644
--- a/newcache.php
+++ b/newcache.php
@@ -50,7 +50,6 @@
exit();
}
-require_once (__DIR__.'/lib/caches.inc.php');
require_once (__DIR__.'/src/Views/newcache.inc.php');
$errors = false; // set if there was any errors
diff --git a/newcaches.php b/newcaches.php
index a6e9d87dfc..866f952c54 100644
--- a/newcaches.php
+++ b/newcaches.php
@@ -3,9 +3,9 @@
use src\Utils\Database\XDb;
use src\Utils\Text\Formatter;
use src\Utils\View\View;
+use src\Models\GeoCache\GeoCacheCommons;
require_once (__DIR__.'/lib/common.inc.php');
-require_once (__DIR__.'/lib/caches.inc.php');
require_once (__DIR__.'/src/Views/lib/icons.inc.php');
require_once (__DIR__.'/src/Views/newcaches.inc.php');
@@ -110,7 +110,7 @@
$thisline = mb_ereg_replace('{GPicon}', ' ', $thisline);
};
- $thisline = mb_ereg_replace('{cachetype}', htmlspecialchars(cache_type_from_id($r['type']), ENT_COMPAT, 'UTF-8'), $thisline);
+ $thisline = mb_ereg_replace('{cachetype}', GeoCacheCommons::CacheTypeTranslationKey($r['type']), $thisline);
$thisline = mb_ereg_replace('{cachename}', htmlspecialchars($r['cachename'], ENT_COMPAT, 'UTF-8'), $thisline);
$thisline = mb_ereg_replace('{username}', htmlspecialchars($r['username'], ENT_COMPAT, 'UTF-8'), $thisline);
$thisline = mb_ereg_replace('{region}', htmlspecialchars($r['region'], ENT_COMPAT, 'UTF-8'), $thisline);
diff --git a/newwp.php b/newwp.php
index d3a5e6650a..22f5d2b1cb 100644
--- a/newwp.php
+++ b/newwp.php
@@ -1,5 +1,6 @@
' . tr('choose_waypoint_type') . '';
// if ($cache_record['type'] == '2' || $cache_record['type'] == '6' || $cache_record['type'] == '8' || $cache_record['type'] == '9')
@@ -95,22 +94,22 @@
else
$pomin = 0;
- foreach ( get_wp_types_from_database($cache_record['type']) as $type ) {
- if ($type['id'] == $sel_type) {
- if (($type['id'] == 3) && ($pomin == 1)) {
+ foreach ( WaypointCommons::getTypesArray($cache_record['type']) as $type ) {
+ if ($type == $sel_type) {
+ if (($type == WaypointCommons::TYPE_FINAL) && ($pomin == 1)) {
} // if final waypoint alreday exist for this cache do not allow create new waypoint type "final location"
else
- $types .= '';
+ $types .= '';
}
else {
if (($type['id'] == 3) && ($pomin == 1)) {
} //// if final waypoint alreday exist for this cache do not allow create new waypoint type "final location"
else
- $types .= '';
+ $types .= '';
}
}
diff --git a/search.php b/search.php
index de8f6250d4..dd3760bbe2 100644
--- a/search.php
+++ b/search.php
@@ -50,7 +50,6 @@ function sanitize(&$array)
$tplname = 'search';
$view->loadJQueryUI();
require(__DIR__.'/src/Views/search.inc.php');
- require(__DIR__.'/lib/caches.inc.php');
sanitize($_REQUEST);
diff --git a/src/Models/GeoCache/GeoCacheLogCommons.php b/src/Models/GeoCache/GeoCacheLogCommons.php
index 3bef4b6f57..bf5b80837d 100644
--- a/src/Models/GeoCache/GeoCacheLogCommons.php
+++ b/src/Models/GeoCache/GeoCacheLogCommons.php
@@ -107,7 +107,7 @@ public static function typeTranslationKey($logType)
}
}
- public static function logTypes()
+ public static function logTypesArray()
{
return array(
self::LOGTYPE_FOUNDIT,
diff --git a/src/Models/GeoCache/Waypoint.php b/src/Models/GeoCache/Waypoint.php
index 78f5776192..3ed3ea21e5 100644
--- a/src/Models/GeoCache/Waypoint.php
+++ b/src/Models/GeoCache/Waypoint.php
@@ -8,22 +8,9 @@
/**
* Geocache Waypoint (place of interest)
* represented in db by waypoints table
- *
- * @author Łza
*/
-class Waypoint
+class Waypoint extends WaypointCommons
{
- const TYPE_PHYSICAL = 1;
- const TYPE_VIRTUAL = 2;
- const TYPE_FINAL = 3;
- const TYPE_INTERESTING = 4;
- const TYPE_PARKING = 5;
- const TYPE_TRAILHEAD = 6;
-
- const STATUS_VISIBLE = 1;
- const STATUS_VISIBLE_HIDDEN_COORDS = 2;
- const STATUS_HIDDEN = 3;
-
const OPENCHECKER_ENABLED = 1;
private $id;
@@ -40,14 +27,7 @@ class Waypoint
private $cacheId;
private $openChecker;
- private $iconNames = array(
- self::TYPE_PHYSICAL => 'images/waypoints/wp_physical.png',
- self::TYPE_VIRTUAL => 'images/waypoints/wp_virtual.png',
- self::TYPE_FINAL => 'images/waypoints/wp_final.png',
- self::TYPE_INTERESTING => 'images/waypoints/wp_reference.png',
- self::TYPE_PARKING => 'images/waypoints/wp_parking.png',
- self::TYPE_TRAILHEAD => 'images/waypoints/wp_trailhead.png'
- );
+
diff --git a/src/Models/GeoCache/WaypointCommons.php b/src/Models/GeoCache/WaypointCommons.php
new file mode 100644
index 0000000000..e587fbe2a5
--- /dev/null
+++ b/src/Models/GeoCache/WaypointCommons.php
@@ -0,0 +1,64 @@
+ 'images/waypoints/wp_physical.png',
+ self::TYPE_VIRTUAL => 'images/waypoints/wp_virtual.png',
+ self::TYPE_FINAL => 'images/waypoints/wp_final.png',
+ self::TYPE_INTERESTING => 'images/waypoints/wp_reference.png',
+ self::TYPE_PARKING => 'images/waypoints/wp_parking.png',
+ self::TYPE_TRAILHEAD => 'images/waypoints/wp_trailhead.png'
+ );
+
+ public static function typeTranslationKey($type)
+ {
+ return 'wayPointType'.$type;
+ }
+
+ public static function getTypesArray($forCacheType=null)
+ {
+ $cacheTypesWithSimpleWps = [
+ GeoCacheCommons::TYPE_TRADITIONAL, GeoCacheCommons::TYPE_VIRTUAL,
+ GeoCacheCommons::TYPE_WEBCAM, GeoCacheCommons::TYPE_EVENT,
+ GeoCacheCommons::TYPE_GEOPATHFINAL
+ ];
+
+ if ($forCacheType && in_array($forCacheType, $cacheTypesWithSimpleWps) ) {
+ return [
+ self::TYPE_INTERESTING,
+ self::TYPE_PARKING,
+ self::TYPE_TRAILHEAD
+ ];
+ } else {
+ return [
+ self::TYPE_PHYSICAL,
+ self::TYPE_VIRTUAL,
+ self::TYPE_FINAL,
+ self::TYPE_INTERESTING,
+ self::TYPE_PARKING,
+ self::TYPE_TRAILHEAD
+ ];
+ }
+ }
+
+ public static function getIcon($type){
+ self::ICONS[$type];
+ }
+
+}
diff --git a/src/Views/log_cache_multi.tpl.php b/src/Views/log_cache_multi.tpl.php
index f3ba1449d5..9668f2911a 100644
--- a/src/Views/log_cache_multi.tpl.php
+++ b/src/Views/log_cache_multi.tpl.php
@@ -1,24 +1,8 @@
$v) {
- if ($v['id'] == $status) {
- return $v['icon_small'];
- }
- }
-}
+use src\Models\GeoCache\GeoCacheLogCommons;
+use src\Models\GeoCache\GeoCacheCommons;
-function get_icon_for_cache_type($type)
-{
- $typySkrzynek = get_cache_types_from_database();
- foreach ($typySkrzynek as $k => $v) {
- if ($v['id'] == $type) {
- return $v['icon_large'];
- }
- }
-}
?>
|