Skip to content

Commit e7cf71f

Browse files
committed
removing depreciated class: cache
1 parent 304dcec commit e7cf71f

File tree

10 files changed

+42
-259
lines changed

10 files changed

+42
-259
lines changed

badge_positions_list.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
use src\Utils\Text\Formatter;
44
use src\Controllers\MeritBadgeController;
55
use src\Controllers\ViewBadgeHeadController;
6+
use src\Models\GeoCache\GeoCacheCommons;
67

78
require_once(__DIR__.'/lib/common.inc.php');
89

@@ -33,7 +34,6 @@
3334
$content = "";
3435

3536
$positionsMeritBadge = $meritBadgeCtrl->buildArrayGainedPositions($userid, $badge_id);
36-
$cacheTypesIcons = cache::getCacheIconsSet();
3737

3838
foreach( $positionsMeritBadge as $onePositionBadge ){
3939

@@ -55,8 +55,7 @@
5555

5656
$typeIcon ='<img src="{src}" />';
5757
$typeIcon = str_replace( "{src}",
58-
$cacheTypesIcons[$onePositionBadge->getType()]['iconSet'][1]['iconSmallFound'],
59-
$typeIcon );
58+
GeoCacheCommons::CacheIconByType($onePositionBadge->getType(), GeoCacheCommons::STATUS_READY), $typeIcon);
6059

6160
$date = Formatter::date($onePositionBadge->getGainDate());
6261
$dateSort = date("y.m.d", strtotime($onePositionBadge->getGainDate()));

lib/ClassPathDictionary.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ class ClassPathDictionary
4242
* !!! please preserve alphabetical order. !!!
4343
*/
4444
private static $classDictionary = array(
45-
'cache' => 'lib/cache.php',
4645
'myninc' => 'lib/myn.inc.php',
4746
'powerTrailBase' => 'powerTrail/powerTrailBase.php',
4847
'powerTrailController' => 'powerTrail/powerTrailController.php',

lib/cache.php

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

lib/myn.inc.php

Lines changed: 12 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<?php
2+
use src\Models\GeoCache\GeoCacheCommons;
3+
use src\Models\GeoCache\GeoCacheLog;
24
use src\Utils\Database\OcDb;
35

46
class myninc
@@ -34,45 +36,20 @@ private static function is_cache_found($cache_id, $user_id)
3436
}
3537
}
3638

37-
/**
38-
* =====================================================================================
39-
* Funkcja sprawdzająca czy użytkownik uczestniczył w wydarzeniu
40-
*
41-
* dane wejściowe:
42-
* id skrzynki
43-
* id zalogowanego użytkownika
44-
*
45-
* zwraca true lub false
46-
*
47-
* =====================================================================================
48-
*/
49-
private static function is_event_attended($cache_id, $user_id)
50-
{
51-
$q = 'SELECT user_id FROM cache_logs WHERE cache_id =:v1 AND user_id =:v2 AND type = 7 AND Deleted=0';
52-
$db = OcDb::instance();
53-
$params = [];
54-
$params['v1']['value'] = (integer) $cache_id;
55-
$params['v1']['data_type'] = 'integer';
56-
$params['v2']['value'] = (integer) $user_id;
57-
$params['v2']['data_type'] = 'integer';
58-
$s = $db->paramQuery($q, $params);
59-
$rec = $db->dbResultFetch($s);
60-
if (isset($rec['user_id'])) {
61-
return true;
62-
} else {
63-
return false;
64-
}
65-
}
6639

6740
public static function checkCacheStatusByUser($record, $userId)
6841
{
69-
$cacheTypesIcons = cache::getCacheIconsSet();
70-
if (isset($record['user_id']) && $record['user_id'] == $userId) {
71-
return $cacheTypesIcons[$record['cache_type']]['iconSet'][1]['iconSmallOwner'];
72-
} elseif (isset($record['cache_id']) && self::is_cache_found($record['cache_id'], $userId)) {
73-
return $cacheTypesIcons[$record['cache_type']]['iconSet'][1]['iconSmallFound'];
42+
if (isset($record['user_id']) && $record['user_id'] == $userId) { //for owner
43+
return GeoCacheCommons::CacheIconByType(
44+
$record['cache_type'], GeoCacheCommons::STATUS_READY, null, false, true);
45+
46+
} else if (isset($record['cache_id']) && self::is_cache_found($record['cache_id'], $userId)){
47+
return GeoCacheCommons::CacheIconByType(
48+
$record['cache_type'], GeoCacheCommons::STATUS_READY, GeoCacheLog::LOGTYPE_FOUNDIT, false, false);
49+
7450
} else {
75-
return $cacheTypesIcons[$record['cache_type']]['iconSet'][1]['iconSmall'];
51+
52+
return GeoCacheCommons::CacheIconByType($record['cache_type'], GeoCacheCommons::STATUS_READY);
7653
}
7754
}
7855
}

lib/search.txt.inc.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@
1818

