Gisher писал(а):(при удалении сообщения в котором было спасибо, количество спасибо не уменьшается)
== OPEN ==
thanks.php
== FIND ==
?>
== ADD BEFORE ==
function delete_post_thanks($post_id)
{
global $db, $user;
$sql = 'DELETE
FROM ' . THANKS_TABLE . "
WHERE post_id = $post_id";
$result = $db->sql_query($sql);
if (!$result)
{
return;
}
$sql = 'SELECT *
FROM ' . THANKS_TABLE;
$result = $db->sql_query($sql);
$thankers = array();
$i = 0;
while ($row = $db->sql_fetchrow($result))
{
$thankers[$i] = array(
'user_id' => $row['user_id'],
'post_id' => $row['post_id'],
);
$i++;
}
$db->sql_freeresult($result);
$sql = 'SELECT *
FROM ' . POSTS_TABLE;
$result = $db->sql_query($sql);
$posts_arr = array();
while ($row = $db->sql_fetchrow($result))
{
$posts_arr[$row['poster_id']][] = $row['post_id'];
}
$db->sql_freeresult($result);
$sql = 'SELECT *
FROM ' . USERS_TABLE;
$result = $db->sql_query($sql);
$users_thanked = array();
$users_thanked_others = array();
while ($row = $db->sql_fetchrow($result))
{
$users_thanked[$row['user_id']] = 0;
$users_thanked_others[$row['user_id']] = 0;
}
$db->sql_freeresult($result);
foreach ($users_thanked as $this_user_id => $thanks_count)
{
if (isset($posts_arr[$this_user_id]) && is_array($posts_arr[$this_user_id]))
{
foreach ($posts_arr[$this_user_id] as $key2 => $this_post_id)
{
foreach ($thankers as $key => $values)
{
if ($values['post_id'] == $this_post_id)
{
$users_thanked[$this_user_id]++;
}
}
}
}
foreach ($thankers as $key => $values)
{
if ($values['user_id'] == $this_user_id)
{
$users_thanked_others[$this_user_id]++;
}
}
$sql = 'UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', array(
'user_thanked' => $users_thanked[$this_user_id],
'user_thanked_others' => $users_thanked_others[$this_user_id],
)) . " WHERE user_id = $this_user_id";
$db->sql_query($sql);
}
}
== OPEN ==
posting.php
== FIND ==
// Start session management
== ADD BEFORE ==
include($phpbb_root_path . 'thanks.' . $phpEx);
== FIND ==
$next_post_id = delete_post($forum_id, $topic_id, $post_id, $data);
== ADD AFTER ==
delete_post_thanks ($post_id);

<dt style="text-align: center">
<!-- IF S_USER_LOGGED_IN and not postrow.S_IS_OWN_POST and not S_IS_BOT -->
<a href="{postrow.THANKS_LINK}"><img src="{T_IMAGESET_PATH}{postrow.THANKS_IMG}" alt="{postrow.THANK_ALT}{postrow.POST_AUTHOR}{postrow.THANK_ALT2}" /></a>
<!-- ENDIF -->
</dt>
<dt style="text-align: center">
<!-- IF S_USER_LOGGED_IN and not postrow.S_IS_OWN_POST and not S_IS_BOT -->
<a href="{postrow.THANKS_LINK}"><img src="{T_IMAGESET_PATH}{postrow.THANKS_IMG}" title="{postrow.THANK_ALT}{postrow.POST_AUTHOR}{postrow.THANK_ALT2}" /></a>
<!-- ENDIF -->
</dt>
Gisher писал(а):поделитесь идеей?
Gisher писал(а):маленькая поправка


CREATE TABLE `phpbb_no_thanks` (
`post_id` mediumint(8) NOT NULL default '0',
`user_id` mediumint(8) NOT NULL default '0'
);
Heldar писал(а):Анти-спасибо это жалоба модераторам.

include($phpbb_root_path . 'nothanks.' . $phpEx);Вернуться в Запросы модов для phpBB 3.0.x
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 0