Skip to content

Commit

Permalink
Cache types options list generation conditions modified, fixes openca…
Browse files Browse the repository at this point in the history
  • Loading branch information
rapotek committed Jun 23, 2020
1 parent 4411f91 commit b241683
Showing 1 changed file with 65 additions and 24 deletions.
89 changes: 65 additions & 24 deletions editcache.php
Original file line number Diff line number Diff line change
Expand Up @@ -737,32 +737,73 @@ function build_drop_seq($item_row, $selected_seq, $max_drop, $thisid, $drop_type

$cacheLimitByTypePerUser = GeoCache::getUserActiveCachesCountByType($usr['userid']);

//build typeoptions
//build type options
$types = '';
foreach (GeoCacheCommons::CacheTypesArray() as $type) {

// blockforbidden cache types
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']) {
continue;
}
if (isset($cacheLimitByTypePerUser[$type]) &&
isset($config['cacheLimitByTypePerUser'][$type]) &&
$cacheLimitByTypePerUser[$type] >= $config['cacheLimitByTypePerUser'][$type] &&
!$usr['admin']) {
continue;
}

if ($type == $cache_type) {
$types .= '<option value="' . $type . '" selected="selected">' .
htmlspecialchars( tr(GeoCacheCommons::CacheTypeTranslationKey($type)), ENT_COMPAT, 'UTF-8') . '</option>';
} else {
$types .= '<option value="' . $type . '">' .
htmlspecialchars( tr( GeoCacheCommons::CacheTypeTranslationKey($type)), ENT_COMPAT, 'UTF-8') . '</option>';
// do not provide change cache type options
// if config limit for current type is exceeded
if (
!$usr['admin']
&& isset($cacheLimitByTypePerUser[$cache_type])
&& isset($config['cacheLimitByTypePerUser'][$cache_type])
&& $cacheLimitByTypePerUser[$cache_type]
>= $config['cacheLimitByTypePerUser'][$cache_type]
) {
} else {
foreach (GeoCacheCommons::CacheTypesArray() as $type) {

if (!$usr['admin']) {
// block forbidden cache types
if (
($type != $cache_type)
&& in_array(
$type, OcConfig::getNoNewCacheOfTypesArray()
)
) {
continue;
}
// do not include types where limit is exceeded
if (
isset($cacheLimitByTypePerUser[$type])
&& isset(
$config['cacheLimitByTypePerUser'][$type]
)
&& $cacheLimitByTypePerUser[$type]
>= $config['cacheLimitByTypePerUser'][$type]
) {
continue;
}
}
if ($type == $cache_type) {
$types .=
'<option value="'
. $type
. '" selected="selected">'
. htmlspecialchars(
tr(
GeoCacheCommons::CacheTypeTranslationKey(
$type
)
),
ENT_COMPAT,
'UTF-8'
)
. '</option>';
} else {
$types .=
'<option value="'
. $type
. '">'
. htmlspecialchars(
tr(
GeoCacheCommons::CacheTypeTranslationKey(
$type
)
),
ENT_COMPAT, 'UTF-8'
)
. '</option>';
}
}
}
tpl_set_var('typeoptions', $types);
Expand Down

0 comments on commit b241683

Please sign in to comment.