log- and recommendation-related fixes and changes
- recommendation will not be lost if the cache is logged a second time - RT406: recommendation will not be lost if other log of same user is deleted * recommendation stars will only be displayed with found and attended logs - recommendations cannot be logged with event notes - multiple found logs of one user will be counted as 1 at top ratings list * reversed event log type order: will attend / attended / note
This commit is contained in:
@@ -114,7 +114,8 @@
|
|||||||
$tpl->assign_rs('newcaches', $rs);
|
$tpl->assign_rs('newcaches', $rs);
|
||||||
sql_free_result($rs);
|
sql_free_result($rs);
|
||||||
|
|
||||||
$rs = sql_slave("SELECT COUNT(`cache_logs`.`cache_id`) AS `cRatings`,
|
// last 30 days' top ratings
|
||||||
|
$rs = sql_slave("SELECT COUNT(DISTINCT `cache_logs`.`user_id`) AS `cRatings`,
|
||||||
`cache_logs`.`cache_id`,
|
`cache_logs`.`cache_id`,
|
||||||
MAX(`cache_logs`.`date`) AS `dLastLog`,
|
MAX(`cache_logs`.`date`) AS `dLastLog`,
|
||||||
`user`.`user_id` AS `user_id`,
|
`user`.`user_id` AS `user_id`,
|
||||||
|
|||||||
@@ -145,6 +145,8 @@ function _chkFound () {
|
|||||||
</form>
|
</form>
|
||||||
<script language="javascript" type="text/javascript">
|
<script language="javascript" type="text/javascript">
|
||||||
<!--
|
<!--
|
||||||
|
_chkFound();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
1 = Text
|
1 = Text
|
||||||
2 = HTML
|
2 = HTML
|
||||||
|
|||||||
@@ -285,7 +285,7 @@ class cache
|
|||||||
`cache_logs`.`text_html` AS `texthtml`,
|
`cache_logs`.`text_html` AS `texthtml`,
|
||||||
`cache_logs`.`picture`,
|
`cache_logs`.`picture`,
|
||||||
`user`.`username` AS `username`,
|
`user`.`username` AS `username`,
|
||||||
IF(ISNULL(`cache_rating`.`cache_id`), 0, 1) AS `recommended`
|
IF(ISNULL(`cache_rating`.`cache_id`), 0, `cache_logs`.`type` IN (1,7)) AS `recommended`
|
||||||
FROM `cache_logs`
|
FROM `cache_logs`
|
||||||
INNER JOIN `user` ON `user`.`user_id` = `cache_logs`.`user_id`
|
INNER JOIN `user` ON `user`.`user_id` = `cache_logs`.`user_id`
|
||||||
LEFT JOIN `cache_rating` ON `cache_logs`.`cache_id`=`cache_rating`.`cache_id` AND `cache_logs`.`user_id`=`cache_rating`.`user_id`
|
LEFT JOIN `cache_rating` ON `cache_logs`.`cache_id`=`cache_rating`.`cache_id` AND `cache_logs`.`user_id`=`cache_rating`.`user_id`
|
||||||
|
|||||||
@@ -99,7 +99,7 @@
|
|||||||
$log_date_day = isset($_POST['logday']) ? ($_POST['logday']+0) : date('d');
|
$log_date_day = isset($_POST['logday']) ? ($_POST['logday']+0) : date('d');
|
||||||
$log_date_month = isset($_POST['logmonth']) ? ($_POST['logmonth']+0) : date('m');
|
$log_date_month = isset($_POST['logmonth']) ? ($_POST['logmonth']+0) : date('m');
|
||||||
$log_date_year = isset($_POST['logyear']) ? ($_POST['logyear']+0) : date('Y');
|
$log_date_year = isset($_POST['logyear']) ? ($_POST['logyear']+0) : date('Y');
|
||||||
$top_cache = isset($_POST['rating']) ? $_POST['rating']+0 : 0;
|
$top_cache = isset($_POST['rating']) ? $_POST['rating']+0 : null;
|
||||||
|
|
||||||
// check if user has exceeded his top5% limit
|
// check if user has exceeded his top5% limit
|
||||||
$user_founds = sqlValue("SELECT IFNULL(`stat_user`.`found`, 0) FROM `user` LEFT JOIN `stat_user` ON `user`.`user_id`=`stat_user`.`user_id` WHERE `user`.`user_id`='" . sql_escape($usr['userid']) . "'", 0);
|
$user_founds = sqlValue("SELECT IFNULL(`stat_user`.`found`, 0) FROM `user` LEFT JOIN `stat_user` ON `user`.`user_id`=`stat_user`.`user_id` WHERE `user`.`user_id`='" . sql_escape($usr['userid']) . "'", 0);
|
||||||
@@ -107,7 +107,7 @@
|
|||||||
|
|
||||||
if (($user_founds * rating_percentage/100) < 1)
|
if (($user_founds * rating_percentage/100) < 1)
|
||||||
{
|
{
|
||||||
$top_cache = 0;
|
$top_cache = null;
|
||||||
$anzahl = (1 - ($user_founds * rating_percentage/100)) / (rating_percentage/100);
|
$anzahl = (1 - ($user_founds * rating_percentage/100)) / (rating_percentage/100);
|
||||||
if ($anzahl > 1)
|
if ($anzahl > 1)
|
||||||
{
|
{
|
||||||
@@ -120,13 +120,15 @@
|
|||||||
}
|
}
|
||||||
elseif ($user_tops < floor($user_founds * rating_percentage/100))
|
elseif ($user_tops < floor($user_founds * rating_percentage/100))
|
||||||
{
|
{
|
||||||
$rating_msg = mb_ereg_replace('{chk_sel}', '', $rating_allowed.'<br />'.$rating_stat);
|
// initialize checkbox with value of past recommandation for this cache (if one exists)
|
||||||
|
$recommended = sqlValue("SELECT COUNT(`user_id`) FROM `cache_rating` WHERE `user_id`='" . sql_escape($usr['userid']) . "' AND `cache_id`='" . sql_escape($cache_id) . "'", 0);
|
||||||
|
$rating_msg = mb_ereg_replace('{chk_sel}', $recommended ? "checked" : "", $rating_allowed.'<br />'.$rating_stat);
|
||||||
$rating_msg = mb_ereg_replace('{max}', floor($user_founds * rating_percentage/100), $rating_msg);
|
$rating_msg = mb_ereg_replace('{max}', floor($user_founds * rating_percentage/100), $rating_msg);
|
||||||
$rating_msg = mb_ereg_replace('{curr}', $user_tops, $rating_msg);
|
$rating_msg = mb_ereg_replace('{curr}', $user_tops, $rating_msg);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$top_cache = 0;
|
$top_cache = null;
|
||||||
$anzahl = ($user_tops + 1 - ($user_founds * rating_percentage/100)) / (rating_percentage/100);
|
$anzahl = ($user_tops + 1 - ($user_founds * rating_percentage/100)) / (rating_percentage/100);
|
||||||
if ($anzahl > 1)
|
if ($anzahl > 1)
|
||||||
{
|
{
|
||||||
@@ -224,7 +226,7 @@
|
|||||||
// not a found log? then ignore the rating
|
// not a found log? then ignore the rating
|
||||||
if ($log_type != 1 && $log_type != 7)
|
if ($log_type != 1 && $log_type != 7)
|
||||||
{
|
{
|
||||||
$top_cache = 0;
|
$top_cache = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$pw_not_ok = false;
|
$pw_not_ok = false;
|
||||||
@@ -280,7 +282,7 @@
|
|||||||
// update top-list
|
// update top-list
|
||||||
if ($top_cache == 1)
|
if ($top_cache == 1)
|
||||||
sql("INSERT IGNORE INTO `cache_rating` (`user_id`, `cache_id`) VALUES('&1', '&2')", $usr['userid'], $cache_id);
|
sql("INSERT IGNORE INTO `cache_rating` (`user_id`, `cache_id`) VALUES('&1', '&2')", $usr['userid'], $cache_id);
|
||||||
else
|
else if ($top_cache === 0) // 0 but not null
|
||||||
sql("DELETE FROM `cache_rating` WHERE `user_id`='&1' AND `cache_id`='&2'", $usr['userid'], $cache_id);
|
sql("DELETE FROM `cache_rating` WHERE `user_id`='&1' AND `cache_id`='&2'", $usr['userid'], $cache_id);
|
||||||
|
|
||||||
//call eventhandler
|
//call eventhandler
|
||||||
@@ -296,6 +298,10 @@
|
|||||||
{
|
{
|
||||||
//build logtypeoptions
|
//build logtypeoptions
|
||||||
$logtypeoptions = '';
|
$logtypeoptions = '';
|
||||||
|
if ($cache_type == 6) // event
|
||||||
|
$logtypeorder = 'DESC';
|
||||||
|
else
|
||||||
|
$logtypeorder = 'ASC';
|
||||||
$rsLogTypes = sql("SELECT `log_types`.`id`, IFNULL(`sys_trans_text`.`text`, `log_types`.`name`) AS `name`
|
$rsLogTypes = sql("SELECT `log_types`.`id`, IFNULL(`sys_trans_text`.`text`, `log_types`.`name`) AS `name`
|
||||||
FROM `caches`
|
FROM `caches`
|
||||||
INNER JOIN `cache_type` ON `caches`.`type`=`cache_type`.`id`
|
INNER JOIN `cache_type` ON `caches`.`type`=`cache_type`.`id`
|
||||||
@@ -304,7 +310,7 @@
|
|||||||
LEFT JOIN `sys_trans` ON `log_types`.`trans_id`=`sys_trans`.`id`
|
LEFT JOIN `sys_trans` ON `log_types`.`trans_id`=`sys_trans`.`id`
|
||||||
LEFT JOIN `sys_trans_text` ON `sys_trans`.`id`=`sys_trans_text`.`trans_id` AND `sys_trans_text`.`lang`='" . sql_escape($locale) . "'
|
LEFT JOIN `sys_trans_text` ON `sys_trans`.`id`=`sys_trans_text`.`trans_id` AND `sys_trans_text`.`lang`='" . sql_escape($locale) . "'
|
||||||
WHERE `caches`.`cache_id`='" . ($cache_id+0) . "'
|
WHERE `caches`.`cache_id`='" . ($cache_id+0) . "'
|
||||||
ORDER BY `log_types`.`id` ASC");
|
ORDER BY `log_types`.`id` " . $logtypeorder);
|
||||||
while ($rLogTypes = sql_fetch_assoc($rsLogTypes))
|
while ($rLogTypes = sql_fetch_assoc($rsLogTypes))
|
||||||
{
|
{
|
||||||
$sSelected = ($rLogTypes['id'] == $log_type) ? ' selected="selected"' : '';
|
$sSelected = ($rLogTypes['id'] == $log_type) ? ' selected="selected"' : '';
|
||||||
|
|||||||
@@ -124,8 +124,11 @@
|
|||||||
//log entfernen
|
//log entfernen
|
||||||
sql("DELETE FROM `cache_logs` WHERE `cache_logs`.`id`='&1' LIMIT 1", $log_id);
|
sql("DELETE FROM `cache_logs` WHERE `cache_logs`.`id`='&1' LIMIT 1", $log_id);
|
||||||
|
|
||||||
// remove cache from users top caches, because the found log was deleted for some reason
|
// remove cache from users top caches, if the only found or attended log
|
||||||
sql("DELETE FROM `cache_rating` WHERE `user_id` = '&1' AND `cache_id` = '&2'", $log_record['log_user_id'], $log_record['cache_id']);
|
// of this user was deleted
|
||||||
|
sql("DELETE FROM `cache_rating` WHERE `user_id` = '&1' AND `cache_id` = '&2' AND
|
||||||
|
0 = (SELECT COUNT(*) FROM `cache_logs` WHERE `user_id` = '&1' AND `cache_id` = '&2' AND `type` IN (1,7))",
|
||||||
|
$log_record['log_user_id'], $log_record['cache_id']);
|
||||||
|
|
||||||
// do not use slave server for the next time ...
|
// do not use slave server for the next time ...
|
||||||
db_slave_exclude();
|
db_slave_exclude();
|
||||||
|
|||||||
Reference in New Issue
Block a user