1919
require_once (__DIR__.'/../lib/calculation.inc.php');
2020

21-
22-
$cache = cache::instance();
23-
$cacheTypesArr = $cache->getCacheTypeIcons();
24-
$cacheStatusArr = $cache->getCacheStatuses();
25-
2621
$txtLine = chr(239) . chr(187) . chr(191) .tr('search_text_01')." {mod_suffix}{cachename} ".tr('search_text_02')." {owner}
2722
".tr('search_text_03')." {lat} {lon}
2823
".tr('search_text_04')." {status}
@@ -253,9 +248,9 @@
253248
} else {
254249
$thisline = str_replace('{rr_comment}', html2txt("<br /><br />--------<br />".$r['rr_comment']), $thisline);
255250
}
256-
$thisline = str_replace('{type}', tr($cacheTypesArr[$r['type_id']]['translation']), $thisline);
251+
$thisline = str_replace('{type}', tr(GeoCacheCommons::CacheTypeTranslationKey($r['type_id']), $thisline);
257252
$thisline = str_replace('{container}', tr(GeoCacheCommons::CacheSizeTranslationKey($r['size'])), $thisline);
258-
$thisline = str_replace('{status}', tr($cacheStatusArr[$r['status']]['translation']), $thisline);
253+
$thisline = str_replace('{status}', tr(GeoCacheCommons::CacheStatusTranslationKey($r['status'])), $thisline);
259254

260255
$difficulty = sprintf('%01.1f', $r['difficulty'] / 2);
261256
$thisline = str_replace('{difficulty}', $difficulty, $thisline);

lib/settingsDefault.inc.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* settings.inc.php file (e.g. $config['debugDB'] = true;).
66
*/
77

8-
require_once (__DIR__.'/cache.php');
8+
use src\Models\GeoCache\GeoCacheCommons;
99

1010
// enable detailed cache access logging
1111
$enable_cache_access_logs = false;
@@ -73,10 +73,10 @@
7373
* cache limits for user. If user is allowed to place limited nomber of specified cache type,
7474
* place cachetype and limit here.
7575
*
76-
* Cachetypes must be lib/cache.php constant TYPE_*
76+
* Cachetypes must be GeoCacheCommons constant TYPE_*
7777
*/
7878
'cacheLimitByTypePerUser' => array(
79-
cache::TYPE_OWNCACHE => 1,
79+
GeoCacheCommons::TYPE_OWNCACHE => 1,
8080
),
8181
/** The filter fragment selecting provinces from nuts_codes table. */
8282
'provinceNutsCondition' => '`code` like \'PL__\'',

newcache.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -316,23 +316,25 @@
316316
}
317317

318318
// typeoptions
319-
320-
$cache = cache::instance();
321-
$cacheTypes = $cache->getCacheTypes();
322319
$types = '<option value="-1" disabled selected="selected">' . tr('select_one') . '</option>';
323-
foreach ($cacheTypes as $typeId => $type) {
320+
foreach (GeoCacheCommons::CacheTypesArray() as $typeId) {
324321
/* block creating forbidden cache types */
325322
if (in_array($typeId, OcConfig::getNoNewCacheOfTypesArray())) {
326323
continue;
327324
}
325+
328326
/* apply cache limit by type per user */
329-
if (isset($config['cacheLimitByTypePerUser'][$typeId]) && isset($cacheLimitByTypePerUser[$typeId]) && $cacheLimitByTypePerUser[$typeId] >= $config['cacheLimitByTypePerUser'][$typeId]) {
327+
if (isset($config['cacheLimitByTypePerUser'][$typeId]) &&
328+
isset($cacheLimitByTypePerUser[$typeId]) &&
329+
$cacheLimitByTypePerUser[$typeId] >= $config['cacheLimitByTypePerUser'][$typeId]) {
330330
continue;
331331
}
332332
if ($typeId == $sel_type) {
333-
$types .= '<option value="' . $typeId . '" selected="selected">' . tr($type['translation']) . '</option>';
333+
$types .= '<option value="' . $typeId . '" selected="selected">' .
334+
tr(GeoCacheCommons::CacheTypeTranslationKey($typeId)) . '</option>';
334335
} else {
335-
$types .= '<option value="' . $typeId . '">' . tr($type['translation']) . '</option>';
336+
$types .= '<option value="' . $typeId . '">' .
337+
tr(GeoCacheCommons::CacheTypeTranslationKey($typeId)) . '</option>';
336338
}
337339
}
338340
tpl_set_var('typeoptions', $types);

powerTrail.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@
3030
$ocConfig = OcConfig::instance();
3131
$appContainer = ApplicationContainer::Instance();
3232

33-
require_once(__DIR__.'/lib/cache.php');
34-
3533
$_SESSION['powerTrail']['userFounds'] = $usr['userFounds'];
3634

3735
if ($ocConfig->isPowerTrailModuleSwitchOn() === false) {

0 commit comments

Comments
 (0)