bugfixes (cachelink translatable, logtype via GET, permission check for

teamcomment), updates #206, updates #241
This commit is contained in:
Nils Bohrs 2013-06-23 16:27:19 +02:00 committed by following
parent 2cb201b5f0
commit c95c4e9746
4 changed files with 52 additions and 11 deletions

View File

@ -425,6 +425,20 @@ class cache
return true;
}
// checks if $userId has adopted this cache
function hasAdopted($userId)
{
// cache_adoption exists?
return (sql_value("
SELECT COUNT(*)
FROM `cache_adoption`
WHERE `cache_id`='&1'
AND `user_id`='&2'",
0,
$this->nCacheId,
$userId) != 0);
}
// true if anyone can view the cache
function isPublic()
@ -609,5 +623,16 @@ class cache
// checks if teamcomment is allowed
return teamcomment_allowed($this->getCacheId(), $logType, $oldTeamComment);
}
function statusUserLogAllowed()
{
return (sql_value("
SELECT `cache_status`.`allow_user_log`
FROM `cache_status`,`caches`
WHERE `caches`.`status`=`cache_status`.`id`
AND `caches`.`cache_id`='&1'",
0,
$this->getCacheId()) == 1);
}
}
?>

View File

@ -1282,5 +1282,12 @@ class user
return ($opt['logic']['rating']['percentageOfFounds'] - ($this->getStatFound() % $opt['logic']['rating']['percentageOfFounds']));
}
function showStatFounds()
{
// wether to show the number of founds on log page
// TODO: make customisable in user profile, see #241
return false;
}
}
?>

View File

@ -67,7 +67,7 @@
// check and prepare form values
$logText = (isset($_POST['logtext'])) ? ($_POST['logtext']) : '';
$logType = (isset($_POST['logtype'])) ? ($_POST['logtype']+0) : null;
$logType = (isset($_REQUEST['logtype'])) ? ($_REQUEST['logtype']+0) : null;
$logDateDay = (isset($_POST['logday'])) ? trim($_POST['logday']) : date('d');
$logDateMonth = (isset($_POST['logmonth'])) ? trim($_POST['logmonth']) : date('m');
$logDateYear = (isset($_POST['logyear'])) ? trim($_POST['logyear']) : date('Y');
@ -187,8 +187,8 @@
// update cache status
$cache->updateCacheStatus($logType);
// update rating (if correct logtype, user has ratings to give and is not owner)
if ($rateOption && $user->allowRatings() && !$isOwner)
// update rating (if correct logtype, user has ratings to give and is not owner (exept owner adopted cache))
if ($rateOption && $user->allowRatings() && (!$isOwner || ($isOwner && $cache->hasAdopted($user->getUserId()))))
if ($rateCache)
$cache->addRecommendation($user->getUserId());
else
@ -233,10 +233,12 @@
$tpl->assign('logtypes', $cache->getUserLogTypes($logType));
// teamcomment
$tpl->assign('octeamcommentallowed', $cache->teamcommentAllowed(3));
$tpl->assign('octeamcomment', ($ocTeamComment || (!$cache->allowLog() && $useradmin)) ? true : false);
$tpl->assign('octeamcommentclass', (!$cache->allowLog() && $useradmin) ? 'redtext' : '');
$tpl->assign('octeamcomment', ($ocTeamComment || (!$cache->statusUserLogAllowed() && $useradmin)) ? true : false);
$tpl->assign('octeamcommentclass', (!$cache->statusUserLogAllowed() && $useradmin) ? 'redtext' : '');
// masslogs
$tpl->assign('masslog', cachelog::isMasslogging($user->getUserId()));
// show number of found on log page
$tpl->assign('showstatfounds', $user->showStatFounds());
}
else

View File

@ -1,4 +1,4 @@
{***************************************************************************
{***************************************************************************
* You can find the license in the docs directory
*
* Unicode Reminder メモ
@ -50,11 +50,16 @@ function _chkFound () {
//-->
{/literal}
{*
* capture allows us to "eval" the link tag with the variable values
* and save the complete link in the variable "cachelink" to use it in translation
*}
{capture name=cachelink assign=cachelink}<a href="viewcache.php?cacheid={$cacheid}">{$cachename|escape}</a>{/capture}
</script>
<div class="content2-pagetitle">
<img src="resource2/{$opt.template.style}/images/description/22x22-logs.png" style="align: left; margin-right: 10px;" width="22" height="22" alt="{t}New log-entry{/t}" />
{t}Add log-entry for the cache{/t} <a href="viewcache.php?cacheid={$cacheid}">{$cachename|escape}</a>
{t 1=$cachelink}Add log-entry for the cache %1{/t}
</div>
{if $masslog==true}
<p class="redtext">
@ -64,14 +69,16 @@ function _chkFound () {
{t}Wrong log dates can adversly affect several OC functions like searching by last log date. Also, the owner and other caches may think that the cache has been currently found date and type of the last log are shown in the owner's caches list!), which can adversely affect cache maintenance and lead to more DNFs.{/t}
</p>
{/if}
{if showstatfounds==true}
<p class="align-right">
<b>{t 1=$userFound}You found %1 caches until now.{/t}</b>
</p>
{/if}
<form action="log.php" method="post" enctype="application/x-www-form-urlencoded" name="logform" dir="ltr">
<input type="hidden" name="cacheid" value="{$cacheid}"/>
<input type="hidden" name="version3" value="1"/>
<input id="descMode" type="hidden" name="descMode" value="1" />
<table class="table">
<tr>
<td colspan="2" style="text-align: right;"><b>{t 1=$userFound}You found %1 caches until now.{/t}</b></td>
</tr>
<tr><td class="spacer" colspan="2"></td></tr>
{if $validate.duplicateLog==false}
<tr>
@ -401,4 +408,4 @@ function _chkFound () {
}
//-->
{/literal}
</script>
</script>