Skip to content

Commit 1280822

Browse files
author
following09
committed
added OCDE cache list watch status; fixes #334
1 parent c3ea3aa commit 1280822

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

okapi/services/caches/geocaches.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,25 @@ public static function call(OkapiRequest $request)
442442
$tmp2 = array();
443443
foreach ($tmp as $cache_code)
444444
$tmp2[$cache_code] = true;
445+
446+
# OCDE caches can also be indirectly watched by watching cache lists:
447+
if (Settings::get('OC_BRANCH') == 'oc.de')
448+
{
449+
$tmp = Db::select_column("
450+
select c.wp_oc
451+
from
452+
caches c,
453+
cache_list_items cli,
454+
cache_list_watches clw
455+
where
456+
cli.cache_id = c.cache_id
457+
and clw.cache_list_id = cli.cache_list_id
458+
and clw.user_id = '".mysql_real_escape_string($request->token->user_id)."'
459+
");
460+
foreach ($tmp as $cache_code)
461+
$tmp2[$cache_code] = true;
462+
}
463+
445464
foreach ($results as $cache_code => &$result_ref)
446465
$result_ref['is_watched'] = isset($tmp2[$cache_code]);
447466
}

okapi/services/caches/search/searching.inc.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,15 @@ public function prepare_common_search_params()
435435
from cache_watches
436436
where user_id = '".mysql_real_escape_string($this->request->token->user_id)."'
437437
");
438+
if (Settings::get('OC_BRANCH') == 'oc.de')
439+
{
440+
$watched_cache_ids = array_merge($watched_cache_ids, Db::select_column("
441+
select cache_id
442+
from cache_list_items cli, cache_list_watches clw
443+
where cli.cache_list_id = clw.cache_list_id
444+
and clw.user_id = '".mysql_real_escape_string($this->request->token->user_id)."'
445+
"));
446+
}
438447
$where_conds[] = "caches.cache_id in ('".implode("','", array_map('mysql_real_escape_string', $watched_cache_ids))."')";
439448
}
440449
}

0 commit comments

Comments
 (0)