I do little mod that uses user_comments from USERS_TABLE and found that this value not changed if:
1. whole category was deleted
2. image was deleted in ACP (member.php work fine)
To fix first problem I did
in the file admin/categories.php
find two times
$image_ids_sql .= (($image_ids_sql != "") ? ", " : "").$image_row['image_id'];
add below
$sql2 = "SELECT user_id
FROM ".COMMENTS_TABLE."
WHERE image_id = ".$image_row['image_id']." AND user_id <> ".GUEST;
$result = $site_db->query($sql2);
while ($row = $site_db->fetch_array($result)) {
$sql3 = "UPDATE ".USERS_TABLE."
SET ".get_user_table_field("", "user_comments")." = ".get_user_table_field("", "user_comments")." - 1
WHERE ".get_user_table_field("", "user_id")." = ".$row['user_id'];
$site_db->query($sql3);
}
To fix second problem I did
in the file admin/images.php
find
if (!empty($user_table_fields['user_comments'])) {
$sql = "SELECT user_id
FROM ".COMMENTS_TABLE."
WHERE image_id = ".$image_row['image_id']." AND user_id <> ".GUEST;
$result = $site_db->query($sql);
while ($row = $site_db->fetch_array($result)) {
$sql = "UPDATE ".USERS_TABLE."
SET ".get_user_table_field("", "user_comments")." = ".get_user_table_field("", "user_comments")." - 1
WHERE ".get_user_table_field("", "user_id")." = ".$row['user_id'];
$site_db->query($sql);
}
}
replace with
// if (!empty($user_table_fields['user_comments'])) {
$sql = "SELECT user_id
FROM ".COMMENTS_TABLE."
WHERE image_id = ".$image_row['image_id']." AND user_id <> ".GUEST;
$result = $site_db->query($sql);
while ($row = $site_db->fetch_array($result)) {
$sql = "UPDATE ".USERS_TABLE."
SET ".get_user_table_field("", "user_comments")." = ".get_user_table_field("", "user_comments")." - 1
WHERE ".get_user_table_field("", "user_id")." = ".$row['user_id'];
$site_db->query($sql);
}
// }
Can someone just check my solution and tell me if I did right?